X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8882246b577a8d24a0e83dcd8905069f7b1937c8..72ee613468c6dee53b98ed1469ce9781a942dbe9:/src/views-components/main-app-bar/account-menu.tsx

diff --git a/src/views-components/main-app-bar/account-menu.tsx b/src/views-components/main-app-bar/account-menu.tsx
index 271cf00f28..346a9ef02e 100644
--- a/src/views-components/main-app-bar/account-menu.tsx
+++ b/src/views-components/main-app-bar/account-menu.tsx
@@ -7,7 +7,6 @@ import { MenuItem, Divider } from "@material-ui/core";
 import { StyleRulesCallback, WithStyles, withStyles } from '@material-ui/core/styles';
 import { User, getUserFullname } from "~/models/user";
 import { DropdownMenu } from "~/components/dropdown-menu/dropdown-menu";
-import { Link } from "react-router-dom";
 import { UserPanelIcon } from "~/components/icon/icon";
 import { DispatchProp, connect } from 'react-redux';
 import { logout } from '~/store/auth/auth-action';
@@ -17,7 +16,8 @@ import { openRepositoriesPanel } from "~/store/repositories/repositories-actions
 import {
     navigateToSiteManager,
     navigateToSshKeysUser,
-    navigateToMyAccount
+    navigateToMyAccount,
+    navigateToLinkAccount
 } from '~/store/navigation/navigation-action';
 import { openUserVirtualMachines } from "~/store/virtual-machines/virtual-machines-actions";
 
@@ -25,12 +25,16 @@ interface AccountMenuProps {
     user?: User;
     currentRoute: string;
     workbenchURL: string;
+    apiToken?: string;
+    localCluster: string;
 }
 
 const mapStateToProps = (state: RootState): AccountMenuProps => ({
     user: state.auth.user,
     currentRoute: state.router.location ? state.router.location.pathname : '',
-    workbenchURL: state.config.workbenchUrl,
+    workbenchURL: state.auth.config.workbenchUrl,
+    apiToken: state.auth.apiToken,
+    localCluster: state.auth.localCluster
 });
 
 const wb1URL = (route: string) => {
@@ -54,7 +58,7 @@ const styles: StyleRulesCallback<CssRules> = () => ({
 
 export const AccountMenu = withStyles(styles)(
     connect(mapStateToProps)(
-        ({ user, dispatch, currentRoute, workbenchURL, classes }: AccountMenuProps & DispatchProp<any> & WithStyles<CssRules>) =>
+        ({ user, dispatch, currentRoute, workbenchURL, apiToken, localCluster, classes }: AccountMenuProps & DispatchProp<any> & WithStyles<CssRules>) =>
             user
                 ? <DropdownMenu
                     icon={<UserPanelIcon />}
@@ -62,19 +66,22 @@ export const AccountMenu = withStyles(styles)(
                     title="Account Management"
                     key={currentRoute}>
                     <MenuItem disabled>
-                        {getUserFullname(user)}
+                        {getUserFullname(user)} {user.uuid.substr(0, 5) !== localCluster && `(${user.uuid.substr(0, 5)})`}
                     </MenuItem>
-                    <MenuItem onClick={() => dispatch(openUserVirtualMachines())}>Virtual Machines</MenuItem>
-                    {!user.isAdmin && <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>}
-                    <MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
-                    <MenuItem onClick={() => dispatch(navigateToSshKeysUser)}>Ssh Keys</MenuItem>
-                    <MenuItem onClick={() => dispatch(navigateToSiteManager)}>Site Manager</MenuItem>
-                    <MenuItem onClick={() => dispatch(navigateToMyAccount)}>My account</MenuItem>
+                    {user.isActive ? <>
+                        <MenuItem onClick={() => dispatch(openUserVirtualMachines())}>Virtual Machines</MenuItem>
+                        {!user.isAdmin && <MenuItem onClick={() => dispatch(openRepositoriesPanel())}>Repositories</MenuItem>}
+                        <MenuItem onClick={() => dispatch(openCurrentTokenDialog)}>Current token</MenuItem>
+                        <MenuItem onClick={() => dispatch(navigateToSshKeysUser)}>Ssh Keys</MenuItem>
+                        <MenuItem onClick={() => dispatch(navigateToSiteManager)}>Site Manager</MenuItem>
+                        <MenuItem onClick={() => dispatch(navigateToMyAccount)}>My account</MenuItem>
+                        <MenuItem onClick={() => dispatch(navigateToLinkAccount)}>Link account</MenuItem>
+                    </> : null}
                     <MenuItem>
-                        <a href={`${workbenchURL.replace(/\/$/, "")}/${wb1URL(currentRoute)}`}
+                        <a href={`${workbenchURL.replace(/\/$/, "")}/${wb1URL(currentRoute)}?api_token=${apiToken}`}
                             className={classes.link}>
                             Switch to Workbench v1</a></MenuItem>
                     <Divider />
-                    <MenuItem onClick={() => dispatch(logout())}>Logout</MenuItem>
+                    <MenuItem onClick={() => dispatch(logout(true))}>Logout</MenuItem>
                 </DropdownMenu>
                 : null));
