1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ContextMenuActionSet } from "../context-menu-action-set";
6 import { ToggleFavoriteAction } from "../actions/favorite-action";
7 import { toggleFavorite } from "store/favorites/favorites-actions";
9 RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon,
10 RemoveIcon, ReRunProcessIcon, InputIcon, OutputIcon, CommandIcon,
12 } from "components/icon/icon";
13 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
14 import { openMoveProcessDialog } from 'store/processes/process-move-actions';
15 import { openProcessUpdateDialog } from "store/processes/process-update-actions";
16 import { openCopyProcessDialog } from 'store/processes/process-copy-actions';
17 import { openSharingDialog } from "store/sharing-dialog/sharing-dialog-actions";
18 import { openRemoveProcessDialog, reRunProcess } from "store/processes/processes-actions";
19 import { toggleDetailsPanel } from 'store/details-panel/details-panel-action';
20 import { snackbarActions, SnackbarKind } from "store/snackbar/snackbar-actions";
21 import { openProcessInputDialog } from "store/processes/process-input-actions";
22 import { navigateToOutput } from "store/process-panel/process-panel-actions";
23 import { openProcessCommandDialog } from "store/processes/process-command-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";
29 export const readOnlyProcessResourceActionSet: ContextMenuActionSet = [[
31 component: ToggleFavoriteAction,
32 execute: (dispatch, resource) => {
33 dispatch<any>(toggleFavorite(resource)).then(() => {
34 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
40 name: "Copy to project",
41 execute: (dispatch, resource) => {
42 dispatch<any>(openCopyProcessDialog(resource));
46 icon: ReRunProcessIcon,
47 name: "Re-run process",
48 execute: (dispatch, resource) => {
49 if(resource.workflowUuid) {
50 dispatch<any>(reRunProcess(resource.uuid, resource.workflowUuid));
52 dispatch(snackbarActions.OPEN_SNACKBAR({ message: `You can't re-run this process`, hideDuration: 2000, kind: SnackbarKind.ERROR }));
59 execute: (dispatch, resource) => {
60 dispatch<any>(openProcessInputDialog(resource.uuid));
66 execute: (dispatch, resource) => {
67 if(resource.outputUuid){
68 dispatch<any>(navigateToOutput(resource.outputUuid));
75 execute: (dispatch, resource) => {
76 dispatch<any>(openProcessCommandDialog(resource.uuid));
82 execute: dispatch => {
83 dispatch<any>(toggleDetailsPanel());
89 execute: (dispatch, resource) => {
90 dispatch<any>(openAdvancedTabDialog(resource.uuid));
95 export const processResourceActionSet: ContextMenuActionSet = [[
96 ...readOnlyProcessResourceActionSet.reduce((prev, next) => prev.concat(next), []),
100 execute: (dispatch, resource) => {
101 dispatch<any>(openProcessUpdateDialog(resource));
107 execute: (dispatch, { uuid }) => {
108 dispatch<any>(openSharingDialog(uuid));
114 execute: (dispatch, resource) => {
115 dispatch<any>(openMoveProcessDialog(resource));
121 execute: (dispatch, resource) => {
122 dispatch<any>(openRemoveProcessDialog(resource.uuid));
127 export const processResourceAdminActionSet: ContextMenuActionSet = [[
128 ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []),
130 component: TogglePublicFavoriteAction,
131 name: "Add to public favorites",
132 execute: (dispatch, resource) => {
133 dispatch<any>(togglePublicFavorite(resource)).then(() => {
134 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());