Merge branch '16005-collections-projects-open-in-new-tab'
[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, AdvancedIcon, OpenIcon, Link } 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 { copyToClipboardAction, openInNewTabAction } from "~/store/open-in-new-tab/open-in-new-tab.actions";
19
20 export const readOnlyCollectionActionSet: ContextMenuActionSet = [[
21     {
22         component: ToggleFavoriteAction,
23         name: 'ToggleFavoriteAction',
24         execute: (dispatch, resource) => {
25             dispatch<any>(toggleFavorite(resource)).then(() => {
26                 dispatch<any>(favoritePanelActions.REQUEST_ITEMS());
27             });
28         }
29     },
30     {
31         icon: OpenIcon,
32         name: "Open in new tab",
33         execute: (dispatch, resource) => {
34             dispatch<any>(openInNewTabAction(resource));
35         }
36     },
37     {
38         icon: Link,
39         name: "Copy to clipboard",
40         execute: (dispatch, resource) => {
41             dispatch<any>(copyToClipboardAction(resource));
42         }
43     },
44     {
45         icon: CopyIcon,
46         name: "Make a copy",
47         execute: (dispatch, resource) => {
48             dispatch<any>(openCollectionCopyDialog(resource));
49         }
50
51     },
52     {
53         icon: DetailsIcon,
54         name: "View details",
55         execute: dispatch => {
56             dispatch<any>(toggleDetailsPanel());
57         }
58     },
59     {
60         icon: AdvancedIcon,
61         name: "Advanced",
62         execute: (dispatch, resource) => {
63             dispatch<any>(openAdvancedTabDialog(resource.uuid));
64         }
65     },
66 ]];
67
68 export const collectionActionSet: ContextMenuActionSet = [
69     [
70         ...readOnlyCollectionActionSet.reduce((prev, next) => prev.concat(next), []),
71         {
72             icon: RenameIcon,
73             name: "Edit collection",
74             execute: (dispatch, resource) => {
75                 dispatch<any>(openCollectionUpdateDialog(resource));
76             }
77         },
78         {
79             icon: ShareIcon,
80             name: "Share",
81             execute: (dispatch, { uuid }) => {
82                 dispatch<any>(openSharingDialog(uuid));
83             }
84         },
85         {
86             icon: MoveToIcon,
87             name: "Move to",
88             execute: (dispatch, resource) => dispatch<any>(openMoveCollectionDialog(resource))
89         },
90         {
91             component: ToggleTrashAction,
92             name: 'ToggleTrashAction',
93             execute: (dispatch, resource) => {
94                 dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
95             }
96         },
97     ]
98 ];