Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 3 additions & 4 deletions src/components/ui/reactHookForm/utils/CancelButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { Button, type ButtonProps, useThemeProps } from '@mui/material';
import { Button, type ButtonProps } from '@mui/material';
import { FormattedMessage } from 'react-intl';

export function CancelButton(inProps: Readonly<Omit<ButtonProps, 'children'>>) {
const props = useThemeProps({ props: inProps, name: 'CancelButton' });
export function CancelButton(buttonProps: Readonly<Omit<ButtonProps, 'children'>>) {
return (
<Button data-testid="CancelButton" {...props}>
<Button data-testid="CancelButton" {...buttonProps}>
<FormattedMessage id="cancel" />
</Button>
);
Expand Down
17 changes: 17 additions & 0 deletions src/components/ui/reactHookForm/utils/CloseButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* Copyright (c) 2026, RTE (http://www.rte-france.com)
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { Button, type ButtonProps } from '@mui/material';
import { FormattedMessage } from 'react-intl';

export function CloseButton(buttonProps: Readonly<Omit<ButtonProps, 'children'>>) {
return (
<Button data-testid="CloseButton" {...buttonProps}>
<FormattedMessage id="close" />
</Button>
);
}
1 change: 1 addition & 0 deletions src/components/ui/reactHookForm/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

export * from './CancelButton';
export * from './CloseButton';
export * from './FieldLabel';
export * from './SubmitButton';
export * from './TextFieldWithAdornment';
Expand Down
6 changes: 2 additions & 4 deletions src/features/topBar/AboutDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import {
AccordionSummary,
Alert,
Box,
Button,
CircularProgress,
Collapse,
Dialog,
Expand All @@ -35,6 +34,7 @@ import { FormattedMessage } from 'react-intl';
import { CustomTooltip } from '../../components/ui/tooltip/CustomTooltip';
import { LogoText } from './GridLogo';
import { mergeSx, type MuiStyles } from '../../utils/styles';
import { CloseButton } from '../../components/ui/reactHookForm/utils/CloseButton';

const styles = {
general: {
Expand Down Expand Up @@ -469,9 +469,7 @@ export function AboutDialog({
</Box>
</DialogContent>
<DialogActions>
<Button onClick={handleClose} autoFocus>
<FormattedMessage id="close" />
</Button>
<CloseButton color="primary" onClick={handleClose} autoFocus />
</DialogActions>
</Dialog>
);
Expand Down
4 changes: 2 additions & 2 deletions src/features/topBar/UserInformationDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import { Box, Dialog, DialogActions, DialogContent, DialogTitle, Grid2 as Grid,
import { FormattedMessage } from 'react-intl';
import type { UserProfile } from 'oidc-client-ts';
import { Fragment, useEffect, useState } from 'react';
import { CancelButton } from '../../components/ui/reactHookForm/utils/CancelButton';
import { fetchUserDetails } from '../../services/userAdmin';
import { UserDetail } from '../../utils/types/types';
import type { MuiStyles } from '../../utils/styles';
import { CloseButton } from '../../components/ui/reactHookForm/utils/CloseButton';

const styles = {
DialogTitle: { fontSize: '1.5rem' },
Expand Down Expand Up @@ -225,7 +225,7 @@ function UserInformationDialog({ openDialog, userProfile, onClose }: UserInforma
</DialogContent>

<DialogActions>
<CancelButton color="primary" onClick={onClose} />
<CloseButton color="primary" onClick={onClose} autoFocus />
</DialogActions>
</Dialog>
);
Expand Down
7 changes: 3 additions & 4 deletions src/features/topBar/UserSettingsDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
*/
import { type ChangeEvent, type SyntheticEvent, useCallback } from 'react';
import { FormattedMessage } from 'react-intl';
import { Alert, Box, Button, Dialog, DialogActions, DialogContent, DialogTitle, Switch } from '@mui/material';
import { Alert, Box, Dialog, DialogActions, DialogContent, DialogTitle, Switch } from '@mui/material';
import type { MuiStyles } from '../../utils/styles';
import { CloseButton } from '../../components/ui/reactHookForm/utils/CloseButton';

const styles = {
parameterName: (theme) => ({
Expand Down Expand Up @@ -70,9 +71,7 @@ function UserSettingsDialog({ openDialog, onClose, developerMode, onDeveloperMod
)}
</DialogContent>
<DialogActions>
<Button onClick={handleClose} variant="outlined">
<FormattedMessage id="user-settings-dialog/close" />
</Button>
<CloseButton color="primary" onClick={handleClose} autoFocus />
</DialogActions>
</Dialog>
);
Expand Down
1 change: 1 addition & 0 deletions src/translations/en/commonButtonEn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

export const commonButtonEn = {
cancel: 'Cancel',
close: 'Close',
validate: 'Validate',
add: 'Add',
replace: 'Replace',
Expand Down
1 change: 0 additions & 1 deletion src/translations/en/topBarEn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,4 @@ export const topBarEn = {
'user-settings-dialog/label-developer-mode': 'Developer mode',
'user-settings-dialog/warning-developer-mode':
'Some of the features are not complete, so they may not work as expected. To hide these features, disable developer mode.',
'user-settings-dialog/close': 'Close',
};
1 change: 1 addition & 0 deletions src/translations/fr/commonButtonFr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

export const commonButtonFr = {
cancel: 'Annuler',
close: 'Fermer',
validate: 'Valider',
add: 'Ajouter',
replace: 'Remplacer',
Expand Down
1 change: 0 additions & 1 deletion src/translations/fr/topBarFr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,5 +62,4 @@ export const topBarFr = {
'user-settings-dialog/label-developer-mode': 'Mode développeur',
'user-settings-dialog/warning-developer-mode':
'Certaines fonctionnalités ne sont pas complètes et peuvent donc ne pas fonctionner comme prévu. Pour masquer ces fonctionnalités, désactivez le mode développeur.',
'user-settings-dialog/close': 'Fermer',
};
Loading