21702: Merge branch 'main' into 21702-keep-web-replace_files
[arvados.git] / services / workbench2 / src / views-components / multiselect-toolbar / ms-group-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { ContextMenuActionNames } from 'views-components/context-menu/context-menu-action-set';
6 import { RenameIcon, AdvancedIcon, RemoveIcon, DetailsIcon } from 'components/icon/icon';
7 import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab';
8 import { openRemoveGroupDialog, openGroupUpdateDialog } from 'store/groups-panel/groups-panel-actions';
9 import { MultiSelectMenuAction, MultiSelectMenuActionSet } from 'views-components/multiselect-toolbar/ms-menu-actions';
10 import { toggleDetailsPanel } from 'store/details-panel/details-panel-action';
11
12 const msRenameGroupAction: MultiSelectMenuAction = {
13     name: ContextMenuActionNames.RENAME,
14     icon: RenameIcon,
15     hasAlts: false,
16     isForMulti: false,
17     execute: (dispatch, resources) => {
18         dispatch<any>(openGroupUpdateDialog(resources[0]))
19     },
20 };
21
22 const msAdvancedAction: MultiSelectMenuAction  = {
23   name: ContextMenuActionNames.API_DETAILS,
24   icon: AdvancedIcon,
25   hasAlts: false,
26   isForMulti: false,
27   execute: (dispatch, resources) => {
28       dispatch<any>(openAdvancedTabDialog(resources[0].uuid));
29   },
30 };
31
32 const msViewDetailsAction: MultiSelectMenuAction  = {
33   name: ContextMenuActionNames.VIEW_DETAILS,
34   icon: DetailsIcon,
35   hasAlts: false,
36   isForMulti: false,
37   execute: (dispatch, resources) => {
38       dispatch<any>(toggleDetailsPanel(resources[0].uuid));
39   },
40 };
41
42 const msRemoveGroupAction: MultiSelectMenuAction = {
43     name: ContextMenuActionNames.REMOVE,
44     icon: RemoveIcon,
45     hasAlts: false,
46     isForMulti: true,
47     execute: (dispatch, resources) => {
48         resources.forEach(resource => dispatch<any>(openRemoveGroupDialog(resource.uuid, resources.length)));
49     },
50 };
51
52 export const msGroupActionSet: MultiSelectMenuActionSet = [
53   [
54     msRenameGroupAction,
55     msAdvancedAction,
56     msRemoveGroupAction,
57     msViewDetailsAction,
58   ]
59 ]