X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2e21cc7eeaecd3282d464c096549486b391c9461..37be20bf76bba0f6dc6fd40f0fcc3d012c6b7e49:/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 7d593ee4b4..aceebe066b 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 @@ -6,18 +6,23 @@ import { ContextMenuActionSet } from "../context-menu-action-set"; import { ToggleFavoriteAction } from "../actions/favorite-action"; import { toggleFavorite } from "store/favorites/favorites-actions"; import { - RenameIcon, ShareIcon, MoveToIcon, DetailsIcon, - RemoveIcon, ReRunProcessIcon, OutputIcon, + RenameIcon, + ShareIcon, + MoveToIcon, + DetailsIcon, + RemoveIcon, + ReRunProcessIcon, + OutputIcon, AdvancedIcon, - OpenIcon + OpenIcon, } from "components/icon/icon"; import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action"; -import { openMoveProcessDialog } from 'store/processes/process-move-actions'; +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 { 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 { 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"; @@ -25,95 +30,107 @@ import { togglePublicFavorite } from "store/public-favorites/public-favorites-ac import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action"; import { openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions"; -export const readOnlyProcessResourceActionSet: ContextMenuActionSet = [[ - { - component: ToggleFavoriteAction, - execute: (dispatch, resource) => { - dispatch(toggleFavorite(resource)).then(() => { - dispatch(favoritePanelActions.REQUEST_ITEMS()); - }); - } - }, - { - icon: OpenIcon, - name: "Open in new tab", - execute: (dispatch, resource) => { - dispatch(openInNewTabAction(resource)); - } - }, - { - icon: ReRunProcessIcon, - name: "Copy and re-run process", - execute: (dispatch, resource) => { - dispatch(openCopyProcessDialog(resource)); - } - }, - { - icon: OutputIcon, - name: "Outputs", - execute: (dispatch, resource) => { - if(resource.outputUuid){ - dispatch(navigateToOutput(resource.outputUuid)); - } - } - }, - { - icon: DetailsIcon, - name: "View details", - execute: dispatch => { - dispatch(toggleDetailsPanel()); - } - }, - { - icon: AdvancedIcon, - name: "API Details", - execute: (dispatch, resource) => { - dispatch(openAdvancedTabDialog(resource.uuid)); - } - }, -]]; +export const readOnlyProcessResourceActionSet: ContextMenuActionSet = [ + [ + { + component: ToggleFavoriteAction, + execute: (dispatch, resources) => { + resources.forEach(resource => + dispatch(toggleFavorite(resource)).then(() => { + dispatch(favoritePanelActions.REQUEST_ITEMS()); + }) + ); + }, + }, + { + icon: OpenIcon, + name: "Open in new tab", + execute: (dispatch, resources) => { + resources.forEach(resource => dispatch(openInNewTabAction(resource))); + }, + }, + { + icon: ReRunProcessIcon, + name: "Copy and re-run process", + execute: (dispatch, resources) => { + resources.forEach(resource => dispatch(openCopyProcessDialog(resource))); + }, + }, + { + icon: OutputIcon, + name: "Outputs", + execute: (dispatch, resources) => { + resources.forEach(resource => { + if (resource.outputUuid) { + dispatch(navigateToOutput(resource.outputUuid)); + } + }); + }, + }, + { + icon: DetailsIcon, + name: "View details", + execute: dispatch => { + dispatch(toggleDetailsPanel()); + }, + }, + { + icon: AdvancedIcon, + name: "API Details", + execute: (dispatch, resources) => { + resources.forEach(resource => dispatch(openAdvancedTabDialog(resource.uuid))); + }, + }, + ], +]; -export const processResourceActionSet: ContextMenuActionSet = [[ - ...readOnlyProcessResourceActionSet.reduce((prev, next) => prev.concat(next), []), - { - icon: RenameIcon, - name: "Edit process", - execute: (dispatch, resource) => { - dispatch(openProcessUpdateDialog(resource)); - } - }, - { - icon: ShareIcon, - name: "Share", - execute: (dispatch, { uuid }) => { - dispatch(openSharingDialog(uuid)); - } - }, - { - icon: MoveToIcon, - name: "Move to", - execute: (dispatch, resource) => { - dispatch(openMoveProcessDialog(resource)); - } - }, - { - name: "Remove", - icon: RemoveIcon, - execute: (dispatch, resource) => { - dispatch(openRemoveProcessDialog(resource.uuid)); - } - } -]]; +export const processResourceActionSet: ContextMenuActionSet = [ + [ + ...readOnlyProcessResourceActionSet.reduce((prev, next) => prev.concat(next), []), + { + icon: RenameIcon, + name: "Edit process", + execute: (dispatch, resources) => { + resources.forEach(resource => dispatch(openProcessUpdateDialog(resource))); + }, + }, + { + icon: ShareIcon, + name: "Share", + execute: (dispatch, resources) => { + resources.forEach(({ uuid }) => dispatch(openSharingDialog(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)); + }, + }, + ], +]; -export const processResourceAdminActionSet: ContextMenuActionSet = [[ - ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []), - { - component: TogglePublicFavoriteAction, - name: "Add to public favorites", - execute: (dispatch, resource) => { - dispatch(togglePublicFavorite(resource)).then(() => { - dispatch(publicFavoritePanelActions.REQUEST_ITEMS()); - }); - } - }, -]]; +export const processResourceAdminActionSet: ContextMenuActionSet = [ + [ + ...processResourceActionSet.reduce((prev, next) => prev.concat(next), []), + { + component: TogglePublicFavoriteAction, + name: "Add to public favorites", + execute: (dispatch, resources) => { + resources.forEach(resource => + dispatch(togglePublicFavorite(resource)).then(() => { + dispatch(publicFavoritePanelActions.REQUEST_ITEMS()); + }) + ); + }, + }, + ], +];