1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { ContextMenuAction, ContextMenuActionSet } from "../context-menu-action-set";
6 import { ToggleFavoriteAction } from "../actions/favorite-action";
7 import { toggleFavorite } from "store/favorites/favorites-actions";
19 } from "components/icon/icon";
20 import { openCollectionUpdateDialog } from "store/collections/collection-update-actions";
21 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
22 import { openMoveCollectionDialog } from "store/collections/collection-move-actions";
23 import { openCollectionCopyDialog, openMultiCollectionCopyDialog } from "store/collections/collection-copy-actions";
24 import { openWebDavS3InfoDialog } from "store/collections/collection-info-actions";
25 import { ToggleTrashAction } from "views-components/context-menu/actions/trash-action";
26 import { toggleCollectionTrashed } from "store/trash/trash-actions";
27 import { openSharingDialog } from "store/sharing-dialog/sharing-dialog-actions";
28 import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
29 import { toggleDetailsPanel } from "store/details-panel/details-panel-action";
30 import { copyToClipboardAction, openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions";
31 import { openRestoreCollectionVersionDialog } from "store/collections/collection-version-actions";
32 import { TogglePublicFavoriteAction } from "../actions/public-favorite-action";
33 import { togglePublicFavorite } from "store/public-favorites/public-favorites-actions";
34 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
35 import { ContextMenuResource } from "store/context-menu/context-menu-actions";
37 const toggleFavoriteAction: ContextMenuAction = {
38 component: ToggleFavoriteAction,
39 name: "ToggleFavoriteAction",
40 execute: (dispatch, resources) => {
41 for (const resource of [...resources]) {
42 dispatch<any>(toggleFavorite(resource)).then(() => {
43 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
48 const commonActionSet: ContextMenuActionSet = [
52 name: "Open in new tab",
53 execute: (dispatch, resources) => {
54 dispatch<any>(openInNewTabAction(resources[0]));
59 name: "Copy to clipboard",
60 execute: (dispatch, resources) => {
61 dispatch<any>(copyToClipboardAction(resources));
67 execute: (dispatch, resources) => {
68 if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
69 else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
75 execute: dispatch => {
76 dispatch<any>(toggleDetailsPanel());
82 execute: (dispatch, resources) => {
83 dispatch<any>(openAdvancedTabDialog(resources[0].uuid));
89 export const readOnlyCollectionActionSet: ContextMenuActionSet = [
91 ...commonActionSet.reduce((prev, next) => prev.concat(next), []),
94 icon: FolderSharedIcon,
95 name: "Open with 3rd party client",
96 execute: (dispatch, resources) => {
97 dispatch<any>(openWebDavS3InfoDialog(resources[0].uuid));
103 export const collectionActionSet: ContextMenuActionSet = [
105 ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
108 name: "Edit collection",
109 execute: (dispatch, resources) => {
110 dispatch<any>(openCollectionUpdateDialog(resources[0]));
116 execute: (dispatch, resources) => {
117 dispatch<any>(openSharingDialog(resources[0].uuid));
123 execute: (dispatch, resources) => dispatch<any>(openMoveCollectionDialog(resources[0])),
126 component: ToggleTrashAction,
127 name: "ToggleTrashAction",
128 execute: (dispatch, resources: ContextMenuResource[]) => {
129 for (const resource of [...resources]) {
130 dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
137 export const collectionAdminActionSet: ContextMenuActionSet = [
139 ...collectionActionSet.reduce((prev, next) => prev.concat(next), []),
141 component: TogglePublicFavoriteAction,
142 name: "TogglePublicFavoriteAction",
143 execute: (dispatch, resources) => {
144 for (const resource of [...resources]) {
145 dispatch<any>(togglePublicFavorite(resource)).then(() => {
146 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
154 export const oldCollectionVersionActionSet: ContextMenuActionSet = [
156 ...commonActionSet.reduce((prev, next) => prev.concat(next), []),
158 icon: RestoreVersionIcon,
159 name: "Restore version",
160 execute: (dispatch, resources) => {
161 for (const resource of [...resources]) {
162 dispatch<any>(openRestoreCollectionVersionDialog(resource.uuid));