Merge branch '15685-file-renaming-empty-name'
[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, 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 { copyToClipboardAction, openInNewTabAction } from "~/store/open-in-new-tab/open-in-new-tab.actions";
20
21 export const readOnlyProjectActionSet: ContextMenuActionSet = [[
22     {
23         component: ToggleFavoriteAction,
24         name: 'ToggleFavoriteAction',
25         execute: (dispatch, resource) => {
26             dispatch<any>(toggleFavorite(resource)).then(() => {
27                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
28             });
29         }
30     },
31     {
32         icon: OpenIcon,
33         name: "Open in new tab",
34         execute: (dispatch, resource) => {
35             dispatch<any>(openInNewTabAction(resource));
36         }
37     },
38     {
39         icon: Link,
40         name: "Copy to clipboard",
41         execute: (dispatch, resource) => {
42             dispatch<any>(copyToClipboardAction(resource));
43         }
44     },
45     {
46         icon: DetailsIcon,
47         name: "View details",
48         execute: dispatch => {
49             dispatch<any>(toggleDetailsPanel());
50         }
51     },
52     {
53         icon: AdvancedIcon,
54         name: "Advanced",
55         execute: (dispatch, resource) => {
56             dispatch<any>(openAdvancedTabDialog(resource.uuid));
57         }
58     },
59 ]];
60
61 export const projectActionSet: ContextMenuActionSet = [
62     [
63         ...readOnlyProjectActionSet.reduce((prev, next) => prev.concat(next), []),
64         {
65             icon: NewProjectIcon,
66             name: "New project",
67             execute: (dispatch, resource) => {
68                 dispatch<any>(openProjectCreateDialog(resource.uuid));
69             }
70         },
71         {
72             icon: RenameIcon,
73             name: "Edit project",
74             execute: (dispatch, resource) => {
75                 dispatch<any>(openProjectUpdateDialog(resource));
76             }
77         },
78         {
79             icon: ShareIcon,
80             name: "Share",
81             execute: (dispatch, { uuid }) => {
82                 dispatch<any>(openSharingDialog(uuid));
83             }
84         },
85         {
86             icon: MoveToIcon,
87             name: "Move to",
88             execute: (dispatch, resource) => {
89                 dispatch<any>(openMoveProjectDialog(resource));
90             }
91         },
92         {
93             component: ToggleTrashAction,
94             name: 'ToggleTrashAction',
95             execute: (dispatch, resource) => {
96                 dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!));
97             }
98         },
99     ]
100 ];