1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ContextMenuActionSet } from "../context-menu-action-set";
6 import { ToggleFavoriteAction } from "../actions/favorite-action";
7 import { toggleFavorite } from "~/store/favorites/favorites-actions";
8 import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, AdvancedIcon, OpenIcon, Link, RecoverVersionIcon } from "~/components/icon/icon";
9 import { openCollectionUpdateDialog } from "~/store/collections/collection-update-actions";
10 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
11 import { openMoveCollectionDialog } from '~/store/collections/collection-move-actions';
12 import { openCollectionCopyDialog } from "~/store/collections/collection-copy-actions";
13 import { ToggleTrashAction } from "~/views-components/context-menu/actions/trash-action";
14 import { toggleCollectionTrashed } from "~/store/trash/trash-actions";
15 import { openSharingDialog } from '~/store/sharing-dialog/sharing-dialog-actions';
16 import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
17 import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
18 import { copyToClipboardAction, openInNewTabAction } from "~/store/open-in-new-tab/open-in-new-tab.actions";
19 import { recoverVersion } from "~/store/collections/collection-version-actions";
20 import { TogglePublicFavoriteAction } from "../actions/public-favorite-action";
21 import { togglePublicFavorite } from "~/store/public-favorites/public-favorites-actions";
22 import { publicFavoritePanelActions } from "~/store/public-favorites-panel/public-favorites-action";
24 export const readOnlyCollectionActionSet: ContextMenuActionSet = [[
26 component: ToggleFavoriteAction,
27 name: 'ToggleFavoriteAction',
28 execute: (dispatch, resource) => {
29 dispatch<any>(toggleFavorite(resource)).then(() => {
30 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
36 name: "Open in new tab",
37 execute: (dispatch, resource) => {
38 dispatch<any>(openInNewTabAction(resource));
43 name: "Copy to clipboard",
44 execute: (dispatch, resource) => {
45 dispatch<any>(copyToClipboardAction(resource));
51 execute: (dispatch, resource) => {
52 dispatch<any>(openCollectionCopyDialog(resource));
59 execute: dispatch => {
60 dispatch<any>(toggleDetailsPanel());
66 execute: (dispatch, resource) => {
67 dispatch<any>(openAdvancedTabDialog(resource.uuid));
72 export const collectionActionSet: ContextMenuActionSet = [
74 ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
77 name: "Edit collection",
78 execute: (dispatch, resource) => {
79 dispatch<any>(openCollectionUpdateDialog(resource));
85 execute: (dispatch, { uuid }) => {
86 dispatch<any>(openSharingDialog(uuid));
92 execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
95 component: ToggleTrashAction,
96 name: 'ToggleTrashAction',
97 execute: (dispatch, resource) => {
98 dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
104 export const collectionAdminActionSet: ContextMenuActionSet = [
106 ...collectionActionSet.reduce((prev, next) => prev.concat(next), []),
108 component: TogglePublicFavoriteAction,
109 name: 'TogglePublicFavoriteAction',
110 execute: (dispatch, resource) => {
111 dispatch<any>(togglePublicFavorite(resource)).then(() => {
112 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
119 export const oldCollectionVersionActionSet: ContextMenuActionSet = [
121 ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
123 icon: RecoverVersionIcon,
124 name: 'Recover version',
125 execute: (dispatch, { uuid }) => {
126 dispatch<any>(recoverVersion(uuid));