16437: Removes context items when projects are not editable by user
[arvados.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 } 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
20 export const readOnlyProjectActionSet: ContextMenuActionSet = [[
21     {
22         component: ToggleFavoriteAction,
23         execute: (dispatch, resource) => {
24             dispatch<any>(toggleFavorite(resource)).then(() => {
25                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
26             });
27         }
28     },
29     {
30         icon: DetailsIcon,
31         name: "View details",
32         execute: dispatch => {
33             dispatch<any>(toggleDetailsPanel());
34         }
35     },
36     {
37         icon: AdvancedIcon,
38         name: "Advanced",
39         execute: (dispatch, resource) => {
40             dispatch<any>(openAdvancedTabDialog(resource.uuid));
41         }
42     },
43 ]];
44
45 export const projectActionSet: ContextMenuActionSet = [
46     [
47         ...readOnlyProjectActionSet.reduce((prev, next) => prev.concat(next), []),
48         {
49             icon: NewProjectIcon,
50             name: "New project",
51             execute: (dispatch, resource) => {
52                 dispatch<any>(openProjectCreateDialog(resource.uuid));
53             }
54         },
55         {
56             icon: RenameIcon,
57             name: "Edit project",
58             execute: (dispatch, resource) => {
59                 dispatch<any>(openProjectUpdateDialog(resource));
60             }
61         },
62         {
63             icon: ShareIcon,
64             name: "Share",
65             execute: (dispatch, { uuid }) => {
66                 dispatch<any>(openSharingDialog(uuid));
67             }
68         },
69         {
70             icon: MoveToIcon,
71             name: "Move to",
72             execute: (dispatch, resource) => {
73                 dispatch<any>(openMoveProjectDialog(resource));
74             }
75         },
76         {
77             component: ToggleTrashAction,
78             execute: (dispatch, resource) => {
79                 dispatch<any>(toggleProjectTrashed(resource.uuid, resource.ownerUuid, resource.isTrashed!!));
80             }
81         },
82     ]
83 ];