51e21592aec26ecf284998b3cc03825c1affc690
[arvados-workbench2.git] / src / views-components / multiselect-toolbar / ms-collection-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { MoveToIcon, CopyIcon } from "components/icon/icon";
6 import { openMoveCollectionDialog } from "store/collections/collection-move-actions";
7 import { openCollectionCopyDialog, openMultiCollectionCopyDialog } from "store/collections/collection-copy-actions";
8 import { ToggleTrashAction } from "views-components/context-menu/actions/trash-action";
9 import { toggleCollectionTrashed } from "store/trash/trash-actions";
10 import { ContextMenuResource } from "store/context-menu/context-menu-actions";
11 import { MultiSelectMenuActionSet } from "./ms-menu-action-set";
12
13 export const msCollectionActionSet: MultiSelectMenuActionSet = [
14     [
15         {
16             icon: CopyIcon,
17             name: "Make a copy",
18             isForMulti: true,
19             execute: (dispatch, [...resources]) => {
20                 if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
21                 else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
22             },
23         },
24         {
25             icon: MoveToIcon,
26             name: "Move to",
27             isForMulti: true,
28             execute: (dispatch, resources) => dispatch<any>(openMoveCollectionDialog(resources[0])),
29         },
30         {
31             component: ToggleTrashAction,
32             name: "ToggleTrashAction",
33             isForMulti: true,
34             execute: (dispatch, resources: ContextMenuResource[]) => {
35                 for (const resource of [...resources]) {
36                     dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
37                 }
38             },
39         },
40     ],
41 ];