16118: Restricts UI elements when a collection is read-only.
[arvados.git] / src / views-components / context-menu / action-sets / collection-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 { ToggleFavoriteAction } from "../actions/favorite-action";
7 import { toggleFavorite } from "~/store/favorites/favorites-actions";
8 import { RenameIcon, ShareIcon, MoveToIcon, CopyIcon, DetailsIcon, AdvancedIcon } from "~/components/icon/icon";
9 import { openCollectionUpdateDialog } from "~/store/collections/collection-update-actions";
10 import { favoritePanelActions } from "~/store/favorite-panel/favorite-panel-action";
11 import { openMoveCollectionDialog } from '~/store/collections/collection-move-actions';
12 import { openCollectionCopyDialog } from "~/store/collections/collection-copy-actions";
13 import { ToggleTrashAction } from "~/views-components/context-menu/actions/trash-action";
14 import { toggleCollectionTrashed } from "~/store/trash/trash-actions";
15 import { openSharingDialog } from '~/store/sharing-dialog/sharing-dialog-actions';
16 import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
17 import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
18
19 export const readOnlyCollectionActionSet: ContextMenuActionSet = [[
20     {
21         component: ToggleFavoriteAction,
22         execute: (dispatch, resource) => {
23             dispatch<any>(toggleFavorite(resource)).then(() => {
24                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
25             });
26         }
27     },
28     {
29         icon: CopyIcon,
30         name: "Copy to project",
31         execute: (dispatch, resource) => {
32             dispatch<any>(openCollectionCopyDialog(resource));
33         }
34
35     },
36     {
37         icon: DetailsIcon,
38         name: "View details",
39         execute: dispatch => {
40             dispatch<any>(toggleDetailsPanel());
41         }
42     },
43     {
44         icon: AdvancedIcon,
45         name: "Advanced",
46         execute: (dispatch, resource) => {
47             dispatch<any>(openAdvancedTabDialog(resource.uuid));
48         }
49     },
50 ]];
51
52 export const collectionActionSet: ContextMenuActionSet = readOnlyCollectionActionSet.concat([[
53     {
54         icon: RenameIcon,
55         name: "Edit collection",
56         execute: (dispatch, resource) => {
57             dispatch<any>(openCollectionUpdateDialog(resource));
58         }
59     },
60     {
61         icon: ShareIcon,
62         name: "Share",
63         execute: (dispatch, { uuid }) => {
64             dispatch<any>(openSharingDialog(uuid));
65         }
66     },
67     {
68         icon: MoveToIcon,
69         name: "Move to",
70         execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
71     },
72     {
73         component: ToggleTrashAction,
74         execute: (dispatch, resource) => {
75             dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
76         }
77     },
78 ]]);