@gridsuite/commons-ui 0.149.0 → 0.151.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/dist/components/index.js +2 -0
  2. package/dist/components/parameters/sensi/constants.d.ts +6 -1
  3. package/dist/components/parameters/sensi/constants.js +6 -2
  4. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-factor-count.d.ts +8 -0
  5. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-factor-count.js +53 -0
  6. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-form.js +2 -3
  7. package/dist/components/parameters/sensi/sensitivity-analysis-parameters-inline.js +3 -3
  8. package/dist/components/parameters/sensi/sensitivity-parameters-selector.d.ts +5 -11
  9. package/dist/components/parameters/sensi/sensitivity-parameters-selector.js +64 -99
  10. package/dist/components/parameters/sensi/sensitivity-table.d.ts +2 -3
  11. package/dist/components/parameters/sensi/sensitivity-table.js +27 -37
  12. package/dist/components/parameters/sensi/table-cell.d.ts +1 -1
  13. package/dist/components/parameters/sensi/table-cell.js +2 -8
  14. package/dist/components/parameters/sensi/table-row.d.ts +2 -2
  15. package/dist/components/parameters/sensi/table-row.js +4 -6
  16. package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.d.ts +7 -10
  17. package/dist/components/parameters/sensi/use-sensitivity-analysis-parameters.js +67 -114
  18. package/dist/components/parameters/sensi/utils.d.ts +6 -15
  19. package/dist/components/parameters/sensi/utils.js +21 -4
  20. package/dist/components/treeViewFinder/TreeViewFinder.js +2 -1
  21. package/dist/components/treeViewFinder/TreeViewUtils.d.ts +2 -0
  22. package/dist/components/treeViewFinder/TreeViewUtils.js +6 -0
  23. package/dist/components/treeViewFinder/index.d.ts +1 -0
  24. package/dist/components/treeViewFinder/index.js +2 -0
  25. package/dist/hooks/use-create-row-data-sensi.js +1 -2
  26. package/dist/index.js +2 -0
  27. package/dist/services/sensitivity-analysis.d.ts +2 -2
  28. package/dist/services/sensitivity-analysis.js +8 -9
  29. package/dist/translations/en/businessErrorsEn.d.ts +1 -0
  30. package/dist/translations/en/businessErrorsEn.js +2 -1
  31. package/dist/translations/en/parameters.d.ts +3 -3
  32. package/dist/translations/en/parameters.js +4 -4
  33. package/dist/translations/fr/businessErrorsFr.d.ts +1 -0
  34. package/dist/translations/fr/businessErrorsFr.js +2 -1
  35. package/dist/translations/fr/parameters.d.ts +3 -3
  36. package/dist/translations/fr/parameters.js +4 -4
  37. package/dist/utils/constants/unitsConstants.d.ts +1 -1
  38. package/dist/utils/constants/unitsConstants.js +1 -1
  39. package/dist/utils/types/sensitivity-analysis.type.d.ts +4 -7
  40. package/package.json +4 -4
@@ -1,10 +1,8 @@
1
1
  import { UseFormReturn } from 'react-hook-form';
2
2
  import { ObjectSchema } from 'yup';
3
- import { Dispatch, SetStateAction } from 'react';
4
3
  import { UUID } from 'node:crypto';
5
4
  import { ComputingType } from '../common';
