f6185804406321a27b36149c1029f3dca3bcea53
[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 } 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
23 export const projectAdminActionSet: ContextMenuActionSet = [[
24     {
25         icon: NewProjectIcon,
26         name: "New project",
27         execute: (dispatch, resource) => {
28             dispatch<any>(openProjectCreateDialog(resource.uuid));
29         }
30     },
31     {
32         icon: RenameIcon,
33         name: "Edit project",
34         execute: (dispatch, resource) => {
35             dispatch<any>(openProjectUpdateDialog(resource));
36         }
37     },
38     {
39         icon: ShareIcon,
40         name: "Share",
41         execute: (dispatch, { uuid }) => {
42             dispatch<any>(openSharingDialog(uuid));
43         }
44     },
45     {
46         component: ToggleFavoriteAction,
47         execute: (dispatch, resource) => {
48             dispatch<any>(toggleFavorite(resource)).then(() => {
49                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
50             });
51         }
52     },
53     {
54         component: TogglePublicFavoriteAction,
55         execute: (dispatch, resource) => {
56             dispatch<any>(togglePublicFavorite(resource)).then(() => {
57                 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
58             });
59         }
60     },
61     {
62         icon: MoveToIcon,
63         name: "Move to",
64         execute: (dispatch, resource) => {
65             dispatch<any>(openMoveProjectDialog(resource));
66         }
67     },
68     // {
69     //     icon: CopyIcon,
70     //     name: "Copy to project",
71     //     execute: (dispatch, resource) => {
72     //         // add code
73     //     }
74     // },
75     {
76         icon: DetailsIcon,
77         name: "View details",
78         execute: dispatch => {
79             dispatch<any>(toggleDetailsPanel());
80         }
81     },
82     {
83         icon: AdvancedIcon,
84         name: "Advanced",
85         execute: (dispatch, resource) => {
86             dispatch<any>(openAdvancedTabDialog(resource.uuid));
87         }
88     },
89     {
90         component: ToggleTrashAction,
91         execute: (dispatch, resource) => {
92             dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!));
93         }
94     },
95 ]];