fixed conflicts + link to ssh-keys panel
[arvados.git] / src / views-components / main-app-bar / account-menu.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import * as React from "react";
6 import { MenuItem } from "@material-ui/core";
7 import { User, getUserFullname } from "~/models/user";
8 import { DropdownMenu } from "~/components/dropdown-menu/dropdown-menu";
9 import { UserPanelIcon } from "~/components/icon/icon";
10 import { DispatchProp, connect } from 'react-redux';
11 import { logout } from '~/store/auth/auth-action';
12 import { RootState } from "~/store/store";
13 import { openCurrentTokenDialog } from '~/store/current-token-dialog/current-token-dialog-actions';
14 import { openRepositoriesPanel } from "~/store/repositories/repositories-actions";
15 import { navigateToSshKeys } from '~/store/navigation/navigation-action';
16
17 interface AccountMenuProps {
18     user?: User;
19 }
20
21 const mapStateToProps = (state: RootState): AccountMenuProps => ({
22     user: state.auth.user
23 });
24
25 export const AccountMenu = connect(mapStateToProps)(
26     ({ user, dispatch }: AccountMenuProps & DispatchProp<any>) =>
27         user
28             ? <DropdownMenu
29                 icon={<UserPanelIcon />}
30                 id="account-menu"
31                 title="Account Management">
32                 <MenuItem>
33                     {getUserFullname(user)}
34                 </MenuItem>
35                 <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>
36                 <MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
37                 <MenuItem onClick={() => dispatch(navigateToSshKeys)}>Ssh Keys</MenuItem>
38                 <MenuItem>My account</MenuItem>
39                 <MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
40             </DropdownMenu>
41             : null);