15768: project copy-to-clipboard works Arvados-DCO-1.1-Signed-off-by: Lisa Knox ...
[arvados-workbench2.git] / src / views-components / context-menu / action-sets / user-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 'views-components/context-menu/context-menu-action-set';
6 import {
7     AdvancedIcon,
8     ProjectIcon,
9     AttributesIcon,
10     DeactivateUserIcon,
11     UserPanelIcon,
12     LoginAsIcon,
13     AdminMenuIcon,
14     ActiveIcon,
15 } from 'components/icon/icon';
16 import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab';
17 import { loginAs, openUserAttributes, openUserProjects } from 'store/users/users-actions';
18 import { openSetupDialog, openDeactivateDialog, openActivateDialog } from 'store/user-profile/user-profile-actions';
19 import { navigateToUserProfile } from 'store/navigation/navigation-action';
20 import {
21     canActivateUser,
22     canDeactivateUser,
23     canSetupUser,
24     isAdmin,
25     needsUserProfileLink,
26     isOtherUser,
27 } from 'store/context-menu/context-menu-filters';
28
29 export const userActionSet: ContextMenuActionSet = [
30     [
31         {
32             name: 'Attributes',
33             icon: AttributesIcon,
34             execute: (dispatch, resources) => {
35                 resources.forEach((resource) => dispatch<any>(openUserAttributes(resource.uuid)));
36             },
37         },
38         {
39             name: 'Project',
40             icon: ProjectIcon,
41             execute: (dispatch, resources) => {
42                 resources.forEach((resource) => dispatch<any>(openUserProjects(resource.uuid)));
43             },
44         },
45         {
46             name: 'API Details',
47             icon: AdvancedIcon,
48             execute: (dispatch, resources) => {
49                 resources.forEach((resource) => dispatch<any>(openAdvancedTabDialog(resource.uuid)));
50             },
51         },
52         {
53             name: 'Account Settings',
54             icon: UserPanelIcon,
55             execute: (dispatch, resources) => {
56                 resources.forEach((resource) => dispatch<any>(navigateToUserProfile(resource.uuid)));
57             },
58             filters: [needsUserProfileLink],
59         },
60     ],
61     [
62         {
63             name: 'Activate User',
64             icon: ActiveIcon,
65             execute: (dispatch, resources) => {
66                 resources.forEach((resource) => dispatch<any>(openActivateDialog(resource.uuid)));
67             },
68             filters: [isAdmin, canActivateUser],
69         },
70         {
71             name: 'Setup User',
72             icon: AdminMenuIcon,
73             execute: (dispatch, resources) => {
74                 resources.forEach((resource) => dispatch<any>(openSetupDialog(resource.uuid)));
75             },
76             filters: [isAdmin, canSetupUser],
77         },
78         {
79             name: 'Deactivate User',
80             icon: DeactivateUserIcon,
81             execute: (dispatch, resources) => {
82                 resources.forEach((resource) => dispatch<any>(openDeactivateDialog(resource.uuid)));
83             },
84             filters: [isAdmin, canDeactivateUser],
85         },
86         {
87             name: 'Login As User',
88             icon: LoginAsIcon,
89             execute: (dispatch, resources) => {
90                 resources.forEach((resource) => dispatch<any>(loginAs(resource.uuid)));
91             },
92             filters: [isAdmin, isOtherUser],
93         },
94     ],
95 ];