Merge branch '22257-pydoc-api-xref'
[arvados.git] / services / workbench2 / src / views-components / multiselect-toolbar / ms-process-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ContextMenuActionNames } from "views-components/context-menu/context-menu-action-set";
6 import { DeleteForever, ReRunProcessIcon, OutputIcon, RenameIcon, StopIcon, CopyIcon, Link } from "components/icon/icon";
7 import { openCopyProcessDialog } from "store/processes/process-copy-actions";
8 import { openRemoveProcessDialog } from "store/processes/processes-actions";
9 import { MultiSelectMenuAction, MultiSelectMenuActionSet, msCommonActionSet } from "./ms-menu-actions";
10 import { openProcessUpdateDialog } from "store/processes/process-update-actions";
11 import { msNavigateToOutput } from "store/multiselect/multiselect-actions";
12 import { cancelRunningWorkflow } from "store/processes/processes-actions";
13 import { copyToClipboardAction, copyStringToClipboardAction } from "store/open-in-new-tab/open-in-new-tab.actions";
14
15 const {REMOVE, COPY_AND_RERUN_PROCESS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, ADD_TO_PUBLIC_FAVORITES, OUTPUTS, EDIT_PROCESS, CANCEL } = ContextMenuActionNames
16
17 const msCopyAndRerunProcess: MultiSelectMenuAction = {
18     name: COPY_AND_RERUN_PROCESS,
19     icon: ReRunProcessIcon,
20     hasAlts: false,
21     isForMulti: false,
22     execute: (dispatch, resources) => {
23         for (const resource of [...resources]) {
24             dispatch<any>(openCopyProcessDialog(resource));
25         }
26     },
27 }
28
29 const msRemoveProcess: MultiSelectMenuAction = {
30     name: REMOVE,
31     icon: DeleteForever,
32     hasAlts: false,
33     isForMulti: true,
34     execute: (dispatch, resources) => {
35         dispatch<any>(openRemoveProcessDialog(resources[0], resources.length));
36     },
37 }
38
39 const msCopyUuid: MultiSelectMenuAction  = {
40     name: COPY_UUID,
41     icon: CopyIcon,
42     hasAlts: false,
43     isForMulti: false,
44     execute: (dispatch, resources) => {
45         dispatch<any>(copyStringToClipboardAction(resources[0].uuid));
46     },
47 };
48
49 const msCopyToClipboardMenuAction: MultiSelectMenuAction  = {
50     name: COPY_LINK_TO_CLIPBOARD,
51     icon: Link,
52     hasAlts: false,
53     isForMulti: false,
54     execute: (dispatch, resources) => {
55         dispatch<any>(copyToClipboardAction(resources));
56     },
57 };
58
59 // removed until auto-move children is implemented
60 // const msMoveTo: MultiSelectMenuAction = {
61 //     name: MOVE_TO,
62 //     icon: MoveToIcon,
63 //     hasAlts: false,
64 //     isForMulti: true,
65 //     execute: (dispatch, resources) => {
66 //         dispatch<any>(openMoveProcessDialog(resources[0]));
67 //     },
68 // }
69
70 const msViewOutputs: MultiSelectMenuAction = {
71     name: OUTPUTS,
72     icon: OutputIcon,
73     hasAlts: false,
74     isForMulti: false,
75     execute: (dispatch, resources) => {
76                 if (resources[0]) {
77             dispatch<any>(msNavigateToOutput(resources[0]));
78         }
79     },
80 }
81
82 const msEditProcess: MultiSelectMenuAction = {
83     name: EDIT_PROCESS,
84     icon: RenameIcon,
85     hasAlts: false,
86     isForMulti: false,
87     execute: (dispatch, resources) => {
88         dispatch<any>(openProcessUpdateDialog(resources[0]));
89     },
90 }
91
92 const msCancelProcess: MultiSelectMenuAction = {
93     name: CANCEL,
94     icon: StopIcon,
95     hasAlts: false,
96     isForMulti: false,
97     execute: (dispatch, resources) => {
98         dispatch<any>(cancelRunningWorkflow(resources[0].uuid));
99     },
100 }
101
102 export const msProcessActionSet: MultiSelectMenuActionSet = [
103     [
104         ...msCommonActionSet,
105         msCopyAndRerunProcess,
106         msRemoveProcess,
107         // msMoveTo,
108         msViewOutputs,
109         msEditProcess,
110         msCancelProcess,
111         msCopyUuid,
112         msCopyToClipboardMenuAction,
113     ]
114 ];
115
116 export const msCommonProcessActionFilter = new Set([REMOVE, COPY_AND_RERUN_PROCESS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, OUTPUTS, EDIT_PROCESS ]);
117 export const msRunningProcessActionFilter = new Set([REMOVE, COPY_AND_RERUN_PROCESS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, OUTPUTS, EDIT_PROCESS, CANCEL ]);
118
119 export const msReadOnlyProcessActionFilter = new Set([COPY_AND_RERUN_PROCESS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, OUTPUTS ]);
120 export const msAdminProcessActionFilter = new Set([REMOVE, COPY_AND_RERUN_PROCESS, COPY_LINK_TO_CLIPBOARD, COPY_UUID, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, ADD_TO_PUBLIC_FAVORITES, OUTPUTS, EDIT_PROCESS ]);
121