data-explorer-routing-and-admins-context-menu-for-resources
[arvados-workbench2.git] / src / views-components / context-menu / action-sets / collection-admin-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 import { TogglePublicFavoriteAction } from "~/views-components/context-menu/actions/public-favorite-action";
19
20 export const collectionAdminActionSet: 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         component: TogglePublicFavoriteAction,
45         execute: (dispatch, resource) => {
46             dispatch<any>(toggleFavorite(resource)).then(() => {
47                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
48             });
49         }
50     },
51     {
52         icon: MoveToIcon,
53         name: "Move to",
54         execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
55     },
56     {
57         icon: CopyIcon,
58         name: "Copy to project",
59         execute: (dispatch, resource) => {
60             dispatch<any>(openCollectionCopyDialog(resource));
61         }
62
63     },
64     {
65         icon: DetailsIcon,
66         name: "View details",
67         execute: dispatch => {
68             dispatch<any>(toggleDetailsPanel());
69         }
70     },
71     // {
72     //     icon: ProvenanceGraphIcon,
73     //     name: "Provenance graph",
74     //     execute: (dispatch, resource) => {
75     //         // add code
76     //     }
77     // },
78     {
79         icon: AdvancedIcon,
80         name: "Advanced",
81         execute: (dispatch, resource) => {
82             dispatch<any>(openAdvancedTabDialog(resource.uuid));
83         }
84     },
85     {
86         component: ToggleTrashAction,
87         execute: (dispatch, resource) => {
88             dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
89         }
90     },
91     // {
92     //     icon: RemoveIcon,
93     //     name: "Remove",
94     //     execute: (dispatch, resource) => {
95     //         // add code
96     //     }
97     // }
98 ]];