21448: removed move to from processes Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa...
[arvados.git] / services / workbench2 / src / views-components / context-menu / action-sets / process-resource-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ContextMenuActionSet, ContextMenuActionNames } from "../context-menu-action-set";
6 import { ToggleFavoriteAction } from "../actions/favorite-action";
7 import { toggleFavorite } from "store/favorites/favorites-actions";
8 import {
9     RenameIcon,
10     ShareIcon,
11     MoveToIcon,
12     DetailsIcon,
13     RemoveIcon,
14     ReRunProcessIcon,
15     OutputIcon,
16     AdvancedIcon,
17     OpenIcon,
18     StopIcon,
19 } from "components/icon/icon";
20 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
21 import { openMoveProcessDialog } from "store/processes/process-move-actions";
22 import { openProcessUpdateDialog } from "store/processes/process-update-actions";
23 import { openCopyProcessDialog } from "store/processes/process-copy-actions";
24 import { openSharingDialog } from "store/sharing-dialog/sharing-dialog-actions";
25 import { openRemoveProcessDialog } from "store/processes/processes-actions";
26 import { toggleDetailsPanel } from "store/details-panel/details-panel-action";
27 import { navigateToOutput } from "store/process-panel/process-panel-actions";
28 import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
29 import { TogglePublicFavoriteAction } from "../actions/public-favorite-action";
30 import { togglePublicFavorite } from "store/public-favorites/public-favorites-actions";
31 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
32 import { openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions";
33 import { cancelRunningWorkflow } from "store/processes/processes-actions";
34
35 export const readOnlyProcessResourceActionSet: ContextMenuActionSet = [
36     [
37         {
38             component: ToggleFavoriteAction,
39             name: ContextMenuActionNames.ADD_TO_FAVORITES,
40             execute: (dispatch, resources) => {
41                 dispatch<any>(toggleFavorite(resources[0])).then(() => {
42                     dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
43                 });
44             },
45         },
46         {
47             icon: OpenIcon,
48             name: ContextMenuActionNames.OPEN_IN_NEW_TAB,
49             execute: (dispatch, resources) => {
50                 dispatch<any>(openInNewTabAction(resources[0]));
51             },
52         },
53         {
54             icon: ReRunProcessIcon,
55             name: ContextMenuActionNames.COPY_AND_RERUN_PROCESS,
56             execute: (dispatch, resources) => {
57                 dispatch<any>(openCopyProcessDialog(resources[0]));
58             },
59         },
60         {
61             icon: OutputIcon,
62             name: ContextMenuActionNames.OUTPUTS,
63             execute: (dispatch, resources) => {
64                 if (resources[0]) {
65                     dispatch<any>(navigateToOutput(resources[0]));
66                 }
67             },
68         },
69         {
70             icon: DetailsIcon,
71             name: ContextMenuActionNames.VIEW_DETAILS,
72             execute: dispatch => {
73                 dispatch<any>(toggleDetailsPanel());
74             },
75         },
76         {
77             icon: AdvancedIcon,
78             name: ContextMenuActionNames.API_DETAILS,
79             execute: (dispatch, resources) => {
80                 dispatch<any>(openAdvancedTabDialog(resources[0].uuid));
81             },
82         },
83     ],
84 ];
85
86 export const processResourceActionSet: ContextMenuActionSet = [
87     [
88         ...readOnlyProcessResourceActionSet.reduce((prev, next) => prev.concat(next), []),
89         {
90             icon: RenameIcon,
91             name: ContextMenuActionNames.EDIT_PROCESS,
92             execute: (dispatch, resources) => {
93                 dispatch<any>(openProcessUpdateDialog(resources[0]));
94             },
95         },
96         // {
97         //     icon: MoveToIcon,
98         //     name: ContextMenuActionNames.MOVE_TO,
99         //     execute: (dispatch, resources) => {
100         //         dispatch<any>(openMoveProcessDialog(resources[0]));
101         //     },
102         // },
103         {
104             name: ContextMenuActionNames.REMOVE,
105             icon: RemoveIcon,
106             execute: (dispatch, resources) => {
107                 dispatch<any>(openRemoveProcessDialog(resources[0], resources.length));
108             },
109         },
110     ],
111 ];
112
113 const runningProcessOnlyActionSet: ContextMenuActionSet = [
114     [
115         {
116             name: ContextMenuActionNames.CANCEL,
117             icon: StopIcon,
118             execute: (dispatch, resources) => {
119                 dispatch<any>(cancelRunningWorkflow(resources[0].uuid));
120             },
121         },
122     ]
123 ];
124
125 export const processResourceAdminActionSet: ContextMenuActionSet = [
126     [
127         ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []),
128         {
129             component: TogglePublicFavoriteAction,
130             name: ContextMenuActionNames.ADD_TO_PUBLIC_FAVORITES,
131             execute: (dispatch, resources) => {
132                 dispatch<any>(togglePublicFavorite(resources[0])).then(() => {
133                     dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
134                 });
135             },
136         },
137     ],
138 ];
139
140 export const runningProcessResourceActionSet = [
141     [
142         ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []),
143         ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []),
144     ],
145 ];
146
147 export const runningProcessResourceAdminActionSet: ContextMenuActionSet = [
148     [
149         ...processResourceAdminActionSet.reduce((prev, next) => prev.concat(next), []),
150         ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []),
151     ],
152 ];