Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 48 additions & 44 deletions src/WrapperApp/components/NavPanel/NavPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { Box, List, useTheme } from '@mui/material';
import Typography from '@mui/material/Typography';
import { SyntheticEvent, useMemo } from 'react';

import { useConfig } from '../../../config/ConfigService';
import { AuthContext, useAuth } from '../../../services/AuthService';
import { useStore } from '../../../services/StoreService';
import deployInfo from '../../../util/identify/deployInfo.json';
Expand Down Expand Up @@ -45,6 +46,7 @@ function LogInOut(props: {
authContext: AuthContext;
handleChange: (event: SyntheticEvent, value: string) => void;
}) {
const { demoMode } = useConfig();
const { isAuthorized, user, logout } = props.authContext;

const username = useMemo(
Expand All @@ -54,51 +56,53 @@ function LogInOut(props: {

return (
<List>
<NavPanelElement
menuOption={{
label: username,
richLabel: (
<Typography
component='div'
sx={{
marginRight: 1,
textOverflow: 'ellipsis',
overflow: 'hidden'
}}>
{isAuthorized && user ? (
<Box>
Log out{' '}
<Box
sx={{
fontWeight: 'bold',
overflowWrap: 'break-word',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis'
}}>
{user.username}
{!demoMode && (
<NavPanelElement
menuOption={{
label: username,
richLabel: (
<Typography
component='div'
sx={{
marginRight: 1,
textOverflow: 'ellipsis',
overflow: 'hidden'
}}>
{isAuthorized && user ? (
<Box>
Log out{' '}
<Box
sx={{
fontWeight: 'bold',
overflowWrap: 'break-word',
whiteSpace: 'nowrap',
overflow: 'hidden',
textOverflow: 'ellipsis'
}}>
{user.username}
</Box>
</Box>
</Box>
) : (
'Log in'
)}
</Typography>
),
description: <Typography />,
value: 'deployInfo',
disabled: false,
info: isAuthorized ? username : 'Log in',
icon: <PersonIcon fontSize='large' />
}}
open={true}
onClick={(event: SyntheticEvent<Element, Event>) => {
if (isAuthorized) logout();
else props.handleChange(event, 'login');
}}
buttonProps={{
type: 'button'
}}
/>
) : (
'Log in'
)}
</Typography>
),
description: <Typography />,
value: 'deployInfo',
disabled: false,
info: isAuthorized ? username : 'Log in',
icon: <PersonIcon fontSize='large' />
}}
open={true}
onClick={(event: SyntheticEvent<Element, Event>) => {
if (isAuthorized) logout();
else props.handleChange(event, 'login');
}}
buttonProps={{
type: 'button'
}}
/>
)}
</List>
);
}
Expand Down
Loading