Skip to content

Commit 7ce511e

Browse files
authored
Merge branch 'main' into limitsProperties
2 parents d167db0 + 9cd9848 commit 7ce511e

File tree

31 files changed

+670
-416
lines changed

31 files changed

+670
-416
lines changed

src/components/app.jsx

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77

88
import { useCallback, useEffect, useState } from 'react';
99
import { useDispatch, useSelector } from 'react-redux';
10-
import {
11-
getOptionalServiceByServerName,
12-
OptionalServicesNames,
13-
OptionalServicesStatus,
14-
} from './utils/optional-services';
10+
import { retrieveOptionalServices } from './utils/optional-services';
1511
import { Navigate, Route, Routes, useLocation, useMatch, useNavigate } from 'react-router';
1612
import {
1713
AnnouncementNotification,
@@ -106,8 +102,22 @@ const App = () => {
106102
);
107103

108104
const updateParams = useCallback(
109-
(params) => {
105+
(params, defaultValues = null) => {
110106
console.debug('received UI parameters : ', params);
107+
if (defaultValues) {
108+
// Browsing defaultParametersValues entries
109+
Object.entries(defaultValues).forEach(([key, defaultValue]) => {
110+
// Checking if keys defined in defaultParametersValues file are already defined in config server
111+
// If they are not defined, values are taken from default values file
112+
if (!params.find((param) => param.name === key)) {
113+
params.push({
114+
name: key,
115+
value: defaultValue,
116+
});
117+
}
118+
});
119+
console.debug('UI parameters filled with default values when undefined : ', params);
120+
}
111121
params.forEach((param) => {
112122
switch (param.name) {
113123
case PARAM_THEME:
@@ -306,18 +316,7 @@ const App = () => {
306316

307317
const fetchAppConfigPromise = fetchConfigParameters(APP_NAME).then((params) => {
308318
fetchDefaultParametersValues().then((defaultValues) => {
309-
// Browsing defaultParametersValues entries
310-
Object.entries(defaultValues).forEach(([key, defaultValue]) => {
311-
// Checking if keys defined in defaultParametersValues file are already defined in config server
312-
// If they are not defined, values are taken from default values file
313-
if (!params.find((param) => param.name === key)) {
314-
params.push({
315-
name: key,
316-
value: defaultValue,
317-
});
318-
}
319-
});
320-
updateParams(params);
319+
updateParams(params, defaultValues);
321320
});
322321
});
323322

@@ -327,29 +326,7 @@ const App = () => {
327326

328327
const fetchOptionalServices = getOptionalServices()
329328
.then((services) => {
330-
const retrieveOptionalServices = services.map((service) => {
331-
return {
332-
...service,
333-
name: getOptionalServiceByServerName(service.name),
334-
};
335-
});
336-
// get all potentially optional services
337-
const optionalServicesNames = Object.keys(OptionalServicesNames);
338-
339-
// if one of those services was not returned by "getOptionalServices", it means it was defined as "not optional"
340-
// in that case, we consider it is UP
341-
optionalServicesNames
342-
.filter(
343-
(serviceName) =>
344-
!retrieveOptionalServices.map((service) => service.name).includes(serviceName)
345-
)
346-
.forEach((serviceName) =>
347-
retrieveOptionalServices.push({
348-
name: serviceName,
349-
status: OptionalServicesStatus.Up,
350-
})
351-
);
352-
dispatch(setOptionalServices(retrieveOptionalServices));
329+
dispatch(setOptionalServices(retrieveOptionalServices(services)));
353330
})
354331
.catch((error) => {
355332
snackError({

src/components/dialogs/export-network-dialog.tsx

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,13 @@ import DialogContent from '@mui/material/DialogContent';
2525
import DialogActions from '@mui/material/DialogActions';
2626
import Button from '@mui/material/Button';
2727
import { useCallback, useEffect, useMemo, useState } from 'react';
28-
import { CancelButton, FlatParameters, fetchDirectoryElementPath, useSnackMessage } from '@gridsuite/commons-ui';
28+
import {
29+
CancelButton,
30+
FlatParameters,
31+
Parameter,
32+
fetchDirectoryElementPath,
33+
useSnackMessage,
34+
} from '@gridsuite/commons-ui';
2935
import { ExportFormatProperties, getAvailableExportFormats } from '../../services/study';
3036
import { getExportUrl } from '../../services/study/network';
3137
import { isBlankOrEmpty } from 'components/utils/validation-functions';
@@ -57,6 +63,18 @@ interface ExportNetworkDialogProps {
5763
rootNetworkUuid: UUID;
5864
}
5965

66+
// we check if the param is for extension, if it is, we select all possible values by default.
67+
// the only way for the moment to check if the param is for extension, is by checking his type is name.
68+
// TODO to be removed when extensions param default value corrected in backend to include all possible values
69+
function getDefaultValuesForExtensionsParameter(parameters: Parameter[]): Parameter[] {
70+
return parameters.map((parameter) => {
71+
if (parameter.type === STRING_LIST && parameter.name?.endsWith('extensions')) {
72+
parameter.defaultValue = parameter.possibleValues;
73+
}
74+
return parameter;
75+
});
76+
}
77+
6078
export function ExportNetworkDialog({
6179
open,
6280
onClose,
@@ -102,16 +120,9 @@ export function ExportNetworkDialog({
102120
const availableFormats = enableDeveloperMode
103121
? formats
104122
: Object.fromEntries(Object.entries(formats).filter(([key]) => key === XIIDM_FORMAT));
105-
// we check if the param is for extension, if it is, we select all possible values by default.
106-
// the only way for the moment to check if the param is for extension, is by checking his type is name.
107-
//TODO to be removed when extensions param default value corrected in backend to include all possible values
123+
108124
Object.values(availableFormats).forEach((format) => {
109-
format.parameters = format.parameters.map((parameter) => {
110-
if (parameter.type === STRING_LIST && parameter.name?.endsWith('extensions')) {
111-
parameter.defaultValue = parameter.possibleValues;
112-
}
113-
return parameter;
114-
});
125+
format.parameters = getDefaultValuesForExtensionsParameter(format.parameters);
115126
});
116127
setFormatsWithParameters(availableFormats);
117128
});

src/components/dialogs/limits/limits-pane-utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,19 +113,19 @@ export const getLimitsValidationSchema = (isModification: boolean = false, id: s
113113
return limitsValidationSchemaCreation(id, isModification);
114114
};
115115

116-
const limitsEmptyFormData = (id: string) => {
116+
const limitsEmptyFormData = (isModification: boolean, id: string) => {
117117
const limitsGroup = {
118118
[OPERATIONAL_LIMITS_GROUPS]: [],
119119
[SELECTED_LIMITS_GROUP_1]: null,
120120
[SELECTED_LIMITS_GROUP_2]: null,
121-
[ENABLE_OLG_MODIFICATION]: false,
121+
[ENABLE_OLG_MODIFICATION]: !isModification,
122122
};
123123

124124
return { [id]: limitsGroup };
125125
};
126126

127-
export const getLimitsEmptyFormData = (id = LIMITS) => {
128-
return limitsEmptyFormData(id);
127+
export const getLimitsEmptyFormData = (isModification = true, id = LIMITS) => {
128+
return limitsEmptyFormData(isModification, id);
129129
};
130130

131131
export const formatOpLimitGroupsToFormInfos = (
@@ -153,7 +153,7 @@ export const getAllLimitsFormData = (
153153
operationalLimitsGroups: OperationalLimitsGroupFormInfos[] = [],
154154
selectedOperationalLimitsGroup1: string | null = null,
155155
selectedOperationalLimitsGroup2: string | null = null,
156-
enableOLGModification?: boolean,
156+
enableOLGModification: boolean | null = true,
157157
id = LIMITS
158158
) => {
159159
return {

src/components/dialogs/network-modifications/by-filter/by-assignment/assignment/assignment-form.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ const AssignmentForm: FC<AssignmentFormProps> = ({ name, index }) => {
5757
});
5858

5959
const equipmentFields = useMemo(
60-
() => Object.values(EQUIPMENTS_FIELDS[watchEquipmentType]) ?? [],
60+
() => Object.values(EQUIPMENTS_FIELDS[watchEquipmentType] ?? []),
6161
[watchEquipmentType]
6262
);
6363

src/components/dialogs/network-modifications/line/creation/line-creation-dialog.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ import { LimitsPane } from '../../../limits/limits-pane.tsx';
9191
const emptyFormData = {
9292
...getHeaderEmptyFormData(),
9393
...getCharacteristicsEmptyFormData(),
94-
...getLimitsEmptyFormData(),
94+
...getLimitsEmptyFormData(false),
9595
...emptyProperties,
9696
};
9797

src/components/dialogs/network-modifications/substation/creation/substation-creation-dialog.jsx

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,19 @@ const SubstationCreationDialog = ({
8888
}
8989
}, [reset, editData]);
9090

91-
// We set the default country if there is one
91+
// We set the default country only in creation mode
9292
useEffect(() => {
93-
fetchDefaultCountry().then((country) => {
94-
if (country) {
95-
reset({
96-
...getValues(),
97-
[COUNTRY]: country,
98-
});
99-
}
100-
});
101-
}, [reset, getValues]);
93+
if (!isUpdate) {
94+
fetchDefaultCountry().then((country) => {
95+
if (country) {
96+
reset({
97+
...getValues(),
98+
[COUNTRY]: country,
99+
});
100+
}
101+
});
102+
}
103+
}, [reset, getValues, isUpdate]);
102104

103105
const clear = useCallback(() => {
104106
reset(emptyFormData);

src/components/dialogs/network-modifications/tabular/tabular-dialog.tsx

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ import {
4848
} from './tabular-creation-utils';
4949
import { NetworkModificationDialogProps } from '../../../graph/menus/network-modifications/network-modification-menu.type';
5050

51+
function convertCreations(creations: Modification[]): Modification[] {
52+
return creations.map((creat: Modification) => {
53+
let creation: Modification = {};
54+
Object.keys(formatModification(creat)).forEach((key) => {
55+
const entry = convertCreationFieldFromBackToFront(key, creat[key]);
56+
(Array.isArray(entry) ? entry : [entry]).forEach((item) => {
57+
creation[item.key] = item.value;
58+
});
59+
});
60+
creation = addPropertiesFromBack(creation, creat?.[TABULAR_PROPERTIES]);
61+
return creation;
62+
});
63+
}
64+
5165
type TabularDialogProps = NetworkModificationDialogProps & {
5266
editData: TabularModificationEditDataType;
5367
dialogMode: TabularModificationType;
@@ -114,17 +128,7 @@ export function TabularDialog({
114128
const initTabularCreationData = useCallback(
115129
(editData: TabularModificationCreationType) => {
116130
const equipmentType = getEquipmentTypeFromCreationType(editData?.creationType);
117-
const creations = editData?.creations.map((creat: Modification) => {
118-
let creation: Modification = {};
119-
Object.keys(formatModification(creat)).forEach((key) => {
120-
const entry = convertCreationFieldFromBackToFront(key, creat[key]);
121-
(Array.isArray(entry) ? entry : [entry]).forEach((item) => {
122-
creation[item.key] = item.value;
123-
});
124-
});
125-
creation = addPropertiesFromBack(creation, creat?.[TABULAR_PROPERTIES]);
126-
return creation;
127-
});
131+
const creations = convertCreations(editData?.creations);
128132
reset({
129133
[TYPE]: equipmentType,
130134
[MODIFICATIONS_TABLE]: creations,

src/components/dialogs/network-modifications/two-windings-transformer/creation/two-windings-transformer-creation-dialog.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const emptyFormData = {
125125
[EQUIPMENT_ID]: '',
126126
[EQUIPMENT_NAME]: '',
127127
...getTwoWindingsTransformerEmptyFormData(),
128-
...getLimitsEmptyFormData(),
128+
...getLimitsEmptyFormData(false),
129129
...getRatioTapChangerEmptyFormData(),
130130
...getPhaseTapChangerEmptyFormData(),
131131
...emptyProperties,

src/components/dialogs/network-modifications/voltage-level/creation/voltage-level-creation-form.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import {
2424
} from 'components/utils/field-constants';
2525
import { useCallback, useEffect, useState } from 'react';
2626
import { KiloAmpereAdornment, VoltageAdornment } from 'components/dialogs/dialog-utils';
27-
import { AutocompleteInput, FloatInput, IntegerInput, TextInput } from '@gridsuite/commons-ui';
27+
import { AutocompleteInput, fetchDefaultCountry, FloatInput, IntegerInput, TextInput } from '@gridsuite/commons-ui';
2828
import { Box, Grid, Paper, Tooltip } from '@mui/material';
2929

3030
import { CouplingOmnibusForm } from '../coupling-omnibus/coupling-omnibus-form';
@@ -49,9 +49,17 @@ const VoltageLevelCreationForm = ({ currentNode, studyUuid, currentRootNetworkUu
4949
const watchBusBarCount = useWatch({ name: BUS_BAR_COUNT });
5050
const watchSectionCount = useWatch({ name: SECTION_COUNT });
5151
const watchAddSubstationCreation = useWatch({ name: ADD_SUBSTATION_CREATION });
52+
5253
useEffect(() => {
53-
setIsWithSubstationCreation(watchAddSubstationCreation);
54-
}, [watchAddSubstationCreation]);
54+
// in new substation mode, set the default country
55+
if (isWithSubstationCreation) {
56+
fetchDefaultCountry().then((country) => {
57+
if (country) {
58+
setValue(COUNTRY, country);
59+
}
60+
});
61+
}
62+
}, [setValue, isWithSubstationCreation]);
5563

5664
useEffect(() => {
5765
if (studyUuid && currentNodeUuid && currentRootNetworkUuid) {
@@ -149,6 +157,10 @@ const VoltageLevelCreationForm = ({ currentNode, studyUuid, currentRootNetworkUu
149157

150158
const handleDeleteButton = useCallback(() => {
151159
setValue(ADD_SUBSTATION_CREATION, false);
160+
// clear the fields of the new substation
161+
setValue(SUBSTATION_CREATION_ID, null);
162+
setValue(SUBSTATION_NAME, null);
163+
setValue(COUNTRY, null);
152164
setIsWithSubstationCreation(false);
153165
}, [setValue]);
154166

@@ -159,7 +171,7 @@ const VoltageLevelCreationForm = ({ currentNode, studyUuid, currentRootNetworkUu
159171
<GridItem>{voltageLevelNameField}</GridItem>
160172
</Grid>
161173

162-
{isWithSubstationCreation ? (
174+
{watchAddSubstationCreation ? (
163175
<Grid>
164176
<Grid item xs={12} container spacing={2}></Grid>
165177
<GridSection title={intl.formatMessage({ id: 'CreateSubstation' })} />

src/components/dialogs/network-modifications/voltage-level/move-feeder-bays/move-voltage-level-feeder-bays-form.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import type { UUID } from 'node:crypto';
3030
import { FeederBaysFormInfos, FeederBaysInfos } from './move-voltage-level-feeder-bays.type';
3131
import PositionDiagramPane from '../../../../grid-layout/cards/diagrams/singleLineDiagram/positionDiagram/position-diagram-pane';
3232
import SeparatorCellRenderer from '../topology-modification/separator-cell-renderer';
33+
import GridSection from '../../../commons/grid-section';
3334

3435
const defaultColDef = {
3536
sortable: false,
@@ -158,7 +159,7 @@ export function MoveVoltageLevelFeederBaysForm({
158159
variant: 'outlined',
159160
autoFocus: true,
160161
sx: {
161-
paddingTop: '8%',
162+
paddingTop: '1rem',
162163
'& input': {
163164
textAlign: 'center',
164165
textOverflow: 'ellipsis',
@@ -184,7 +185,7 @@ export function MoveVoltageLevelFeederBaysForm({
184185
name={`${MOVE_VOLTAGE_LEVEL_FEEDER_BAYS_TABLE}[${formIndex}].${BUSBAR_SECTION_ID}`}
185186
options={busBarSectionIds}
186187
size="small"
187-
sx={{ padding: '8%' }}
188+
sx={{ padding: '1rem' }}
188189
disabled={data.isRemoved}
189190
disableClearable
190191
/>
@@ -220,7 +221,7 @@ export function MoveVoltageLevelFeederBaysForm({
220221
size: 'small',
221222
variant: 'outlined',
222223
sx: {
223-
padding: '8%',
224+
padding: '1rem',
224225
'& input': { textAlign: 'center' },
225226
},
226227
}}
@@ -314,6 +315,9 @@ export function MoveVoltageLevelFeederBaysForm({
314315
</GridItem>
315316
)}
316317
</Grid>
318+
<Grid item xs={1}>
319+
<GridSection title={'moveFeederBaysSections'} />
320+
</Grid>
317321
<Grid item xs paddingTop={2}>
318322
<CustomAGGrid
319323
rowData={groupedRowData}

0 commit comments

Comments
 (0)