Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,14 @@ export interface ILimitReductionsByVoltageLevel {
}

export enum TabValues {
General = 0,
LimitReductions = 1,
Contingencies = 0,
Aggravation = 1,
LimitReductions = 2,
}

export const TAB_INFO = [
{ label: TabValues[TabValues.General], developerModeOnly: false },
{ label: TabValues[TabValues.Contingencies], developerModeOnly: false },
{ label: TabValues[TabValues.Aggravation], developerModeOnly: false },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add the missing Contingencies translation key.

TabValues[TabValues.Contingencies] produces the message ID Contingencies, but neither src/translations/en/parameters.ts nor src/translations/fr/parameters.ts defines that key. The new tab will therefore render a missing-translation fallback instead of its label.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/features/parameters/common/limitreductions/columns-definitions.ts` around
lines 44 - 46, Add the missing Contingencies translation key to both the English
and French parameters translation definitions, using the existing translation
structure and appropriate localized labels. Ensure the TabValues.Contingencies
message ID resolves correctly for the TAB_INFO entry.

{ label: TabValues[TabValues.LimitReductions], developerModeOnly: false },
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@
* 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 { Box, Stack } from '@mui/material';
import { Stack } from '@mui/material';
import { ForwardedRef } from 'react';
import { UUID } from 'node:crypto';
import type { UUID } from 'node:crypto';
import { parametersStyles } from '../parameters-style';
import { CONTINGENCY_LISTS_INFOS, ContingencyTableApi, LineSeparator, ProviderParam } from '../common';
import { ContingencyTableApi, ProviderParam } from '../common';
import { SecurityAnalysisParametersSelector } from './security-analysis-parameters-selector';
import { UseSecurityAnalysisParametersFormReturn } from './use-security-analysis-parameters-form';
import { ContingencyTable } from '../common/contingency-table';
import { ContingencyCount } from '../common/contingency-table/types';

export type SecurityAnalysisParametersFormProps = {
Expand All @@ -34,21 +33,15 @@ export function SecurityAnalysisParametersForm({
return (
<Stack sx={parametersStyles.scrollableGrid}>
<ProviderParam options={securityAnalysisMethods.formattedProviders} id="Sa" sx={{ paddingBottom: 1 }} />
<ContingencyTable
name={CONTINGENCY_LISTS_INFOS}
showContingencyCount={showContingencyCount}
fetchContingencyCount={fetchContingencyCount}
isBuiltCurrentNode={isBuiltCurrentNode}
ref={contingencyTableApiRef}
/>
<Box paddingTop={4} paddingBottom={2}>
<LineSeparator />
</Box>
<SecurityAnalysisParametersSelector
params={securityAnalysisMethods.params}
currentProvider={securityAnalysisMethods.watchProvider?.trim()}
isDeveloperMode={isDeveloperMode}
defaultLimitReductions={securityAnalysisMethods.defaultLimitReductions}
showContingencyCount={showContingencyCount}
fetchContingencyCount={fetchContingencyCount}
contingencyTableApiRef={contingencyTableApiRef}
isBuiltCurrentNode={isBuiltCurrentNode}
/>
</Stack>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,23 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/

import { SyntheticEvent, useCallback, useEffect, useMemo, useState } from 'react';
import { SyntheticEvent, useCallback, useEffect, useMemo, useState, ForwardedRef } from 'react';

import { FormattedMessage } from 'react-intl';

import { Grid2 as Grid, Tab, Tabs } from '@mui/material';
import { ILimitReductionsByVoltageLevel, LimitReductionsTableForm, TAB_INFO, TabPanel, TabValues } from '../common';
import type { UUID } from 'node:crypto';
import {
ILimitReductionsByVoltageLevel,
LimitReductionsTableForm,
TAB_INFO,
TabPanel,
TabValues,
CONTINGENCY_LISTS_INFOS,
ContingencyTableApi,
} from '../common';
import { ContingencyTable } from '../common/contingency-table';
import { ContingencyCount } from '../common/contingency-table/types';
import { PARAM_PROVIDER_OPENLOADFLOW } from '../loadflow';
import { ViolationsHidingParameters } from './security-analysis-violations-hiding';
import { SAParametersEnriched } from '../../../utils/types';
Expand All @@ -20,31 +31,44 @@ export function SecurityAnalysisParametersSelector({
currentProvider,
isDeveloperMode,
defaultLimitReductions,
showContingencyCount,
fetchContingencyCount,
contingencyTableApiRef,
isBuiltCurrentNode,
}: Readonly<{
params: SAParametersEnriched | null;
currentProvider?: string;
isDeveloperMode: boolean;
defaultLimitReductions: ILimitReductionsByVoltageLevel[];
showContingencyCount: boolean;
fetchContingencyCount?: (contingencyListIds: UUID[] | null, abortSignal: AbortSignal) => Promise<ContingencyCount>;
contingencyTableApiRef?: ForwardedRef<ContingencyTableApi>;
isBuiltCurrentNode?: boolean;
}>) {
const [tabSelected, setTabSelected] = useState(TabValues.General);
const [tabSelected, setTabSelected] = useState(TabValues.Contingencies);

const handleTabChange = useCallback((event: SyntheticEvent, newValue: number) => {
setTabSelected(newValue);
}, []);

const tabValue = useMemo(() => {
return tabSelected === TabValues.LimitReductions && !params?.limitReductions ? TabValues.General : tabSelected;
return tabSelected === TabValues.LimitReductions && !params?.limitReductions
? TabValues.Contingencies
: tabSelected;
}, [params, tabSelected]);

useEffect(() => {
if (currentProvider !== PARAM_PROVIDER_OPENLOADFLOW) {
setTabSelected(TabValues.General);
if (currentProvider !== PARAM_PROVIDER_OPENLOADFLOW && tabSelected === TabValues.LimitReductions) {
setTabSelected(TabValues.Contingencies);
}
}, [currentProvider]);
}, [currentProvider, tabSelected]);

const visibleTabs = TAB_INFO.filter((t) => isDeveloperMode || !t.developerModeOnly);

return (
<Grid sx={{ width: '100%' }}>
<Tabs value={tabValue} onChange={handleTabChange}>
{TAB_INFO.filter((t) => isDeveloperMode || !t.developerModeOnly).map(
{visibleTabs.map(
(tab, index) =>
(tab.label !== TabValues[TabValues.LimitReductions] ||
(currentProvider === PARAM_PROVIDER_OPENLOADFLOW && params?.limitReductions)) && (
Expand All @@ -61,9 +85,20 @@ export function SecurityAnalysisParametersSelector({
)}
</Tabs>

{TAB_INFO.filter((t) => isDeveloperMode || !t.developerModeOnly).map((tab, index) => (
<TabPanel key={tab.label} value={tabValue} index={index}>
{tabValue === TabValues.General && <ViolationsHidingParameters />}
{visibleTabs.map((tab, index) => (
<TabPanel key={tab.label} value={tabValue} index={index} keepState={index === TabValues.Contingencies}>
{index === TabValues.Contingencies && (
<ContingencyTable
name={CONTINGENCY_LISTS_INFOS}
showContingencyCount={showContingencyCount}
fetchContingencyCount={fetchContingencyCount}
isBuiltCurrentNode={isBuiltCurrentNode}
ref={contingencyTableApiRef}
/>
)}

{tabValue === TabValues.Aggravation && <ViolationsHidingParameters />}

{tabValue === TabValues.LimitReductions &&
currentProvider === PARAM_PROVIDER_OPENLOADFLOW &&
params?.limitReductions && (
Expand Down
Loading