Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
Tristan-WorkGH committed Nov 30, 2023
1 parent ce479aa commit b3fd448
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/components/TopBar/AboutDialog.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const AboutDialog: FunctionComponent<{
appVersion?: string;
appLicense?: string;
getGlobalVersion?: (setVersion: React.SetStateAction<string>) => void;
getLogoThemed?: (themeMode: PaletteMode) => React.ReactElement;
logo?: React.ReactElement;
getAdditionalComponents?: (setComponents: React.SetStateAction<AboutAdditionalComponent[]>) => void;
}>;

Expand Down
20 changes: 5 additions & 15 deletions src/components/TopBar/AboutDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import React, { useCallback, useEffect, useMemo, useState } from 'react';
import React, { useCallback, useEffect, useState } from 'react';
import {
Alert,
AlertTitle,
Expand Down Expand Up @@ -71,7 +71,7 @@ const AboutDialog = ({
open,
onClose,
getGlobalVersion,
getLogoThemed,
logo,
appName,
appVersion,
appLicense,
Expand All @@ -80,14 +80,6 @@ const AboutDialog = ({
const theme = useTheme();

//TODO is useCallback in component or in caller?
const logo = useMemo(() => {
if (getLogoThemed) {
return getLogoThemed(theme.palette.mode);
} else {
return <BrokenImage />;
}
}, [getLogoThemed, theme.palette.mode]);

const handlerGetGlobalVersion = useCallback(getGlobalVersion, [
getGlobalVersion,
]);
Expand Down Expand Up @@ -123,7 +115,6 @@ const AboutDialog = ({
const [additionalComponents, setAdditionalComponents] = useState(null);
useEffect(() => {
if (open) {
//
const currentApp = {
name: `Grid${appName}`,
type: 'app',
Expand Down Expand Up @@ -181,15 +172,15 @@ const AboutDialog = ({
justifyContent: 'center',
}}
>
{logo}
{logo || <BrokenImage />}
</Box>
<Box component="p">
<FormattedMessage
id="about-dialog/deploy"
values={{
version: loadingGlobalVersion
? '…'
: actualGlobalVersion || '?unknown?',
: actualGlobalVersion || <i>unknown</i>,
}}
/>
<Fade
Expand Down Expand Up @@ -327,7 +318,6 @@ const AboutDialog = ({
variant="filled"
size="small"
label={
'License: ' +
cmpnt.license
}
/>
Expand Down Expand Up @@ -361,6 +351,6 @@ AboutDialog.propTypes = {
appVersion: PropTypes.string,
appLicense: PropTypes.string,
getGlobalVersion: PropTypes.func,
getLogoThemed: PropTypes.func,
logo: PropTypes.element,
getAdditionalComponents: PropTypes.func,
};
33 changes: 23 additions & 10 deletions src/components/TopBar/TopBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import React, { useEffect, useRef, useState } from 'react';
import React, { useEffect, useRef, useState, useMemo } from 'react';
import { FormattedMessage } from 'react-intl';

import {
Expand Down Expand Up @@ -284,13 +284,26 @@ const TopBar = ({
}
}, [user, withElementsSearch, searchDisabled]);

const logo = (
<LogoWithText
onClick={onLogoClick}
appLogo={appLogo}
appName={appName}
appColor={appColor}
/>
const logo = useMemo(
() => (
<LogoWithText
appLogo={appLogo}
appName={appName}
appColor={appColor}
/>
),
[appLogo, appName, appColor]
);
const logo_clickable = useMemo(
() => (
<LogoWithText
onClick={onLogoClick}
appLogo={appLogo}
appName={appName}
appColor={appColor}
/>
),
[onLogoClick, appLogo, appName, appColor]
);

return (
Expand All @@ -303,7 +316,7 @@ const TopBar = ({
}
/>
<Toolbar>
{logo}
{logo_clickable}
<Box sx={styles.grow}>{children}</Box>
{user && withElementsSearch && (
<React.Fragment>
Expand Down Expand Up @@ -751,7 +764,7 @@ const TopBar = ({
appVersion={appVersion}
appLicense={appLicense}
getGlobalVersion={getGlobalVersion}
getLogoThemed={(mode) => logo}
logo={logo}
getAdditionalComponents={getAdditionalComponents}
/>
</Toolbar>
Expand Down
2 changes: 1 addition & 1 deletion src/components/translations/top-bar-fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const top_bar_fr = {
'about-dialog/alert-running-old-version-title':
"Ancienne version de l'application",
'about-dialog/alert-running-old-version-content':
"Une nouvelle version de l'environnement à été détecté.\nVeuillez rafraîchir l'application pour charger la dernière version",
"Une nouvelle version de l'environnement a été détectée.\nVeuillez rafraîchir l'application pour charger la dernière version",
'about-dialog/license': 'Licence',
'about-dialog/components-version': 'Composants:',
'about-dialog/git-version': 'Tag',
Expand Down

0 comments on commit b3fd448

Please sign in to comment.