X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8a5f805a21c44cd47b0b8b6d0b55e3f752f00a21..eda7767bc88b7a2a3dc582af47417937ff4de38a:/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 7fa6f2241f..a870a813df 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,23 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { 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 { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, AdvancedIcon } from "~/components/icon/icon"; +import { + RenameIcon, + ShareIcon, + MoveToIcon, + CopyIcon, + DetailsIcon, + AdvancedIcon, + OpenIcon, + Link, + RecoverVersionIcon +} 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'; @@ -15,14 +28,35 @@ import { toggleCollectionTrashed } from "~/store/trash/trash-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 { copyToClipboardAction, openInNewTabAction } from "~/store/open-in-new-tab/open-in-new-tab.actions"; +import { recoverVersion } 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"; -export const readOnlyCollectionActionSet: ContextMenuActionSet = [[ +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)); + } + }, { - component: ToggleFavoriteAction, + icon: Link, + name: "Copy to clipboard", execute: (dispatch, resource) => { - dispatch(toggleFavorite(resource)).then(() => { - dispatch(favoritePanelActions.REQUEST_ITEMS()); - }); + dispatch(copyToClipboardAction(resource)); } }, { @@ -49,6 +83,11 @@ export const readOnlyCollectionActionSet: ContextMenuActionSet = [[ }, ]]; +export const readOnlyCollectionActionSet: ContextMenuActionSet = [[ + ...commonActionSet.reduce((prev, next) => prev.concat(next), []), + toggleFavoriteAction, +]]; + export const collectionActionSet: ContextMenuActionSet = [ [ ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []), @@ -73,9 +112,38 @@ export const collectionActionSet: ContextMenuActionSet = [ }, { component: ToggleTrashAction, + name: 'ToggleTrashAction', execute: (dispatch, resource) => { dispatch(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!)); } }, ] ]; + +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()); + }); + } + }, + ] +]; + +export const oldCollectionVersionActionSet: ContextMenuActionSet = [ + [ + ...commonActionSet.reduce((prev, next) => prev.concat(next), []), + { + icon: RecoverVersionIcon, + name: 'Recover version', + execute: (dispatch, { uuid }) => { + dispatch(recoverVersion(uuid)); + } + }, + ] +]; \ No newline at end of file