1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ContextMenuActionSet, ContextMenuActionNames } from "../context-menu-action-set";
6 import { ToggleFavoriteAction } from "../actions/favorite-action";
7 import { toggleFavorite } from "store/favorites/favorites-actions";
18 } from "components/icon/icon";
19 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
20 import { openProcessUpdateDialog } from "store/processes/process-update-actions";
21 import { openCopyProcessDialog } from "store/processes/process-copy-actions";
22 import { openRemoveProcessDialog } from "store/processes/processes-actions";
23 import { openDetailsPanel } from "store/details-panel/details-panel-action";
24 import { navigateToOutput } from "store/process-panel/process-panel-actions";
25 import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
26 import { TogglePublicFavoriteAction } from "../actions/public-favorite-action";
27 import { togglePublicFavorite } from "store/public-favorites/public-favorites-actions";
28 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
29 import { openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions";
30 import { cancelRunningWorkflow } from "store/processes/processes-actions";
31 import { copyStringToClipboardAction } from "store/open-in-new-tab/open-in-new-tab.actions";
33 export const readOnlyProcessResourceActionSet: ContextMenuActionSet = [
36 component: ToggleFavoriteAction,
37 name: ContextMenuActionNames.ADD_TO_FAVORITES,
38 execute: (dispatch, resources) => {
39 dispatch<any>(toggleFavorite(resources[0])).then(() => {
40 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
46 name: ContextMenuActionNames.OPEN_IN_NEW_TAB,
47 execute: (dispatch, resources) => {
48 dispatch<any>(openInNewTabAction(resources[0]));
52 icon: ReRunProcessIcon,
53 name: ContextMenuActionNames.COPY_AND_RERUN_PROCESS,
54 execute: (dispatch, resources) => {
55 dispatch<any>(openCopyProcessDialog(resources[0]));
60 name: ContextMenuActionNames.OUTPUTS,
61 execute: (dispatch, resources) => {
63 dispatch<any>(navigateToOutput(resources[0]));
69 name: ContextMenuActionNames.VIEW_DETAILS,
70 execute: (dispatch, resources) => {
71 dispatch<any>(openDetailsPanel(resources[0].uuid));
76 name: ContextMenuActionNames.API_DETAILS,
77 execute: (dispatch, resources) => {
78 dispatch<any>(openAdvancedTabDialog(resources[0].uuid));
83 name: ContextMenuActionNames.COPY_UUID,
84 execute: (dispatch, resources) => {
85 dispatch<any>(copyStringToClipboardAction(resources[0].uuid));
91 export const processResourceActionSet: ContextMenuActionSet = [
93 ...readOnlyProcessResourceActionSet.reduce((prev, next) => prev.concat(next), []),
96 name: ContextMenuActionNames.EDIT_PROCESS,
97 execute: (dispatch, resources) => {
98 dispatch<any>(openProcessUpdateDialog(resources[0]));
101 // removed until auto-move children is implemented
104 // name: ContextMenuActionNames.MOVE_TO,
105 // execute: (dispatch, resources) => {
106 // dispatch<any>(openMoveProcessDialog(resources[0]));
110 name: ContextMenuActionNames.REMOVE,
112 execute: (dispatch, resources) => {
113 dispatch<any>(openRemoveProcessDialog(resources[0], resources.length));
119 const runningProcessOnlyActionSet: ContextMenuActionSet = [
122 name: ContextMenuActionNames.CANCEL,
124 execute: (dispatch, resources) => {
125 dispatch<any>(cancelRunningWorkflow(resources[0].uuid));
131 export const processResourceAdminActionSet: ContextMenuActionSet = [
133 ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []),
135 component: TogglePublicFavoriteAction,
136 name: ContextMenuActionNames.ADD_TO_PUBLIC_FAVORITES,
137 execute: (dispatch, resources) => {
138 dispatch<any>(togglePublicFavorite(resources[0])).then(() => {
139 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
146 export const runningProcessResourceActionSet = [
148 ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []),
149 ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []),
153 export const runningProcessResourceAdminActionSet: ContextMenuActionSet = [
155 ...processResourceAdminActionSet.reduce((prev, next) => prev.concat(next), []),
156 ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []),