21224: merged main to pass int tests
[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 } 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
14 const msCopyAndRerunProcess: MultiSelectMenuAction = {
15     name: ContextMenuActionNames.COPY_AND_RERUN_PROCESS,
16     icon: ReRunProcessIcon,
17     hasAlts: false,
18     isForMulti: false,
19     execute: (dispatch, resources) => {
20         for (const resource of [...resources]) {
21             dispatch<any>(openCopyProcessDialog(resource));
22         }
23     },
24 }
25
26 const msRemoveProcess: MultiSelectMenuAction = {
27     name: ContextMenuActionNames.REMOVE,
28     icon: DeleteForever,
29     hasAlts: false,
30     isForMulti: true,
31     execute: (dispatch, resources) => {
32         dispatch<any>(openRemoveProcessDialog(resources[0], resources.length));
33     },
34 }
35
36 // removed until auto-move children is implemented
37 // const msMoveTo: MultiSelectMenuAction = {
38 //     name: ContextMenuActionNames.MOVE_TO,
39 //     icon: MoveToIcon,
40 //     hasAlts: false,
41 //     isForMulti: true,
42 //     execute: (dispatch, resources) => {
43 //         dispatch<any>(openMoveProcessDialog(resources[0]));
44 //     },
45 // }
46
47 const msViewOutputs: MultiSelectMenuAction = {
48     name: ContextMenuActionNames.OUTPUTS,
49     icon: OutputIcon,
50     hasAlts: false,
51     isForMulti: false,
52     execute: (dispatch, resources) => {
53                 if (resources[0]) {
54             dispatch<any>(msNavigateToOutput(resources[0]));
55         }
56     },
57 }
58
59 const msEditProcess: MultiSelectMenuAction = {
60     name: ContextMenuActionNames.EDIT_PROCESS,
61     icon: RenameIcon,
62     hasAlts: false,
63     isForMulti: false,
64     execute: (dispatch, resources) => {
65         dispatch<any>(openProcessUpdateDialog(resources[0]));
66     },
67 }
68
69 const msCancelProcess: MultiSelectMenuAction = {
70     name: ContextMenuActionNames.CANCEL,
71     icon: StopIcon,
72     hasAlts: false,
73     isForMulti: false,
74     execute: (dispatch, resources) => {
75         dispatch<any>(cancelRunningWorkflow(resources[0].uuid));
76     },
77 }
78
79 export const msProcessActionSet: MultiSelectMenuActionSet = [
80     [
81         ...msCommonActionSet,
82         msCopyAndRerunProcess,
83         msRemoveProcess,
84         // msMoveTo,
85         msViewOutputs,
86         msEditProcess,
87         msCancelProcess
88     ]
89 ];
90
91 const {REMOVE, COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, ADD_TO_PUBLIC_FAVORITES, OUTPUTS, EDIT_PROCESS, CANCEL } = ContextMenuActionNames
92
93 export const msCommonProcessActionFilter = new Set([REMOVE, COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, OUTPUTS, EDIT_PROCESS ]);
94 export const msRunningProcessActionFilter = new Set([REMOVE, COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, OUTPUTS, EDIT_PROCESS, CANCEL ]);
95
96 export const msReadOnlyProcessActionFilter = new Set([COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, OUTPUTS ]);
97 export const msAdminProcessActionFilter = new Set([REMOVE, COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, ADD_TO_PUBLIC_FAVORITES, OUTPUTS, EDIT_PROCESS ]);
98