21700: Install Bundler system-wide in Rails postinst
[arvados.git] / services / workbench2 / 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, ContextMenuActionNames } from "../context-menu-action-set";
6 import { FileCopyIcon, FileMoveIcon, 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 import {
12     openCollectionPartialMoveToExistingCollectionDialog,
13     openCollectionPartialMoveToNewCollectionDialog,
14 } from "store/collections/collection-partial-move-actions";
15 import {
16     openCollectionPartialCopyToExistingCollectionDialog,
17     openCollectionPartialCopyToNewCollectionDialog,
18 } from "store/collections/collection-partial-copy-actions";
19
20 export const readOnlyCollectionDirectoryItemActionSet: ContextMenuActionSet = [
21     [
22         {
23             name: ContextMenuActionNames.COPY_ITEM_INTO_NEW_COLLECTION,
24             icon: FileCopyIcon,
25             execute: (dispatch, resources) => {
26                 dispatch<any>(openCollectionPartialCopyToNewCollectionDialog(resources[0]));
27             },
28         },
29         {
30             name: ContextMenuActionNames.COPY_ITEM_INTO_EXISTING_COLLECTION,
31             icon: FileCopyIcon,
32             execute: (dispatch, resources) => {
33                 dispatch<any>(openCollectionPartialCopyToExistingCollectionDialog(resources[0]));
34             },
35         },
36         {
37             component: CollectionFileViewerAction,
38             name: ContextMenuActionNames.OPEN_IN_NEW_TAB,
39             execute: () => {
40                 return;
41             },
42         },
43         {
44             component: CollectionCopyToClipboardAction,
45             name: ContextMenuActionNames.COPY_LINK_TO_CLIPBOARD,
46             execute: () => {
47                 return;
48             },
49         },
50     ],
51 ];
52
53 export const readOnlyCollectionFileItemActionSet: ContextMenuActionSet = [
54     [
55         {
56             component: DownloadCollectionFileAction,
57             name: ContextMenuActionNames.DOWNLOAD,
58             execute: () => {
59                 return;
60             },
61         },
62         ...readOnlyCollectionDirectoryItemActionSet.reduce((prev, next) => prev.concat(next), []),
63     ],
64 ];
65
66 const writableActionSet: ContextMenuActionSet = [
67     [
68         {
69             name: ContextMenuActionNames.MOVE_ITEM_INTO_NEW_COLLECTION,
70             icon: FileMoveIcon,
71             execute: (dispatch, resources) => {
72                 dispatch<any>(openCollectionPartialMoveToNewCollectionDialog(resources[0]));
73             },
74         },
75         {
76             name: ContextMenuActionNames.MOVE_ITEM_INTO_EXISTING_COLLECTION,
77             icon: FileMoveIcon,
78             execute: (dispatch, resources) => {
79                 dispatch<any>(openCollectionPartialMoveToExistingCollectionDialog(resources[0]));
80             },
81         },
82         {
83             name: ContextMenuActionNames.RENAME,
84             icon: RenameIcon,
85             execute: (dispatch, resources) => {
86                 dispatch<any>(
87                     openRenameFileDialog({
88                         name: resources[0].name,
89                         id: resources[0].uuid,
90                         path: resources[0].uuid.split("/").slice(1).join("/"),
91                     })
92                 );
93             },
94         },
95         {
96             name: ContextMenuActionNames.REMOVE,
97             icon: RemoveIcon,
98             execute: (dispatch, resources) => {
99                 dispatch<any>(openFileRemoveDialog(resources[0].uuid));
100             },
101         },
102     ],
103 ];
104
105 export const collectionDirectoryItemActionSet: ContextMenuActionSet = readOnlyCollectionDirectoryItemActionSet.concat(writableActionSet);
106
107 export const collectionFileItemActionSet: ContextMenuActionSet = readOnlyCollectionFileItemActionSet.concat(writableActionSet);