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";
19 } from "components/icon/icon";
20 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
21 import { openMoveProcessDialog } from "store/processes/process-move-actions";
22 import { openProcessUpdateDialog } from "store/processes/process-update-actions";
23 import { openCopyProcessDialog } from "store/processes/process-copy-actions";
24 import { openSharingDialog } from "store/sharing-dialog/sharing-dialog-actions";
25 import { openRemoveProcessDialog } from "store/processes/processes-actions";
26 import { toggleDetailsPanel } from "store/details-panel/details-panel-action";
27 import { navigateToOutput } from "store/process-panel/process-panel-actions";
28 import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
29 import { TogglePublicFavoriteAction } from "../actions/public-favorite-action";
30 import { togglePublicFavorite } from "store/public-favorites/public-favorites-actions";
31 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
32 import { openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions";
33 import { cancelRunningWorkflow } from "store/processes/processes-actions";
35 export const readOnlyProcessResourceActionSet: ContextMenuActionSet = [
38 component: ToggleFavoriteAction,
39 name: ContextMenuActionNames.ADD_TO_FAVORITES,
40 execute: (dispatch, resources) => {
41 dispatch<any>(toggleFavorite(resources[0])).then(() => {
42 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
48 name: ContextMenuActionNames.OPEN_IN_NEW_TAB,
49 execute: (dispatch, resources) => {
50 dispatch<any>(openInNewTabAction(resources[0]));
54 icon: ReRunProcessIcon,
55 name: ContextMenuActionNames.COPY_AND_RERUN_PROCESS,
56 execute: (dispatch, resources) => {
57 dispatch<any>(openCopyProcessDialog(resources[0]));
62 name: ContextMenuActionNames.OUTPUTS,
63 execute: (dispatch, resources) => {
65 dispatch<any>(navigateToOutput(resources[0]));
71 name: ContextMenuActionNames.VIEW_DETAILS,
72 execute: dispatch => {
73 dispatch<any>(toggleDetailsPanel());
78 name: ContextMenuActionNames.API_DETAILS,
79 execute: (dispatch, resources) => {
80 dispatch<any>(openAdvancedTabDialog(resources[0].uuid));
86 export const processResourceActionSet: ContextMenuActionSet = [
88 ...readOnlyProcessResourceActionSet.reduce((prev, next) => prev.concat(next), []),
91 name: ContextMenuActionNames.EDIT_PROCESS,
92 execute: (dispatch, resources) => {
93 dispatch<any>(openProcessUpdateDialog(resources[0]));
98 name: ContextMenuActionNames.MOVE_TO,
99 execute: (dispatch, resources) => {
100 dispatch<any>(openMoveProcessDialog(resources[0]));
104 name: ContextMenuActionNames.REMOVE,
106 execute: (dispatch, resources) => {
107 dispatch<any>(openRemoveProcessDialog(resources[0], resources.length));
113 const runningProcessOnlyActionSet: ContextMenuActionSet = [
116 name: ContextMenuActionNames.CANCEL,
118 execute: (dispatch, resources) => {
119 dispatch<any>(cancelRunningWorkflow(resources[0].uuid));
125 export const processResourceAdminActionSet: ContextMenuActionSet = [
127 ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []),
129 component: TogglePublicFavoriteAction,
130 name: ContextMenuActionNames.ADD_TO_PUBLIC_FAVORITES,
131 execute: (dispatch, resources) => {
132 dispatch<any>(togglePublicFavorite(resources[0])).then(() => {
133 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
140 export const runningProcessResourceActionSet = [
142 ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []),
143 ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []),
147 export const runningProcessResourceAdminActionSet: ContextMenuActionSet = [
149 ...processResourceAdminActionSet.reduce((prev, next) => prev.concat(next), []),
150 ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []),