16437: Removes context items when projects are not editable by user
[arvados-workbench2.git] / src / views-components / context-menu / action-sets / process-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 "~/views-components/context-menu/context-menu-action-set";
6 import { ToggleFavoriteAction } from "~/views-components/context-menu/actions/favorite-action";
7 import { toggleFavorite } from "~/store/favorites/favorites-actions";
8 import {
9     RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon,
10     AdvancedIcon, RemoveIcon, ReRunProcessIcon, LogIcon, InputIcon, CommandIcon, OutputIcon
11 } from "~/components/icon/icon";
12 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
13 import { navigateToProcessLogs } from '~/store/navigation/navigation-action';
14 import { openMoveProcessDialog } from '~/store/processes/process-move-actions';
15 import { openProcessUpdateDialog } from "~/store/processes/process-update-actions";
16 import { openCopyProcessDialog } from '~/store/processes/process-copy-actions';
17 import { openProcessCommandDialog } from '~/store/processes/process-command-actions';
18 import { openSharingDialog } from "~/store/sharing-dialog/sharing-dialog-actions";
19 import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
20 import { openProcessInputDialog } from "~/store/processes/process-input-actions";
21 import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
22 import { openRemoveProcessDialog, reRunProcess } from "~/store/processes/processes-actions";
23 import { navigateToOutput } from "~/store/process-panel/process-panel-actions";
24 import { snackbarActions, SnackbarKind } from "~/store/snackbar/snackbar-actions";
25
26 export const processActionSet: ContextMenuActionSet = [[
27     {
28         icon: RenameIcon,
29         name: "Edit process",
30         execute: (dispatch, resource) => {
31             dispatch<any>(openProcessUpdateDialog(resource));
32         }
33     },
34     {
35         icon: ShareIcon,
36         name: "Share",
37         execute: (dispatch, { uuid }) => {
38             dispatch<any>(openSharingDialog(uuid));
39         }
40     },
41     {
42         component: ToggleFavoriteAction,
43         execute: (dispatch, resource) => {
44             dispatch<any>(toggleFavorite(resource)).then(() => {
45                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
46             });
47         }
48     },
49     {
50         icon: MoveToIcon,
51         name: "Move to",
52         execute: (dispatch, resource) => {
53             dispatch<any>(openMoveProcessDialog(resource));
54         }
55     },
56     {
57         icon: CopyIcon,
58         name: "Copy to project",
59         execute: (dispatch, resource) => {
60             dispatch<any>(openCopyProcessDialog(resource));
61         }
62     },
63     {
64         icon: ReRunProcessIcon,
65         name: "Re-run process",
66         execute: (dispatch, resource) => {
67             if(resource.workflowUuid) {
68                 dispatch<any>(reRunProcess(resource.uuid, resource.workflowUuid));
69             } else {
70                 dispatch(snackbarActions.OPEN_SNACKBAR({ message: `You can't re-run this process`, hideDuration: 2000, kind: SnackbarKind.ERROR }));
71             }        
72         }        
73     },
74     {
75         icon: InputIcon,
76         name: "Inputs",
77         execute: (dispatch, resource) => {
78             dispatch<any>(openProcessInputDialog(resource.uuid));
79         }
80     },
81     {
82         icon: OutputIcon,
83         name: "Outputs",
84         execute: (dispatch, resource) => {
85             if(resource.outputUuid){
86                 dispatch<any>(navigateToOutput(resource.outputUuid));
87             }
88         }
89     },
90     {
91         icon: CommandIcon,
92         name: "Command",
93         execute: (dispatch, resource) => {
94             dispatch<any>(openProcessCommandDialog(resource.uuid));
95         }
96     },
97     {
98         icon: LogIcon,
99         name: "Log",
100         execute: (dispatch, resource) => {
101             dispatch<any>(navigateToProcessLogs(resource.uuid));
102         }
103     },
104     {
105         icon: DetailsIcon,
106         name: "View details",
107         execute: dispatch => {
108             dispatch<any>(toggleDetailsPanel());
109         }
110     },
111     // {
112     //     icon: ProvenanceGraphIcon,
113     //     name: "Provenance graph",
114     //     execute: (dispatch, resource) => {
115     //         // add code
116     //     }
117     // },
118     {
119         icon: AdvancedIcon,
120         name: "Advanced",
121         execute: (dispatch, resource) => {
122             dispatch<any>(openAdvancedTabDialog(resource.uuid));
123         }
124     },
125     {
126         name: "Remove",
127         icon: RemoveIcon,
128         execute: (dispatch, resource) => {
129             dispatch<any>(openRemoveProcessDialog(resource.uuid));
130         }
131     }
132 ]];