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 } 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 resources.forEach(resource =>
42 dispatch<any>(toggleFavorite(resource)).then(() => {
43 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
49 const commonActionSet: ContextMenuActionSet = [
53 name: "Open in new tab",
54 execute: (dispatch, resources) => {
55 dispatch<any>(openInNewTabAction(resources[0]));
60 name: "Copy to clipboard",
61 execute: (dispatch, resources) => {
62 dispatch<any>(copyToClipboardAction(resources));
68 execute: (dispatch, resources) => {
69 dispatch<any>(openCollectionCopyDialog(resources[0]));
75 execute: dispatch => {
76 dispatch<any>(toggleDetailsPanel());
82 execute: (dispatch, resources) => {
83 resources.forEach(resource => dispatch<any>(openAdvancedTabDialog(resource.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 resources.forEach(resource => dispatch<any>(openWebDavS3InfoDialog(resource.uuid)));
103 export const collectionActionSet: ContextMenuActionSet = [
105 ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
108 name: "Edit collection",
109 execute: (dispatch, resources) => {
110 resources.forEach(resource => dispatch<any>(openCollectionUpdateDialog(resource)));
116 execute: (dispatch, resources) => {
117 resources.forEach(({ uuid }) => dispatch<any>(openSharingDialog(uuid)));
123 execute: (dispatch, resources) => dispatch<any>(openMoveCollectionDialog(resources[0])),
126 component: ToggleTrashAction,
127 name: "ToggleTrashAction",
128 execute: (dispatch, resources: ContextMenuResource[]) => {
129 resources.forEach(resource => dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!)));
135 export const collectionAdminActionSet: ContextMenuActionSet = [
137 ...collectionActionSet.reduce((prev, next) => prev.concat(next), []),
139 component: TogglePublicFavoriteAction,
140 name: "TogglePublicFavoriteAction",
141 execute: (dispatch, resources) => {
142 resources.forEach(resource =>
143 dispatch<any>(togglePublicFavorite(resource)).then(() => {
144 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
152 export const oldCollectionVersionActionSet: ContextMenuActionSet = [
154 ...commonActionSet.reduce((prev, next) => prev.concat(next), []),
156 icon: RestoreVersionIcon,
157 name: "Restore version",
158 execute: (dispatch, resources) => {
159 resources.forEach(({ uuid }) => dispatch<any>(openRestoreCollectionVersionDialog(uuid)));