Merge branch 'master' into 14604-ui-improvements
[arvados-workbench2.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, ProvenanceGraphIcon, AdvancedIcon, RemoveIcon } 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 { detailsPanelActions } from '~/store/details-panel/details-panel-action';
16 import { openSharingDialog } from '~/store/sharing-dialog/sharing-dialog-actions';
17 import { openAdvancedTabDialog } from "~/store/advanced-tab/advanced-tab";
18 import { toggleDetailsPanel } from '~/store/details-panel/details-panel-action';
19
20 export const collectionActionSet: ContextMenuActionSet = [[
21     {
22         icon: RenameIcon,
23         name: "Edit collection",
24         execute: (dispatch, resource) => {
25             dispatch<any>(openCollectionUpdateDialog(resource));
26         }
27     },
28     {
29         icon: ShareIcon,
30         name: "Share",
31         execute: (dispatch, { uuid }) => {
32             dispatch<any>(openSharingDialog(uuid));
33         }
34     },
35     {
36         component: ToggleFavoriteAction,
37         execute: (dispatch, resource) => {
38             dispatch<any>(toggleFavorite(resource)).then(() => {
39                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
40             });
41         }
42     },
43     {
44         icon: MoveToIcon,
45         name: "Move to",
46         execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
47     },
48     {
49         icon: CopyIcon,
50         name: "Copy to project",
51         execute: (dispatch, resource) => {
52             dispatch<any>(openCollectionCopyDialog(resource));
53         }
54
55     },
56     {
57         icon: DetailsIcon,
58         name: "View details",
59         execute: dispatch => {
60             dispatch<any>(toggleDetailsPanel());
61         }
62     },
63     // {
64     //     icon: ProvenanceGraphIcon,
65     //     name: "Provenance graph",
66     //     execute: (dispatch, resource) => {
67     //         // add code
68     //     }
69     // },
70     {
71         icon: AdvancedIcon,
72         name: "Advanced",
73         execute: (dispatch, resource) => {
74             dispatch<any>(openAdvancedTabDialog(resource.uuid));
75         }
76     },
77     {
78         component: ToggleTrashAction,
79         execute: (dispatch, resource) => {
80             dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
81         }
82     },
83     // {
84     //     icon: RemoveIcon,
85     //     name: "Remove",
86     //     execute: (dispatch, resource) => {
87     //         // add code
88     //     }
89     // }
90 ]];