Merge branch '21121-cluster-activity' refs #21121
[arvados.git] / services / workbench2 / src / views-components / main-app-bar / admin-menu.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import React from "react";
6 import { MenuItem } from "@mui/material";
7 import { User } from "models/user";
8 import { DropdownMenu } from "components/dropdown-menu/dropdown-menu";
9 import { AdminMenuIcon } from "components/icon/icon";
10 import { DispatchProp, connect } from 'react-redux';
11 import { RootState } from "store/store";
12 import { openRepositoriesPanel } from "store/repositories/repositories-actions";
13 import * as NavigationAction from 'store/navigation/navigation-action';
14 import { openAdminVirtualMachines } from "store/virtual-machines/virtual-machines-actions";
15 import { openUserPanel } from "store/users/users-actions";
16 interface AdminMenuProps {
17     user?: User;
18     currentRoute: string;
19 }
20
21 const mapStateToProps = (state: RootState): AdminMenuProps => ({
22     user: state.auth.user,
23     currentRoute: state.router.location ? state.router.location.pathname : ''
24 });
25
26 export const AdminMenu = connect(mapStateToProps)(
27     ({ user, dispatch, currentRoute }: AdminMenuProps & DispatchProp<any>) =>
28         user
29             ? <DropdownMenu
30                 icon={<AdminMenuIcon />}
31                 id="admin-menu"
32                 title="Admin Panel"
33                 key={currentRoute}>
34                 <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>
35                 <MenuItem onClick={() => dispatch(openAdminVirtualMachines())}>Shell Access</MenuItem>
36                 <MenuItem onClick={() => dispatch(NavigationAction.navigateToSshKeysAdmin)}>Ssh Keys</MenuItem>
37                 <MenuItem onClick={() => dispatch(NavigationAction.navigateToApiClientAuthorizations)}>Api Tokens</MenuItem>
38                 <MenuItem onClick={() => dispatch(openUserPanel())}>Users</MenuItem>
39                 <MenuItem onClick={() => dispatch(NavigationAction.navigateToGroups)}>Groups</MenuItem>
40                 <MenuItem onClick={() => dispatch(NavigationAction.navigateToKeepServices)}>Keep Services</MenuItem>
41                 <MenuItem onClick={() => dispatch(NavigationAction.navigateToLinks)}>Links</MenuItem>
42             </DropdownMenu>
43             : null);