Merge branch 'master' into 14137-new-button
[arvados-workbench2.git] / src / views-components / context-menu / action-sets / project-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, CopyIcon, MoveToIcon } 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
16 export const projectActionSet: ContextMenuActionSet = [[
17     {
18         icon: NewProjectIcon,
19         name: "New project",
20         execute: (dispatch, resource) => {
21             dispatch<any>(openProjectCreateDialog(resource.uuid));
22         }
23     },
24     {
25         icon: RenameIcon,
26         name: "Edit project",
27         execute: (dispatch, resource) => {
28             dispatch<any>(openProjectUpdateDialog(resource));
29         }
30     },
31     {
32         component: ToggleFavoriteAction,
33         execute: (dispatch, resource) => {
34             dispatch<any>(toggleFavorite(resource)).then(() => {
35                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
36             });
37         }
38     },
39     {
40         component: ToggleTrashAction,
41         execute: (dispatch, resource) => {
42             dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!));
43         }
44     },
45     {
46         icon: MoveToIcon,
47         name: "Move to",
48         execute: (dispatch, resource) => dispatch<any>(openMoveProjectDialog(resource))
49     },
50     {
51         icon: CopyIcon,
52         name: "Copy to project",
53         execute: (dispatch, resource) => {
54             // add code
55         }
56     },
57 ]];