18559: Add adminOnly context menu item flag
[arvados.git] / src / views-components / context-menu / action-sets / process-resource-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 { ToggleFavoriteAction } from "../actions/favorite-action";
7 import { toggleFavorite } from "store/favorites/favorites-actions";
8 import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, RemoveIcon } from "components/icon/icon";
9 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
10 import { openMoveProcessDialog } from 'store/processes/process-move-actions';
11 import { openProcessUpdateDialog } from "store/processes/process-update-actions";
12 import { openCopyProcessDialog } from 'store/processes/process-copy-actions';
13 import { openSharingDialog } from "store/sharing-dialog/sharing-dialog-actions";
14 import { openRemoveProcessDialog } from "store/processes/processes-actions";
15 import { toggleDetailsPanel } from 'store/details-panel/details-panel-action';
16 import { TogglePublicFavoriteAction } from "views-components/context-menu/actions/public-favorite-action";
17 import { togglePublicFavorite } from "store/public-favorites/public-favorites-actions";
18 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
19
20 export const processResourceAdminActionSet: ContextMenuActionSet = [[
21     {
22         icon: RenameIcon,
23         name: "Edit process",
24         execute: (dispatch, resource) => {
25             dispatch<any>(openProcessUpdateDialog(resource));
26         }
27     },
28     {
29         icon: ShareIcon,
30         name: "Share",
31         execute: (dispatch, { uuid }) => {
32             dispatch<any>(openSharingDialog(uuid));
33         }
34     },
35     {
36         component: ToggleFavoriteAction,
37         execute: (dispatch, resource) => {
38             dispatch<any>(toggleFavorite(resource)).then(() => {
39                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
40             });
41         }
42     },
43     {
44         component: TogglePublicFavoriteAction,
45         execute: (dispatch, resource) => {
46             dispatch<any>(togglePublicFavorite(resource)).then(() => {
47                 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
48             });
49         }
50     },
51     {
52         icon: MoveToIcon,
53         name: "Move to",
54         execute: (dispatch, resource) => {
55             dispatch<any>(openMoveProcessDialog(resource));
56         }
57     },
58     {
59         icon: CopyIcon,
60         name: "Copy to project",
61         execute: (dispatch, resource) => {
62             dispatch<any>(openCopyProcessDialog(resource));
63         }
64     },
65     {
66         icon: DetailsIcon,
67         name: "View details",
68         execute: dispatch => {
69             dispatch<any>(toggleDetailsPanel());
70         }
71     },
72     {
73         name: "Remove",
74         icon: RemoveIcon,
75         execute: (dispatch, resource) => {
76             dispatch<any>(openRemoveProcessDialog(resource.uuid));
77         }
78     }
79 ]];