21128: added workflow actions Arvados-DCO-1.1-Signed-off-by: Lisa Knox <lisa.knox...
[arvados.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 { toggleCollectionTrashed } from "store/trash/trash-actions";
9 import { ContextMenuResource } from "store/context-menu/context-menu-actions";
10 import { MultiSelectMenuActionSet, MultiSelectMenuActionNames } from "./ms-menu-actions";
11 import { TrashIcon } from "components/icon/icon";
12
13 export const msCollectionActionSet: MultiSelectMenuActionSet = [
14     [
15         {
16             name: MultiSelectMenuActionNames.MAKE_A_COPY,
17             icon: CopyIcon,
18             hasAlts: false,
19             isForMulti: true,
20             execute: (dispatch, [...resources]) => {
21                 if (resources[0].fromContextMenu || resources.length === 1) dispatch<any>(openCollectionCopyDialog(resources[0]));
22                 else dispatch<any>(openMultiCollectionCopyDialog(resources[0]));
23             },
24         },
25         {
26             name: MultiSelectMenuActionNames.MOVE_TO,
27             icon: MoveToIcon,
28             hasAlts: false,
29             isForMulti: true,
30             execute: (dispatch, resources) => dispatch<any>(openMoveCollectionDialog(resources[0])),
31         },
32         {
33             name: MultiSelectMenuActionNames.ADD_TO_TRASH,
34             icon: TrashIcon,
35             isForMulti: true,
36             hasAlts: false,
37             execute: (dispatch, resources: ContextMenuResource[]) => {
38                 for (const resource of [...resources]) {
39                     dispatch<any>(toggleCollectionTrashed(resource.uuid, resource.isTrashed!!));
40                 }
41             },
42         },
43     ],
44 ];