Merge branch 'master' into 13988-make-a-copy-popup
[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 { reset, initialize } from "redux-form";
6
7 import { ContextMenuActionSet } from "../context-menu-action-set";
8 import { projectActions, PROJECT_FORM_NAME } from "~/store/project/project-action";
9 import { NewProjectIcon, RenameIcon, CopyIcon, MoveToIcon } from "~/components/icon/icon";
10 import { ToggleFavoriteAction } from "../actions/favorite-action";
11 import { toggleFavorite } from "~/store/favorites/favorites-actions";
12 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
13 import { openMoveToDialog } from "../../move-to-dialog/move-to-dialog";
14 import { PROJECT_CREATE_DIALOG } from "../../dialog-create/dialog-project-create";
15 import { openProjectCopyDialog } from "~/views-components/project-copy-dialog/project-copy-dialog";
16
17 export const projectActionSet: ContextMenuActionSet = [[
18     {
19         icon: NewProjectIcon,
20         name: "New project",
21         execute: (dispatch, resource) => {
22             dispatch(reset(PROJECT_CREATE_DIALOG));
23             dispatch(projectActions.OPEN_PROJECT_CREATOR({ ownerUuid: resource.uuid }));
24         }
25     },
26     {
27         icon: RenameIcon,
28         name: "Edit project",
29         execute: (dispatch, resource) => {
30             dispatch(projectActions.OPEN_PROJECT_UPDATER({ uuid: resource.uuid }));
31             dispatch(initialize(PROJECT_FORM_NAME, { name: resource.name, description: resource.description }));
32         }
33     },
34     {
35         component: ToggleFavoriteAction,
36         execute: (dispatch, resource) => {
37             dispatch<any>(toggleFavorite(resource)).then(() => {
38                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
39             });
40         }
41     },
42     {
43         icon: MoveToIcon,
44         name: "Move to",
45         execute: dispatch => dispatch<any>(openMoveToDialog())       
46     },
47     {
48         icon: CopyIcon,
49         name: "Copy to project",
50         execute: (dispatch, resource) => {
51             dispatch<any>(openProjectCopyDialog({name: resource.name, projectUuid: resource.uuid}));
52         }
53     }
54 ]];