@gridsuite/commons-ui 0.121.0 → 0.123.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.
@@ -60,7 +60,7 @@ function FilterCreationDialog({
60
60
  null,
61
61
  (error) => {
62
62
  snackError({
63
- messageTxt: error
63
+ messageTxt: error.message
64
64
  });
65
65
  },
66
66
  onClose,
@@ -78,7 +78,7 @@ function FilterCreationDialog({
78
78
  onClose,
79
79
  (error) => {
80
80
  snackError({
81
- messageTxt: error
81
+ messageTxt: error.message
82
82
  });
83
83
  }
84
84
  );
@@ -84,7 +84,8 @@ function ExpertFilterEditionDialog({
84
84
  onClose,
85
85
  (error) => {
86
86
  snackError({
87
- messageTxt: error
87
+ messageTxt: error.message,
88
+ headerId: "cannotSaveFilter"
88
89
  });
89
90
  }
90
91
  );
@@ -81,7 +81,7 @@ function ExplicitNamingFilterEditionDialog({
81
81
  id,
82
82
  (error) => {
83
83
  snackError({
84
- messageTxt: error
84
+ messageTxt: error.message
85
85
  });
86
86
  },
87
87
  onClose
@@ -1,3 +1,3 @@
1
1
  import { UUID } from 'crypto';
2
- export declare const saveExplicitNamingFilter: (tableValues: any[], isFilterCreation: boolean, equipmentType: string, name: string, description: string, id: string | null, setCreateFilterErr: (value?: string) => void, handleClose: () => void, activeDirectory?: UUID, token?: string) => void;
3
- export declare const saveExpertFilter: (id: string | null, query: any, equipmentType: string, name: string, description: string, isFilterCreation: boolean, activeDirectory: UUID | undefined | null, onClose: () => void, onError: (message: string) => void, token?: string) => void;
2
+ export declare const saveExplicitNamingFilter: (tableValues: any[], isFilterCreation: boolean, equipmentType: string, name: string, description: string, id: string | null, setCreateFilterErr: (error: Error) => void, handleClose: () => void, activeDirectory?: UUID, token?: string) => void;
3
+ export declare const saveExpertFilter: (id: string | null, query: any, equipmentType: string, name: string, description: string, isFilterCreation: boolean, activeDirectory: UUID | undefined | null, onClose: () => void, onError: (error: Error) => void, token?: string) => void;
@@ -37,7 +37,7 @@ const saveExplicitNamingFilter = (tableValues, isFilterCreation, equipmentType,
37
37
  ).then(() => {
38
38
  handleClose();
39
39
  }).catch((error) => {
40
- setCreateFilterErr(error.message);
40
+ setCreateFilterErr(error instanceof Error ? error : new Error("unknown error"));
41
41
  });
42
42
  } else {
43
43
  saveFilter(
@@ -53,7 +53,7 @@ const saveExplicitNamingFilter = (tableValues, isFilterCreation, equipmentType,
53
53
  ).then(() => {
54
54
  handleClose();
55
55
  }).catch((error) => {
56
- setCreateFilterErr(error.message);
56
+ setCreateFilterErr(error instanceof Error ? error : new Error("unknown error"));
57
57
  });
58
58
  }
59
59
  };
@@ -74,7 +74,7 @@ const saveExpertFilter = (id, query, equipmentType, name, description, isFilterC
74
74
  onClose();
75
75
  }).catch((error) => {
76
76
  catchErrorHandler(error, (message) => {
77
- onError(message);
77
+ onError(new Error(message));
78
78
  });
79
79
  });
80
80
  } else {
@@ -92,7 +92,7 @@ const saveExpertFilter = (id, query, equipmentType, name, description, isFilterC
92
92
  onClose();
93
93
  }).catch((error) => {
94
94
  catchErrorHandler(error, (message) => {
95
- onError(message);
95
+ onError(new Error(message));
96
96
  });
97
97
  });
98
98
  }
@@ -12,7 +12,6 @@ import { VoltageLevel, Substation } from "../../../utils/types/equipmentTypes.js
12
12
  import { ElementValueEditor } from "./ElementValueEditor.js";
13
13
  import { ElementType } from "../../../utils/types/elementType.js";
14
14
  import { PropertyValueEditor } from "./PropertyValueEditor.js";
15
- import { FilterType } from "../../filter/constants/FilterConstants.js";
16
15
  import { GroupValueEditor } from "./compositeRuleEditor/GroupValueEditor.js";
17
16
  import { OPERATOR_OPTIONS } from "../../filter/expert/expertFilterConstants.js";
18
17
  import { FieldType } from "../../../utils/types/fieldType.js";
@@ -32,13 +31,9 @@ function ValueEditor(props) {
32
31
  const { getValues } = formContext;
33
32
  const itemFilter = useCallback(
34
33
  (filterValue) => {
35
- var _a, _b, _c, _d;
34
+ var _a, _b, _c;
36
35
  if ((filterValue == null ? void 0 : filterValue.type) === ElementType.FILTER) {
37
- return (
38
- // we do not authorize to use an expert filter in the rules of
39
- // another expert filter, to prevent potential cycle problems
40
- ((_a = filterValue == null ? void 0 : filterValue.specificMetadata) == null ? void 0 : _a.type) !== FilterType.EXPERT.id && (field === FieldType.ID && ((_b = filterValue == null ? void 0 : filterValue.specificMetadata) == null ? void 0 : _b.equipmentType) === getValues(FieldConstants.EQUIPMENT_TYPE) || (field === FieldType.VOLTAGE_LEVEL_ID || field === FieldType.VOLTAGE_LEVEL_ID_1 || field === FieldType.VOLTAGE_LEVEL_ID_2 || field === FieldType.VOLTAGE_LEVEL_ID_3) && ((_c = filterValue == null ? void 0 : filterValue.specificMetadata) == null ? void 0 : _c.equipmentType) === VoltageLevel.type || (field === FieldType.SUBSTATION_ID || field === FieldType.SUBSTATION_ID_1 || field === FieldType.SUBSTATION_ID_2) && ((_d = filterValue == null ? void 0 : filterValue.specificMetadata) == null ? void 0 : _d.equipmentType) === Substation.type)
41
- );
36
+ return field === FieldType.ID && ((_a = filterValue == null ? void 0 : filterValue.specificMetadata) == null ? void 0 : _a.equipmentType) === getValues(FieldConstants.EQUIPMENT_TYPE) || (field === FieldType.VOLTAGE_LEVEL_ID || field === FieldType.VOLTAGE_LEVEL_ID_1 || field === FieldType.VOLTAGE_LEVEL_ID_2 || field === FieldType.VOLTAGE_LEVEL_ID_3) && ((_b = filterValue == null ? void 0 : filterValue.specificMetadata) == null ? void 0 : _b.equipmentType) === VoltageLevel.type || (field === FieldType.SUBSTATION_ID || field === FieldType.SUBSTATION_ID_1 || field === FieldType.SUBSTATION_ID_2) && ((_c = filterValue == null ? void 0 : filterValue.specificMetadata) == null ? void 0 : _c.equipmentType) === Substation.type;
42
37
  }
43
38
  return true;
44
39
  },
@@ -13,7 +13,13 @@ const useListenerManager = (urls) => {
13
13
  const addListenerEvent = useCallback((urlKey, listener) => {
14
14
  const urlsListeners = urlsListenersRef.current;
15
15
  if (urlKey in urlsListeners) {
16
- urlsListeners[urlKey].push(listener);
16
+ const existingIndex = urlsListeners[urlKey].findIndex((l) => l.id === listener.id);
17
+ if (existingIndex !== -1) {
18
+ console.warn(`🔄 Replacing existing listener ${listener.id} on ${urlKey}`);
19
+ urlsListeners[urlKey][existingIndex] = listener;
20
+ } else {
21
+ urlsListeners[urlKey].push(listener);
22
+ }
17
23
  } else {
18
24
  urlsListeners[urlKey] = [listener];
19
25
  }
@@ -77,7 +77,7 @@ const useShortCircuitParametersForm = ({
77
77
  const resetAll = useCallback(
78
78
  (predefinedParameter) => {
79
79
  const dirty = { shouldDirty: true };
80
- setValue(SHORT_CIRCUIT_WITH_FEEDER_RESULT, true, dirty);
80
+ setValue(SHORT_CIRCUIT_WITH_FEEDER_RESULT, false, dirty);
81
81
  setValue(SHORT_CIRCUIT_WITH_LOADS, false, dirty);
82
82
  setValue(
83
83
  SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS,
@@ -178,6 +178,7 @@ export declare const filterExpertEn: {
178
178
  pairingKey: string;
179
179
  tieLineId: string;
180
180
  cannotRetrieveFilter: string;
181
+ cannotSaveFilter: string;
181
182
  equality: string;
182
183
  notEquality: string;
183
184
  greaterThan: string;
@@ -172,6 +172,7 @@ const filterExpertEn = {
172
172
  pairingKey: "Xnode",
173
173
  tieLineId: "Tie line ID",
174
174
  cannotRetrieveFilter: "Could not retrieve filter: ",
175
+ cannotSaveFilter: "Error while saving filter: ",
175
176
  equality: "=",
176
177
  notEquality: "!=",
177
178
  greaterThan: ">",
@@ -178,6 +178,7 @@ export declare const filterExpertFr: {
178
178
  pairingKey: string;
179
179
  tieLineId: string;
180
180
  cannotRetrieveFilter: string;
181
+ cannotSaveFilter: string;
181
182
  equality: string;
182
183
  notEquality: string;
183
184
  greaterThan: string;
@@ -172,6 +172,7 @@ const filterExpertFr = {
172
172
  pairingKey: "Xnode",
173
173
  tieLineId: "ID de l'interconnexion",
174
174
  cannotRetrieveFilter: "Erreur d'accès au filtre : ",
175
+ cannotSaveFilter: "Erreur lors de la mise à jour du filtre : ",
175
176
  equality: "=",
176
177
  notEquality: "!=",
177
178
  greaterThan: ">",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.121.0",
3
+ "version": "0.123.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",