X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/5e12403f4dcfe39eda79c256a94ceadc90458a99..23575ae95aab42c4c4d9c2b5ee0236fab004dccb:/src/views-components/context-menu/action-sets/collection-action-set.ts diff --git a/src/views-components/context-menu/action-sets/collection-action-set.ts b/src/views-components/context-menu/action-sets/collection-action-set.ts index edfaa3cdf0..f960571e8c 100644 --- a/src/views-components/context-menu/action-sets/collection-action-set.ts +++ b/src/views-components/context-menu/action-sets/collection-action-set.ts @@ -2,10 +2,7 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { - ContextMenuAction, - ContextMenuActionSet -} from "../context-menu-action-set"; +import { ContextMenuAction, ContextMenuActionSet } from "../context-menu-action-set"; import { ToggleFavoriteAction } from "../actions/favorite-action"; import { toggleFavorite } from "store/favorites/favorites-actions"; import { @@ -18,84 +15,90 @@ import { OpenIcon, Link, RestoreVersionIcon, - FolderSharedIcon + FolderSharedIcon, } from "components/icon/icon"; import { openCollectionUpdateDialog } from "store/collections/collection-update-actions"; import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action"; -import { openMoveCollectionDialog } from 'store/collections/collection-move-actions'; +import { openMoveCollectionDialog } from "store/collections/collection-move-actions"; import { openCollectionCopyDialog } from "store/collections/collection-copy-actions"; import { openWebDavS3InfoDialog } from "store/collections/collection-info-actions"; import { ToggleTrashAction } from "views-components/context-menu/actions/trash-action"; import { toggleCollectionTrashed } from "store/trash/trash-actions"; -import { openSharingDialog } from 'store/sharing-dialog/sharing-dialog-actions'; +import { openSharingDialog } from "store/sharing-dialog/sharing-dialog-actions"; import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab"; -import { toggleDetailsPanel } from 'store/details-panel/details-panel-action'; +import { toggleDetailsPanel } from "store/details-panel/details-panel-action"; import { copyToClipboardAction, openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions"; import { openRestoreCollectionVersionDialog } from "store/collections/collection-version-actions"; 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 { ContextMenuResource } from "store/context-menu/context-menu-actions"; const toggleFavoriteAction: ContextMenuAction = { component: ToggleFavoriteAction, - name: 'ToggleFavoriteAction', - execute: (dispatch, resource) => { - dispatch(toggleFavorite(resource)).then(() => { - dispatch(favoritePanelActions.REQUEST_ITEMS()); - }); - } -}; - -const commonActionSet: ContextMenuActionSet = [[ - { - icon: OpenIcon, - name: "Open in new tab", - execute: (dispatch, resource) => { - dispatch(openInNewTabAction(resource)); - } - }, - { - icon: Link, - name: "Copy to clipboard", - execute: (dispatch, resource) => { - dispatch(copyToClipboardAction(resource)); - } + name: "ToggleFavoriteAction", + execute: (dispatch, resources) => { + resources.forEach(resource => + dispatch(toggleFavorite(resource)).then(() => { + dispatch(favoritePanelActions.REQUEST_ITEMS()); + }) + ); }, - { - icon: CopyIcon, - name: "Make a copy", - execute: (dispatch, resource) => { - dispatch(openCollectionCopyDialog(resource)); - } +}; - }, - { - icon: DetailsIcon, - name: "View details", - execute: dispatch => { - dispatch(toggleDetailsPanel()); - } - }, - { - icon: AdvancedIcon, - name: "API Details", - execute: (dispatch, resource) => { - dispatch(openAdvancedTabDialog(resource.uuid)); - } - }, -]]; +const commonActionSet: ContextMenuActionSet = [ + [ + { + icon: OpenIcon, + name: "Open in new tab", + execute: (dispatch, resources) => { + dispatch(openInNewTabAction(resources[0])); + }, + }, + { + icon: Link, + name: "Copy to clipboard", + execute: (dispatch, resources) => { + dispatch(copyToClipboardAction(resources)); + }, + }, + { + icon: CopyIcon, + name: "Make a copy", + execute: (dispatch, resources) => { + resources.forEach(resource => dispatch(openCollectionCopyDialog(resource))); //here + }, + }, + { + 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 readOnlyCollectionActionSet: ContextMenuActionSet = [[ - ...commonActionSet.reduce((prev, next) => prev.concat(next), []), - toggleFavoriteAction, - { - icon: FolderSharedIcon, - name: "Open with 3rd party client", - execute: (dispatch, resource) => { - dispatch(openWebDavS3InfoDialog(resource.uuid)); - } - }, -]]; +export const readOnlyCollectionActionSet: ContextMenuActionSet = [ + [ + ...commonActionSet.reduce((prev, next) => prev.concat(next), []), + toggleFavoriteAction, + { + icon: FolderSharedIcon, + name: "Open with 3rd party client", + execute: (dispatch, resources) => { + resources.forEach(resource => dispatch(openWebDavS3InfoDialog(resource.uuid))); + }, + }, + ], +]; export const collectionActionSet: ContextMenuActionSet = [ [ @@ -103,30 +106,30 @@ export const collectionActionSet: ContextMenuActionSet = [ { icon: RenameIcon, name: "Edit collection", - execute: (dispatch, resource) => { - dispatch(openCollectionUpdateDialog(resource)); - } + execute: (dispatch, resources) => { + resources.forEach(resource => dispatch(openCollectionUpdateDialog(resource))); + }, }, { icon: ShareIcon, name: "Share", - execute: (dispatch, { uuid }) => { - dispatch(openSharingDialog(uuid)); - } + execute: (dispatch, resources) => { + resources.forEach(({ uuid }) => dispatch(openSharingDialog(uuid))); + }, }, { icon: MoveToIcon, name: "Move to", - execute: (dispatch, resource) => dispatch(openMoveCollectionDialog(resource)) + execute: (dispatch, resources) => dispatch(openMoveCollectionDialog(resources[0])), }, { component: ToggleTrashAction, - name: 'ToggleTrashAction', - execute: (dispatch, resource) => { - dispatch(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!)); - } + name: "ToggleTrashAction", + execute: (dispatch, resources: ContextMenuResource[]) => { + resources.forEach(resource => dispatch(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!))); + }, }, - ] + ], ]; export const collectionAdminActionSet: ContextMenuActionSet = [ @@ -134,14 +137,16 @@ export const collectionAdminActionSet: ContextMenuActionSet = [ ...collectionActionSet.reduce((prev, next) => prev.concat(next), []), { component: TogglePublicFavoriteAction, - name: 'TogglePublicFavoriteAction', - execute: (dispatch, resource) => { - dispatch(togglePublicFavorite(resource)).then(() => { - dispatch(publicFavoritePanelActions.REQUEST_ITEMS()); - }); - } + name: "TogglePublicFavoriteAction", + execute: (dispatch, resources) => { + resources.forEach(resource => + dispatch(togglePublicFavorite(resource)).then(() => { + dispatch(publicFavoritePanelActions.REQUEST_ITEMS()); + }) + ); + }, }, - ] + ], ]; export const oldCollectionVersionActionSet: ContextMenuActionSet = [ @@ -149,10 +154,10 @@ export const oldCollectionVersionActionSet: ContextMenuActionSet = [ ...commonActionSet.reduce((prev, next) => prev.concat(next), []), { icon: RestoreVersionIcon, - name: 'Restore version', - execute: (dispatch, { uuid }) => { - dispatch(openRestoreCollectionVersionDialog(uuid)); - } + name: "Restore version", + execute: (dispatch, resources) => { + resources.forEach(({ uuid }) => dispatch(openRestoreCollectionVersionDialog(uuid))); + }, }, - ] + ], ];