Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix about window #326

Merged
merged 22 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion demo/src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@ const AppContent = ({ language, onLanguageClick }) => {
{
type: 'app',
name: 'My application with a long name',
version: 'v0.0.1',
version: 'v0.0.1-long-tag',
},
{ type: 'other', name: 'Something', version: 'none' },
{
Expand Down
178 changes: 144 additions & 34 deletions src/components/TopBar/AboutDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ import {
Grid,
Stack,
Tooltip,
tooltipClasses,
Typography,
useMediaQuery,
useTheme,
Zoom,
} from '@mui/material';
import { LoadingButton } from '@mui/lab';
import {
Expand Down Expand Up @@ -116,6 +118,17 @@ const AboutDialog = ({
} else {
setModules([currentApp]);
}
} else {
// we wait the end of the fade animation of the dialog before reset content
setTimeout(
(setModules, setActualGlobalVersion) => {
setModules(null);
setActualGlobalVersion(null);
},
195 + 5,
Tristan-WorkGH marked this conversation as resolved.
Show resolved Hide resolved
setModules,
setActualGlobalVersion
);
}
}, [
open,
Expand All @@ -130,8 +143,6 @@ const AboutDialog = ({
if (onClose) {
onClose();
}
setModules(null);
setActualGlobalVersion(null);
}, [onClose]);

return (
Expand All @@ -143,11 +154,12 @@ const AboutDialog = ({
fullScreen={useMediaQuery(theme.breakpoints.down('md'))}
aria-labelledby="alert-dialog-title"
aria-describedby="alert-dialog-description"
transitionDuration={{ exit: 195 }}
>
<DialogTitle id="alert-dialog-title">
<FormattedMessage id={'about-dialog/title'} />
</DialogTitle>
<DialogContent dividers id="alert-dialog-description">
<DialogContent id="alert-dialog-description">
<Box>
{startingGlobalVersion !== undefined &&
startingGlobalVersion !== null &&
Expand Down Expand Up @@ -192,17 +204,23 @@ const AboutDialog = ({
appColor={theme.palette.grey['500']}
/>
</Box>
<Box
<Grid
container
component="dl"
columnSpacing={1}
justifyContent="center"
alignItems="center"
sx={{
textAlign: 'center',
marginTop: 0,
'dt, dd': {
display: 'inline',
margin: 0,
height: '2em',
},
'.MuiGrid-item': {
height: '100%',
},
dt: {
marginRight: '0.5em',
'&:after': {
content: '" :"',
},
Expand All @@ -215,31 +233,49 @@ const AboutDialog = ({
content: "''",
},
},
textAlign: 'right',
},
dd: {
//paddingLeft: '0.5em',
textAlign: 'left',
},
}}
>
<dt>
<Grid item component="dt" xs={6}>
<FormattedMessage id="about-dialog/version" />
</dt>
<dd>
{loadingGlobalVersion ? (
'…'
) : actualGlobalVersion ? (
<b style={{ fontSize: '1.5em' }}>
{actualGlobalVersion}
</b>
) : (
<i>unknown</i>
)}
</dd>
<Fade
in={loadingGlobalVersion}
style={{ transitionDelay: '500ms' }}
unmountOnExit
</Grid>
<Grid
item
component="dd"
xs={6}
fontSize={
!loadingGlobalVersion &&
actualGlobalVersion &&
'1.5em'
}
fontWeight={
!loadingGlobalVersion &&
actualGlobalVersion &&
'bold'
}
fontStyle={
!loadingGlobalVersion &&
!actualGlobalVersion &&
'italic'
}
>
<CircularProgress size="1rem" />
</Fade>
</Box>
{loadingGlobalVersion
? '…'
: actualGlobalVersion || 'unknown'}
<Fade
in={loadingGlobalVersion}
style={{ transitionDelay: '100ms' }}
unmountOnExit
>
<CircularProgress size="1rem" />
</Fade>
</Grid>
</Grid>
</Box>

{/* TODO found how to scroll only in this box, to keep logo and global version always visible */}
Expand Down Expand Up @@ -282,7 +318,6 @@ const AboutDialog = ({
<Accordion
disableGutters
variant="outlined"
defaultExpanded
TransitionProps={{ unmountOnExit: true }}
>
<AccordionSummary
Expand Down Expand Up @@ -314,10 +349,8 @@ const AboutDialog = ({
key={`module-${idx}`}
type={module.type}
name={module.name}
version={
module.gitTag ||
module.version
}
version={module.version}
gitTag={module.gitTag}
license={module.license}
/>
))}
Expand Down Expand Up @@ -371,6 +404,27 @@ const style = {
alignSelf: 'flex-end',
flexShrink: 0,
},
tooltip: (theme) => ({
[`& .${tooltipClasses.tooltip}`]: {
border: '1px solid #dadde9',
boxShadow: theme.shadows[1],
},
}),
tooltipDetails: {
display: 'grid',
gridTemplateColumns: 'max-content auto',
margin: 0,
dt: {
gridColumnStart: 1,
'&:after': {
content: '" :"',
},
},
dd: {
gridColumnStart: 2,
paddingLeft: '0.5em',
},
},
};

const ModuleTypesIcons = {
Expand All @@ -379,7 +433,7 @@ const ModuleTypesIcons = {
other: <QuestionMark sx={style.icons} fontSize="small" />,
};

const Module = ({ type, name, version, license }) => {
const Module = ({ type, name, version, gitTag, license }) => {
return (
<Grid
item
Expand All @@ -392,7 +446,62 @@ const Module = ({ type, name, version, license }) => {
},
}}
>
<Tooltip title={(name || '<?>') + ' ' + (version || '')}>
<Tooltip
TransitionComponent={Zoom}
enterDelay={3500}
enterNextDelay={350}
leaveDelay={200}
placement="bottom-start"
arrow
sx={style.tooltip}
title={
<>
<Typography variant="body1">{name || '<?>'}</Typography>
<Box component="dl" sx={style.tooltipDetails}>
<Typography variant="body2" component="dt">
<FormattedMessage id="about-dialog/label-type" />
</Typography>
<Typography variant="body2" component="dd">
<FormattedMessage
id={`about-dialog/module-tooltip-${
'app'.localeCompare(type, undefined, {
sensitivity: 'base',
}) === 0
? 'app'
: 'server'.localeCompare(
type,
undefined,
{ sensitivity: 'base' }
) === 0
? 'server'
: 'other'
}`}
Tristan-WorkGH marked this conversation as resolved.
Show resolved Hide resolved
/>
</Typography>
{version && (
<>
<Typography variant="body2" component="dt">
<FormattedMessage id="about-dialog/version" />
</Typography>
<Typography variant="body2" component="dd">
{version}
</Typography>
</>
)}
{gitTag && (
<>
<Typography variant="body2" component="dt">
<FormattedMessage id="about-dialog/git-version" />
</Typography>
<Typography variant="body2" component="dd">
{gitTag}
</Typography>
</>
)}
</Box>
</>
}
>
<Stack
direction="row"
justifyContent="flex-start"
Expand All @@ -410,7 +519,7 @@ const Module = ({ type, name, version, license }) => {
noWrap
sx={style.version}
>
{version || null}
{gitTag || version || null}
</Typography>
</Stack>
</Tooltip>
Expand All @@ -421,5 +530,6 @@ Module.propTypes = {
type: PropTypes.string,
name: PropTypes.string,
version: PropTypes.string,
gitTag: PropTypes.string,
license: PropTypes.string,
};
4 changes: 4 additions & 0 deletions src/components/translations/top-bar-en.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const top_bar_en = {
'about-dialog/license': 'License',
'about-dialog/modules-section': 'Modules details',
'about-dialog/git-version': 'Tag',
'about-dialog/label-type': 'Type',
'about-dialog/module-tooltip-app': 'application',
'about-dialog/module-tooltip-server': 'server',
'about-dialog/module-tooltip-other': 'other',
};

export default top_bar_en;
4 changes: 4 additions & 0 deletions src/components/translations/top-bar-fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const top_bar_fr = {
'about-dialog/license': 'Licence',
'about-dialog/modules-section': 'Détails des modules',
'about-dialog/git-version': 'Tag',
'about-dialog/label-type': 'Type',
'about-dialog/module-tooltip-app': 'application',
'about-dialog/module-tooltip-server': 'serveur',
'about-dialog/module-tooltip-other': 'autre',
};

export default top_bar_fr;
Loading