Merge branch 'main' of git.arvados.org:arvados-workbench2 into 19079-search-results...
[arvados.git] / src / views-components / context-menu / action-sets / collection-files-item-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ContextMenuActionSet } from "../context-menu-action-set";
6 import { RemoveIcon, RenameIcon } from "components/icon/icon";
7 import { DownloadCollectionFileAction } from "../actions/download-collection-file-action";
8 import { openFileRemoveDialog, openRenameFileDialog } from 'store/collection-panel/collection-panel-files/collection-panel-files-actions';
9 import { CollectionFileViewerAction } from 'views-components/context-menu/actions/collection-file-viewer-action';
10 import { CollectionCopyToClipboardAction } from "../actions/collection-copy-to-clipboard-action";
11
12 export const readOnlyCollectionDirectoryItemActionSet: ContextMenuActionSet = [[
13     {
14         component: CollectionFileViewerAction,
15         execute: () => { return; },
16     },
17     {
18         component: CollectionCopyToClipboardAction,
19         execute: () => { return; },
20     }
21 ]];
22
23 export const readOnlyCollectionFileItemActionSet: ContextMenuActionSet = [[
24     {
25         component: DownloadCollectionFileAction,
26         execute: () => { return; }
27     },
28     ...readOnlyCollectionDirectoryItemActionSet.reduce((prev, next) => prev.concat(next), []),
29 ]];
30
31 const writableActionSet: ContextMenuActionSet = [[
32     {
33         name: "Rename",
34         icon: RenameIcon,
35         execute: (dispatch, resource) => {
36             dispatch<any>(openRenameFileDialog({
37                 name: resource.name,
38                 id: resource.uuid,
39                 path: resource.uuid.split('/').slice(1).join('/') }));
40         }
41     },
42     {
43         name: "Remove",
44         icon: RemoveIcon,
45         execute: (dispatch, resource) => {
46             dispatch<any>(openFileRemoveDialog(resource.uuid));
47         }
48     }
49 ]];
50
51 export const collectionDirectoryItemActionSet: ContextMenuActionSet = readOnlyCollectionDirectoryItemActionSet.concat(writableActionSet);
52
53 export const collectionFileItemActionSet: ContextMenuActionSet = readOnlyCollectionFileItemActionSet.concat(writableActionSet);