X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/aed4e6256e6d5ecb5edc60a04a5aab6f04d9fb99..73e8a8225a4a702e3392da9ac9bb50ff479377c0:/src/views-components/context-menu/action-sets/process-resource-action-set.ts diff --git a/src/views-components/context-menu/action-sets/process-resource-action-set.ts b/src/views-components/context-menu/action-sets/process-resource-action-set.ts index 8cab9bfd..2aa7faa1 100644 --- a/src/views-components/context-menu/action-sets/process-resource-action-set.ts +++ b/src/views-components/context-menu/action-sets/process-resource-action-set.ts @@ -4,65 +4,155 @@ import { ContextMenuActionSet } from "../context-menu-action-set"; import { ToggleFavoriteAction } from "../actions/favorite-action"; -import { toggleFavorite } from "~/store/favorites/favorites-actions"; -import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, RemoveIcon } from "~/components/icon/icon"; -import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action"; -import { openMoveProcessDialog } from '~/store/processes/process-move-actions'; -import { openProcessUpdateDialog } from "~/store/processes/process-update-actions"; -import { openCopyProcessDialog } from '~/store/processes/process-copy-actions'; -import { openSharingDialog } from "~/store/sharing-dialog/sharing-dialog-actions"; -import { openRemoveProcessDialog } from "~/store/processes/processes-actions"; -import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action'; +import { toggleFavorite } from "store/favorites/favorites-actions"; +import { + RenameIcon, + ShareIcon, + MoveToIcon, + DetailsIcon, + RemoveIcon, + ReRunProcessIcon, + OutputIcon, + AdvancedIcon, + OpenIcon, + StopIcon, +} from "components/icon/icon"; +import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action"; +import { openMoveProcessDialog } from "store/processes/process-move-actions"; +import { openProcessUpdateDialog } from "store/processes/process-update-actions"; +import { openCopyProcessDialog } from "store/processes/process-copy-actions"; +import { openSharingDialog } from "store/sharing-dialog/sharing-dialog-actions"; +import { openRemoveProcessDialog } from "store/processes/processes-actions"; +import { toggleDetailsPanel } from "store/details-panel/details-panel-action"; +import { navigateToOutput } from "store/process-panel/process-panel-actions"; +import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab"; +import { TogglePublicFavoriteAction } from "../actions/public-favorite-action"; +import { togglePublicFavorite } from "store/public-favorites/public-favorites-actions"; +import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action"; +import { openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions"; +import { cancelRunningWorkflow } from "store/processes/processes-actions"; -export const processResourceActionSet: ContextMenuActionSet = [[ - { - icon: RenameIcon, - name: "Edit process", - execute: (dispatch, resource) => { - dispatch(openProcessUpdateDialog(resource)); - } - }, - { - icon: ShareIcon, - name: "Share", - execute: (dispatch, { uuid }) => { - dispatch(openSharingDialog(uuid)); - } - }, - { - component: ToggleFavoriteAction, - execute: (dispatch, resource) => { - dispatch(toggleFavorite(resource)).then(() => { - dispatch(favoritePanelActions.REQUEST_ITEMS()); - }); - } - }, - { - icon: MoveToIcon, - name: "Move to", - execute: (dispatch, resource) => { - dispatch(openMoveProcessDialog(resource)); - } - }, - { - icon: CopyIcon, - name: "Copy to project", - execute: (dispatch, resource) => { - dispatch(openCopyProcessDialog(resource)); - } - }, - { - icon: DetailsIcon, - name: "View details", - execute: dispatch => { - dispatch(toggleDetailsPanel()); - } - }, - { - name: "Remove", - icon: RemoveIcon, - execute: (dispatch, resource) => { - dispatch(openRemoveProcessDialog(resource.uuid)); - } - } -]]; +export const readOnlyProcessResourceActionSet: ContextMenuActionSet = [ + [ + { + component: ToggleFavoriteAction, + execute: (dispatch, resources) => { + dispatch(toggleFavorite(resources[0])).then(() => { + dispatch(favoritePanelActions.REQUEST_ITEMS()); + }); + }, + }, + { + icon: OpenIcon, + name: "Open in new tab", + execute: (dispatch, resources) => { + dispatch(openInNewTabAction(resources[0])); + }, + }, + { + icon: ReRunProcessIcon, + name: "Copy and re-run process", + execute: (dispatch, resources) => { + dispatch(openCopyProcessDialog(resources[0])); + }, + }, + { + icon: OutputIcon, + name: "Outputs", + execute: (dispatch, resources) => { + if (resources[0]) { + dispatch(navigateToOutput(resources[0])); + } + }, + }, + { + icon: DetailsIcon, + name: "View details", + execute: dispatch => { + dispatch(toggleDetailsPanel()); + }, + }, + { + icon: AdvancedIcon, + name: "API Details", + execute: (dispatch, resources) => { + dispatch(openAdvancedTabDialog(resources[0].uuid)); + }, + }, + ], +]; + +export const processResourceActionSet: ContextMenuActionSet = [ + [ + ...readOnlyProcessResourceActionSet.reduce((prev, next) => prev.concat(next), []), + { + icon: RenameIcon, + name: "Edit process", + execute: (dispatch, resources) => { + dispatch(openProcessUpdateDialog(resources[0])); + }, + }, + { + icon: ShareIcon, + name: "Share", + execute: (dispatch, resources) => { + dispatch(openSharingDialog(resources[0].uuid)); + }, + }, + { + icon: MoveToIcon, + name: "Move to", + execute: (dispatch, resources) => { + dispatch(openMoveProcessDialog(resources[0])); + }, + }, + { + name: "Remove", + icon: RemoveIcon, + execute: (dispatch, resources) => { + dispatch(openRemoveProcessDialog(resources[0], resources.length)); + }, + }, + ], +]; + +const runningProcessOnlyActionSet: ContextMenuActionSet = [ + [ + { + name: "CANCEL", + icon: StopIcon, + execute: (dispatch, resources) => { + dispatch(cancelRunningWorkflow(resources[0].uuid)); + }, + }, + ] +]; + +export const processResourceAdminActionSet: ContextMenuActionSet = [ + [ + ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []), + { + component: TogglePublicFavoriteAction, + name: "Add to public favorites", + execute: (dispatch, resources) => { + dispatch(togglePublicFavorite(resources[0])).then(() => { + dispatch(publicFavoritePanelActions.REQUEST_ITEMS()); + }); + }, + }, + ], +]; + +export const runningProcessResourceActionSet = [ + [ + ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []), + ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []), + ], +]; + +export const runningProcessResourceAdminActionSet: ContextMenuActionSet = [ + [ + ...processResourceAdminActionSet.reduce((prev, next) => prev.concat(next), []), + ...runningProcessOnlyActionSet.reduce((prev, next) => prev.concat(next), []), + ], +];