@gridsuite/commons-ui 0.176.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,
@@ -1,7 +1,6 @@
1
1
  import { UseShortCircuitParametersFormReturn } from './use-short-circuit-parameters-form';
2
2
  type ShortCircuitParametersContentProps = {
3
3
  shortCircuitMethods: UseShortCircuitParametersFormReturn;
4
- isDeveloperMode: boolean;
5
4
  };
6
- declare function ShortCircuitParametersContent({ shortCircuitMethods, isDeveloperMode, }: Readonly<ShortCircuitParametersContentProps>): import("react/jsx-runtime").JSX.Element;
5
+ declare function ShortCircuitParametersContent({ shortCircuitMethods }: Readonly<ShortCircuitParametersContentProps>): import("react/jsx-runtime").JSX.Element;
7
6
  export default ShortCircuitParametersContent;
@@ -56,10 +56,7 @@ const styles = {
56
56
  paddingLeft: 1
57
57
  }
58
58
  };
59
- function ShortCircuitParametersContent({
60
- shortCircuitMethods,
61
- isDeveloperMode
62
- }) {
59
+ function ShortCircuitParametersContent({ shortCircuitMethods }) {
63
60
  const { resetAll, selectedTab, handleTabChange, tabIndexesWithError } = shortCircuitMethods;
64
61
  const watchSpecificParameters = useWatch({
65
62
  name: `${SPECIFIC_PARAMETERS}`
@@ -78,7 +75,7 @@ function ShortCircuitParametersContent({
78
75
  sx: getTabStyle(tabIndexesWithError, ShortCircuitParametersTabValues.GENERAL)
79
76
  }
80
77
  ),
81
- isThereSpecificParameters && isDeveloperMode && /* @__PURE__ */ jsx(
78
+ isThereSpecificParameters && /* @__PURE__ */ jsx(
82
79
  Tab,
83
80
  {
84
81
  label: /* @__PURE__ */ jsx(FormattedMessage, { id: ShortCircuitParametersTabValues.STUDY_AREA }),
@@ -86,7 +83,7 @@ function ShortCircuitParametersContent({
86
83
  sx: getTabStyle(tabIndexesWithError, ShortCircuitParametersTabValues.STUDY_AREA)
87
84
  }
88
85
  ),
89
- isThereSpecificParameters && isDeveloperMode && /* @__PURE__ */ jsx(
86
+ isThereSpecificParameters && /* @__PURE__ */ jsx(
90
87
  Tab,
91
88
  {
92
89
  label: /* @__PURE__ */ jsx(FormattedMessage, { id: ShortCircuitParametersTabValues.POWER_ELECTRONICS }),
@@ -97,7 +94,7 @@ function ShortCircuitParametersContent({
97
94
  ] }) }),
98
95
  /* @__PURE__ */ jsx(Box, { sx: styles.wrapper, children: /* @__PURE__ */ jsx(Grid, { container: true, sx: styles.container, children: /* @__PURE__ */ jsxs(Grid, { item: true, sx: styles.maxWidth, children: [
99
96
  /* @__PURE__ */ jsx(ShortCircuitGeneralTabPanel, { resetAll, value: selectedTab }),
100
- isThereSpecificParameters && isDeveloperMode && /* @__PURE__ */ jsxs(Fragment, { children: [
97
+ isThereSpecificParameters && /* @__PURE__ */ jsxs(Fragment, { children: [
101
98
  /* @__PURE__ */ jsx(ShortCircuitStudyAreaTabPanel, { value: selectedTab }),
102
99
  /* @__PURE__ */ jsx(ShortCircuitPowerElectronicsTabPanel, { value: selectedTab })
103
100
  ] })
@@ -1,4 +1,2 @@
1
1
  import { ParametersEditionDialogProps } from '../common';
2
- export declare function ShortCircuitParametersEditionDialog({ id, open, onClose, titleId, name, description, activeDirectory, user, language, isDeveloperMode, }: Readonly<ParametersEditionDialogProps & {
3
- isDeveloperMode: boolean;
4
- }>): import("react/jsx-runtime").JSX.Element;
2
+ export declare function ShortCircuitParametersEditionDialog({ id, open, onClose, titleId, name, description, activeDirectory, user, language, }: Readonly<ParametersEditionDialogProps>): import("react/jsx-runtime").JSX.Element;
@@ -53,8 +53,7 @@ function ShortCircuitParametersEditionDialog({
53
53
  description,
54
54
  activeDirectory,
55
55
  user,
56
- language,
57
- isDeveloperMode
56
+ language
58
57
  }) {
59
58
  const parametersBackend = useParametersBackend(user, id, ComputingType.SHORT_CIRCUIT, OptionalServicesStatus.Up, {
60
59
  backendFetchParameters: fetchShortCircuitParameters,
@@ -91,7 +90,6 @@ function ShortCircuitParametersEditionDialog({
91
90
  ShortCircuitParametersForm,
92
91
  {
93
92
  shortCircuitMethods,
94
- isDeveloperMode,
95
93
  renderTitleFields: () => {
96
94
  return /* @__PURE__ */ jsx(
97
95
  NameElementEditorForm,
@@ -4,7 +4,6 @@ interface ShortCircuitParametersFormProps {
4
4
  shortCircuitMethods: UseShortCircuitParametersFormReturn;
5
5
  renderTitleFields?: () => ReactNode;
6
6
  renderActions?: () => ReactNode;
7
- isDeveloperMode: boolean;
8
7
  }
9
- export declare function ShortCircuitParametersForm({ shortCircuitMethods, renderTitleFields, renderActions, isDeveloperMode, }: Readonly<ShortCircuitParametersFormProps>): import("react/jsx-runtime").JSX.Element;
8
+ export declare function ShortCircuitParametersForm({ shortCircuitMethods, renderTitleFields, renderActions, }: Readonly<ShortCircuitParametersFormProps>): import("react/jsx-runtime").JSX.Element;
10
9
  export {};
@@ -45,19 +45,12 @@ const styles = {
45
45
  function ShortCircuitParametersForm({
46
46
  shortCircuitMethods,
47
47
  renderTitleFields,
48
- renderActions,
49
- isDeveloperMode
48
+ renderActions
50
49
  }) {
51
50
  const { formMethods, formSchema, paramsLoaded } = shortCircuitMethods;
52
51
  return /* @__PURE__ */ jsx(CustomFormProvider, { validationSchema: formSchema, ...formMethods, removeOptional: true, children: /* @__PURE__ */ jsxs(Box, { sx: styles.shortCircuitParameters, children: [
53
52
  /* @__PURE__ */ jsx(Grid, { item: true, container: true, direction: "column", children: renderTitleFields?.() }),
54
- paramsLoaded ? /* @__PURE__ */ jsx(Grid, { sx: parametersStyles.scrollableGrid, children: /* @__PURE__ */ jsx(
55
- ShortCircuitParametersContent,
56
- {
57
- isDeveloperMode,
58
- shortCircuitMethods
59
- }
60
- ) }) : /* @__PURE__ */ jsx(LinearProgress, {}),
53
+ paramsLoaded ? /* @__PURE__ */ jsx(Grid, { sx: parametersStyles.scrollableGrid, children: /* @__PURE__ */ jsx(ShortCircuitParametersContent, { shortCircuitMethods }) }) : /* @__PURE__ */ jsx(LinearProgress, {}),
61
54
  /* @__PURE__ */ jsx(
62
55
  Grid,
63
56
  {
@@ -1,9 +1,8 @@
1
1
  import { UUID } from 'node:crypto';
2
2
  import { UseParametersBackendReturnProps } from '../../../utils';
3
3
  import { ComputingType } from '../common';
4
- export declare function ShortCircuitParametersInLine({ studyUuid, setHaveDirtyFields, parametersBackend, isDeveloperMode, }: Readonly<{
4
+ export declare function ShortCircuitParametersInLine({ studyUuid, setHaveDirtyFields, parametersBackend, }: Readonly<{
5
5
  studyUuid: UUID | null;
6
6
  setHaveDirtyFields: (isDirty: boolean) => void;
7
7
  parametersBackend: UseParametersBackendReturnProps<ComputingType.SHORT_CIRCUIT>;
8
- isDeveloperMode: boolean;
9
8
  }>): import("react/jsx-runtime").JSX.Element;
@@ -48,8 +48,7 @@ import "../../dialogs/elementSaveDialog/ElementSaveDialog.js";
48
48
  function ShortCircuitParametersInLine({
49
49
  studyUuid,
50
50
  setHaveDirtyFields,
51
- parametersBackend,
52
- isDeveloperMode
51
+ parametersBackend
53
52
  }) {
54
53
  const shortCircuitMethods = useShortCircuitParametersForm({
55
54
  parametersBackend,
@@ -105,7 +104,6 @@ function ShortCircuitParametersInLine({
105
104
  ShortCircuitParametersForm,
106
105
  {
107
106
  shortCircuitMethods,
108
- isDeveloperMode,
109
107
  renderActions: () => {
110
108
  return /* @__PURE__ */ jsxs(Box, { children: [
111
109
  /* @__PURE__ */ jsxs(Grid, { container: true, item: true, children: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.176.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",