6
- import { SensitivityAnalysisParametersInfos, UseParametersBackendReturnProps } from '../../../utils';
7
- type SubTabsValues = 'sensitivityInjectionsSet' | 'sensitivityInjection' | 'sensitivityHVDC' | 'sensitivityPST';
5
+ import { FactorsCount, SensitivityAnalysisParametersInfos, UseParametersBackendReturnProps } from '../../../utils';
8
6
  export interface UseSensitivityAnalysisParametersReturn {
9
7
  formMethods: UseFormReturn<any>;
10
8
  formSchema: ObjectSchema<any>;
@@ -19,14 +17,13 @@ export interface UseSensitivityAnalysisParametersReturn {
19
17
  isStudyLinked: boolean;
20
18
  onSaveInline: (formData: Record<string, any>) => void;
21
19
  onSaveDialog: (formData: Record<string, any>) => void;
22
- isMaxReached: boolean;
23
- launchLoader: boolean;
24
- initRowsCount: () => void;
25
- onFormChanged: (formChanged: boolean) => void;
26
- onChangeParams: (row: any, arrayFormName: SubTabsValues, index: number) => void;
20
+ isMaxResultsReached: boolean;
21
+ isMaxVariablesReached: boolean;
22
+ isLoading: boolean;
23
+ onFormChanged: () => void;
27
24
  emptyFormData: Record<string, unknown>;
28
- analysisComputeComplexity: number;
29
- setAnalysisComputeComplexity: Dispatch<SetStateAction<number>>;
25
+ factorsCount: FactorsCount;
26
+ resetFactorsCount: () => void;
30
27
  }
31
28
  type UseSensitivityAnalysisParametersFormProps = {
32
29
  name: string;
@@ -17,7 +17,6 @@ import "localized-countries";
17
17
  import "localized-countries/data/fr";
18
18
  import "localized-countries/data/en";
19
19
  import { useSnackMessage } from "../../../hooks/useSnackMessage.js";
20
- import { PARAMETER_SENSI_NODES, PARAMETER_SENSI_PST, PARAMETER_SENSI_HVDC, PARAMETER_SENSI_INJECTION, PARAMETER_SENSI_INJECTIONS_SET, FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD, ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD, FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD, ACTIVATED, MONITORED_BRANCHES, INJECTIONS, PSTS, HVDC_LINES, COUNT, SENSI_INJECTIONS_SET, CONTINGENCIES, CONTAINER_NAME, CONTAINER_ID, EQUIPMENTS_IN_VOLTAGE_REGULATION, SUPERVISED_VOLTAGE_LEVELS, SENSITIVITY_TYPE, DISTRIBUTION_TYPE } from "./constants.js";
21
20
  import "../../inputs/reactHookForm/provider/CustomFormProvider.js";
22
21
  import "../../dialogs/descriptionModificationDialog/DescriptionModificationDialog.js";
23
22
  import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
@@ -38,11 +37,11 @@ import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
38
37
  import "react-querybuilder";
39
38
  import "../common/widget/parameter-line-slider.js";
40
39
  import "../common/limitreductions/columns-definitions.js";
41
- import { getFormSchema, getSensiNodesformatNewParams, getSensiPstformatNewParams, getSensiHvdcformatNewParams, getSensiInjectionsformatNewParams, getSensiInjectionsSetformatNewParams, getGenericRowNewParams } from "./utils.js";
40
+ import { getFormSchema, getSensiNodesformatNewParams, getSensiPstformatNewParams, getSensiHvdcformatNewParams, getSensiInjectionsformatNewParams, getSensiInjectionsSetformatNewParams, filterSensiParameterRows } from "./utils.js";
41
+ import { DEFAULT_FACTOR_COUNT, PARAMETER_SENSI_NODES, PARAMETER_SENSI_PST, PARAMETER_SENSI_HVDC, PARAMETER_SENSI_INJECTION, PARAMETER_SENSI_INJECTIONS_SET, FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD, ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD, FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD, ACTIVATED, CONTINGENCIES, CONTAINER_NAME, CONTAINER_ID, EQUIPMENTS_IN_VOLTAGE_REGULATION, SUPERVISED_VOLTAGE_LEVELS, SENSITIVITY_TYPE, PSTS, MONITORED_BRANCHES, HVDC_LINES, INJECTIONS, DISTRIBUTION_TYPE, MAX_RESULTS_COUNT, MAX_VARIABLES_COUNT } from "./constants.js";
42
42
  import { getSensitivityAnalysisFactorsCount, setSensitivityAnalysisParameters } from "../../../services/sensitivity-analysis.js";
43
43
  import "../../filter/HeaderFilterForm.js";
44
44
  import { getNameElementEditorEmptyFormData } from "../common/name-element-editor/name-element-editor-utils.js";
45
- const numberMax = 5e5;
46
45
  const useSensitivityAnalysisParametersForm = ({
47
46
  studyUuid,
48
47
  currentNodeUuid,
@@ -55,8 +54,8 @@ const useSensitivityAnalysisParametersForm = ({
55
54
  const [providers, , , , , params, , updateParameters] = parametersBackend;
56
55
  const [sensitivityAnalysisParams, setSensitivityAnalysisParams] = useState(params);
57
56
  const { snackError } = useSnackMessage();
58
- const [analysisComputeComplexity, setAnalysisComputeComplexity] = useState(0);
59
- const [launchLoader, setLaunchLoader] = useState(false);
57
+ const [factorsCount, setFactorsCount] = useState(DEFAULT_FACTOR_COUNT);
58
+ const [isLoading, setIsLoading] = useState(false);
60
59
  const [isSubmitAction, setIsSubmitAction] = useState(false);
61
60
  const emptyFormData = useMemo(() => {
62
61
  return {
@@ -82,7 +81,7 @@ const useSensitivityAnalysisParametersForm = ({
82
81
  defaultValues: emptyFormData,
83
82
  resolver: yupResolver(formSchema)
84
83
  });
85
- const { reset, getValues, setValue } = formMethods;
84
+ const { reset, getValues } = formMethods;
86
85
  const formattedProviders = Object.keys(providers).map((key) => ({
87
86
  id: key,
88
87
  label: providers[key]
@@ -100,72 +99,56 @@ const useSensitivityAnalysisParametersForm = ({
100
99
  ...getSensiNodesformatNewParams(newParams)
101
100
  };
102
101
  }, []);
103
- const formatFilteredParams = useCallback((row) => {
104
- return getGenericRowNewParams(row);
102
+ const resetFactorsCount = useCallback(() => {
103
+ setIsLoading(false);
104
+ setFactorsCount(DEFAULT_FACTOR_COUNT);
105
105
  }, []);
106
- const getResultCount = useCallback(() => {
107
- const values = getValues();
108
- let totalResultCount = 0;
109
- const tabsToCheck = [
110
- "sensitivityInjectionsSet",
111
- "sensitivityInjection",
112
- "sensitivityHVDC",
113
- "sensitivityPST"
114
- ];
115
- tabsToCheck.forEach((tab) => {
116
- const tabToCheck = values[tab];
117
- if (tabToCheck) {
118
- const count = tabToCheck.filter((entry) => entry[ACTIVATED]).filter((entry) => entry[MONITORED_BRANCHES].length > 0).filter(
119
- (entry) => entry[INJECTIONS]?.length > 0 || entry[PSTS]?.length > 0 || entry[HVDC_LINES]?.length > 0
120
- ).map((entry) => entry[COUNT]).reduce((a, b) => a + b, 0);
121
- totalResultCount += count;
122
- }
106
+ const updateFactorCount = useCallback(() => {
107
+ if (!currentNodeUuid || !currentRootNetworkUuid) {
108
+ return;
109
+ }
110
+ const formValues = getValues();
111
+ const filteredInjectionsSet = filterSensiParameterRows(formValues[PARAMETER_SENSI_INJECTIONS_SET]);
112
+ const filteredInjection = filterSensiParameterRows(formValues[PARAMETER_SENSI_INJECTION]);
113
+ const filteredHvdc = filterSensiParameterRows(formValues[PARAMETER_SENSI_HVDC]);
114
+ const filteredPst = filterSensiParameterRows(formValues[PARAMETER_SENSI_PST]);
115
+ const filteredNodes = filterSensiParameterRows(formValues[PARAMETER_SENSI_NODES]);
116
+ const hasAnyEntries = filteredInjectionsSet.length > 0 || filteredInjection.length > 0 || filteredHvdc.length > 0 || filteredPst.length > 0 || filteredNodes.length > 0;
117
+ if (!hasAnyEntries) {
118
+ resetFactorsCount();
119
+ return;
120
+ }
121
+ const filteredFormValues = {
122
+ ...formValues,
123
+ [PARAMETER_SENSI_INJECTIONS_SET]: filteredInjectionsSet,
124
+ [PARAMETER_SENSI_INJECTION]: filteredInjection,
125
+ [PARAMETER_SENSI_HVDC]: filteredHvdc,
126
+ [PARAMETER_SENSI_PST]: filteredPst,
127
+ [PARAMETER_SENSI_NODES]: filteredNodes
128
+ };
129
+ setIsLoading(true);
130
+ getSensitivityAnalysisFactorsCount(
131
+ studyUuid,
132
+ currentNodeUuid,
133
+ currentRootNetworkUuid,
134
+ formatNewParams(filteredFormValues)
135
+ ).then((factorsCountResponse) => {
136
+ setFactorsCount(factorsCountResponse);
137
+ const timeoutId = setTimeout(() => {
138
+ setIsLoading(false);
139
+ }, 500);
140
+ return () => clearTimeout(timeoutId);
141
+ }).catch((error) => {
142
+ setIsLoading(false);
143
+ snackWithFallback(snackError, error, { headerId: "getSensitivityAnalysisFactorsCountError" });
123
144
  });
124
- setAnalysisComputeComplexity(totalResultCount);
125
- const timeoutId = setTimeout(() => {
126
- setLaunchLoader(false);
127
- }, 500);
128
- return () => clearTimeout(timeoutId);
129
- }, [getValues]);
130
- const onFormChanged = useCallback(
131
- (formChanged) => {
132
- if (formChanged) {
133
- setLaunchLoader(true);
134
- getResultCount();
135
- }
136
- },
137
- [getResultCount]
138
- );
139
- const onChangeParams = useCallback(
140
- (row, arrayFormName, index) => {
141
- if (!currentNodeUuid || !currentRootNetworkUuid) {
142
- return;
143
- }
144
- setLaunchLoader(true);
145
- getSensitivityAnalysisFactorsCount(
146
- studyUuid,
147
- currentNodeUuid,
148
- currentRootNetworkUuid,
149
- arrayFormName === SENSI_INJECTIONS_SET,
150
- formatFilteredParams(row)
151
- ).then((response) => {
152
- response.text().then((value) => {
153
- setValue(
154
- `${arrayFormName}.${index}.${COUNT}`,
155
- !Number.isNaN(Number(value)) ? parseInt(value, 10) : 0
156
- );
157
- getResultCount();
158
- });
159
- }).catch((error) => {
160
- setLaunchLoader(false);
161
- snackWithFallback(snackError, error, { headerId: "getSensitivityAnalysisFactorsCountError" });
162
- });
163
- },
164
- [snackError, studyUuid, currentRootNetworkUuid, formatFilteredParams, setValue, getResultCount, currentNodeUuid]
165
- );
145
+ }, [snackError, studyUuid, currentRootNetworkUuid, formatNewParams, currentNodeUuid, getValues, resetFactorsCount]);
146
+ const onFormChanged = useCallback(() => {
147
+ updateFactorCount();
148
+ }, [updateFactorCount]);
166
149
  const fromSensitivityAnalysisParamsDataToFormValues = useCallback(
167
150
  (parameters) => {
168
- const values = {
151
+ return {
169
152
  [PROVIDER]: parameters[PROVIDER],
170
153
  [FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD]: parameters.flowFlowSensitivityValueThreshold,
171
154
  [ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD]: parameters.angleFlowSensitivityValueThreshold,
@@ -191,8 +174,7 @@ const useSensitivityAnalysisParametersForm = ({
191
174
  [FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
192
175
  };
193
176
  }) ?? [],
194
- [ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false,
195
- [COUNT]: 0
177
+ [ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false
196
178
  };
197
179
  }) ?? [],
198
180
  [PARAMETER_SENSI_INJECTION]: parameters.sensitivityInjection?.map((sensiInjections) => {
@@ -215,8 +197,7 @@ const useSensitivityAnalysisParametersForm = ({
215
197
  [FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
216
198
  };
217
199
  }) ?? [],
218
- [ACTIVATED]: sensiInjections[ACTIVATED] ?? false,
219
- [COUNT]: 0
200
+ [ACTIVATED]: sensiInjections[ACTIVATED] ?? false
220
201
  };
221
202
  }) ?? [],
222
203
  [PARAMETER_SENSI_HVDC]: parameters.sensitivityHVDC?.map((sensiInjectionsSet) => {
@@ -240,8 +221,7 @@ const useSensitivityAnalysisParametersForm = ({
240
221
  [FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
241
222
  };
242
223
  }) ?? [],
243
- [ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false,
244
- [COUNT]: 0
224
+ [ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false
245
225
  };
246
226
  }) ?? [],
247
227
  [PARAMETER_SENSI_PST]: parameters.sensitivityPST?.map((sensiInjectionsSet) => {
@@ -265,8 +245,7 @@ const useSensitivityAnalysisParametersForm = ({
265
245
  [FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
266
246
  };
267
247
  }) ?? [],
268
- [ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false,
269
- [COUNT]: 0
248
+ [ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false
270
249
  };
271
250
  }) ?? [],
272
251
  [PARAMETER_SENSI_NODES]: parameters.sensitivityNodes?.map((sensiInjectionsSet) => {
@@ -289,38 +268,13 @@ const useSensitivityAnalysisParametersForm = ({
289
268
  [FieldConstants.NAME]: sensiInjection[CONTAINER_NAME]
290
269
  };
291
270
  }) ?? [],
292
- [ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false,
293
- [COUNT]: 0
271
+ [ACTIVATED]: sensiInjectionsSet[ACTIVATED] ?? false
294
272
  };
295
273
  }) ?? []
296
274
  };
297
- return values;
298
275
  },
299
276
  []
300
277
  );
301
- const initRowsCount = useCallback(() => {
302
- const handleEntries = (entries, parameter) => {
303
- if (!entries) {
304
- return;
305
- }
306
- const entriesWithIndices = entries.map((entry, index) => ({
307
- entry,
308
- index
309
- }));
310
- const filteredInitEntries = entries.filter(
311
- (entry) => entry[ACTIVATED] && entry[MONITORED_BRANCHES].length > 0 && (entry[INJECTIONS]?.length > 0 || entry[PSTS]?.length > 0 || entry[HVDC_LINES]?.length > 0)
312
- );
313
- filteredInitEntries.forEach((entry) => {
314
- const originalIndex = entriesWithIndices.findIndex((obj) => obj.entry === entry);
315
- onChangeParams(entry, parameter, originalIndex);
316
- });
317
- };
318
- const values = getValues();
319
- handleEntries(values[PARAMETER_SENSI_INJECTIONS_SET], PARAMETER_SENSI_INJECTIONS_SET);
320
- handleEntries(values[PARAMETER_SENSI_INJECTION], PARAMETER_SENSI_INJECTION);
321
- handleEntries(values[PARAMETER_SENSI_HVDC], PARAMETER_SENSI_HVDC);
322
- handleEntries(values[PARAMETER_SENSI_PST], PARAMETER_SENSI_PST);
323
- }, [onChangeParams, getValues]);
324
278
  const onSaveInline = useCallback(
325
279
  (newParams) => {
326
280
  setIsSubmitAction(true);
@@ -328,12 +282,11 @@ const useSensitivityAnalysisParametersForm = ({
328
282
  const formattedParams = formatNewParams(newParams);
329
283
  setSensitivityAnalysisParams(formattedParams);
330
284
  updateParameters(formattedParams);
331
- initRowsCount();
332
285
  }).catch((error) => {
333
286
  snackWithFallback(snackError, error, { headerId: "updateSensitivityAnalysisParametersError" });
334
287
  });
335
288
  },
336
- [setSensitivityAnalysisParams, snackError, studyUuid, formatNewParams, initRowsCount, updateParameters]
289
+ [setSensitivityAnalysisParams, snackError, studyUuid, formatNewParams, updateParameters]
337
290
  );
338
291
  const onSaveDialog = useCallback(
339
292
  (formData) => {
@@ -355,22 +308,23 @@ const useSensitivityAnalysisParametersForm = ({
355
308
  if (sensitivityAnalysisParams) {
356
309
  reset(fromSensitivityAnalysisParamsDataToFormValues(sensitivityAnalysisParams));
357
310
  if (!isSubmitAction) {
358
- initRowsCount();
311
+ onFormChanged();
359
312
  }
360
313
  }
361
314
  }, [
362
315
  fromSensitivityAnalysisParamsDataToFormValues,
363
316
  sensitivityAnalysisParams,
364
- initRowsCount,
365
317
  isSubmitAction,
366
- reset
318
+ reset,
319
+ onFormChanged
367
320
  ]);
368
321
  useEffect(() => {
369
322
  if (params) {
370
323
  reset(fromSensitivityAnalysisParamsDataToFormValues(params));
371
324
  }
372
325
  }, [params, reset, fromSensitivityAnalysisParamsDataToFormValues]);
373
- const isMaxReached = useMemo(() => analysisComputeComplexity > numberMax, [analysisComputeComplexity]);
326
+ const isMaxResultsReached = useMemo(() => factorsCount.resultCount > MAX_RESULTS_COUNT, [factorsCount]);
327
+ const isMaxVariablesReached = useMemo(() => factorsCount.variableCount > MAX_VARIABLES_COUNT, [factorsCount]);
374
328
  const paramsLoaded = useMemo(() => !!params, [params]);
375
329
  return {
376
330
  formMethods,
@@ -383,14 +337,13 @@ const useSensitivityAnalysisParametersForm = ({
383
337
  isStudyLinked,
384
338
  onSaveInline,
385
339
  onSaveDialog,
386
- isMaxReached,
387
- launchLoader,
388
- initRowsCount,
340
+ isMaxResultsReached,
341
+ isMaxVariablesReached,
342
+ isLoading,
389
343
  onFormChanged,
390
- onChangeParams,
391
344
  emptyFormData,
392
- analysisComputeComplexity,
393
- setAnalysisComputeComplexity
345
+ factorsCount,
346
+ resetFactorsCount
394
347
  };
395
348
  };
396
349
  export {
@@ -1,3 +1,4 @@
1
+ import { FieldValues } from 'react-hook-form';
1
2
  import { default as yup } from '../../../utils/yupConfig';
2
3
  import { CONTINGENCIES, HVDC_LINES, INJECTIONS, MONITORED_BRANCHES, PSTS } from './constants';
3
4
  import { DistributionType, SensitivityType } from '../../../utils';
@@ -10,7 +11,6 @@ export declare const getSensiHVDCsFormSchema: () => {
10
11
  name: string;
11
12
  }[] | undefined;
12
13
  sensitivityType?: SensitivityType | undefined;
13
- count?: number | null | undefined;
14
14
  activated: NonNullable<boolean | undefined>;
15
15
  monitoredBranches: {
16
16
  id: string;
@@ -46,7 +46,6 @@ export declare const getSensiInjectionsFormSchema: () => {
46
46
  id: string;
47
47
  name: string;
48
48
  }[] | undefined;
49
- count?: number | null | undefined;
50
49
  activated: NonNullable<boolean | undefined>;
51
50
  monitoredBranches: {
52
51
  id: string;
@@ -82,7 +81,6 @@ export declare const getSensiInjectionsSetFormSchema: () => {
82
81
  name: string;
83
82
  }[] | undefined;
84
83
  distributionType?: DistributionType | undefined;
85
- count?: number | null | undefined;
86
84
  activated: NonNullable<boolean | undefined>;
87
85
  monitoredBranches: {
88
86
  id: string;
@@ -155,7 +153,6 @@ export declare const getSensiNodesFormSchema: () => {
155
153
  id: string;
156
154
  name: string;
157
155
  }[] | undefined;
158
- count?: number | null | undefined;
159
156
  activated: NonNullable<boolean | undefined>;
160
157
  }[] | undefined, yup.AnyObject, "", "">;
161
158
  };
@@ -183,7 +180,6 @@ export declare const getSensiPSTsFormSchema: () => {
183
180
  name: string;
184
181
  }[] | undefined;
185
182
  sensitivityType?: SensitivityType | undefined;
186
- count?: number | null | undefined;
187
183
  activated: NonNullable<boolean | undefined>;
188
184
  monitoredBranches: {
189
185
  id: string;
@@ -213,6 +209,11 @@ export declare const getSensiPstformatNewParams: (newParams: SensitivityAnalysis
213
209
  activated: NonNullable<boolean | undefined>;
214
210
  }[] | undefined;
215
211
  };
212
+ export declare const hasVariables: (row: any) => boolean;
213
+ export declare const hasMonitoredEquipments: (row: any) => boolean;
214
+ export declare const isActivatedSensiParameterRow: (entry: FieldValues) => any;
215
+ export declare const isValidSensiParameterRow: (entry: FieldValues) => any;
216
+ export declare const filterSensiParameterRows: (entries?: FieldValues[]) => FieldValues[];
216
217
  export declare const formSchema: yup.ObjectSchema<{
217
218
  sensitivityNodes: {
218
219
  contingencies?: {
@@ -227,7 +228,6 @@ export declare const formSchema: yup.ObjectSchema<{
227
228
  id: string;
228
229
  name: string;
229
230
  }[] | undefined;
230
- count?: number | null | undefined;
231
231
  activated: NonNullable<boolean | undefined>;
232
232
  }[] | undefined;
233
233
  sensitivityPST: {
@@ -236,7 +236,6 @@ export declare const formSchema: yup.ObjectSchema<{
236
236
  name: string;
237
237
  }[] | undefined;
238
238
  sensitivityType?: SensitivityType | undefined;
239
- count?: number | null | undefined;
240
239
  activated: NonNullable<boolean | undefined>;
241
240
  monitoredBranches: {
242
241
  id: string;
@@ -253,7 +252,6 @@ export declare const formSchema: yup.ObjectSchema<{
253
252
  name: string;
254
253
  }[] | undefined;
255
254
  sensitivityType?: SensitivityType | undefined;
256
- count?: number | null | undefined;
257
255
  activated: NonNullable<boolean | undefined>;
258
256
  monitoredBranches: {
259
257
  id: string;
@@ -269,7 +267,6 @@ export declare const formSchema: yup.ObjectSchema<{
269
267
  id: string;
270
268
  name: string;
271
269
  }[] | undefined;
272
- count?: number | null | undefined;
273
270
  activated: NonNullable<boolean | undefined>;
274
271
  monitoredBranches: {
275
272
  id: string;
@@ -286,7 +283,6 @@ export declare const formSchema: yup.ObjectSchema<{
286
283
  name: string;
287
284
  }[] | undefined;
288
285
  distributionType?: DistributionType | undefined;
289
- count?: number | null | undefined;
290
286
  activated: NonNullable<boolean | undefined>;
291
287
  monitoredBranches: {
292
288
  id: string;
@@ -327,7 +323,6 @@ export declare const getFormSchema: (name: string | null) => yup.ObjectSchema<{
327
323
  id: string;
328
324
  name: string;
329
325
  }[] | undefined;
330
- count?: number | null | undefined;
331
326
  activated: NonNullable<boolean | undefined>;
332
327
  }[] | undefined;
333
328
  sensitivityPST: {
@@ -336,7 +331,6 @@ export declare const getFormSchema: (name: string | null) => yup.ObjectSchema<{
336
331
  name: string;
337
332
  }[] | undefined;
338
333
  sensitivityType?: SensitivityType | undefined;
339
- count?: number | null | undefined;
340
334
  activated: NonNullable<boolean | undefined>;
341
335
  monitoredBranches: {
342
336
  id: string;
@@ -353,7 +347,6 @@ export declare const getFormSchema: (name: string | null) => yup.ObjectSchema<{
353
347
  name: string;
354
348
  }[] | undefined;
355
349
  sensitivityType?: SensitivityType | undefined;
356
- count?: number | null | undefined;
357
350
  activated: NonNullable<boolean | undefined>;
358
351
  monitoredBranches: {
359
352
  id: string;
@@ -369,7 +362,6 @@ export declare const getFormSchema: (name: string | null) => yup.ObjectSchema<{
369
362
  id: string;
370
363
  name: string;
371
364
  }[] | undefined;
372
- count?: number | null | undefined;
373
365
  activated: NonNullable<boolean | undefined>;
374
366
  monitoredBranches: {
375
367
  id: string;
@@ -386,7 +378,6 @@ export declare const getFormSchema: (name: string | null) => yup.ObjectSchema<{
386
378
  name: string;
387
379
  }[] | undefined;
388
380
  distributionType?: DistributionType | undefined;
389
- count?: number | null | undefined;
390
381
  activated: NonNullable<boolean | undefined>;
391
382
  monitoredBranches: {
392
383
  id: string;
@@ -1,5 +1,5 @@
1
1
  import "../../../utils/yupConfig.js";
2
- import { FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD, ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD, FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD, PARAMETER_SENSI_NODES, EQUIPMENTS_IN_VOLTAGE_REGULATION, SUPERVISED_VOLTAGE_LEVELS, PARAMETER_SENSI_PST, PSTS, ACTIVATED, PARAMETER_SENSI_HVDC, HVDC_LINES, PARAMETER_SENSI_INJECTION, INJECTIONS, PARAMETER_SENSI_INJECTIONS_SET, DISTRIBUTION_TYPE, COUNT, CONTINGENCIES, SENSITIVITY_TYPE, MONITORED_BRANCHES, CONTAINER_NAME, CONTAINER_ID } from "./constants.js";
2
+ import { FLOW_VOLTAGE_SENSITIVITY_VALUE_THRESHOLD, ANGLE_FLOW_SENSITIVITY_VALUE_THRESHOLD, FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD, PARAMETER_SENSI_NODES, EQUIPMENTS_IN_VOLTAGE_REGULATION, SUPERVISED_VOLTAGE_LEVELS, PARAMETER_SENSI_PST, PSTS, ACTIVATED, PARAMETER_SENSI_HVDC, HVDC_LINES, PARAMETER_SENSI_INJECTION, INJECTIONS, PARAMETER_SENSI_INJECTIONS_SET, DISTRIBUTION_TYPE, CONTINGENCIES, SENSITIVITY_TYPE, MONITORED_BRANCHES, CONTAINER_NAME, CONTAINER_ID } from "./constants.js";
3
3
  import { ID } from "../../../utils/constants/filterConstant.js";
4
4
  import "../../../utils/conversionUtils.js";
5
5
  import "../../../utils/types/equipmentType.js";
@@ -67,8 +67,7 @@ const getContingenciesSchema = () => {
67
67
  [NAME]: yup.string().required()
68
68
  })
69
69
  ),
70
- [ACTIVATED]: yup.boolean().required(),
71
- [COUNT]: yup.number().nullable()
70
+ [ACTIVATED]: yup.boolean().required()
72
71
  };
73
72
  };
74
73
  const getSensiHVDCsFormSchema = () => ({
@@ -313,6 +312,19 @@ const getSensiPstformatNewParams = (newParams) => {
313
312
  })
314
313
  };
315
314
  };
315
+ const hasVariables = (row) => {
316
+ return row[INJECTIONS]?.length > 0 || row[HVDC_LINES]?.length > 0 || row[PSTS]?.length > 0 || row[EQUIPMENTS_IN_VOLTAGE_REGULATION]?.length > 0;
317
+ };
318
+ const hasMonitoredEquipments = (row) => {
319
+ return row[MONITORED_BRANCHES]?.length > 0 || row[SUPERVISED_VOLTAGE_LEVELS]?.length > 0;
320
+ };
321
+ const isActivatedSensiParameterRow = (entry) => {
322
+ return entry[ACTIVATED];
323
+ };
324
+ const isValidSensiParameterRow = (entry) => {
325
+ return isActivatedSensiParameterRow(entry) && hasMonitoredEquipments(entry) && hasVariables(entry);
326
+ };
327
+ const filterSensiParameterRows = (entries) => (entries ?? []).filter((entry) => isValidSensiParameterRow(entry));
316
328
  const formSchema = yup.object().shape({
317
329
  [PROVIDER]: yup.string().required(),
318
330
  [FLOW_FLOW_SENSITIVITY_VALUE_THRESHOLD]: yup.number().required(),
@@ -328,6 +340,7 @@ const getFormSchema = (name) => {
328
340
  return formSchema.concat(getNameElementEditorSchema(name));
329
341
  };
330
342
  export {
343
+ filterSensiParameterRows,
331
344
  formSchema,
332
345
  getFormSchema,
333
346
  getGenericRowNewParams,
@@ -340,5 +353,9 @@ export {
340
353
  getSensiNodesFormSchema,
341
354
  getSensiNodesformatNewParams,
342
355
  getSensiPSTsFormSchema,
343
- getSensiPstformatNewParams
356
+ getSensiPstformatNewParams,
357
+ hasMonitoredEquipments,
358
+ hasVariables,
359
+ isActivatedSensiParameterRow,
360
+ isValidSensiParameterRow
344
361
  };
@@ -6,6 +6,7 @@ import { SimpleTreeView, TreeItem } from "@mui/x-tree-view";
6
6
  import { ExpandMore, ChevronRight, Check } from "@mui/icons-material";
7
7
  import { toNestedGlobalSelectors, makeComposeClasses } from "../../utils/styles.js";
8
8
  import { CancelButton } from "../inputs/reactHookForm/utils/CancelButton.js";
9
+ import { doesNodeHasChildren } from "./TreeViewUtils.js";
9
10
  const cssDialogPaper = "dialogPaper";
10
11
  const cssLabelRoot = "labelRoot";
11
12
  const cssLabelText = "labelText";
@@ -224,7 +225,7 @@ function TreeViewFinderComponant(props) {
224
225
  }
225
226
  let childrenNodes = null;
226
227
  const showExpandIcon = showChevron(node);
227
- if (Array.isArray(node.children) && node.children.length > 0) {
228
+ if (doesNodeHasChildren(node)) {
228
229
  childrenNodes = node.children.toSorted(sortMethod).map(renderTree);
229
230
  } else if (showExpandIcon) {
230
231
  childrenNodes = [/* @__PURE__ */ jsx("span", { style: { display: "none" } }, "placeholder")];
@@ -0,0 +1,2 @@
1
+ import { ElementAttributes } from '../../utils';
2
+ export declare function doesNodeHasChildren(node: ElementAttributes): boolean;
@@ -0,0 +1,6 @@
1
+ function doesNodeHasChildren(node) {
2
+ return Array.isArray(node.children) && node.children.length > 0;
3
+ }
4
+ export {
5
+ doesNodeHasChildren
6
+ };
@@ -5,3 +5,4 @@
5
5
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6
6
  */
7
7
  export * from './TreeViewFinder';
8
+ export * from './TreeViewUtils';
@@ -1,5 +1,7 @@
1
1
  import { TreeViewFinder, generateTreeViewFinderClass } from "./TreeViewFinder.js";
2
+ import { doesNodeHasChildren } from "./TreeViewUtils.js";
2
3
  export {
3
4
  TreeViewFinder,
5
+ doesNodeHasChildren,
4
6
  generateTreeViewFinderClass
5
7
  };
@@ -1,12 +1,11 @@
1
1
  import { useFieldArray } from "react-hook-form";
2
2
  import { useMemo } from "react";
3
- import { COUNT } from "../components/parameters/sensi/constants.js";
4
3
  function useCreateRowDataSensi(sensiParam) {
5
4
  const useFieldArrayOutput = useFieldArray({
6
5
  name: sensiParam.name || ""
7
6
  });
8
7
  const newRowData = useMemo(() => {
9
- const rowData = { [COUNT]: 0 };
8
+ const rowData = {};
10
9
  sensiParam.columnsDef.forEach((column) => {
11
10
  rowData[column.dataKey] = column.initialValue;
12
11
  });
package/dist/index.js CHANGED
@@ -123,6 +123,7 @@ import { GridLogo, LogoText } from "./components/topBar/GridLogo.js";
123
123
  import { DevModeBanner } from "./components/topBar/DevModeBanner.js";
124
124
  import { TopBar } from "./components/topBar/TopBar.js";
125
125
  import { TreeViewFinder, generateTreeViewFinderClass } from "./components/treeViewFinder/TreeViewFinder.js";
126
+ import { doesNodeHasChildren } from "./components/treeViewFinder/TreeViewUtils.js";
126
127
  import { NotificationsProvider } from "./components/notifications/NotificationsProvider.js";
127
128
  import { NotificationsContext } from "./components/notifications/contexts/NotificationsContext.js";
128
129
  import { useNotificationsListener } from "./components/notifications/hooks/useNotificationsListener.js";
@@ -728,6 +729,7 @@ export {
728
729
  dispatchUser,
729
730
  dndTableEn,
730
731
  dndTableFr,
732
+ doesNodeHasChildren,
731
733
  elementAlreadyExists,
732
734
  elementSearchEn,
733
735
  elementSearchFr,
@@ -1,5 +1,5 @@
1
1
  import { UUID } from 'node:crypto';
2
- import { SensitivityAnalysisFactorsCountParameters, SensitivityAnalysisParametersInfos } from '../utils';
2
+ import { FactorsCount, SensitivityAnalysisParametersInfos } from '../utils';
3
3
  export declare const getStudyUrl: (studyUuid: UUID | null) => string;
4
4
  export declare const getStudyUrlWithNodeUuidAndRootNetworkUuid: (studyUuid: string | null | undefined, nodeUuid: string | undefined, rootNetworkUuid: string | undefined | null) => string;
5
5
  export declare function getSensiUrl(): string;
@@ -7,6 +7,6 @@ export declare function fetchSensitivityAnalysisProviders(): Promise<string[]>;
7
7
  export declare function getSensitivityAnalysisParameters(studyUuid: UUID): Promise<any>;
8
8
  export declare function fetchSensitivityAnalysisParameters(parameterUuid: string): Promise<any>;
9
9
  export declare function setSensitivityAnalysisParameters(studyUuid: UUID | null, newParams: SensitivityAnalysisParametersInfos | null): Promise<Response>;
10
- export declare function getSensitivityAnalysisFactorsCount(studyUuid: UUID | null, currentNodeUuid: UUID, currentRootNetworkUuid: UUID, isInjectionsSet: boolean, newParams: SensitivityAnalysisFactorsCountParameters): Promise<Response>;
10
+ export declare function getSensitivityAnalysisFactorsCount(studyUuid: UUID | null, currentNodeUuid: UUID, currentRootNetworkUuid: UUID, newParams: SensitivityAnalysisParametersInfos): Promise<FactorsCount>;
11
11
  export declare function fetchDefaultSensitivityAnalysisProvider(): Promise<string>;
12
12
  export declare function updateSensitivityAnalysisParameters(parameterUuid: UUID, newParams: any): Promise<Response>;
@@ -41,17 +41,16 @@ function setSensitivityAnalysisParameters(studyUuid, newParams) {
41
41
  body: newParams ? JSON.stringify(newParams) : null
42
42
  });
43
43
  }
44
- function getSensitivityAnalysisFactorsCount(studyUuid, currentNodeUuid, currentRootNetworkUuid, isInjectionsSet, newParams) {
44
+ function getSensitivityAnalysisFactorsCount(studyUuid, currentNodeUuid, currentRootNetworkUuid, newParams) {
45
45
  console.info("get sensitivity analysis parameters computing count");
46
- const urlSearchParams = new URLSearchParams();
47
- const jsoned = JSON.stringify(isInjectionsSet);
48
- urlSearchParams.append("isInjectionsSet", jsoned);
49
- Object.keys(newParams).filter((key) => newParams[key]).forEach((key) => urlSearchParams.append(`ids[${key}]`, newParams[key]));
50
- const url = `${getStudyUrlWithNodeUuidAndRootNetworkUuid(studyUuid, currentNodeUuid, currentRootNetworkUuid)}
51
- /sensitivity-analysis/factors-count?${urlSearchParams}`;
46
+ const url = `${getStudyUrlWithNodeUuidAndRootNetworkUuid(studyUuid, currentNodeUuid, currentRootNetworkUuid)}/sensitivity-analysis/factor-count`;
52
47
  console.debug(url);
53
- return backendFetch(url, {
54
- method: "GET"
48
+ return backendFetchJson(url, {
49
+ method: "POST",
50
+ headers: {
51
+ "Content-Type": "application/json"
52
+ },
53
+ body: JSON.stringify(newParams)
55
54
  });
56
55
  }
57
56
  function fetchDefaultSensitivityAnalysisProvider() {
@@ -60,4 +60,5 @@ export declare const businessErrorsEn: {
60
60
  'dynamicSimulation.providerNotFound': string;
61
61
  'dynamicSimulation.mappingNotProvided': string;
62
62
  'dynamicSimulation.mappingNotLastRuleWithEmptyFilterError': string;
63
+ 'sensitivityAnalysis.tooManyFactors': string;
63
64
  };
@@ -53,7 +53,8 @@ const businessErrorsEn = {
53
53
  "dynamicSecurityAnalysis.contingencyListEmpty": "Contingency list parameter must not be null or empty.",
54
54
  "dynamicSimulation.providerNotFound": "Dynamic simulation provider not found.",
55
55
  "dynamicSimulation.mappingNotProvided": "Dynamic simulation mapping not provided.",
56
- "dynamicSimulation.mappingNotLastRuleWithEmptyFilterError": "Only last rule can have empty filter: type {equipmentType}, rule index {index}."
56
+ "dynamicSimulation.mappingNotLastRuleWithEmptyFilterError": "Only last rule can have empty filter: type {equipmentType}, rule index {index}.",
57
+ "sensitivityAnalysis.tooManyFactors": "Too many factors to run sensitivity analysis: {resultCount} results (limit: {resultCountLimit}) and {variableCount} variables (limit: {variableCountLimit})."
57
58
  };
58
59
  export {
59
60
  businessErrorsEn