X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/095e176632bbf81d28a239742a1ecce12404bd2d..362fec1a8b8c33498a4daf5b0fd204285f537c29:/services/workbench2/src/views-components/multiselect-toolbar/ms-process-action-set.ts diff --git a/services/workbench2/src/views-components/multiselect-toolbar/ms-process-action-set.ts b/services/workbench2/src/views-components/multiselect-toolbar/ms-process-action-set.ts index 820fc7999e..7802ad81f1 100644 --- a/services/workbench2/src/views-components/multiselect-toolbar/ms-process-action-set.ts +++ b/services/workbench2/src/views-components/multiselect-toolbar/ms-process-action-set.ts @@ -2,36 +2,97 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { ContextMenuActionSet } from "views-components/context-menu/context-menu-action-set"; -import { MoveToIcon, RemoveIcon, ReRunProcessIcon } from "components/icon/icon"; +import { MoveToIcon, RemoveIcon, ReRunProcessIcon, OutputIcon, RenameIcon, StopIcon } from "components/icon/icon"; import { openMoveProcessDialog } from "store/processes/process-move-actions"; import { openCopyProcessDialog } from "store/processes/process-copy-actions"; import { openRemoveProcessDialog } from "store/processes/processes-actions"; +import { MultiSelectMenuAction, MultiSelectMenuActionSet, msCommonActionSet } from "./ms-menu-actions"; +import { MultiSelectMenuActionNames } from "views-components/multiselect-toolbar/ms-menu-actions"; +import { openProcessUpdateDialog } from "store/processes/process-update-actions"; +import { msNavigateToOutput } from "store/multiselect/multiselect-actions"; +import { cancelRunningWorkflow } from "store/processes/processes-actions"; -export const msProcessActionSet: ContextMenuActionSet = [ +const msCopyAndRerunProcess: MultiSelectMenuAction = { + name: MultiSelectMenuActionNames.COPY_AND_RERUN_PROCESS, + icon: ReRunProcessIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + for (const resource of [...resources]) { + dispatch(openCopyProcessDialog(resource)); + } + }, +} + +const msRemoveProcess: MultiSelectMenuAction = { + name: MultiSelectMenuActionNames.REMOVE, + icon: RemoveIcon, + hasAlts: false, + isForMulti: true, + execute: (dispatch, resources) => { + dispatch(openRemoveProcessDialog(resources[0], resources.length)); + }, +} + +const msMoveTo: MultiSelectMenuAction = { + name: MultiSelectMenuActionNames.MOVE_TO, + icon: MoveToIcon, + hasAlts: false, + isForMulti: true, + execute: (dispatch, resources) => { + dispatch(openMoveProcessDialog(resources[0])); + }, +} + +const msViewOutputs: MultiSelectMenuAction = { + name: MultiSelectMenuActionNames.OUTPUTS, + icon: OutputIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + if (resources[0]) { + dispatch(msNavigateToOutput(resources[0])); + } + }, +} + +const msEditProcess: MultiSelectMenuAction = { + name: MultiSelectMenuActionNames.EDIT_PROCESS, + icon: RenameIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(openProcessUpdateDialog(resources[0])); + }, +} + +const msCancelProcess: MultiSelectMenuAction = { + name: MultiSelectMenuActionNames.CANCEL, + icon: StopIcon, + hasAlts: false, + isForMulti: false, + execute: (dispatch, resources) => { + dispatch(cancelRunningWorkflow(resources[0].uuid)); + }, +} + +export const msProcessActionSet: MultiSelectMenuActionSet = [ [ - { - icon: ReRunProcessIcon, - name: "Copy and re-run process", - execute: (dispatch, resources) => { - for (const resource of [...resources]) { - dispatch(openCopyProcessDialog(resource)); - } - }, - }, - { - 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)); - }, - }, - ], + ...msCommonActionSet, + msCopyAndRerunProcess, + msRemoveProcess, + msMoveTo, + msViewOutputs, + msEditProcess, + msCancelProcess + ] ]; + +const { MOVE_TO, REMOVE, COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, ADD_TO_PUBLIC_FAVORITES, OUTPUTS, EDIT_PROCESS, CANCEL } = MultiSelectMenuActionNames + +export const msCommonProcessActionFilter = new Set([MOVE_TO, REMOVE, COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, OUTPUTS, EDIT_PROCESS ]); +export const msRunningProcessActionFilter = new Set([MOVE_TO, REMOVE, COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, OUTPUTS, EDIT_PROCESS, CANCEL ]); + +export const msReadOnlyProcessActionFilter = new Set([COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, OUTPUTS ]); +export const msAdminProcessActionFilter = new Set([MOVE_TO, REMOVE, COPY_AND_RERUN_PROCESS, ADD_TO_FAVORITES, OPEN_IN_NEW_TAB, VIEW_DETAILS, API_DETAILS, SHARE, ADD_TO_PUBLIC_FAVORITES, OUTPUTS, EDIT_PROCESS ]); +