16005: Open collection and project in new tab feature added
[arvados-workbench2.git] / src / views-components / context-menu / action-sets / project-admin-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ContextMenuActionSet } from "../context-menu-action-set";
6 import { NewProjectIcon, RenameIcon, MoveToIcon, DetailsIcon, AdvancedIcon, OpenIcon, Link } from '~/components/icon/icon';
7 import { ToggleFavoriteAction } from "../actions/favorite-action";
8 import { toggleFavorite } from "~/store/favorites/favorites-actions";
9 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
10 import { openMoveProjectDialog } from '~/store/projects/project-move-actions';
11 import { openProjectCreateDialog } from '~/store/projects/project-create-actions';
12 import { openProjectUpdateDialog } from '~/store/projects/project-update-actions';
13 import { ToggleTrashAction } from "~/views-components/context-menu/actions/trash-action";
14 import { toggleProjectTrashed } from "~/store/trash/trash-actions";
15 import { ShareIcon } from '~/components/icon/icon';
16 import { openSharingDialog } from "~/store/sharing-dialog/sharing-dialog-actions";
17 import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
18 import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
19 import { TogglePublicFavoriteAction } from "~/views-components/context-menu/actions/public-favorite-action";
20 import { togglePublicFavorite } from "~/store/public-favorites/public-favorites-actions";
21 import { publicFavoritePanelActions } from "~/store/public-favorites-panel/public-favorites-action";
22 import { copyToClipboardAction, openInNewTabAction } from "~/store/open-in-new-tab/open-in-new-tab.actions";
23
24 export const projectAdminActionSet: ContextMenuActionSet = [[
25     {
26         icon: NewProjectIcon,
27         name: "New project",
28         execute: (dispatch, resource) => {
29             dispatch<any>(openProjectCreateDialog(resource.uuid));
30         }
31     },
32     {
33         icon: OpenIcon,
34         name: "Open in new tab",
35         execute: (dispatch, resource) => {
36             dispatch<any>(openInNewTabAction(resource));
37         }
38     },
39     {
40         icon: Link,
41         name: "Copy to clipboard",
42         execute: (dispatch, resource) => {
43             dispatch<any>(copyToClipboardAction(resource));
44         }
45     },
46     {
47         icon: RenameIcon,
48         name: "Edit project",
49         execute: (dispatch, resource) => {
50             dispatch<any>(openProjectUpdateDialog(resource));
51         }
52     },
53     {
54         icon: ShareIcon,
55         name: "Share",
56         execute: (dispatch, { uuid }) => {
57             dispatch<any>(openSharingDialog(uuid));
58         }
59     },
60     {
61         component: ToggleFavoriteAction,
62         name: 'ToggleFavoriteAction',
63         execute: (dispatch, resource) => {
64             dispatch<any>(toggleFavorite(resource)).then(() => {
65                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
66             });
67         }
68     },
69     {
70         component: TogglePublicFavoriteAction,
71         name: 'TogglePublicFavoriteAction',
72         execute: (dispatch, resource) => {
73             dispatch<any>(togglePublicFavorite(resource)).then(() => {
74                 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
75             });
76         }
77     },
78     {
79         icon: MoveToIcon,
80         name: "Move to",
81         execute: (dispatch, resource) => {
82             dispatch<any>(openMoveProjectDialog(resource));
83         }
84     },
85     // {
86     //     icon: CopyIcon,
87     //     name: "Copy to project",
88     //     execute: (dispatch, resource) => {
89     //         // add code
90     //     }
91     // },
92     {
93         icon: DetailsIcon,
94         name: "View details",
95         execute: dispatch => {
96             dispatch<any>(toggleDetailsPanel());
97         }
98     },
99     {
100         icon: AdvancedIcon,
101         name: "Advanced",
102         execute: (dispatch, resource) => {
103             dispatch<any>(openAdvancedTabDialog(resource.uuid));
104         }
105     },
106     {
107         component: ToggleTrashAction,
108         name: 'ToggleTrashAction',
109         execute: (dispatch, resource) => {
110             dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!));
111         }
112     },
113 ]];