X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/090f4825bdd30925a10c6df1b9493df0c2e8f541..454ef1c106b3d738526d65ecfae8db98ad7bebc2:/src/views-components/main-app-bar/admin-menu.tsx?ds=sidebyside

diff --git a/src/views-components/main-app-bar/admin-menu.tsx b/src/views-components/main-app-bar/admin-menu.tsx
new file mode 100644
index 00000000..88aafbae
--- /dev/null
+++ b/src/views-components/main-app-bar/admin-menu.tsx
@@ -0,0 +1,43 @@
+// Copyright (C) The Arvados Authors. All rights reserved.
+//
+// SPDX-License-Identifier: AGPL-3.0
+
+import * as React from "react";
+import { MenuItem } from "@material-ui/core";
+import { User } from "~/models/user";
+import { DropdownMenu } from "~/components/dropdown-menu/dropdown-menu";
+import { AdminMenuIcon } from "~/components/icon/icon";
+import { DispatchProp, connect } from 'react-redux';
+import { logout } from '~/store/auth/auth-action';
+import { RootState } from "~/store/store";
+import { openRepositoriesPanel } from "~/store/repositories/repositories-actions";
+import * as NavigationAction from '~/store/navigation/navigation-action';
+import { openAdminVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
+import { openUserPanel } from "~/store/users/users-actions";
+
+interface AdminMenuProps {
+    user?: User;
+}
+
+const mapStateToProps = (state: RootState): AdminMenuProps => ({
+    user: state.auth.user
+});
+
+export const AdminMenu = connect(mapStateToProps)(
+    ({ user, dispatch }: AdminMenuProps & DispatchProp<any>) =>
+        user
+            ? <DropdownMenu
+                icon={<AdminMenuIcon />}
+                id="admin-menu"
+                title="Admin Panel">
+                <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>
+                <MenuItem onClick={() => dispatch(openAdminVirtualMachines())}>Virtual Machines</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToSshKeysAdmin)}>Ssh Keys</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToApiClientAuthorizations)}>Api Tokens</MenuItem>
+                <MenuItem onClick={() => dispatch(openUserPanel())}>Users</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToComputeNodes)}>Compute Nodes</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToKeepServices)}>Keep Services</MenuItem>
+                <MenuItem onClick={() => dispatch(NavigationAction.navigateToLinks)}>Links</MenuItem>
+                <MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
+            </DropdownMenu>
+            : null);
