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";
17 } from "components/icon/icon";
18 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
19 import { openProcessUpdateDialog } from "store/processes/process-update-actions";
20 import { openCopyProcessDialog } from "store/processes/process-copy-actions";
21 import { openRemoveProcessDialog } from "store/processes/processes-actions";
22 import { toggleDetailsPanel } from "store/details-panel/details-panel-action";
23 import { navigateToOutput } from "store/process-panel/process-panel-actions";
24 import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
25 import { TogglePublicFavoriteAction } from "../actions/public-favorite-action";
26 import { togglePublicFavorite } from "store/public-favorites/public-favorites-actions";
27 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
28 import { openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions";
29 import { cancelRunningWorkflow } from "store/processes/processes-actions";
31 export const readOnlyProcessResourceActionSet: ContextMenuActionSet = [
34 component: ToggleFavoriteAction,
35 name: ContextMenuActionNames.ADD_TO_FAVORITES,
36 execute: (dispatch, resources) => {
37 dispatch<any>(toggleFavorite(resources[0])).then(() => {
38 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
44 name: ContextMenuActionNames.OPEN_IN_NEW_TAB,
45 execute: (dispatch, resources) => {
46 dispatch<any>(openInNewTabAction(resources[0]));
50 icon: ReRunProcessIcon,
51 name: ContextMenuActionNames.COPY_AND_RERUN_PROCESS,
52 execute: (dispatch, resources) => {
53 dispatch<any>(openCopyProcessDialog(resources[0]));
58 name: ContextMenuActionNames.OUTPUTS,
59 execute: (dispatch, resources) => {
61 dispatch<any>(navigateToOutput(resources[0]));
67 name: ContextMenuActionNames.VIEW_DETAILS,
68 execute: dispatch => {
69 dispatch<any>(toggleDetailsPanel());
74 name: ContextMenuActionNames.API_DETAILS,
75 execute: (dispatch, resources) => {
76 dispatch<any>(openAdvancedTabDialog(resources[0].uuid));
82 export const processResourceActionSet: ContextMenuActionSet = [
84 ...readOnlyProcessResourceActionSet.reduce((prev, next) => prev.concat(next), []),
87 name: ContextMenuActionNames.EDIT_PROCESS,
88 execute: (dispatch, resources) => {
89 dispatch<any>(openProcessUpdateDialog(resources[0]));
92 // removed until auto-move children is implemented
95 // name: ContextMenuActionNames.MOVE_TO,
96 // execute: (dispatch, resources) => {
97 // dispatch<any>(openMoveProcessDialog(resources[0]));
101 name: ContextMenuActionNames.REMOVE,
103 execute: (dispatch, resources) => {
104 dispatch<any>(openRemoveProcessDialog(resources[0], resources.length));
110 const runningProcessOnlyActionSet: ContextMenuActionSet = [
113 name: ContextMenuActionNames.CANCEL,
115 execute: (dispatch, resources) => {
116 dispatch<any>(cancelRunningWorkflow(resources[0].uuid));
122 export const processResourceAdminActionSet: ContextMenuActionSet = [
124 ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []),
126 component: TogglePublicFavoriteAction,
127 name: ContextMenuActionNames.ADD_TO_PUBLIC_FAVORITES,
128 execute: (dispatch, resources) => {
129 dispatch<any>(togglePublicFavorite(resources[0])).then(() => {
130 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
137 export const runningProcessResourceActionSet = [
139 ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []),
140 ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []),
144 export const runningProcessResourceAdminActionSet: ContextMenuActionSet = [
146 ...processResourceAdminActionSet.reduce((prev, next) => prev.concat(next), []),
147 ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []),