1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
8 } from "../context-menu-action-set";
9 import { ToggleFavoriteAction } from "../actions/favorite-action";
10 import { toggleFavorite } from "store/favorites/favorites-actions";
22 } from "components/icon/icon";
23 import { openCollectionUpdateDialog } from "store/collections/collection-update-actions";
24 import { favoritePanelActions } from "store/favorite-panel/favorite-panel-action";
25 import { openMoveCollectionDialog } from 'store/collections/collection-move-actions';
26 import { openCollectionCopyDialog } from "store/collections/collection-copy-actions";
27 import { openWebDavS3InfoDialog } from "store/collections/collection-info-actions";
28 import { ToggleTrashAction } from "views-components/context-menu/actions/trash-action";
29 import { toggleCollectionTrashed } from "store/trash/trash-actions";
30 import { openSharingDialog } from 'store/sharing-dialog/sharing-dialog-actions';
31 import { openAdvancedTabDialog } from "store/advanced-tab/advanced-tab";
32 import { toggleDetailsPanel } from 'store/details-panel/details-panel-action';
33 import { copyToClipboardAction, openInNewTabAction } from "store/open-in-new-tab/open-in-new-tab.actions";
34 import { openRestoreCollectionVersionDialog } from "store/collections/collection-version-actions";
35 import { TogglePublicFavoriteAction } from "../actions/public-favorite-action";
36 import { togglePublicFavorite } from "store/public-favorites/public-favorites-actions";
37 import { publicFavoritePanelActions } from "store/public-favorites-panel/public-favorites-action";
39 const toggleFavoriteAction: ContextMenuAction = {
40 component: ToggleFavoriteAction,
41 name: 'ToggleFavoriteAction',
42 execute: (dispatch, resource) => {
43 dispatch<any>(toggleFavorite(resource)).then(() => {
44 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
49 const commonActionSet: ContextMenuActionSet = [[
52 name: "Open in new tab",
53 execute: (dispatch, resource) => {
54 dispatch<any>(openInNewTabAction(resource));
59 name: "Copy to clipboard",
60 execute: (dispatch, resource) => {
61 dispatch<any>(copyToClipboardAction(resource));
67 execute: (dispatch, resource) => {
68 dispatch<any>(openCollectionCopyDialog(resource));
75 execute: dispatch => {
76 dispatch<any>(toggleDetailsPanel());
82 execute: (dispatch, resource) => {
83 dispatch<any>(openAdvancedTabDialog(resource.uuid));
88 export const readOnlyCollectionActionSet: ContextMenuActionSet = [[
89 ...commonActionSet.reduce((prev, next) => prev.concat(next), []),
92 icon: FolderSharedIcon,
93 name: "Open with 3rd party client",
94 execute: (dispatch, resource) => {
95 dispatch<any>(openWebDavS3InfoDialog(resource.uuid));
100 export const collectionActionSet: ContextMenuActionSet = [
102 ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
105 name: "Edit collection",
106 execute: (dispatch, resource) => {
107 dispatch<any>(openCollectionUpdateDialog(resource));
113 execute: (dispatch, { uuid }) => {
114 dispatch<any>(openSharingDialog(uuid));
120 execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
123 component: ToggleTrashAction,
124 name: 'ToggleTrashAction',
125 execute: (dispatch, resource) => {
126 dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
132 export const collectionAdminActionSet: ContextMenuActionSet = [
134 ...collectionActionSet.reduce((prev, next) => prev.concat(next), []),
136 component: TogglePublicFavoriteAction,
137 name: 'TogglePublicFavoriteAction',
138 execute: (dispatch, resource) => {
139 dispatch<any>(togglePublicFavorite(resource)).then(() => {
140 dispatch<any>(publicFavoritePanelActions.REQUEST_ITEMS());
147 export const oldCollectionVersionActionSet: ContextMenuActionSet = [
149 ...commonActionSet.reduce((prev, next) => prev.concat(next), []),
151 icon: RestoreVersionIcon,
152 name: 'Restore version',
153 execute: (dispatch, { uuid }) => {
154 dispatch<any>(openRestoreCollectionVersionDialog(uuid));