X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/c067c93c2159b21980551e2d87ebb10f985cba84..ebaede5aff01400db400a3e69bb3bec2b636db3a:/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 7d49e34c..4a6c910b 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,76 +2,148 @@ // // 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, ProvenanceGraphIcon, AdvancedIcon, RemoveIcon } from "~/components/icon/icon"; -import { openUpdater } from "~/store/collections/updater/collection-updater-action"; +import { + RenameIcon, + ShareIcon, + MoveToIcon, + CopyIcon, + DetailsIcon, + AdvancedIcon, + OpenIcon, + Link, + RestoreVersionIcon +} from "~/components/icon/icon"; +import { openCollectionUpdateDialog } from "~/store/collections/collection-update-actions"; import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action"; -import { openProjectCopyDialog } from "~/views-components/project-copy-dialog/project-copy-dialog"; -import { openMoveToDialog } from "../../move-to-dialog/move-to-dialog"; +import { openMoveCollectionDialog } from '~/store/collections/collection-move-actions'; +import { openCollectionCopyDialog } from "~/store/collections/collection-copy-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 { 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 { 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"; -export const collectionActionSet: ContextMenuActionSet = [[ - { - icon: RenameIcon, - name: "Edit collection", - execute: (dispatch, resource) => { - dispatch(openUpdater(resource)); - } - }, +const toggleFavoriteAction: ContextMenuAction = { + component: ToggleFavoriteAction, + name: 'ToggleFavoriteAction', + execute: (dispatch, resource) => { + dispatch(toggleFavorite(resource)).then(() => { + dispatch(favoritePanelActions.REQUEST_ITEMS()); + }); + } +}; + +const commonActionSet: ContextMenuActionSet = [[ { - icon: ShareIcon, - name: "Share", + icon: OpenIcon, + name: "Open in new tab", execute: (dispatch, resource) => { - // add code + dispatch(openInNewTabAction(resource)); } }, { - icon: MoveToIcon, - name: "Move to", - execute: dispatch => dispatch(openMoveToDialog()) - }, - { - component: ToggleFavoriteAction, + icon: Link, + name: "Copy to clipboard", execute: (dispatch, resource) => { - dispatch(toggleFavorite(resource)).then(() => { - dispatch(favoritePanelActions.REQUEST_ITEMS()); - }); + dispatch(copyToClipboardAction(resource)); } }, { icon: CopyIcon, - name: "Copy to project", + name: "Make a copy", execute: (dispatch, resource) => { - dispatch(openProjectCopyDialog({name: resource.name, projectUuid: resource.uuid})); + dispatch(openCollectionCopyDialog(resource)); } + }, { icon: DetailsIcon, name: "View details", - execute: (dispatch, resource) => { - // add code - } - }, - { - icon: ProvenanceGraphIcon, - name: "Provenance graph", - execute: (dispatch, resource) => { - // add code + execute: dispatch => { + dispatch(toggleDetailsPanel()); } }, { icon: AdvancedIcon, name: "Advanced", execute: (dispatch, resource) => { - // add code + dispatch(openAdvancedTabDialog(resource.uuid)); } }, - { - icon: RemoveIcon, - name: "Remove", - execute: (dispatch, resource) => { - // add code - } - } ]]; + +export const readOnlyCollectionActionSet: ContextMenuActionSet = [[ + ...commonActionSet.reduce((prev, next) => prev.concat(next), []), + toggleFavoriteAction, +]]; + +export const collectionActionSet: ContextMenuActionSet = [ + [ + ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []), + { + icon: RenameIcon, + name: "Edit collection", + execute: (dispatch, resource) => { + dispatch(openCollectionUpdateDialog(resource)); + } + }, + { + icon: ShareIcon, + name: "Share", + execute: (dispatch, { uuid }) => { + dispatch(openSharingDialog(uuid)); + } + }, + { + icon: MoveToIcon, + name: "Move to", + execute: (dispatch, resource) => dispatch(openMoveCollectionDialog(resource)) + }, + { + 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: RestoreVersionIcon, + name: 'Restore version', + execute: (dispatch, { uuid }) => { + dispatch(openRestoreCollectionVersionDialog(uuid)); + } + }, + ] +]; \ No newline at end of file