21224: moved openuserattributes to resolve circular dep Arvados-DCO-1.1-Signed-off...
[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, deleteWorkflow } from 'store/workflow-panel/workflow-panel-actions';
6 import { StartIcon, TrashIcon, 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: TrashIcon,
28     hasAlts: false,
29     isForMulti: false,
30     execute: (dispatch, resources) => {
31         dispatch<any>(deleteWorkflow(resources[0].uuid, resources[0].ownerUuid));
32     },
33 };
34
35 const msCopyToClipboardMenuAction: MultiSelectMenuAction  = {
36     name: COPY_LINK_TO_CLIPBOARD,
37     icon: Link,
38     hasAlts: false,
39     isForMulti: false,
40     execute: (dispatch, resources) => {
41         dispatch<any>(copyToClipboardAction(resources));
42     },
43 };
44
45 const msShareAction: MultiSelectMenuAction  = {
46     name: SHARE,
47     icon: ShareIcon,
48     hasAlts: false,
49     isForMulti: false,
50     execute: (dispatch, resources) => {
51         dispatch<any>(openSharingDialog(resources[0].uuid));
52     },
53 };
54
55 export const msWorkflowActionSet: MultiSelectMenuActionSet = [[...msCommonActionSet, msRunWorkflow, msDeleteWorkflow, msCopyToClipboardMenuAction, msShareAction]];
56
57 export const msReadOnlyWorkflowActionFilter = new Set([OPEN_IN_NEW_TAB, COPY_LINK_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, RUN_WORKFLOW ]);
58 export const msWorkflowActionFilter = new Set([OPEN_IN_NEW_TAB, COPY_LINK_TO_CLIPBOARD, VIEW_DETAILS, API_DETAILS, RUN_WORKFLOW, DELETE_WORKFLOW]);