Merge branch '21128-toolbar-context-menu'
[arvados-workbench2.git] / src / views-components / context-menu / action-sets / workflow-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set";
6 import { openRunProcess, deleteWorkflow } from "store/workflow-panel/workflow-panel-actions";
7 import { DetailsIcon, AdvancedIcon, OpenIcon, Link, StartIcon, TrashIcon } from "components/icon/icon";
8 import { copyToClipboardAction, openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions";
9 import { toggleDetailsPanel } from "store/details-panel/details-panel-action";
10 import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
11
12 export const readOnlyWorkflowActionSet: ContextMenuActionSet = [
13     [
14         {
15             icon: OpenIcon,
16             name: "Open in new tab",
17             execute: (dispatch, resources) => {
18                 dispatch<any>(openInNewTabAction(resources[0]));
19             },
20         },
21         {
22             icon: Link,
23             name: "Copy to clipboard",
24             execute: (dispatch, resources) => {
25                 dispatch<any>(copyToClipboardAction(resources));
26             },
27         },
28         {
29             icon: DetailsIcon,
30             name: "View details",
31             execute: dispatch => {
32                 dispatch<any>(toggleDetailsPanel());
33             },
34         },
35         {
36             icon: AdvancedIcon,
37             name: "API Details",
38             execute: (dispatch, resources) => {
39                 dispatch<any>(openAdvancedTabDialog(resources[0].uuid));
40             },
41         },
42         {
43             icon: StartIcon,
44             name: "Run Workflow",
45             execute: (dispatch, resources) => {
46                 dispatch<any>(openRunProcess(resources[0].uuid, resources[0].ownerUuid, resources[0].name));
47             },
48         },
49     ],
50 ];
51
52 export const workflowActionSet: ContextMenuActionSet = [
53     [
54         ...readOnlyWorkflowActionSet[0],
55         {
56             icon: TrashIcon,
57             name: "Delete Workflow",
58             execute: (dispatch, resources) => {
59                 dispatch<any>(deleteWorkflow(resources[0].uuid, resources[0].ownerUuid));
60             },
61         },
62     ],
63 ];