Merge branch '19079-search-results-open-newtab' into main. Closes #19079
[arvados.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 { canActivateUser, canDeactivateUser, canSetupUser, isAdmin, needsUserProfileLink, isOtherUser } from "store/context-menu/context-menu-filters";
21
22 export const userActionSet: ContextMenuActionSet = [[{
23     name: "Attributes",
24     icon: AttributesIcon,
25     execute: (dispatch, { uuid }) => {
26         dispatch<any>(openUserAttributes(uuid));
27     }
28 }, {
29     name: "Project",
30     icon: ProjectIcon,
31     execute: (dispatch, { uuid }) => {
32         dispatch<any>(openUserProjects(uuid));
33     }
34 }, {
35     name: "Advanced",
36     icon: AdvancedIcon,
37     execute: (dispatch, { uuid }) => {
38         dispatch<any>(openAdvancedTabDialog(uuid));
39     }
40 }, {
41     name: "Account Settings",
42     icon: UserPanelIcon,
43     execute: (dispatch, { uuid }) => {
44         dispatch<any>(navigateToUserProfile(uuid));
45     },
46     filters: [needsUserProfileLink]
47 }],[{
48     name: "Activate User",
49     icon: ActiveIcon,
50     execute: (dispatch, { uuid }) => {
51         dispatch<any>(openActivateDialog(uuid));
52     },
53     filters: [
54         isAdmin,
55         canActivateUser,
56     ],
57 }, {
58     name: "Setup User",
59     icon: AdminMenuIcon,
60     execute: (dispatch, { uuid }) => {
61         dispatch<any>(openSetupDialog(uuid));
62     },
63     filters: [
64         isAdmin,
65         canSetupUser,
66     ],
67 }, {
68     name: "Deactivate User",
69     icon: DeactivateUserIcon,
70     execute: (dispatch, { uuid }) => {
71         dispatch<any>(openDeactivateDialog(uuid));
72     },
73     filters: [
74         isAdmin,
75         canDeactivateUser,
76     ],
77 }, {
78     name: "Login As User",
79     icon: LoginAsIcon,
80     execute: (dispatch, { uuid }) => {
81         dispatch<any>(loginAs(uuid));
82     },
83     filters: [
84         isAdmin,
85         isOtherUser,
86     ],
87 }]];