21224: moved project card to separate file
[arvados.git] / services / workbench2 / src / views-components / multiselect-toolbar / ms-user-details-action-set.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { AdvancedIcon, AttributesIcon, UserPanelIcon } from 'components/icon/icon';
6 import { openAdvancedTabDialog } from 'store/advanced-tab/advanced-tab';
7 import { navigateToUserProfile } from 'store/navigation/navigation-action';
8 import { ContextMenuActionNames } from "views-components/context-menu/context-menu-action-set";
9 import { MultiSelectMenuActionSet } from './ms-menu-actions';
10 import { Dispatch } from 'redux';
11 import { RootState } from 'store/store';
12 import { ServiceRepository } from 'services/services';
13 import { dialogActions } from 'store/dialog/dialog-actions';
14 import { UserResource } from 'models/user';
15 import { getResource } from 'store/resources/resources';
16
17 const USER_ATTRIBUTES_DIALOG = 'userAttributesDialog';
18
19 const msOpenUserAttributes = (uuid: string) =>
20     (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
21         const { resources } = getState();
22         const data = getResource<UserResource>(uuid)(resources);
23         dispatch(dialogActions.OPEN_DIALOG({ id: USER_ATTRIBUTES_DIALOG, data }));
24     };
25
26 export const UserDetailsActionSet: MultiSelectMenuActionSet= [
27     [
28         {
29             name: ContextMenuActionNames.ATTRIBUTES,
30             icon: AttributesIcon,
31             hasAlts: false,
32             isForMulti: false,
33             execute: (dispatch, resources) => {
34                 dispatch<any>(msOpenUserAttributes(resources[0].uuid));
35             },
36         },
37         {
38             name: ContextMenuActionNames.API_DETAILS,
39             icon: AdvancedIcon,
40             hasAlts: false,
41             isForMulti: false,
42             execute: (dispatch, resources) => {
43                 dispatch<any>(openAdvancedTabDialog(resources[0].uuid));
44             },
45         },
46         {
47             name: ContextMenuActionNames.USER_ACCOUNT,
48             icon: UserPanelIcon,
49             hasAlts: false,
50             isForMulti: false,
51             execute: (dispatch, resources) => {
52                 dispatch<any>(navigateToUserProfile(resources[0].uuid));
53             },
54         },
55     ],
56 ];