21224: merged main to pass int tests
[arvados.git] / services / workbench2 / src / views-components / multiselect-toolbar / ms-workflow-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { openRunProcess, openRemoveWorkflowDialog } from 'store/workflow-panel/workflow-panel-actions';
6 import { StartIcon, DeleteForever, Link } from 'components/icon/icon';
7 import { MultiSelectMenuAction, MultiSelectMenuActionSet, msCommonActionSet } from './ms-menu-actions';
8 import { ContextMenuActionNames } from 'views-components/context-menu/context-menu-action-set';
9 import { copyToClipboardAction } from 'store/open-in-new-tab/open-in-new-tab.actions';
10 import { openSharingDialog } from 'store/sharing-dialog/sharing-dialog-actions';
11 import { ShareIcon } from 'components/icon/icon';
12
13 const { OPEN_IN_NEW_TAB, COPY_LINK_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, RUN_WORKFLOW, DELETE_WORKFLOW, SHARE } = ContextMenuActionNames;
14
15 const msRunWorkflow: MultiSelectMenuAction = {
16     name: RUN_WORKFLOW,
17     icon: StartIcon,
18     hasAlts: false,
19     isForMulti: false,
20     execute: (dispatch, resources) => {
21         dispatch<any>(openRunProcess(resources[0].uuid, resources[0].ownerUuid, resources[0].name));
22     },
23 };
24
25 const msDeleteWorkflow: MultiSelectMenuAction = {
26     name: DELETE_WORKFLOW,
27     icon: DeleteForever,
28     hasAlts: false,
29     isForMulti: true,
30     execute: (dispatch, resources) => {
31         for (const resource of [...resources]){
32             dispatch<any>(openRemoveWorkflowDialog(resource, resources.length));
33         }
34     },
35 };
36
37 const msCopyToClipboardMenuAction: MultiSelectMenuAction  = {
38     name: COPY_LINK_TO_CLIPBOARD,
39     icon: Link,
40     hasAlts: false,
41     isForMulti: false,
42     execute: (dispatch, resources) => {
43         dispatch<any>(copyToClipboardAction(resources));
44     },
45 };
46
47 const msShareAction: MultiSelectMenuAction  = {
48     name: SHARE,
49     icon: ShareIcon,
50     hasAlts: false,
51     isForMulti: false,
52     execute: (dispatch, resources) => {
53         dispatch<any>(openSharingDialog(resources[0].uuid));
54     },
55 };
56
57 export const msWorkflowActionSet: MultiSelectMenuActionSet = [[...msCommonActionSet, msRunWorkflow, msDeleteWorkflow, msCopyToClipboardMenuAction, msShareAction]];
58
59 export const msReadOnlyWorkflowActionFilter = new Set([OPEN_IN_NEW_TAB, COPY_LINK_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, RUN_WORKFLOW ]);
60 export const msWorkflowActionFilter = new Set([OPEN_IN_NEW_TAB, COPY_LINK_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, RUN_WORKFLOW, DELETE_WORKFLOW]);