From 69cf64a572981b3c48e73036afabd3c774a5cef5 Mon Sep 17 00:00:00 2001 From: sBouzols Date: Wed, 21 Jan 2026 18:23:32 +0100 Subject: [PATCH 01/11] feat(): module ENR part 2, add `powerElectronicsClusters` parameters management Signed-off-by: sBouzols --- src/components/parameters/common/utils.ts | 1 + .../short-circuit/columns-definition.ts | 118 ++++++++++++++++++ .../parameters/short-circuit/constants.ts | 4 +- .../short-circuit/short-circuit-fields.tsx | 82 +++++++++--- .../short-circuit-icc-cluster-table-cell.tsx | 51 ++++++++ .../short-circuit-icc-cluster-table-row.tsx | 55 ++++++++ .../short-circuit-icc-cluster-table.tsx | 106 ++++++++++++++++ .../short-circuit-icc-material-table-cell.tsx | 2 +- ...t-icc-material-table-columns-definition.ts | 52 -------- .../short-circuit-icc-material-table-row.tsx | 2 +- .../short-circuit-icc-material-table.tsx | 2 +- .../short-circuit-parameters-utils.ts | 111 +++++++++++++++- .../short-circuit-parameters.type.ts | 23 +++- .../use-short-circuit-parameters-form.ts | 4 +- src/translations/en/parameters.ts | 21 ++-- src/translations/fr/parameters.ts | 21 ++-- 16 files changed, 557 insertions(+), 98 deletions(-) create mode 100644 src/components/parameters/short-circuit/columns-definition.ts create mode 100644 src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx create mode 100644 src/components/parameters/short-circuit/short-circuit-icc-cluster-table-row.tsx create mode 100644 src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx delete mode 100644 src/components/parameters/short-circuit/short-circuit-icc-material-table-columns-definition.ts diff --git a/src/components/parameters/common/utils.ts b/src/components/parameters/common/utils.ts index 682c3fe72..ba18b01d4 100644 --- a/src/components/parameters/common/utils.ts +++ b/src/components/parameters/common/utils.ts @@ -96,6 +96,7 @@ export const getAllSpecificParametersValues = ( _specificParametersValues: SpecificParametersValues ): SpecificParametersValues => { return Object.keys(formData[SPECIFIC_PARAMETERS]).reduce((acc: SpecificParametersValues, key: string) => { + console.log('SBO :', _specificParametersValues, key, formData[SPECIFIC_PARAMETERS][key]); if (_specificParametersValues[key].toString() !== formData[SPECIFIC_PARAMETERS][key].toString()) { acc[key] = formData[SPECIFIC_PARAMETERS][key].toString(); } diff --git a/src/components/parameters/short-circuit/columns-definition.ts b/src/components/parameters/short-circuit/columns-definition.ts new file mode 100644 index 000000000..9fc7ef9a2 --- /dev/null +++ b/src/components/parameters/short-circuit/columns-definition.ts @@ -0,0 +1,118 @@ +/** + * Copyright (c) 2025, 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 { ElementType, EquipmentType } from '../../../utils'; + +export const SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE = 'active'; +export const SHORT_CIRCUIT_ICC_MATERIAL_TYPE = 'type'; +export const SHORT_CIRCUIT_ICC_MATERIAL_ALPHA = 'alpha'; +export const SHORT_CIRCUIT_ICC_MATERIAL_USMIN = 'usMin'; +export const SHORT_CIRCUIT_ICC_MATERIAL_USMAX = 'usMax'; +export const SHORT_CIRCUIT_ICC_MATERIAL_U0 = 'u0'; +export const SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE = SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE; +export const SHORT_CIRCUIT_ICC_CLUSTER_FILTERS = 'filters'; +export const SHORT_CIRCUIT_ICC_CLUSTER_TYPE = SHORT_CIRCUIT_ICC_MATERIAL_TYPE; +export const SHORT_CIRCUIT_ICC_CLUSTER_ALPHA = SHORT_CIRCUIT_ICC_MATERIAL_ALPHA; +export const SHORT_CIRCUIT_ICC_CLUSTER_USMIN = SHORT_CIRCUIT_ICC_MATERIAL_USMIN; +export const SHORT_CIRCUIT_ICC_CLUSTER_USMAX = SHORT_CIRCUIT_ICC_MATERIAL_USMAX; +export const SHORT_CIRCUIT_ICC_CLUSTER_U0 = SHORT_CIRCUIT_ICC_MATERIAL_U0; + +export interface IccCommonIColumnsDef { + label: React.ReactNode; + dataKey: string; + tooltip: React.ReactNode; +} + +export interface IccMaterialIColumnsDef extends IccCommonIColumnsDef {} +export interface IccClusterIColumnsDef extends IccCommonIColumnsDef { + equipmentTypes?: EquipmentType[]; + elementType?: string; + titleId?: string; + initialValue?: any; +} + +export const COLUMNS_DEFINITIONS_ICC_MATERIALS: IccMaterialIColumnsDef[] = [ + { + label: 'ShortCircuitIccActivate', + dataKey: SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE, + tooltip: 'ShortCircuitIccMaterialActivateTooltip', + }, + { + label: 'ShortCircuitIccMaterialType', + dataKey: SHORT_CIRCUIT_ICC_MATERIAL_TYPE, + tooltip: 'ShortCircuitIccMaterialTypeTooltip', + }, + { + label: 'ShortCircuitIccAlpha', + dataKey: SHORT_CIRCUIT_ICC_MATERIAL_ALPHA, + tooltip: 'ShortCircuitIccAlphaTooltip', + }, + { + label: 'ShortCircuitIccUsmin', + dataKey: SHORT_CIRCUIT_ICC_MATERIAL_USMIN, + tooltip: 'ShortCircuitIccUsminTooltip', + }, + { + label: 'ShortCircuitIccUsmax', + dataKey: SHORT_CIRCUIT_ICC_MATERIAL_USMAX, + tooltip: 'ShortCircuitIccUsmaxTooltip', + }, + { + label: 'ShortCircuitIccU0', + dataKey: SHORT_CIRCUIT_ICC_MATERIAL_U0, + tooltip: 'ShortCircuitIccU0Tooltip', + }, +]; + +export const COLUMNS_DEFINITIONS_ICC_CLUSTERS: IccClusterIColumnsDef[] = [ + { + label: 'ShortCircuitIccActivate', + dataKey: SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE, + tooltip: 'ShortCircuitIccClusterActivateTooltip', + initialValue: false, + }, + { + label: 'ShortCircuitIccClusterFilters', + dataKey: SHORT_CIRCUIT_ICC_CLUSTER_FILTERS, + tooltip: 'ShortCircuitIccClusterFiltersTooltip', + equipmentTypes: [EquipmentType.GENERATOR, EquipmentType.HVDC_CONVERTER_STATION], + elementType: ElementType.FILTER, + titleId: 'TypeListsSelection', + initialValue: [], + }, + { + label: 'ShortCircuitIccClusterType', + dataKey: SHORT_CIRCUIT_ICC_CLUSTER_TYPE, + tooltip: 'ShortCircuitIccClusterTypeTooltip', + titleId: 'FiltersListsSelection', + initialValue: [], + }, + { + label: 'ShortCircuitIccAlpha', + dataKey: SHORT_CIRCUIT_ICC_CLUSTER_ALPHA, + tooltip: 'ShortCircuitIccAlphaTooltip', + initialValue: 1, + }, + { + label: 'ShortCircuitIccUsmin', + dataKey: SHORT_CIRCUIT_ICC_CLUSTER_USMIN, + tooltip: 'ShortCircuitIccUsminTooltip', + initialValue: 0, + }, + { + label: 'ShortCircuitIccUsmax', + dataKey: SHORT_CIRCUIT_ICC_CLUSTER_USMAX, + tooltip: 'ShortCircuitIccUsmaxTooltip', + initialValue: 100, + }, + { + label: 'ShortCircuitIccU0', + dataKey: SHORT_CIRCUIT_ICC_CLUSTER_U0, + tooltip: 'ShortCircuitIccU0Tooltip', + initialValue: 100, + }, +]; diff --git a/src/components/parameters/short-circuit/constants.ts b/src/components/parameters/short-circuit/constants.ts index 15856500b..29277b181 100644 --- a/src/components/parameters/short-circuit/constants.ts +++ b/src/components/parameters/short-circuit/constants.ts @@ -28,9 +28,11 @@ export const SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE = 'initialVoltageProfile export const SHORT_CIRCUIT_VOLTAGE_RANGES = 'voltageRanges'; // specific parameters -export const SHORT_CIRCUIT_ONLY_STARTED_GENERATORS = 'onlyStartedGenerators'; +export const SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER = 'onlyStartedGeneratorsInCalculationCluster'; export const SHORT_CIRCUIT_MODEL_POWER_ELECTRONICS = 'modelPowerElectronics'; export const SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS = 'powerElectronicsMaterials'; +export const SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTER = 'powerElectronicsCluster'; // TODO REMOVE WHEN fixed in powsybl +export const SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS = 'powerElectronicsClusters'; export const intlPredefinedParametersOptions = () => [ { diff --git a/src/components/parameters/short-circuit/short-circuit-fields.tsx b/src/components/parameters/short-circuit/short-circuit-fields.tsx index bbc03b0ce..6375847f5 100644 --- a/src/components/parameters/short-circuit/short-circuit-fields.tsx +++ b/src/components/parameters/short-circuit/short-circuit-fields.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { useEffect, useMemo, useState } from 'react'; +import { useCallback, useEffect, useMemo, useState } from 'react'; import { Grid } from '@mui/material'; import { green, red } from '@mui/material/colors'; import { Lens } from '@mui/icons-material'; @@ -18,7 +18,6 @@ import { onlyStartedGeneratorsOptions, PredefinedParameters, SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, - SHORT_CIRCUIT_ONLY_STARTED_GENERATORS, SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS, SHORT_CIRCUIT_MODEL_POWER_ELECTRONICS, SHORT_CIRCUIT_PREDEFINED_PARAMS, @@ -27,6 +26,8 @@ import { SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, + SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS, + SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER, } from './constants'; import { VoltageTable } from './short-circuit-voltage-table'; import GridItem from '../../grid/grid-item'; @@ -35,7 +36,8 @@ import { CheckboxInput, FieldLabel, MuiSelectInput, RadioInput, SwitchInput } fr import type { SxStyle } from '../../../utils/styles'; import { COMMON_PARAMETERS, SPECIFIC_PARAMETERS } from '../common'; import { ShortCircuitIccMaterialTable } from './short-circuit-icc-material-table'; -import { COLUMNS_DEFINITIONS_ICC_MATERIALS } from './short-circuit-icc-material-table-columns-definition'; +import { COLUMNS_DEFINITIONS_ICC_CLUSTERS, COLUMNS_DEFINITIONS_ICC_MATERIALS } from './columns-definition'; +import { ShortCircuitIccClusterTable } from './short-circuit-icc-cluster-table'; export interface ShortCircuitFieldsProps { resetAll: (predefinedParams: PredefinedParameters) => void; @@ -47,7 +49,13 @@ export enum Status { ERROR = 'ERROR', } -const columnsDef = COLUMNS_DEFINITIONS_ICC_MATERIALS.map((col) => ({ +const iccMaterialsColumnsDef = COLUMNS_DEFINITIONS_ICC_MATERIALS.map((col) => ({ + ...col, + label: , + tooltip: , +})); + +const iccClustersColumnsDef = COLUMNS_DEFINITIONS_ICC_CLUSTERS.map((col) => ({ ...col, label: , tooltip: , @@ -82,21 +90,41 @@ export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonl [watchSpecificParameters] ); // Courcirc specific parameters - const watchOnlyStartedGenerators = useWatch({ - name: `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS}`, + const watchOnlyStartedGeneratorsInCalculationCluster = useWatch({ + name: `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER}`, }); const isIccMinFeaturesDefaultConfiguration = useMemo(() => { return ( - !watchLoads && !watchShuntCompensators && !watchVSC && !watchNeutralPosition && watchOnlyStartedGenerators + !watchLoads && + !watchShuntCompensators && + !watchVSC && + !watchNeutralPosition && + watchOnlyStartedGeneratorsInCalculationCluster ); - }, [watchLoads, watchShuntCompensators, watchVSC, watchNeutralPosition, watchOnlyStartedGenerators]); + }, [ + watchLoads, + watchShuntCompensators, + watchVSC, + watchNeutralPosition, + watchOnlyStartedGeneratorsInCalculationCluster, + ]); const isIccMaxFeaturesDefaultConfiguration = useMemo(() => { return ( - !watchLoads && !watchShuntCompensators && watchVSC && !watchNeutralPosition && !watchOnlyStartedGenerators + !watchLoads && + !watchShuntCompensators && + watchVSC && + !watchNeutralPosition && + !watchOnlyStartedGeneratorsInCalculationCluster ); - }, [watchLoads, watchShuntCompensators, watchVSC, watchNeutralPosition, watchOnlyStartedGenerators]); + }, [ + watchLoads, + watchShuntCompensators, + watchVSC, + watchNeutralPosition, + watchOnlyStartedGeneratorsInCalculationCluster, + ]); // the translation of values const predefinedParamsOptions = useMemo(() => { @@ -167,16 +195,20 @@ export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonl /> ); - // Forced to specificly manage this onlyStartedGenerators parameter because it's a boolean type, but we want to use a radio button here. - const onlyStartedGenerators = ( + // Forced to specificly manage this onlyStartedGeneratorsInCalculationCluster parameter because it's a boolean type, but we want to use a radio button here. + const onlyStartedGeneratorsInCalculationCluster = ( { - setValue(`${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS}`, value === 'true', { - shouldDirty: true, - }); + setValue( + `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER}`, + value === 'true', + { + shouldDirty: true, + } + ); }, }} /> @@ -220,6 +252,14 @@ export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonl isIccMinFeaturesDefaultConfiguration, ]); + const createRows = useCallback(() => { + const rowData: { [key: string]: any } = {}; + iccClustersColumnsDef.forEach((column) => { + rowData[column.dataKey] = column.initialValue; + }); + return rowData; + }, []); + return ( @@ -250,7 +290,7 @@ export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonl <> - {onlyStartedGenerators} + {onlyStartedGeneratorsInCalculationCluster} {isDeveloperMode && ( <> @@ -261,7 +301,13 @@ export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonl + )} diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx new file mode 100644 index 000000000..9b56e7ccb --- /dev/null +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx @@ -0,0 +1,51 @@ +/* eslint-disable prettier/prettier */ +/** + * Copyright (c) 2025, 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 { TableCell } from '@mui/material'; +import { DirectoryItemsInput, FloatInput, SelectInput, SwitchInput } from '../../inputs'; +import { IccClusterIColumnsDef, SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE, SHORT_CIRCUIT_ICC_CLUSTER_FILTERS, SHORT_CIRCUIT_ICC_CLUSTER_TYPE } from './columns-definition'; + +export function ShortCircuitIccClusterTableCell({ + formName, + rowIndex, + column, + inputsDisabled, +}: Readonly<{ + formName: string; + rowIndex: number; + column: IccClusterIColumnsDef; + inputsDisabled?: boolean; +}>) { + return ( + + {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE && ( + + )} + {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_FILTERS && ( + // + + )} + {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_TYPE && ( + + )} + {column.dataKey !== SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE && + column.dataKey !== SHORT_CIRCUIT_ICC_CLUSTER_FILTERS && ( + + )} + + ); +} diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-row.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-row.tsx new file mode 100644 index 000000000..6f1148d10 --- /dev/null +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-row.tsx @@ -0,0 +1,55 @@ +/** + * Copyright (c) 2025, 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 { IconButton, TableCell, TableRow, Tooltip } from '@mui/material'; +import { Delete as DeleteIcon } from '@mui/icons-material'; +import { useWatch } from 'react-hook-form'; +import { useState } from 'react'; +import { FormattedMessage } from 'react-intl'; +import { IccClusterIColumnsDef, SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE } from './columns-definition'; +import { ShortCircuitIccClusterTableCell } from './short-circuit-icc-cluster-table-cell'; + +interface ShortCircuitIccClusterTableRowProps { + formName: string; + columnsDefinition: IccClusterIColumnsDef[]; + index: number; + onDeleteButton: (index: number) => void; +} + +export function ShortCircuitIccClusterTableRow({ + formName, + columnsDefinition, + index, + onDeleteButton, +}: Readonly) { + const [isHover, setIsHover] = useState(false); + const watchRowActive = useWatch({ + name: `${formName}[${index}].${SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE}`, + }); + + return ( + setIsHover(true)} onMouseLeave={() => setIsHover(false)}> + {columnsDefinition.map((column: IccClusterIColumnsDef) => ( + + ))} + + {isHover && ( + }> + onDeleteButton(index)}> + + + + )} + + + ); +} diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx new file mode 100644 index 000000000..9fc8c8757 --- /dev/null +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx @@ -0,0 +1,106 @@ +/** + * Copyright (c) 2025, 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 { IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip } from '@mui/material'; +import { AddCircle as AddCircleIcon } from '@mui/icons-material'; +import { useFieldArray, useFormContext } from 'react-hook-form'; +import { FormattedMessage } from 'react-intl'; +import { useCallback } from 'react'; +import { IccClusterIColumnsDef } from './columns-definition'; +import { ShortCircuitIccClusterTableRow } from './short-circuit-icc-cluster-table-row'; + +interface ShortCircuitIccClusterTableProps { + columnsDefinition: IccClusterIColumnsDef[]; + tableHeight: number; + formName: string; + createRows: () => unknown; +} + +export function ShortCircuitIccClusterTable({ + formName, + columnsDefinition, + tableHeight, + createRows, +}: Readonly) { + const { getValues } = useFormContext(); + const { + fields: rows, + append, + remove, + } = useFieldArray({ + name: formName, + }); + + const handleAddRowsButton = useCallback(() => { + append(createRows()); + }, [append, createRows]); + + const handleDeleteButton = useCallback( + (index: number) => { + const currentRowsValues = getValues(formName); + // let isFormChanged = false; + // if (index >= 0 && index < currentRowsValues.length) { + // if (currentRowsValues[index][COUNT] && currentRowsValues[index][ACTIVATED]) { + // isFormChanged = true; + // } + remove(index); + // } + // if (isFormChanged) { + // onFormChanged(true); + // } + }, + [formName, getValues, remove] + ); + + return ( + + + + + {columnsDefinition.map((column) => ( + + + {column.label} + + + ))} + + }> + + + + + + + + + + + {rows.map((row, index) => ( + + ))} + +
+
+ ); +} diff --git a/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx index 9fb1df2fc..b3c3f6eaa 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx @@ -10,7 +10,7 @@ import { IccMaterialIColumnsDef, SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE, SHORT_CIRCUIT_ICC_MATERIAL_TYPE, -} from './short-circuit-icc-material-table-columns-definition'; +} from './columns-definition'; export function ShortCircuitIccMaterialTableCell({ formName, diff --git a/src/components/parameters/short-circuit/short-circuit-icc-material-table-columns-definition.ts b/src/components/parameters/short-circuit/short-circuit-icc-material-table-columns-definition.ts deleted file mode 100644 index 39e747962..000000000 --- a/src/components/parameters/short-circuit/short-circuit-icc-material-table-columns-definition.ts +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2025, 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/. - */ - -export const SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE = 'active'; -export const SHORT_CIRCUIT_ICC_MATERIAL_TYPE = 'type'; -export const SHORT_CIRCUIT_ICC_MATERIAL_ALPHA = 'alpha'; -export const SHORT_CIRCUIT_ICC_MATERIAL_USMIN = 'usMin'; -export const SHORT_CIRCUIT_ICC_MATERIAL_USMAX = 'usMax'; -export const SHORT_CIRCUIT_ICC_MATERIAL_U0 = 'u0'; - -export interface IccMaterialIColumnsDef { - label: React.ReactNode; - dataKey: string; - tooltip: React.ReactNode; -} - -export const COLUMNS_DEFINITIONS_ICC_MATERIALS: IccMaterialIColumnsDef[] = [ - { - label: 'ShortCircuitIccMaterialActivate', - dataKey: SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE, - tooltip: 'ShortCircuitIccMaterialActivateTooltip', - }, - { - label: 'ShortCircuitIccMaterialType', - dataKey: SHORT_CIRCUIT_ICC_MATERIAL_TYPE, - tooltip: 'ShortCircuitIccMaterialTypeTooltip', - }, - { - label: 'ShortCircuitIccMaterialAlpha', - dataKey: SHORT_CIRCUIT_ICC_MATERIAL_ALPHA, - tooltip: 'ShortCircuitIccMaterialAlphaTooltip', - }, - { - label: 'ShortCircuitIccMaterialUsmin', - dataKey: SHORT_CIRCUIT_ICC_MATERIAL_USMIN, - tooltip: 'ShortCircuitIccMaterialUsminTooltip', - }, - { - label: 'ShortCircuitIccMaterialUsmax', - dataKey: SHORT_CIRCUIT_ICC_MATERIAL_USMAX, - tooltip: 'ShortCircuitIccMaterialUsmaxTooltip', - }, - { - label: 'ShortCircuitIccMaterialU0', - dataKey: SHORT_CIRCUIT_ICC_MATERIAL_U0, - tooltip: 'ShortCircuitIccMaterialU0Tooltip', - }, -]; diff --git a/src/components/parameters/short-circuit/short-circuit-icc-material-table-row.tsx b/src/components/parameters/short-circuit/short-circuit-icc-material-table-row.tsx index 3950d3bfe..f4aa66793 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-material-table-row.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-material-table-row.tsx @@ -9,7 +9,7 @@ import { useWatch } from 'react-hook-form'; import { IccMaterialIColumnsDef, SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE, -} from './short-circuit-icc-material-table-columns-definition'; +} from './columns-definition'; import { ShortCircuitIccMaterialTableCell } from './short-circuit-icc-material-table-cell'; interface ShortCircuitIccMaterialTableRowProps { diff --git a/src/components/parameters/short-circuit/short-circuit-icc-material-table.tsx b/src/components/parameters/short-circuit/short-circuit-icc-material-table.tsx index d52e99f1d..778508a80 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-material-table.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-material-table.tsx @@ -7,7 +7,7 @@ import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip } from '@mui/material'; import { useFieldArray } from 'react-hook-form'; -import { IccMaterialIColumnsDef } from './short-circuit-icc-material-table-columns-definition'; +import { IccMaterialIColumnsDef } from './columns-definition'; import { ShortCircuitIccMaterialTableRow } from './short-circuit-icc-material-table-row'; interface ShortCircuitIccMaterialTableProps { diff --git a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts index ca5d1bd5c..7bb9d3c7d 100644 --- a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts +++ b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts @@ -8,6 +8,8 @@ import { InitialVoltage, SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, + SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTER, + SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS, SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS, SHORT_CIRCUIT_WITH_FEEDER_RESULT, SHORT_CIRCUIT_WITH_LOADS, @@ -17,15 +19,21 @@ import { } from './constants'; import yup from '../../../utils/yupConfig'; import { COMMON_PARAMETERS, SPECIFIC_PARAMETERS } from '../common'; -import { type SpecificParameterInfos, type SpecificParametersValues } from '../../../utils'; +import { ID, type SpecificParameterInfos, type SpecificParametersValues } from '../../../utils'; -import type { PowerElectronicsMaterial } from './short-circuit-parameters.type'; +import { + FilterPOJO, + FormPowerElectronicsCluster, + type PowerElectronicsCluster, + type PowerElectronicsMaterial, +} from './short-circuit-parameters.type'; import { formatSpecificParameters, getAllSpecificParametersValues, getDefaultSpecificParamsValues, getSpecificParametersFormSchema, } from '../common/utils'; +import { NAME } from '../../inputs'; export const getCommonShortCircuitParametersFormSchema = () => { return yup.object().shape({ @@ -68,6 +76,32 @@ export const getSpecificShortCircuitParametersFormSchema = ( .required() : undefined; + const powerElectronicsClustersParam = specificParametersDescriptionForProvider?.find( + (specificParam) => specificParam.name === SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTER + ); + + const powerElectronicsClustersSchema = powerElectronicsClustersParam + ? yup + .array() + .of( + yup.object().shape({ + active: yup.boolean().required(), + alpha: yup.number().required(), + u0: yup.number().required(), + usMin: yup.number().required(), + usMax: yup.number().required(), + filters: yup.array().of( + yup.object().shape({ + [ID]: yup.string().required(), + [NAME]: yup.string().required(), + }) + ), + type: yup.string().oneOf(['WIND', 'SOLAR', 'HVDC']).required(), + }) + ) + .required() + : undefined; + // try to extract existing SPECIFIC_PARAMETERS fields from defaultSchema (if present) const existingSpecificSchema = (defaultSchema as any).fields?.[SPECIFIC_PARAMETERS] as | yup.ObjectSchema @@ -79,6 +113,9 @@ export const getSpecificShortCircuitParametersFormSchema = ( ...(powerElectronicsMaterialsSchema ? { [SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS]: powerElectronicsMaterialsSchema } : {}), + ...(powerElectronicsClustersSchema + ? { [SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS]: powerElectronicsClustersSchema } + : {}), }; const overrideSchema = yup.object().shape({ @@ -99,6 +136,16 @@ const parsepowerElectronicsMaterialsParamString = (paramString: string): PowerEl } }; +const parsepowerElectronicsClustersParamString = (paramString: string): PowerElectronicsCluster[] => { + // Attempt to parse the string into an array of PowerElectronicsCluster objects + try { + return JSON.parse(paramString); + } catch (error) { + console.error('Error parsing power electronics materials parameter string:', error); + return []; + } +}; + export const getDefaultShortCircuitSpecificParamsValues = ( specificParametersDescriptionForProvider: SpecificParameterInfos[] ): SpecificParametersValues => { @@ -118,6 +165,14 @@ export const getDefaultShortCircuitSpecificParamsValues = ( active: false, })); } + const powerElectronicsClustersParam = specificParametersDescriptionForProvider.find( + (specificParam) => specificParam.name === SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTER + ); + if (powerElectronicsClustersParam) { + defaultValues[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] = []; // there is no default params for clusters for now + console.log('SBO : getDefaultShortCircuitSpecificParamsValues SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS set'); + } + console.log('SBO : getDefaultShortCircuitSpecificParamsValues', defaultValues); return defaultValues; }; @@ -127,7 +182,9 @@ export const getShortCircuitSpecificParametersValues = ( ): SpecificParametersValues => { const powerElectronicsMaterialsParam: (PowerElectronicsMaterial & { active: boolean })[] = formData[SPECIFIC_PARAMETERS][SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS]; - if (powerElectronicsMaterialsParam) { + const powerElectronicsClustersParam: (FormPowerElectronicsCluster & { active: boolean })[] = + formData[SPECIFIC_PARAMETERS][SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS]; + if (powerElectronicsMaterialsParam && powerElectronicsClustersParam) { // create pretty JSON return { ...getAllSpecificParametersValues(formData, _specificParametersValues), @@ -139,6 +196,19 @@ export const getShortCircuitSpecificParametersValues = ( return rest; }) ), + [SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS]: JSON.stringify( + powerElectronicsClustersParam + .filter((sParam) => sParam.active) // keep only active ones + .map((sParam) => { + const { active, filters, ...rest } = sParam; // remove 'active' property + const lightFilters = // keep only id and name in filters for backend + filters?.map((filter) => ({ + filterId: filter[ID], + filterName: filter.name, + })) ?? []; + return { ...rest, filters: lightFilters }; + }) + ), }; } return getAllSpecificParametersValues(formData, _specificParametersValues); @@ -156,6 +226,22 @@ const formatElectronicsMaterialsParamString = ( }); }; +const formatElectronicsClustersParamString = (defaultValues: PowerElectronicsCluster[], specificParamValue: string) => { + const electronicsClustersArrayInParams: PowerElectronicsCluster[] = + parsepowerElectronicsClustersParamString(specificParamValue); + return electronicsClustersArrayInParams.map((cluster) => { + const { filters, ...rest } = cluster; + return { + ...rest, + filters: filters.map((filter) => ({ + [ID]: filter.filterId, + [NAME]: filter.filterName, // TODO from back to front -> {id: uuid, name: string} + })), + active: true, + }; + }); +}; + export const formatShortCircuitSpecificParameters = ( specificParametersDescriptionForProvider: SpecificParameterInfos[], specificParamsList: SpecificParametersValues @@ -183,5 +269,24 @@ export const formatShortCircuitSpecificParameters = ( ]; } } + + // handle special power-electronics-clusters case by overriding the generic result + const powerElectronicsClustersParam = specificParametersDescriptionForProvider.find( + (p) => p.name === SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTER + ); + if (powerElectronicsClustersParam) { + if (Object.hasOwn(specificParamsList, SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS)) { + formatted[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] = formatElectronicsClustersParamString( + getDefaultShortCircuitSpecificParamsValues([powerElectronicsClustersParam])?.[ + SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS + ], + specificParamsList[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] as string + ); + } else { + formatted[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] = getDefaultSpecificParamsValues([ + powerElectronicsClustersParam, + ])?.[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS]; + } + } return formatted; }; diff --git a/src/components/parameters/short-circuit/short-circuit-parameters.type.ts b/src/components/parameters/short-circuit/short-circuit-parameters.type.ts index fcbb664f9..f7cde42b7 100644 --- a/src/components/parameters/short-circuit/short-circuit-parameters.type.ts +++ b/src/components/parameters/short-circuit/short-circuit-parameters.type.ts @@ -4,7 +4,8 @@ * 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 { SpecificParametersPerProvider } from '../../../utils'; +import { UUID } from 'node:crypto'; +import { FilterIdentifier, SpecificParametersPerProvider } from '../../../utils'; import { InitialVoltage, PredefinedParameters } from './constants'; export interface VoltageRange { @@ -22,6 +23,26 @@ export interface PowerElectronicsMaterial { type: 'WIND' | 'SOLAR' | 'HVDC'; } +export type FilterPOJO = { + id: UUID; + name: string; +}; + +export interface FormPowerElectronicsCluster { + alpha: number; + u0: number; + usMin: number; + usMax: number; + filters: FilterPOJO[]; +} +export interface PowerElectronicsCluster { + alpha: number; + u0: number; + usMin: number; + usMax: number; + filters: FilterIdentifier[]; +} + export interface ShortCircuitParametersDto { withFeederResult: boolean; withLoads: boolean; diff --git a/src/components/parameters/short-circuit/use-short-circuit-parameters-form.ts b/src/components/parameters/short-circuit/use-short-circuit-parameters-form.ts index ae5d11cc3..45d0b767d 100644 --- a/src/components/parameters/short-circuit/use-short-circuit-parameters-form.ts +++ b/src/components/parameters/short-circuit/use-short-circuit-parameters-form.ts @@ -16,7 +16,7 @@ import { InitialVoltage, PredefinedParameters, SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, - SHORT_CIRCUIT_ONLY_STARTED_GENERATORS, + SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER, SHORT_CIRCUIT_PREDEFINED_PARAMS, SHORT_CIRCUIT_VOLTAGE_RANGES, SHORT_CIRCUIT_WITH_FEEDER_RESULT, @@ -136,7 +136,7 @@ export const useShortCircuitParametersForm = ({ setValue(SHORT_CIRCUIT_PREDEFINED_PARAMS, predefinedParameter, dirty); setValue( - `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS}`, + `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER}`, predefinedParameter === PredefinedParameters.ICC_MIN_WITH_NOMINAL_VOLTAGE_MAP, dirty ); diff --git a/src/translations/en/parameters.ts b/src/translations/en/parameters.ts index 0a9b41654..fb41f7ff4 100644 --- a/src/translations/en/parameters.ts +++ b/src/translations/en/parameters.ts @@ -121,18 +121,21 @@ export const parametersEn = { ShortCircuitStartedGeneratorsMode: 'Generators started', ShortCircuitPowerElectronicsSection: 'Modeling of power electronics connected equipment', ShortCircuitModelPowerElectronics: 'Consider following Icc characteristics', - ShortCircuitIccMaterialActivate: 'Activate', + ShortCircuitIccActivate: 'Activate', ShortCircuitIccMaterialActivateTooltip: 'Activate or deactivate this material characteristic', + ShortCircuitIccClusterActivateTooltip: 'Activate or deactivate this cluster characteristic', + ShortCircuitIccClusterFilters: 'Filters', + ShortCircuitIccClusterFiltersTooltip: 'Select the filters to be included in this cluster', ShortCircuitIccMaterialType: 'Material', ShortCircuitIccMaterialTypeTooltip: 'Type of power electronics equipment', - ShortCircuitIccMaterialAlpha: 'Alpha', - ShortCircuitIccMaterialAlphaTooltip: 'Exponent of the voltage dependency of the Icc', - ShortCircuitIccMaterialUsmin: 'Usmin (%)', - ShortCircuitIccMaterialUsminTooltip: 'Minimum voltage for the Icc calculation', - ShortCircuitIccMaterialUsmax: 'Usmax (%)', - ShortCircuitIccMaterialUsmaxTooltip: 'Maximum voltage for the Icc calculation', - ShortCircuitIccMaterialU0: 'U0 (%)', - ShortCircuitIccMaterialU0Tooltip: 'Voltage level at which the Icc is nominal', + ShortCircuitIccAlpha: 'Alpha', + ShortCircuitIccAlphaTooltip: 'Exponent of the voltage dependency of the Icc', + ShortCircuitIccUsmin: 'Usmin (%)', + ShortCircuitIccUsminTooltip: 'Minimum voltage for the Icc calculation', + ShortCircuitIccUsmax: 'Usmax (%)', + ShortCircuitIccUsmaxTooltip: 'Maximum voltage for the Icc calculation', + ShortCircuitIccU0: 'U0 (%)', + ShortCircuitIccU0Tooltip: 'Voltage level at which the Icc is nominal', ShortCircuitWindLabel: 'Wind', ShortCircuitSolarLabel: 'Solar', ShortCircuitHvdcLabel: 'HVDC', diff --git a/src/translations/fr/parameters.ts b/src/translations/fr/parameters.ts index 5abde27e5..9823f1144 100644 --- a/src/translations/fr/parameters.ts +++ b/src/translations/fr/parameters.ts @@ -125,19 +125,22 @@ export const parametersFr = { ShortCircuitStartedGeneratorsMode: 'Démarrage des groupes', ShortCircuitPowerElectronicsSection: "Modélisation des équipements raccordés par de l'électronique de puissance", ShortCircuitModelPowerElectronics: "Prise en compte des caractéristiques d'Icc suivantes", - ShortCircuitIccMaterialActivate: 'Actif', + ShortCircuitIccActivate: 'Actif', ShortCircuitIccMaterialActivateTooltip: "Activer la modélisation des équipements raccordés par de l'électronique de puissance", + ShortCircuitIccClusterActivateTooltip: "Activer la modélisation des clusters d'électronique de puissance", + ShortCircuitIccClusterFilters: 'Filtres', + ShortCircuitIccClusterFiltersTooltip: 'Filtres de sélection des clusters', ShortCircuitIccMaterialType: 'Matériel', ShortCircuitIccMaterialTypeTooltip: "Type d'équipement raccordé par de l'électronique de puissance", - ShortCircuitIccMaterialAlpha: 'Alpha', - ShortCircuitIccMaterialAlphaTooltip: 'Coefficient de pente de la caractéristique Icc', - ShortCircuitIccMaterialUsmin: 'Usmin (%)', - ShortCircuitIccMaterialUsminTooltip: 'Tension minimale pour le calcul de Icc', - ShortCircuitIccMaterialUsmax: 'Usmax (%)', - ShortCircuitIccMaterialUsmaxTooltip: 'Tension maximale pour le calcul de Icc', - ShortCircuitIccMaterialU0: 'U0 (%)', - ShortCircuitIccMaterialU0Tooltip: 'Tension de référence pour le calcul de Icc', + ShortCircuitIccAlpha: 'Alpha', + ShortCircuitIccAlphaTooltip: 'Coefficient de pente de la caractéristique Icc', + ShortCircuitIccUsmin: 'Usmin (%)', + ShortCircuitIccUsminTooltip: 'Tension minimale pour le calcul de Icc', + ShortCircuitIccUsmax: 'Usmax (%)', + ShortCircuitIccUsmaxTooltip: 'Tension maximale pour le calcul de Icc', + ShortCircuitIccU0: 'U0 (%)', + ShortCircuitIccU0Tooltip: 'Tension de référence pour le calcul de Icc', ShortCircuitWindLabel: 'Éolien', ShortCircuitSolarLabel: 'Solaire', ShortCircuitHvdcLabel: 'HVDC', From 50d3a28cad4dc640e96722765b2d16b4febc69b8 Mon Sep 17 00:00:00 2001 From: sBouzols Date: Tue, 27 Jan 2026 10:40:58 +0100 Subject: [PATCH 02/11] complete fix and refactor usage of SelectInput for cluster configuration Signed-off-by: sBouzols --- src/components/parameters/common/utils.ts | 1 - .../short-circuit/columns-definition.ts | 6 ++--- .../short-circuit-icc-cluster-table-cell.tsx | 5 ++-- .../short-circuit-parameters-utils.ts | 27 ++++++++----------- src/translations/en/parameters.ts | 2 ++ src/translations/fr/parameters.ts | 2 ++ 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/components/parameters/common/utils.ts b/src/components/parameters/common/utils.ts index ba18b01d4..682c3fe72 100644 --- a/src/components/parameters/common/utils.ts +++ b/src/components/parameters/common/utils.ts @@ -96,7 +96,6 @@ export const getAllSpecificParametersValues = ( _specificParametersValues: SpecificParametersValues ): SpecificParametersValues => { return Object.keys(formData[SPECIFIC_PARAMETERS]).reduce((acc: SpecificParametersValues, key: string) => { - console.log('SBO :', _specificParametersValues, key, formData[SPECIFIC_PARAMETERS][key]); if (_specificParametersValues[key].toString() !== formData[SPECIFIC_PARAMETERS][key].toString()) { acc[key] = formData[SPECIFIC_PARAMETERS][key].toString(); } diff --git a/src/components/parameters/short-circuit/columns-definition.ts b/src/components/parameters/short-circuit/columns-definition.ts index 9fc7ef9a2..c7bf2b825 100644 --- a/src/components/parameters/short-circuit/columns-definition.ts +++ b/src/components/parameters/short-circuit/columns-definition.ts @@ -79,16 +79,16 @@ export const COLUMNS_DEFINITIONS_ICC_CLUSTERS: IccClusterIColumnsDef[] = [ label: 'ShortCircuitIccClusterFilters', dataKey: SHORT_CIRCUIT_ICC_CLUSTER_FILTERS, tooltip: 'ShortCircuitIccClusterFiltersTooltip', - equipmentTypes: [EquipmentType.GENERATOR, EquipmentType.HVDC_CONVERTER_STATION], + equipmentTypes: [EquipmentType.GENERATOR, EquipmentType.BATTERY], elementType: ElementType.FILTER, - titleId: 'TypeListsSelection', + titleId: 'FiltersListsSelection', initialValue: [], }, { label: 'ShortCircuitIccClusterType', dataKey: SHORT_CIRCUIT_ICC_CLUSTER_TYPE, tooltip: 'ShortCircuitIccClusterTypeTooltip', - titleId: 'FiltersListsSelection', + titleId: 'ShortCircuitIccClusterTypeListsSelection', initialValue: [], }, { diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx index 9b56e7ccb..642c89bb2 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx @@ -40,10 +40,11 @@ export function ShortCircuitIccClusterTableCell({ /> )} {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_TYPE && ( - + )} {column.dataKey !== SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE && - column.dataKey !== SHORT_CIRCUIT_ICC_CLUSTER_FILTERS && ( + column.dataKey !== SHORT_CIRCUIT_ICC_CLUSTER_FILTERS && + column.dataKey !== SHORT_CIRCUIT_ICC_CLUSTER_TYPE && ( )} diff --git a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts index 7bb9d3c7d..01f4e8823 100644 --- a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts +++ b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts @@ -136,7 +136,7 @@ const parsepowerElectronicsMaterialsParamString = (paramString: string): PowerEl } }; -const parsepowerElectronicsClustersParamString = (paramString: string): PowerElectronicsCluster[] => { +const parsepowerElectronicsClustersParamString = (paramString: string): (PowerElectronicsCluster & { active: boolean })[] => { // Attempt to parse the string into an array of PowerElectronicsCluster objects try { return JSON.parse(paramString); @@ -170,9 +170,7 @@ export const getDefaultShortCircuitSpecificParamsValues = ( ); if (powerElectronicsClustersParam) { defaultValues[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] = []; // there is no default params for clusters for now - console.log('SBO : getDefaultShortCircuitSpecificParamsValues SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS set'); } - console.log('SBO : getDefaultShortCircuitSpecificParamsValues', defaultValues); return defaultValues; }; @@ -197,17 +195,15 @@ export const getShortCircuitSpecificParametersValues = ( }) ), [SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS]: JSON.stringify( - powerElectronicsClustersParam - .filter((sParam) => sParam.active) // keep only active ones - .map((sParam) => { - const { active, filters, ...rest } = sParam; // remove 'active' property - const lightFilters = // keep only id and name in filters for backend - filters?.map((filter) => ({ - filterId: filter[ID], - filterName: filter.name, - })) ?? []; - return { ...rest, filters: lightFilters }; - }) + powerElectronicsClustersParam.map((sParam) => { + const { filters, ...rest } = sParam; + const lightFilters = // keep only id and name in filters for backend + filters?.map((filter) => ({ + filterId: filter[ID], + filterName: filter.name, + })) ?? []; + return { ...rest, filters: lightFilters }; + }) ), }; } @@ -227,7 +223,7 @@ const formatElectronicsMaterialsParamString = ( }; const formatElectronicsClustersParamString = (defaultValues: PowerElectronicsCluster[], specificParamValue: string) => { - const electronicsClustersArrayInParams: PowerElectronicsCluster[] = + const electronicsClustersArrayInParams: (PowerElectronicsCluster & { active: boolean })[] = parsepowerElectronicsClustersParamString(specificParamValue); return electronicsClustersArrayInParams.map((cluster) => { const { filters, ...rest } = cluster; @@ -237,7 +233,6 @@ const formatElectronicsClustersParamString = (defaultValues: PowerElectronicsClu [ID]: filter.filterId, [NAME]: filter.filterName, // TODO from back to front -> {id: uuid, name: string} })), - active: true, }; }); }; diff --git a/src/translations/en/parameters.ts b/src/translations/en/parameters.ts index fb41f7ff4..c9a5e098d 100644 --- a/src/translations/en/parameters.ts +++ b/src/translations/en/parameters.ts @@ -126,6 +126,8 @@ export const parametersEn = { ShortCircuitIccClusterActivateTooltip: 'Activate or deactivate this cluster characteristic', ShortCircuitIccClusterFilters: 'Filters', ShortCircuitIccClusterFiltersTooltip: 'Select the filters to be included in this cluster', + ShortCircuitIccClusterTypeTooltip: 'Select the types of equipment to be included in this cluster', + ShortCircuitIccClusterTypeListsSelection: 'Type lists selection', ShortCircuitIccMaterialType: 'Material', ShortCircuitIccMaterialTypeTooltip: 'Type of power electronics equipment', ShortCircuitIccAlpha: 'Alpha', diff --git a/src/translations/fr/parameters.ts b/src/translations/fr/parameters.ts index 9823f1144..78bdb4ca5 100644 --- a/src/translations/fr/parameters.ts +++ b/src/translations/fr/parameters.ts @@ -131,6 +131,8 @@ export const parametersFr = { ShortCircuitIccClusterActivateTooltip: "Activer la modélisation des clusters d'électronique de puissance", ShortCircuitIccClusterFilters: 'Filtres', ShortCircuitIccClusterFiltersTooltip: 'Filtres de sélection des clusters', + ShortCircuitIccClusterTypeTooltip: "Sélectionner les types d'équipements à inclure dans ce cluster", + ShortCircuitIccClusterTypeListsSelection: 'Sélection du type de cluster', ShortCircuitIccMaterialType: 'Matériel', ShortCircuitIccMaterialTypeTooltip: "Type d'équipement raccordé par de l'électronique de puissance", ShortCircuitIccAlpha: 'Alpha', From d3af371e19057ab143a270e306698e3cfc499d42 Mon Sep 17 00:00:00 2001 From: sBouzols Date: Wed, 4 Feb 2026 10:21:42 +0100 Subject: [PATCH 03/11] fix some sonar issues Signed-off-by: sBouzols --- .../short-circuit-icc-cluster-table.tsx | 15 ++------------- .../short-circuit-parameters-utils.ts | 6 ++++-- 2 files changed, 6 insertions(+), 15 deletions(-) diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx index 9fc8c8757..5a8e380a5 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx @@ -7,7 +7,7 @@ import { IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip } from '@mui/material'; import { AddCircle as AddCircleIcon } from '@mui/icons-material'; -import { useFieldArray, useFormContext } from 'react-hook-form'; +import { useFieldArray } from 'react-hook-form'; import { FormattedMessage } from 'react-intl'; import { useCallback } from 'react'; import { IccClusterIColumnsDef } from './columns-definition'; @@ -26,7 +26,6 @@ export function ShortCircuitIccClusterTable({ tableHeight, createRows, }: Readonly) { - const { getValues } = useFormContext(); const { fields: rows, append, @@ -41,19 +40,9 @@ export function ShortCircuitIccClusterTable({ const handleDeleteButton = useCallback( (index: number) => { - const currentRowsValues = getValues(formName); - // let isFormChanged = false; - // if (index >= 0 && index < currentRowsValues.length) { - // if (currentRowsValues[index][COUNT] && currentRowsValues[index][ACTIVATED]) { - // isFormChanged = true; - // } remove(index); - // } - // if (isFormChanged) { - // onFormChanged(true); - // } }, - [formName, getValues, remove] + [remove] ); return ( diff --git a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts index 01f4e8823..c266d420c 100644 --- a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts +++ b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts @@ -136,7 +136,9 @@ const parsepowerElectronicsMaterialsParamString = (paramString: string): PowerEl } }; -const parsepowerElectronicsClustersParamString = (paramString: string): (PowerElectronicsCluster & { active: boolean })[] => { +const parsepowerElectronicsClustersParamString = ( + paramString: string +): (PowerElectronicsCluster & { active: boolean })[] => { // Attempt to parse the string into an array of PowerElectronicsCluster objects try { return JSON.parse(paramString); @@ -231,7 +233,7 @@ const formatElectronicsClustersParamString = (defaultValues: PowerElectronicsClu ...rest, filters: filters.map((filter) => ({ [ID]: filter.filterId, - [NAME]: filter.filterName, // TODO from back to front -> {id: uuid, name: string} + [NAME]: filter.filterName, // from back to front -> {id: uuid, name: string} })), }; }); From eea0b350f16db497d5c2c9f25dc2a22e7068fd6a Mon Sep 17 00:00:00 2001 From: sBouzols Date: Wed, 4 Feb 2026 11:04:18 +0100 Subject: [PATCH 04/11] prettier Signed-off-by: sBouzols --- .../short-circuit-icc-cluster-table-cell.tsx | 33 +++++++++++-------- .../short-circuit-icc-material-table-row.tsx | 5 +-- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx index 642c89bb2..c594817fe 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx @@ -7,7 +7,12 @@ */ import { TableCell } from '@mui/material'; import { DirectoryItemsInput, FloatInput, SelectInput, SwitchInput } from '../../inputs'; -import { IccClusterIColumnsDef, SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE, SHORT_CIRCUIT_ICC_CLUSTER_FILTERS, SHORT_CIRCUIT_ICC_CLUSTER_TYPE } from './columns-definition'; +import { + IccClusterIColumnsDef, + SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE, + SHORT_CIRCUIT_ICC_CLUSTER_FILTERS, + SHORT_CIRCUIT_ICC_CLUSTER_TYPE, +} from './columns-definition'; export function ShortCircuitIccClusterTableCell({ formName, @@ -26,21 +31,23 @@ export function ShortCircuitIccClusterTableCell({ )} {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_FILTERS && ( - // + name={`${formName}[${rowIndex}].${column.dataKey}`} + equipmentTypes={column.equipmentTypes} + elementType={column.elementType ?? ''} + titleId={column.titleId} + hideErrorMessage + label={undefined} + itemFilter={undefined} + disable={inputsDisabled} + /> )} {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_TYPE && ( - + )} {column.dataKey !== SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE && column.dataKey !== SHORT_CIRCUIT_ICC_CLUSTER_FILTERS && diff --git a/src/components/parameters/short-circuit/short-circuit-icc-material-table-row.tsx b/src/components/parameters/short-circuit/short-circuit-icc-material-table-row.tsx index f4aa66793..43e4cebcb 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-material-table-row.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-material-table-row.tsx @@ -6,10 +6,7 @@ */ import { TableRow } from '@mui/material'; import { useWatch } from 'react-hook-form'; -import { - IccMaterialIColumnsDef, - SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE, -} from './columns-definition'; +import { IccMaterialIColumnsDef, SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE } from './columns-definition'; import { ShortCircuitIccMaterialTableCell } from './short-circuit-icc-material-table-cell'; interface ShortCircuitIccMaterialTableRowProps { From 820cbebae11d17e40b2316bf2c2d45a782bf1433 Mon Sep 17 00:00:00 2001 From: sBouzols Date: Wed, 4 Feb 2026 11:05:07 +0100 Subject: [PATCH 05/11] remove disable prettier line Signed-off-by: sBouzols --- .../short-circuit/short-circuit-icc-cluster-table-cell.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx index c594817fe..ac506b5be 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx @@ -1,4 +1,3 @@ -/* eslint-disable prettier/prettier */ /** * Copyright (c) 2025, RTE (http://www.rte-france.com) * This Source Code Form is subject to the terms of the Mozilla Public From 93d56215b66f712cfccd36b6eac198bb7e7ee793 Mon Sep 17 00:00:00 2001 From: sBouzols Date: Thu, 5 Feb 2026 10:22:03 +0100 Subject: [PATCH 06/11] try som labels and alignments Signed-off-by: sBouzols --- .../parameters/short-circuit/columns-definition.ts | 8 ++++---- .../short-circuit-icc-cluster-table-cell.tsx | 5 +++-- .../short-circuit-icc-cluster-table-row.tsx | 2 +- .../short-circuit/short-circuit-icc-cluster-table.tsx | 2 +- .../short-circuit-icc-material-table-cell.tsx | 2 +- src/translations/en/parameters.ts | 9 +++++---- src/translations/fr/parameters.ts | 9 +++++---- 7 files changed, 20 insertions(+), 17 deletions(-) diff --git a/src/components/parameters/short-circuit/columns-definition.ts b/src/components/parameters/short-circuit/columns-definition.ts index c7bf2b825..47c8c58c7 100644 --- a/src/components/parameters/short-circuit/columns-definition.ts +++ b/src/components/parameters/short-circuit/columns-definition.ts @@ -37,9 +37,9 @@ export interface IccClusterIColumnsDef extends IccCommonIColumnsDef { export const COLUMNS_DEFINITIONS_ICC_MATERIALS: IccMaterialIColumnsDef[] = [ { - label: 'ShortCircuitIccActivate', + label: 'ShortCircuitIccActive', dataKey: SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE, - tooltip: 'ShortCircuitIccMaterialActivateTooltip', + tooltip: 'ShortCircuitIccMaterialActiveTooltip', }, { label: 'ShortCircuitIccMaterialType', @@ -70,9 +70,9 @@ export const COLUMNS_DEFINITIONS_ICC_MATERIALS: IccMaterialIColumnsDef[] = [ export const COLUMNS_DEFINITIONS_ICC_CLUSTERS: IccClusterIColumnsDef[] = [ { - label: 'ShortCircuitIccActivate', + label: 'ShortCircuitIccActive', dataKey: SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE, - tooltip: 'ShortCircuitIccClusterActivateTooltip', + tooltip: 'ShortCircuitIccClusterActiveTooltip', initialValue: false, }, { diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx index ac506b5be..48451e5ae 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx @@ -25,7 +25,7 @@ export function ShortCircuitIccClusterTableCell({ inputsDisabled?: boolean; }>) { return ( - + {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE && ( )} @@ -43,8 +43,9 @@ export function ShortCircuitIccClusterTableCell({ )} {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_TYPE && ( )} diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-row.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-row.tsx index 6f1148d10..85e5cbe3b 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-row.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-row.tsx @@ -41,7 +41,7 @@ export function ShortCircuitIccClusterTableRow({ inputsDisabled={!watchRowActive} /> ))} - + {isHover && ( }> onDeleteButton(index)}> diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx index 5a8e380a5..b857240db 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx @@ -67,7 +67,7 @@ export function ShortCircuitIccClusterTable({ ))} - + }> diff --git a/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx index b3c3f6eaa..c42b450e0 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx @@ -24,7 +24,7 @@ export function ShortCircuitIccMaterialTableCell({ inputsDisabled?: boolean; }>) { return ( - + {column.dataKey === SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE && ( )} diff --git a/src/translations/en/parameters.ts b/src/translations/en/parameters.ts index c9a5e098d..a434615b2 100644 --- a/src/translations/en/parameters.ts +++ b/src/translations/en/parameters.ts @@ -121,13 +121,14 @@ export const parametersEn = { ShortCircuitStartedGeneratorsMode: 'Generators started', ShortCircuitPowerElectronicsSection: 'Modeling of power electronics connected equipment', ShortCircuitModelPowerElectronics: 'Consider following Icc characteristics', - ShortCircuitIccActivate: 'Activate', - ShortCircuitIccMaterialActivateTooltip: 'Activate or deactivate this material characteristic', - ShortCircuitIccClusterActivateTooltip: 'Activate or deactivate this cluster characteristic', + ShortCircuitIccActive: 'Activate', + ShortCircuitIccMaterialActiveTooltip: 'Activate or deactivate this material characteristic', + ShortCircuitIccClusterActiveTooltip: 'Activate or deactivate this cluster characteristic', ShortCircuitIccClusterFilters: 'Filters', ShortCircuitIccClusterFiltersTooltip: 'Select the filters to be included in this cluster', + ShortCircuitIccClusterType: 'Cluster type', ShortCircuitIccClusterTypeTooltip: 'Select the types of equipment to be included in this cluster', - ShortCircuitIccClusterTypeListsSelection: 'Type lists selection', + ShortCircuitIccClusterTypeListsSelection: 'Type', ShortCircuitIccMaterialType: 'Material', ShortCircuitIccMaterialTypeTooltip: 'Type of power electronics equipment', ShortCircuitIccAlpha: 'Alpha', diff --git a/src/translations/fr/parameters.ts b/src/translations/fr/parameters.ts index 78bdb4ca5..fa7c131e0 100644 --- a/src/translations/fr/parameters.ts +++ b/src/translations/fr/parameters.ts @@ -125,14 +125,15 @@ export const parametersFr = { ShortCircuitStartedGeneratorsMode: 'Démarrage des groupes', ShortCircuitPowerElectronicsSection: "Modélisation des équipements raccordés par de l'électronique de puissance", ShortCircuitModelPowerElectronics: "Prise en compte des caractéristiques d'Icc suivantes", - ShortCircuitIccActivate: 'Actif', - ShortCircuitIccMaterialActivateTooltip: + ShortCircuitIccActive: 'Actif', + ShortCircuitIccMaterialActiveTooltip: "Activer la modélisation des équipements raccordés par de l'électronique de puissance", - ShortCircuitIccClusterActivateTooltip: "Activer la modélisation des clusters d'électronique de puissance", + ShortCircuitIccClusterActiveTooltip: "Activer la modélisation des clusters d'électronique de puissance", ShortCircuitIccClusterFilters: 'Filtres', ShortCircuitIccClusterFiltersTooltip: 'Filtres de sélection des clusters', + ShortCircuitIccClusterType: 'Type de cluster', ShortCircuitIccClusterTypeTooltip: "Sélectionner les types d'équipements à inclure dans ce cluster", - ShortCircuitIccClusterTypeListsSelection: 'Sélection du type de cluster', + ShortCircuitIccClusterTypeListsSelection: 'Type', ShortCircuitIccMaterialType: 'Matériel', ShortCircuitIccMaterialTypeTooltip: "Type d'équipement raccordé par de l'électronique de puissance", ShortCircuitIccAlpha: 'Alpha', From 2adc1d362ff8f4831fd7273d5a3e3bdab4080950 Mon Sep 17 00:00:00 2001 From: sBouzols Date: Thu, 5 Feb 2026 15:16:49 +0100 Subject: [PATCH 07/11] style(shortcircuit ENR params): style tables and all Signed-off-by: sBouzols --- .../short-circuit/columns-definition.ts | 12 +++++ .../short-circuit/short-circuit-fields.tsx | 2 - .../short-circuit-icc-cluster-table-cell.tsx | 2 +- .../short-circuit-icc-cluster-table-row.tsx | 4 +- .../short-circuit-icc-cluster-table.tsx | 48 +++++++++++-------- .../short-circuit-icc-material-table-cell.tsx | 2 +- .../short-circuit-icc-material-table.tsx | 34 ++++++------- 7 files changed, 63 insertions(+), 41 deletions(-) diff --git a/src/components/parameters/short-circuit/columns-definition.ts b/src/components/parameters/short-circuit/columns-definition.ts index 47c8c58c7..b95fd81a8 100644 --- a/src/components/parameters/short-circuit/columns-definition.ts +++ b/src/components/parameters/short-circuit/columns-definition.ts @@ -25,6 +25,7 @@ export interface IccCommonIColumnsDef { label: React.ReactNode; dataKey: string; tooltip: React.ReactNode; + width?: string; } export interface IccMaterialIColumnsDef extends IccCommonIColumnsDef {} @@ -40,6 +41,7 @@ export const COLUMNS_DEFINITIONS_ICC_MATERIALS: IccMaterialIColumnsDef[] = [ label: 'ShortCircuitIccActive', dataKey: SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE, tooltip: 'ShortCircuitIccMaterialActiveTooltip', + width: '8%', }, { label: 'ShortCircuitIccMaterialType', @@ -50,21 +52,25 @@ export const COLUMNS_DEFINITIONS_ICC_MATERIALS: IccMaterialIColumnsDef[] = [ label: 'ShortCircuitIccAlpha', dataKey: SHORT_CIRCUIT_ICC_MATERIAL_ALPHA, tooltip: 'ShortCircuitIccAlphaTooltip', + width: '8%', }, { label: 'ShortCircuitIccUsmin', dataKey: SHORT_CIRCUIT_ICC_MATERIAL_USMIN, tooltip: 'ShortCircuitIccUsminTooltip', + width: '8%', }, { label: 'ShortCircuitIccUsmax', dataKey: SHORT_CIRCUIT_ICC_MATERIAL_USMAX, tooltip: 'ShortCircuitIccUsmaxTooltip', + width: '8%', }, { label: 'ShortCircuitIccU0', dataKey: SHORT_CIRCUIT_ICC_MATERIAL_U0, tooltip: 'ShortCircuitIccU0Tooltip', + width: '8%', }, ]; @@ -74,6 +80,7 @@ export const COLUMNS_DEFINITIONS_ICC_CLUSTERS: IccClusterIColumnsDef[] = [ dataKey: SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE, tooltip: 'ShortCircuitIccClusterActiveTooltip', initialValue: false, + width: '8%', }, { label: 'ShortCircuitIccClusterFilters', @@ -90,29 +97,34 @@ export const COLUMNS_DEFINITIONS_ICC_CLUSTERS: IccClusterIColumnsDef[] = [ tooltip: 'ShortCircuitIccClusterTypeTooltip', titleId: 'ShortCircuitIccClusterTypeListsSelection', initialValue: [], + width: '15%', }, { label: 'ShortCircuitIccAlpha', dataKey: SHORT_CIRCUIT_ICC_CLUSTER_ALPHA, tooltip: 'ShortCircuitIccAlphaTooltip', initialValue: 1, + width: '8%', }, { label: 'ShortCircuitIccUsmin', dataKey: SHORT_CIRCUIT_ICC_CLUSTER_USMIN, tooltip: 'ShortCircuitIccUsminTooltip', initialValue: 0, + width: '8%', }, { label: 'ShortCircuitIccUsmax', dataKey: SHORT_CIRCUIT_ICC_CLUSTER_USMAX, tooltip: 'ShortCircuitIccUsmaxTooltip', initialValue: 100, + width: '8%', }, { label: 'ShortCircuitIccU0', dataKey: SHORT_CIRCUIT_ICC_CLUSTER_U0, tooltip: 'ShortCircuitIccU0Tooltip', initialValue: 100, + width: '8%', }, ]; diff --git a/src/components/parameters/short-circuit/short-circuit-fields.tsx b/src/components/parameters/short-circuit/short-circuit-fields.tsx index ad7189d39..23d7cb824 100644 --- a/src/components/parameters/short-circuit/short-circuit-fields.tsx +++ b/src/components/parameters/short-circuit/short-circuit-fields.tsx @@ -300,12 +300,10 @@ export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonl
diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx index 48451e5ae..2db8d8be9 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx @@ -27,7 +27,7 @@ export function ShortCircuitIccClusterTableCell({ return ( {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE && ( - + )} {column.dataKey === SHORT_CIRCUIT_ICC_CLUSTER_FILTERS && ( {isHover && ( }> - onDeleteButton(index)}> - + onDeleteButton(index)}> + )} diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx index b857240db..35087fea9 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table.tsx @@ -5,7 +5,17 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { IconButton, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip } from '@mui/material'; +import { + IconButton, + Table, + TableBody, + TableCell, + TableContainer, + TableHead, + TableRow, + Theme, + Tooltip, +} from '@mui/material'; import { AddCircle as AddCircleIcon } from '@mui/icons-material'; import { useFieldArray } from 'react-hook-form'; import { FormattedMessage } from 'react-intl'; @@ -15,15 +25,25 @@ import { ShortCircuitIccClusterTableRow } from './short-circuit-icc-cluster-tabl interface ShortCircuitIccClusterTableProps { columnsDefinition: IccClusterIColumnsDef[]; - tableHeight: number; formName: string; createRows: () => unknown; } +const styles = { + tableContainer: (theme: Theme) => ({ + width: '100%', + border: 'solid 0px rgba(0,0,0,0.1)', + marginBottom: theme.spacing(4), + }), + table: { + minWidth: '80em', + tableLayout: 'fixed', + }, +}; + export function ShortCircuitIccClusterTable({ formName, columnsDefinition, - tableHeight, createRows, }: Readonly) { const { @@ -46,32 +66,22 @@ export function ShortCircuitIccClusterTable({ ); return ( - - + +
{columnsDefinition.map((column) => ( - + {column.label} ))} - + }> - - + + diff --git a/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx index c42b450e0..a8c04f6ca 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-material-table-cell.tsx @@ -26,7 +26,7 @@ export function ShortCircuitIccMaterialTableCell({ return ( {column.dataKey === SHORT_CIRCUIT_ICC_MATERIAL_ACTIVE && ( - + )} {column.dataKey === SHORT_CIRCUIT_ICC_MATERIAL_TYPE && ( diff --git a/src/components/parameters/short-circuit/short-circuit-icc-material-table.tsx b/src/components/parameters/short-circuit/short-circuit-icc-material-table.tsx index 778508a80..31a7c65c9 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-material-table.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-material-table.tsx @@ -5,48 +5,50 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Tooltip } from '@mui/material'; +import { Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Theme, Tooltip } from '@mui/material'; import { useFieldArray } from 'react-hook-form'; import { IccMaterialIColumnsDef } from './columns-definition'; import { ShortCircuitIccMaterialTableRow } from './short-circuit-icc-material-table-row'; interface ShortCircuitIccMaterialTableProps { columnsDefinition: IccMaterialIColumnsDef[]; - tableHeight: number; formName: string; } +const styles = { + tableContainer: (theme: Theme) => ({ + width: '100%', + border: 'solid 0px rgba(0,0,0,0.1)', + marginBottom: theme.spacing(4), + }), + table: { + minWidth: '80em', + tableLayout: 'fixed', + }, +}; + export function ShortCircuitIccMaterialTable({ formName, columnsDefinition, - tableHeight, }: Readonly) { const { fields: rows } = useFieldArray({ name: formName, }); return ( - -
+ +
{columnsDefinition.map((column) => ( - + {column.label} ))} + + {/* empty cell for alignment with delete button column in cluster table */} From a6c37f4a0b7f82dd724d1f43ba1c2f50dc7481d7 Mon Sep 17 00:00:00 2001 From: sBouzols Date: Fri, 6 Feb 2026 15:18:25 +0100 Subject: [PATCH 08/11] disable Select as well Signed-off-by: sBouzols --- .../short-circuit/short-circuit-icc-cluster-table-cell.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx index 2db8d8be9..2f3093fa9 100644 --- a/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx +++ b/src/components/parameters/short-circuit/short-circuit-icc-cluster-table-cell.tsx @@ -47,6 +47,7 @@ export function ShortCircuitIccClusterTableCell({ name={`${formName}[${rowIndex}].${column.dataKey}`} label={column.titleId} options={['WIND', 'SOLAR', 'HVDC']} + disabled={inputsDisabled} /> )} {column.dataKey !== SHORT_CIRCUIT_ICC_CLUSTER_ACTIVE && From 7ca0daa679af83260083cb5a1cbce63d8d802fed Mon Sep 17 00:00:00 2001 From: sBouzols Date: Tue, 10 Feb 2026 15:14:27 +0100 Subject: [PATCH 09/11] fixes from review Signed-off-by: sBouzols --- .../short-circuit/short-circuit-fields.tsx | 16 ++++++++-------- .../short-circuit-parameters-utils.ts | 10 +++++----- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/components/parameters/short-circuit/short-circuit-fields.tsx b/src/components/parameters/short-circuit/short-circuit-fields.tsx index c397297a0..0fc6e13e2 100644 --- a/src/components/parameters/short-circuit/short-circuit-fields.tsx +++ b/src/components/parameters/short-circuit/short-circuit-fields.tsx @@ -61,6 +61,14 @@ const iccClustersColumnsDef = COLUMNS_DEFINITIONS_ICC_CLUSTERS.map((col) => ({ tooltip: , })); +function createRows() { + const rowData: { [key: string]: any } = {}; + iccClustersColumnsDef.forEach((column) => { + rowData[column.dataKey] = column.initialValue; + }); + return rowData; +} + export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonly) { const [status, setStatus] = useState(Status.SUCCESS); const watchInitialVoltageProfileMode = useWatch({ @@ -254,14 +262,6 @@ export function ShortCircuitFields({ resetAll, isDeveloperMode = true }: Readonl isIccMinFeaturesDefaultConfiguration, ]); - const createRows = useCallback(() => { - const rowData: { [key: string]: any } = {}; - iccClustersColumnsDef.forEach((column) => { - rowData[column.dataKey] = column.initialValue; - }); - return rowData; - }, []); - return ( diff --git a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts index c266d420c..d687915eb 100644 --- a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts +++ b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts @@ -126,7 +126,7 @@ export const getSpecificShortCircuitParametersFormSchema = ( return defaultSchema.concat(overrideSchema); }; -const parsepowerElectronicsMaterialsParamString = (paramString: string): PowerElectronicsMaterial[] => { +const parsePowerElectronicsMaterialsParamString = (paramString: string): PowerElectronicsMaterial[] => { // Attempt to parse the string into an array of PowerElectronicsMaterial objects try { return JSON.parse(paramString); @@ -136,7 +136,7 @@ const parsepowerElectronicsMaterialsParamString = (paramString: string): PowerEl } }; -const parsepowerElectronicsClustersParamString = ( +const parsePowerElectronicsClustersParamString = ( paramString: string ): (PowerElectronicsCluster & { active: boolean })[] => { // Attempt to parse the string into an array of PowerElectronicsCluster objects @@ -158,7 +158,7 @@ export const getDefaultShortCircuitSpecificParamsValues = ( (specificParam) => specificParam.name === SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS ); if (powerElectronicsMaterialsParam) { - const electronicsMaterialsArray: PowerElectronicsMaterial[] = parsepowerElectronicsMaterialsParamString( + const electronicsMaterialsArray: PowerElectronicsMaterial[] = parsePowerElectronicsMaterialsParamString( powerElectronicsMaterialsParam.defaultValue ); @@ -217,7 +217,7 @@ const formatElectronicsMaterialsParamString = ( specificParamValue: string ) => { const electronicsMaterialsArrayInParams: PowerElectronicsMaterial[] = - parsepowerElectronicsMaterialsParamString(specificParamValue); + parsePowerElectronicsMaterialsParamString(specificParamValue); return defaultValues.map((material) => { const foundInParams = electronicsMaterialsArrayInParams.find((m) => m.type === material.type); return foundInParams ? { ...foundInParams, active: true } : { ...material, active: false }; @@ -226,7 +226,7 @@ const formatElectronicsMaterialsParamString = ( const formatElectronicsClustersParamString = (defaultValues: PowerElectronicsCluster[], specificParamValue: string) => { const electronicsClustersArrayInParams: (PowerElectronicsCluster & { active: boolean })[] = - parsepowerElectronicsClustersParamString(specificParamValue); + parsePowerElectronicsClustersParamString(specificParamValue); return electronicsClustersArrayInParams.map((cluster) => { const { filters, ...rest } = cluster; return { From 67f83c2e8c99e63387a2b83e2076d04da7338b9b Mon Sep 17 00:00:00 2001 From: sBouzols Date: Tue, 10 Feb 2026 15:50:51 +0100 Subject: [PATCH 10/11] remove unused import Signed-off-by: sBouzols --- .../parameters/short-circuit/short-circuit-fields.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/parameters/short-circuit/short-circuit-fields.tsx b/src/components/parameters/short-circuit/short-circuit-fields.tsx index 0fc6e13e2..b75e88cd6 100644 --- a/src/components/parameters/short-circuit/short-circuit-fields.tsx +++ b/src/components/parameters/short-circuit/short-circuit-fields.tsx @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { useCallback, useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { Grid } from '@mui/material'; import { green, red } from '@mui/material/colors'; import { Lens } from '@mui/icons-material'; From c4c8e13b04aaa0a0d7a75a47fe6b36a7945fc288 Mon Sep 17 00:00:00 2001 From: sBouzols Date: Tue, 10 Feb 2026 18:16:29 +0100 Subject: [PATCH 11/11] Pass snackError to utility class to manage JSON parse error with a snackbar Signed-off-by: sBouzols --- .../short-circuit-parameters-utils.ts | 54 +++++++++++++------ .../use-short-circuit-parameters-form.ts | 9 ++-- src/translations/en/parameters.ts | 8 ++- src/translations/fr/parameters.ts | 8 ++- 4 files changed, 54 insertions(+), 25 deletions(-) diff --git a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts index d687915eb..7b5134d65 100644 --- a/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts +++ b/src/components/parameters/short-circuit/short-circuit-parameters-utils.ts @@ -19,7 +19,7 @@ import { } from './constants'; import yup from '../../../utils/yupConfig'; import { COMMON_PARAMETERS, SPECIFIC_PARAMETERS } from '../common'; -import { ID, type SpecificParameterInfos, type SpecificParametersValues } from '../../../utils'; +import { ID, snackWithFallback, type SpecificParameterInfos, type SpecificParametersValues } from '../../../utils'; import { FilterPOJO, @@ -34,6 +34,7 @@ import { getSpecificParametersFormSchema, } from '../common/utils'; import { NAME } from '../../inputs'; +import { SnackInputs } from '../../../hooks'; export const getCommonShortCircuitParametersFormSchema = () => { return yup.object().shape({ @@ -126,30 +127,36 @@ export const getSpecificShortCircuitParametersFormSchema = ( return defaultSchema.concat(overrideSchema); }; -const parsePowerElectronicsMaterialsParamString = (paramString: string): PowerElectronicsMaterial[] => { +const parsePowerElectronicsMaterialsParamString = ( + paramString: string, + snackError: (message: SnackInputs) => void +): PowerElectronicsMaterial[] => { // Attempt to parse the string into an array of PowerElectronicsMaterial objects try { return JSON.parse(paramString); } catch (error) { console.error('Error parsing power electronics materials parameter string:', error); + snackWithFallback(snackError, error, { headerId: 'ShortCircuitPowerElectronicsMaterialsParamParsingError' }); return []; } }; const parsePowerElectronicsClustersParamString = ( - paramString: string + paramString: string, + snackError: (message: SnackInputs) => void ): (PowerElectronicsCluster & { active: boolean })[] => { // Attempt to parse the string into an array of PowerElectronicsCluster objects try { return JSON.parse(paramString); } catch (error) { - console.error('Error parsing power electronics materials parameter string:', error); + snackWithFallback(snackError, error, { headerId: 'ShortCircuitPowerElectronicsClustersParamParsingError' }); return []; } }; export const getDefaultShortCircuitSpecificParamsValues = ( - specificParametersDescriptionForProvider: SpecificParameterInfos[] + specificParametersDescriptionForProvider: SpecificParameterInfos[], + snackError: (message: SnackInputs) => void ): SpecificParametersValues => { const defaultValues: SpecificParametersValues = getDefaultSpecificParamsValues( specificParametersDescriptionForProvider @@ -159,7 +166,8 @@ export const getDefaultShortCircuitSpecificParamsValues = ( ); if (powerElectronicsMaterialsParam) { const electronicsMaterialsArray: PowerElectronicsMaterial[] = parsePowerElectronicsMaterialsParamString( - powerElectronicsMaterialsParam.defaultValue + powerElectronicsMaterialsParam.defaultValue, + snackError ); defaultValues[SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS] = electronicsMaterialsArray.map((material) => ({ @@ -214,19 +222,26 @@ export const getShortCircuitSpecificParametersValues = ( const formatElectronicsMaterialsParamString = ( defaultValues: PowerElectronicsMaterial[], - specificParamValue: string + specificParamValue: string, + snackError: (message: SnackInputs) => void ) => { - const electronicsMaterialsArrayInParams: PowerElectronicsMaterial[] = - parsePowerElectronicsMaterialsParamString(specificParamValue); + const electronicsMaterialsArrayInParams: PowerElectronicsMaterial[] = parsePowerElectronicsMaterialsParamString( + specificParamValue, + snackError + ); return defaultValues.map((material) => { const foundInParams = electronicsMaterialsArrayInParams.find((m) => m.type === material.type); return foundInParams ? { ...foundInParams, active: true } : { ...material, active: false }; }); }; -const formatElectronicsClustersParamString = (defaultValues: PowerElectronicsCluster[], specificParamValue: string) => { +const formatElectronicsClustersParamString = ( + defaultValues: PowerElectronicsCluster[], + specificParamValue: string, + snackError: (message: SnackInputs) => void +) => { const electronicsClustersArrayInParams: (PowerElectronicsCluster & { active: boolean })[] = - parsePowerElectronicsClustersParamString(specificParamValue); + parsePowerElectronicsClustersParamString(specificParamValue, snackError); return electronicsClustersArrayInParams.map((cluster) => { const { filters, ...rest } = cluster; return { @@ -241,10 +256,11 @@ const formatElectronicsClustersParamString = (defaultValues: PowerElectronicsClu export const formatShortCircuitSpecificParameters = ( specificParametersDescriptionForProvider: SpecificParameterInfos[], - specificParamsList: SpecificParametersValues + specificParamsList: SpecificParametersValues, + snackError: (message: SnackInputs) => void ): SpecificParametersValues => { if (!specificParamsList) { - return getDefaultShortCircuitSpecificParamsValues(specificParametersDescriptionForProvider); + return getDefaultShortCircuitSpecificParamsValues(specificParametersDescriptionForProvider, snackError); } // reuse generic formatter for specific params @@ -257,8 +273,11 @@ export const formatShortCircuitSpecificParameters = ( if (powerParam) { if (Object.hasOwn(specificParamsList, SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS)) { formatted[SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS] = formatElectronicsMaterialsParamString( - getDefaultShortCircuitSpecificParamsValues([powerParam])?.[SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS], - specificParamsList[SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS] as string + getDefaultShortCircuitSpecificParamsValues([powerParam], snackError)?.[ + SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS + ], + specificParamsList[SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS] as string, + snackError ); } else { formatted[SHORT_CIRCUIT_POWER_ELECTRONICS_MATERIALS] = getDefaultSpecificParamsValues([powerParam])?.[ @@ -274,10 +293,11 @@ export const formatShortCircuitSpecificParameters = ( if (powerElectronicsClustersParam) { if (Object.hasOwn(specificParamsList, SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS)) { formatted[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] = formatElectronicsClustersParamString( - getDefaultShortCircuitSpecificParamsValues([powerElectronicsClustersParam])?.[ + getDefaultShortCircuitSpecificParamsValues([powerElectronicsClustersParam], snackError)?.[ SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS ], - specificParamsList[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] as string + specificParamsList[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] as string, + snackError ); } else { formatted[SHORT_CIRCUIT_POWER_ELECTRONICS_CLUSTERS] = getDefaultSpecificParamsValues([ diff --git a/src/components/parameters/short-circuit/use-short-circuit-parameters-form.ts b/src/components/parameters/short-circuit/use-short-circuit-parameters-form.ts index e67908772..48d9a6761 100644 --- a/src/components/parameters/short-circuit/use-short-circuit-parameters-form.ts +++ b/src/components/parameters/short-circuit/use-short-circuit-parameters-form.ts @@ -78,9 +78,9 @@ export const useShortCircuitParametersForm = ({ const specificParametersDefaultValues = useMemo(() => { return { - ...getDefaultShortCircuitSpecificParamsValues(specificParametersDescriptionForProvider), + ...getDefaultShortCircuitSpecificParamsValues(specificParametersDescriptionForProvider, snackError), }; - }, [specificParametersDescriptionForProvider]); + }, [snackError, specificParametersDescriptionForProvider]); const formSchema = useMemo(() => { return yup @@ -205,13 +205,14 @@ export const useShortCircuitParametersForm = ({ [SPECIFIC_PARAMETERS]: { ...formatShortCircuitSpecificParameters( specificParametersDescriptionForProvider, - specificParamsListForCurrentProvider + specificParamsListForCurrentProvider, + snackError ), }, }; return values; }, - [provider, specificParametersDescriptionForProvider] + [provider, snackError, specificParametersDescriptionForProvider] ); const onValidationError = useCallback((_errors: FieldErrors) => { diff --git a/src/translations/en/parameters.ts b/src/translations/en/parameters.ts index a434615b2..30473e7e1 100644 --- a/src/translations/en/parameters.ts +++ b/src/translations/en/parameters.ts @@ -123,14 +123,18 @@ export const parametersEn = { ShortCircuitModelPowerElectronics: 'Consider following Icc characteristics', ShortCircuitIccActive: 'Activate', ShortCircuitIccMaterialActiveTooltip: 'Activate or deactivate this material characteristic', + ShortCircuitIccMaterialType: 'Material', + ShortCircuitIccMaterialTypeTooltip: 'Type of power electronics equipment', + ShortCircuitPowerElectronicsMaterialsParamParsingError: + 'An error occurred while parsing the power electronics materials parameters', ShortCircuitIccClusterActiveTooltip: 'Activate or deactivate this cluster characteristic', ShortCircuitIccClusterFilters: 'Filters', ShortCircuitIccClusterFiltersTooltip: 'Select the filters to be included in this cluster', ShortCircuitIccClusterType: 'Cluster type', ShortCircuitIccClusterTypeTooltip: 'Select the types of equipment to be included in this cluster', ShortCircuitIccClusterTypeListsSelection: 'Type', - ShortCircuitIccMaterialType: 'Material', - ShortCircuitIccMaterialTypeTooltip: 'Type of power electronics equipment', + ShortCircuitPowerElectronicsClustersParamParsingError: + 'An error occurred while parsing the power electronics clusters parameters', ShortCircuitIccAlpha: 'Alpha', ShortCircuitIccAlphaTooltip: 'Exponent of the voltage dependency of the Icc', ShortCircuitIccUsmin: 'Usmin (%)', diff --git a/src/translations/fr/parameters.ts b/src/translations/fr/parameters.ts index fa7c131e0..c3061beac 100644 --- a/src/translations/fr/parameters.ts +++ b/src/translations/fr/parameters.ts @@ -128,14 +128,18 @@ export const parametersFr = { ShortCircuitIccActive: 'Actif', ShortCircuitIccMaterialActiveTooltip: "Activer la modélisation des équipements raccordés par de l'électronique de puissance", + ShortCircuitIccMaterialType: 'Matériel', + ShortCircuitIccMaterialTypeTooltip: "Type d'équipement raccordé par de l'électronique de puissance", + ShortCircuitPowerElectronicsMaterialsParamParsingError: + "Une erreur est survenue lors de l'analyse des paramètres des matériaux d'électronique de puissance", ShortCircuitIccClusterActiveTooltip: "Activer la modélisation des clusters d'électronique de puissance", ShortCircuitIccClusterFilters: 'Filtres', ShortCircuitIccClusterFiltersTooltip: 'Filtres de sélection des clusters', ShortCircuitIccClusterType: 'Type de cluster', ShortCircuitIccClusterTypeTooltip: "Sélectionner les types d'équipements à inclure dans ce cluster", ShortCircuitIccClusterTypeListsSelection: 'Type', - ShortCircuitIccMaterialType: 'Matériel', - ShortCircuitIccMaterialTypeTooltip: "Type d'équipement raccordé par de l'électronique de puissance", + ShortCircuitPowerElectronicsClustersParamParsingError: + "Une erreur est survenue lors de l'analyse des paramètres des clusters d'électronique de puissance", ShortCircuitIccAlpha: 'Alpha', ShortCircuitIccAlphaTooltip: 'Coefficient de pente de la caractéristique Icc', ShortCircuitIccUsmin: 'Usmin (%)',