Skip to content

Commit 7f69f1f

Browse files
authored
Change limit reductions labels (#847)
* add tooltips for the limit reductions table * fix translation * remove capitalization
1 parent 8813b46 commit 7f69f1f

File tree

10 files changed

+137
-68
lines changed

10 files changed

+137
-68
lines changed

src/components/parameters/common/limitreductions/columns-definitions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@ export const TAB_INFO = [
6969
];
7070

7171
export interface LimitReductionIColumnsDef {
72-
label: string;
72+
label: React.ReactNode;
7373
dataKey: string;
74-
tooltip: string;
74+
tooltip: React.ReactNode;
7575
width?: string;
7676
}
7777

src/components/parameters/common/limitreductions/limit-reduction-table-cell.tsx

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,44 @@
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
77

8-
import { TableCell } from '@mui/material';
9-
import { LimitReductionIColumnsDef, LIMIT_REDUCTIONS_FORM, VOLTAGE_LEVELS_FORM } from './columns-definitions';
8+
import { TableCell, Tooltip } from '@mui/material';
9+
import { FormattedMessage } from 'react-intl';
10+
import {
11+
LimitReductionIColumnsDef,
12+
LIMIT_REDUCTIONS_FORM,
13+
VOLTAGE_LEVELS_FORM,
14+
ILimitReductionsByVoltageLevel,
15+
} from './columns-definitions';
1016
import { FloatInput, RawReadOnlyInput } from '../../../inputs';
1117

1218
export function LimitReductionTableCell({
1319
rowIndex,
1420
column,
21+
limits,
1522
}: Readonly<{
1623
rowIndex: number;
1724
column: LimitReductionIColumnsDef;
25+
limits: ILimitReductionsByVoltageLevel[];
1826
}>) {
19-
return (
20-
<TableCell sx={{ fontWeight: 'bold' }}>
21-
{column.dataKey === VOLTAGE_LEVELS_FORM ? (
27+
return column.dataKey === VOLTAGE_LEVELS_FORM ? (
28+
<Tooltip
29+
title={
30+
<FormattedMessage
31+
id="VoltageRangeInterval"
32+
values={{
33+
lowBound: `${limits[rowIndex].voltageLevel.lowBound}`,
34+
highBound: `${limits[rowIndex].voltageLevel.highBound}`,
35+
}}
36+
/>
37+
}
38+
>
39+
<TableCell sx={{ fontWeight: 'bold' }}>
2240
<RawReadOnlyInput name={`${LIMIT_REDUCTIONS_FORM}[${rowIndex}].${column.dataKey}`} />
23-
) : (
24-
<FloatInput name={`${LIMIT_REDUCTIONS_FORM}[${rowIndex}].${column.dataKey}`} />
25-
)}
41+
</TableCell>
42+
</Tooltip>
43+
) : (
44+
<TableCell sx={{ fontWeight: 'bold' }}>
45+
<FloatInput name={`${LIMIT_REDUCTIONS_FORM}[${rowIndex}].${column.dataKey}`} />
2646
</TableCell>
2747
);
2848
}

src/components/parameters/common/limitreductions/limit-reduction-table-row.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,19 @@
77

88
import { TableRow } from '@mui/material';
99
import { LimitReductionTableCell } from './limit-reduction-table-cell';
10-
import { LimitReductionIColumnsDef } from './columns-definitions';
10+
import { ILimitReductionsByVoltageLevel, LimitReductionIColumnsDef } from './columns-definitions';
1111

1212
interface TableRowComponentProps {
1313
columnsDefinition: LimitReductionIColumnsDef[];
1414
index: number;
15+
limits: ILimitReductionsByVoltageLevel[];
1516
}
1617

17-
export function LimitReductionTableRow({ columnsDefinition, index }: Readonly<TableRowComponentProps>) {
18+
export function LimitReductionTableRow({ columnsDefinition, index, limits }: Readonly<TableRowComponentProps>) {
1819
return (
1920
<TableRow>
2021
{columnsDefinition.map((column: LimitReductionIColumnsDef) => (
21-
<LimitReductionTableCell key={`${column.dataKey}`} rowIndex={index} column={column} />
22+
<LimitReductionTableCell key={`${column.dataKey}`} rowIndex={index} column={column} limits={limits} />
2223
))}
2324
</TableRow>
2425
);
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import { FormattedMessage } from 'react-intl';
9+
import { ITemporaryLimitReduction } from './columns-definitions';
10+
11+
type LimitReductionsLabelColumnProps = {
12+
limits: ITemporaryLimitReduction;
13+
};
14+
15+
export function LimitReductionsLabelColumn({ limits }: Readonly<LimitReductionsLabelColumnProps>) {
16+
const highBound = Math.trunc(limits.limitDuration.lowBound / 60);
17+
const lowBound = Math.trunc(limits.limitDuration.highBound / 60);
18+
19+
if (lowBound === 0) {
20+
return <FormattedMessage id="LimitVoltageAfterIST" values={{ highBound: `${highBound}` }} />;
21+
}
22+
23+
return (
24+
<FormattedMessage
25+
id="LimitVoltageInterval"
26+
values={{
27+
lowBound: `${lowBound}`,
28+
highBound: `${highBound}`,
29+
}}
30+
/>
31+
);
32+
}

src/components/parameters/common/limitreductions/limit-reductions-table-form.tsx

Lines changed: 11 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -4,73 +4,46 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
7-
import { useCallback, useMemo } from 'react';
8-
import { useIntl } from 'react-intl';
7+
8+
import { useMemo } from 'react';
9+
import { FormattedMessage } from 'react-intl';
910
import {
1011
COLUMNS_DEFINITIONS_LIMIT_REDUCTIONS,
1112
ILimitReductionsByVoltageLevel,
12-
ITemporaryLimitReduction,
1313
LIMIT_DURATION_FORM,
1414
LIMIT_REDUCTIONS_FORM,
1515
} from './columns-definitions';
1616
import { CustomVoltageLevelTable } from '../voltage-level-table';
17-
18-
const getLabelColumn = (limit: ITemporaryLimitReduction) => {
19-
const lowBound = `${Math.trunc(limit.limitDuration.lowBound / 60)} min`;
20-
const highBoundValue = Math.trunc(limit.limitDuration.highBound / 60);
21-
const highBound = highBoundValue === 0 ? '∞' : `${Math.trunc(limit.limitDuration.highBound / 60)} min`;
22-
const lowerBoundClosed = limit.limitDuration.lowClosed ? '[' : ']';
23-
const highBoundClosed = limit.limitDuration.highClosed || null ? ']' : '[';
24-
return `${lowerBoundClosed}${lowBound}, ${highBound}${highBoundClosed}`;
25-
};
17+
import { LimitReductionsToolTipColumn } from './limit-reductions-tooltip-column';
18+
import { LimitReductionsLabelColumn } from './limit-reductions-label-column';
2619

2720
export function LimitReductionsTableForm({ limits }: Readonly<{ limits: ILimitReductionsByVoltageLevel[] }>) {
28-
const intl = useIntl();
29-
30-
const getToolTipColumn = useCallback(
31-
(limit: ITemporaryLimitReduction) => {
32-
const lowBound = Math.trunc(limit.limitDuration.lowBound / 60);
33-
const highBound = Math.trunc(limit.limitDuration.highBound / 60);
34-
if (lowBound === 0) {
35-
return intl.formatMessage({ id: 'LimitDurationAfterIST' }, { value: highBound });
36-
}
37-
38-
return intl.formatMessage(
39-
{ id: 'LimitDurationInterval' },
40-
{
41-
lowBound: `IT${lowBound}`,
42-
highBound: highBound === 0 ? 'IST' : `IT${highBound}`,
43-
}
44-
);
45-
},
46-
[intl]
47-
);
48-
4921
const columnsDefinition = useMemo(() => {
5022
const columnsDef = COLUMNS_DEFINITIONS_LIMIT_REDUCTIONS.map((column) => ({
5123
...column,
52-
label: intl.formatMessage({ id: column.label }),
53-
tooltip: intl.formatMessage({ id: column.tooltip }),
24+
label: <FormattedMessage id={column.label as string} />,
25+
tooltip: <FormattedMessage id={column.tooltip as string} />,
5426
}));
5527

5628
if (limits !== null && limits.length > 0) {
5729
limits[0].temporaryLimitReductions.forEach((tlimit, index) => {
5830
columnsDef.push({
59-
label: getLabelColumn(tlimit),
31+
label: <LimitReductionsLabelColumn limits={tlimit} />,
6032
dataKey: LIMIT_DURATION_FORM + index,
61-
tooltip: getToolTipColumn(tlimit),
33+
tooltip: <LimitReductionsToolTipColumn limits={tlimit} />,
6234
});
6335
});
6436
}
6537

6638
return columnsDef;
67-
}, [intl, limits, getToolTipColumn]);
39+
}, [limits]);
6840

6941
return (
7042
<CustomVoltageLevelTable
7143
formName={LIMIT_REDUCTIONS_FORM}
7244
columnsDefinition={columnsDefinition}
7345
tableHeight={450}
46+
limits={limits}
7447
/>
7548
);
7649
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Copyright (c) 2025, RTE (http://www.rte-france.com)
3+
* This Source Code Form is subject to the terms of the Mozilla Public
4+
* License, v. 2.0. If a copy of the MPL was not distributed with this
5+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
6+
*/
7+
8+
import { FormattedMessage } from 'react-intl';
9+
import { ITemporaryLimitReduction } from './columns-definitions';
10+
11+
type LimitReductionsLabelColumnProps = {
12+
limits: ITemporaryLimitReduction;
13+
};
14+
15+
export function LimitReductionsToolTipColumn({ limits }: Readonly<LimitReductionsLabelColumnProps>) {
16+
const lowBound = `${Math.trunc(limits.limitDuration.lowBound / 60)} min`;
17+
const highBoundValue = Math.trunc(limits.limitDuration.highBound / 60);
18+
const highBound = highBoundValue === 0 ? '∞' : `${Math.trunc(limits.limitDuration.highBound / 60)} min`;
19+
const lowerBoundClosed = limits.limitDuration.lowClosed ? '[' : ']';
20+
const higherBoundClosed = limits.limitDuration.highClosed || null ? ']' : '[';
21+
return (
22+
<FormattedMessage
23+
id="LimitDurationInterval"
24+
values={{
25+
lowBound: `${lowBound}`,
26+
highBound: `${highBound}`,
27+
higherBoundClosed: `${higherBoundClosed}`,
28+
lowerBoundClosed: `${lowerBoundClosed}`,
29+
}}
30+
/>
31+
);
32+
}

src/components/parameters/common/voltage-level-table/custom-voltage-level-table.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,29 @@
44
* License, v. 2.0. If a copy of the MPL was not distributed with this
55
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
66
*/
7-
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow } from '@mui/material';
7+
import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip } from '@mui/material';
88
import { useMemo } from 'react';
99
import { useFieldArray } from 'react-hook-form';
10-
import { LimitReductionIColumnsDef, LIMIT_REDUCTIONS_FORM } from '../limitreductions/columns-definitions';
10+
import {
11+
LimitReductionIColumnsDef,
12+
LIMIT_REDUCTIONS_FORM,
13+
ILimitReductionsByVoltageLevel,
14+
} from '../limitreductions/columns-definitions';
1115
import { LimitReductionTableRow } from '../limitreductions/limit-reduction-table-row';
1216
import { CustomVoltageLevelTableRow } from './custom-voltage-level-table-row';
1317

1418
interface LimitReductionsTableProps {
1519
columnsDefinition: LimitReductionIColumnsDef[];
1620
tableHeight: number;
1721
formName: string;
22+
limits: ILimitReductionsByVoltageLevel[];
1823
}
1924

2025
export function CustomVoltageLevelTable({
2126
formName,
2227
columnsDefinition,
2328
tableHeight,
29+
limits,
2430
}: Readonly<LimitReductionsTableProps>) {
2531
const { fields: rows } = useFieldArray({
2632
name: formName,
@@ -43,15 +49,16 @@ export function CustomVoltageLevelTable({
4349
<TableHead>
4450
<TableRow>
4551
{columnsDefinition.map((column) => (
46-
<TableCell
47-
key={column.dataKey}
48-
sx={{
49-
textAlign: 'center',
50-
}}
51-
title={column.tooltip}
52-
>
53-
{column.label}
54-
</TableCell>
52+
<Tooltip title={column.tooltip}>
53+
<TableCell
54+
key={column.dataKey}
55+
sx={{
56+
textAlign: 'center',
57+
}}
58+
>
59+
{column.label}
60+
</TableCell>
61+
</Tooltip>
5562
))}
5663
</TableRow>
5764
</TableHead>
@@ -62,6 +69,7 @@ export function CustomVoltageLevelTable({
6269
columnsDefinition={columnsDefinition}
6370
index={index}
6471
formName={formName}
72+
limits={limits}
6573
/>
6674
))}
6775
</TableBody>

src/components/parameters/security-analysis/security-analysis-parameters-selector.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ export function SecurityAnalysisParametersSelector({
6161
sx={{
6262
fontSize: 17,
6363
fontWeight: 'bold',
64-
textTransform: 'capitalize',
6564
}}
6665
/>
6766
)

src/translations/en/parameters.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,12 @@ export const parametersEn = {
5656

5757
General: 'General',
5858
LimitReductions: 'Limit reductions',
59-
IST: 'IST',
60-
LimitDurationInterval: 'Between {highBound} and {lowBound}',
61-
LimitDurationAfterIST: 'Beyond IT{value}',
59+
IST: 'PATL',
60+
LimitVoltageInterval: 'Between TATL{lowBound} and TATL{highBound}',
61+
LimitVoltageAfterIST: 'Between PATL and TATL{highBound}',
62+
LimitDurationInterval: 'Duration {lowerBoundClosed}{lowBound}, {highBound}{higherBoundClosed}',
6263
voltageRange: 'Voltage range',
64+
VoltageRangeInterval: 'Voltage interval ]{lowBound} kV,{highBound} kV]',
6365

6466
Provider: 'Provider',
6567
LimitReduction: 'Limit reduction',

src/translations/fr/parameters.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,11 @@ export const parametersFr = {
5959
General: 'Général',
6060
LimitReductions: 'Abattements',
6161
IST: 'IST',
62-
LimitDurationInterval: 'Entre {highBound} et {lowBound}',
63-
LimitDurationAfterIST: 'Au-delà de IT{value}',
62+
LimitVoltageInterval: 'Entre IT{lowBound} et IT{highBound}',
63+
LimitVoltageAfterIST: 'Entre IST et IT{highBound}',
64+
LimitDurationInterval: 'Tempo {lowerBoundClosed}{lowBound}, {highBound}{higherBoundClosed}',
6465
voltageRange: 'Niveau de tension',
66+
VoltageRangeInterval: 'Plage de tension ]{lowBound} kV,{highBound} kV]',
6567

6668
Provider: 'Simulateur',
6769
LimitReduction: 'Abattement des seuils',

0 commit comments

Comments
 (0)