@gridsuite/commons-ui 0.177.0 → 0.177.1

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.
@@ -39,7 +39,10 @@ function ContingencyTable({
39
39
  );
40
40
  useEffect(() => {
41
41
  if (showContingencyCount) {
42
- if (!contingencyListsInfos || contingencyListsInfos.length === 0) {
42
+ const hasNoContingencies = !contingencyListsInfos || (contingencyListsInfos.length ?? 0) === 0 || contingencyListsInfos.every(
43
+ (contingencyList) => (contingencyList[CONTINGENCY_LISTS]?.length ?? 0) === 0
44
+ );
45
+ if (hasNoContingencies) {
43
46
  setSimulatedContingencyCount(null);
44
47
  return;
45
48
  }
@@ -203,6 +203,13 @@ const useLoadFlowParametersForm = (parametersBackend, isDeveloperMode, parameter
203
203
  [parametersUuid, formatNewParams, snackError]
204
204
  );
205
205
  const resetForm = useEffectEvent((_params) => {
206
+ previousWatchProviderRef.current = _params.provider;
207
+ setSpecificParametersDescriptionForProvider(specificParamsDescription?.[_params.provider] ?? []);
208
+ if (_params.provider === PARAM_PROVIDER_OPENLOADFLOW) {
209
+ setLimitReductionNumber(_params.limitReductions?.at(0)?.temporaryLimitReductions?.length ?? 0);
210
+ } else {
211
+ setLimitReductionNumber(0);
212
+ }
206
213
  reset(toLoadFlowFormValues(_params));
207
214
  });
208
215
  useEffect(() => {
@@ -215,21 +222,15 @@ const useLoadFlowParametersForm = (parametersBackend, isDeveloperMode, parameter
215
222
  if (!watchProvider || watchProvider === previousWatchProviderRef.current) {
216
223
  return;
217
224
  }
218
- if (previousWatchProviderRef.current) {
219
- setSpecificParameters(watchProvider, specificParamsDescription, formMethods);
220
- setLimitReductions(watchProvider, defaultLimitReductions, formMethods);
221
- }
225
+ setSpecificParameters(watchProvider, specificParamsDescription, formMethods);
226
+ setLimitReductions(watchProvider, defaultLimitReductions, formMethods);
222
227
  if (watchProvider === PARAM_PROVIDER_OPENLOADFLOW) {
223
- if (previousWatchProviderRef.current) {
224
- setLimitReductionNumber(defaultLimitReductions?.at(0)?.temporaryLimitReductions?.length ?? 0);
225
- } else {
226
- setLimitReductionNumber(params?.limitReductions?.at(0)?.temporaryLimitReductions?.length ?? 0);
227
- }
228
+ setLimitReductionNumber(defaultLimitReductions?.at(0)?.temporaryLimitReductions?.length ?? 0);
228
229
  } else {
229
230
  setLimitReductionNumber(0);
230
231
  }
231
232
  previousWatchProviderRef.current = watchProvider;
232
- }, [defaultLimitReductions, formMethods, params?.limitReductions, specificParamsDescription, watchProvider]);
233
+ }, [defaultLimitReductions, formMethods, specificParamsDescription, watchProvider]);
233
234
  return {
234
235
  formMethods,
235
236
  formSchema,
@@ -63,7 +63,7 @@ const getSAParametersFormSchema = (name, limitReductions) => {
63
63
  };
64
64
  const toFormValueSaParameters = (params) => ({
65
65
  [PARAM_SA_PROVIDER]: params[PARAM_SA_PROVIDER],
66
- ...toFormValuesContingencyListsInfos(params?.[CONTINGENCY_LISTS_INFOS]),
66
+ ...toFormValuesContingencyListsInfos(params?.[CONTINGENCY_LISTS_INFOS] ?? []),
67
67
  ...toFormValuesLimitReductions(params?.limitReductions),
68
68
  // SA specific form values
69
69
  [PARAM_SA_FLOW_PROPORTIONAL_THRESHOLD]: params[PARAM_SA_FLOW_PROPORTIONAL_THRESHOLD] * 100,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.177.0",
3
+ "version": "0.177.1",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",