@gridsuite/commons-ui 0.161.0 → 0.163.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.
@@ -4,6 +4,11 @@ import { DataType } from "./expertFilter.type.js";
4
4
  import { OPERATOR_OPTIONS, RULES, FIELDS_OPTIONS } from "./expertFilterConstants.js";
5
5
  import { isBlankOrEmpty, convertOutputValue, convertInputValue } from "../../../utils/conversionUtils.js";
6
6
  import { FieldType } from "../../../utils/types/fieldType.js";
7
+ import "../../../utils/types/equipmentType.js";
8
+ import { isEmpty } from "../../../utils/functions.js";
9
+ import "react/jsx-runtime";
10
+ import "@mui/icons-material";
11
+ import "../../../utils/yupConfig.js";
7
12
  const searchTree = (tree, key, value) => {
8
13
  const stack = Object.values(tree);
9
14
  while (stack.length) {
@@ -262,7 +267,7 @@ const queryValidator = (query) => {
262
267
  reasons: void 0
263
268
  };
264
269
  } else if (rule.id && rule.operator === OPERATOR_OPTIONS.BETWEEN.name) {
265
- if (!rule.value?.[0] || !rule.value?.[1]) {
270
+ if (isEmpty(rule.value?.[0]) || isEmpty(rule.value?.[1])) {
266
271
  result[rule.id] = {
267
272
  valid: false,
268
273
  reasons: [RULES.EMPTY_RULE]
@@ -1,5 +1,6 @@
1
1
  export interface CountryInputProps {
2
2
  name: string;
3
3
  label: string;
4
+ dataTestId?: string;
4
5
  }
5
- export declare function CountriesInput({ name, label }: Readonly<CountryInputProps>): import("react/jsx-runtime").JSX.Element;
6
+ export declare function CountriesInput({ name, label, dataTestId }: Readonly<CountryInputProps>): import("react/jsx-runtime").JSX.Element;
@@ -4,7 +4,7 @@ import { Chip } from "@mui/material";
4
4
  import { AutocompleteInput } from "../autocompleteInputs/AutocompleteInput.js";
5
5
  import { useLocalizedCountries } from "../../../../hooks/useLocalizedCountries.js";
6
6
  import { useCustomFormContext } from "../provider/useCustomFormContext.js";
7
- function CountriesInput({ name, label }) {
7
+ function CountriesInput({ name, label, dataTestId }) {
8
8
  const { language } = useCustomFormContext();
9
9
  const { translate, countryCodes } = useLocalizedCountries(language);
10
10
  const translateOption = useCallback(
@@ -19,13 +19,23 @@ function CountriesInput({ name, label }) {
19
19
  return /* @__PURE__ */ jsx(
20
20
  AutocompleteInput,
21
21
  {
22
+ "data-testid": dataTestId,
22
23
  name,
23
24
  label,
24
25
  options: countryCodes,
25
26
  getOptionLabel: translateOption,
26
27
  fullWidth: true,
27
28
  multiple: true,
28
- renderTags: (val, getTagsProps) => val.map((code, index) => /* @__PURE__ */ jsx(Chip, { size: "small", label: translate(code), ...getTagsProps({ index }) }, code))
29
+ renderTags: (val, getTagsProps) => val.map((code, index) => /* @__PURE__ */ jsx(
30
+ Chip,
31
+ {
32
+ "data-testid": `${dataTestId}.${code}`,
33
+ size: "small",
34
+ label: translate(code),
35
+ ...getTagsProps({ index })
36
+ },
37
+ code
38
+ ))
29
39
  }
30
40
  );
31
41
  }
@@ -21,6 +21,7 @@ export interface TextInputProps {
21
21
  formProps?: Omit<TextFieldWithAdornmentProps | TextFieldProps, 'value' | 'onChange' | 'inputRef' | 'inputProps' | 'InputProps'>;
22
22
  disabledTooltip?: boolean;
23
23
  disabled?: boolean;
24
+ dataTestId?: string;
24
25
  }
25
26
  export declare function TextInput({ name, label, labelValues, // this prop is used to add a value to label. this value is displayed without being translated
26
27
  id, adornment, customAdornment, outputTransform, // transform materialUi input value before sending it to react hook form, mostly used to deal with number fields
@@ -28,4 +29,4 @@ inputTransform, // transform react hook form value before sending it to material
28
29
  acceptValue, // used to check user entry before committing the input change, used mostly to prevent user from typing a character in number field
29
30
  onChange, // method called when input value changed, if you want to manually trigger validation for example (do not update the form here unless you know what you do, it's already done by RHF)
30
31
  previousValue, clearable, formProps, disabledTooltip, // In case we don't want to show tooltip on the value and warning/info icons
31
- disabled, }: TextInputProps): import("react/jsx-runtime").JSX.Element;
32
+ disabled, dataTestId, }: TextInputProps): import("react/jsx-runtime").JSX.Element;
@@ -28,7 +28,8 @@ function TextInput({
28
28
  formProps,
29
29
  disabledTooltip,
30
30
  // In case we don't want to show tooltip on the value and warning/info icons
31
- disabled
31
+ disabled,
32
+ dataTestId
32
33
  }) {
33
34
  const { validationSchema, getValues, removeOptional, isNodeBuilt, isUpdate } = useCustomFormContext();
34
35
  const {
@@ -58,6 +59,7 @@ function TextInput({
58
59
  return /* @__PURE__ */ jsx(
59
60
  Field,
60
61
  {
62
+ "data-testid": dataTestId,
61
63
  size: "small",
62
64
  fullWidth: true,
63
65
  id: id ?? label,
@@ -53,28 +53,46 @@ function LoadFlowParameterField({
53
53
  const renderField = () => {
54
54
  switch (type) {
55
55
  case ParameterType.STRING:
56
- return possibleValues ? /* @__PURE__ */ jsx(MuiSelectInput, { name: `${id}.${name}`, options: possibleValues, size: "small" }) : /* @__PURE__ */ jsx(TextInput, { name: `${id}.${name}` });
56
+ return possibleValues ? /* @__PURE__ */ jsx(
57
+ MuiSelectInput,
58
+ {
59
+ name: `${id}.${name}`,
60
+ options: possibleValues,
61
+ size: "small",
62
+ "data-testid": `${id}.${name}`
63
+ }
64
+ ) : /* @__PURE__ */ jsx(TextInput, { name: `${id}.${name}`, dataTestId: `${id}.${name}` });
57
65
  case ParameterType.BOOLEAN:
58
- return /* @__PURE__ */ jsx(SwitchInput, { name: `${id}.${name}` });
66
+ return /* @__PURE__ */ jsx(SwitchInput, { name: `${id}.${name}`, "data-testid": `${id}.${name}` });
59
67
  case ParameterType.COUNTRIES:
60
- return /* @__PURE__ */ jsx(CountriesInput, { name: `${id}.${name}`, label: "descLfCountries" });
68
+ return /* @__PURE__ */ jsx(CountriesInput, { name: `${id}.${name}`, label: "descLfCountries", dataTestId: `${id}.${name}` });
61
69
  case ParameterType.DOUBLE:
62
- return /* @__PURE__ */ jsx(FloatInput, { name: `${id}.${name}` });
70
+ return /* @__PURE__ */ jsx(FloatInput, { name: `${id}.${name}`, dataTestId: `${id}.${name}` });
63
71
  case ParameterType.STRING_LIST:
64
72
  return possibleValues ? /* @__PURE__ */ jsx(
65
73
  AutocompleteInput,
66
74
  {
75
+ "data-testid": `${id}.${name}`,
67
76
  name: `${id}.${name}`,
68
77
  label,
69
78
  options: possibleValues,
70
79
  fullWidth: true,
71
80
  multiple: true,
72
81
  size: "small",
73
- renderTags: (val, getTagsProps) => val.map((code, index) => /* @__PURE__ */ jsx(Chip, { size: "small", label: code, ...getTagsProps({ index }) }, code))
82
+ renderTags: (val, getTagsProps) => val.map((code, index) => /* @__PURE__ */ jsx(
83
+ Chip,
84
+ {
85
+ "data-testid": `${id}.${name}.${code}`,
86
+ size: "small",
87
+ label: code,
88
+ ...getTagsProps({ index })
89
+ },
90
+ code
91
+ ))
74
92
  }
75
- ) : /* @__PURE__ */ jsx(MultipleAutocompleteInput, { name: `${id}.${name}`, size: "small" });
93
+ ) : /* @__PURE__ */ jsx(MultipleAutocompleteInput, { name: `${id}.${name}`, size: "small", "data-testid": `${id}.${name}` });
76
94
  case ParameterType.INTEGER:
77
- return /* @__PURE__ */ jsx(IntegerInput, { name: `${id}.${name}` });
95
+ return /* @__PURE__ */ jsx(IntegerInput, { name: `${id}.${name}`, dataTestId: `${id}.${name}` });
78
96
  default:
79
97
  return null;
80
98
  }
@@ -55,7 +55,15 @@ function LoadFlowParametersHeader({
55
55
  justifyContent: "space-between",
56
56
  children: [
57
57
  /* @__PURE__ */ jsx(Grid, { item: true, xs: 5, sx: parametersStyles.parameterName, children: /* @__PURE__ */ jsx(FormattedMessage, { id: "Provider" }) }),
58
- /* @__PURE__ */ jsx(Grid, { item: true, xs: "auto", sx: parametersStyles.controlItem, children: /* @__PURE__ */ jsx(MuiSelectInput, { name: PROVIDER, size: "small", options: Object.values(formattedProviders) }) }),
58
+ /* @__PURE__ */ jsx(Grid, { item: true, xs: "auto", sx: parametersStyles.controlItem, children: /* @__PURE__ */ jsx(
59
+ MuiSelectInput,
60
+ {
61
+ "data-testid": "LfProvider",
62
+ name: PROVIDER,
63
+ size: "small",
64
+ options: Object.values(formattedProviders)
65
+ }
66
+ ) }),
59
67
  /* @__PURE__ */ jsx(LineSeparator, {}),
60
68
  /* @__PURE__ */ jsx(Grid, { item: true, sx: { width: "100%" }, children: /* @__PURE__ */ jsxs(Tabs, { value: selectedTab, onChange: handleTabChange, children: [
61
69
  /* @__PURE__ */ jsx(
@@ -63,7 +71,8 @@ function LoadFlowParametersHeader({
63
71
  {
64
72
  label: /* @__PURE__ */ jsx(FormattedMessage, { id: TabValues.GENERAL }),
65
73
  value: TabValues.GENERAL,
66
- sx: getTabStyle(tabIndexesWithError, TabValues.GENERAL)
74
+ sx: getTabStyle(tabIndexesWithError, TabValues.GENERAL),
75
+ "data-testid": "LfGeneralTab"
67
76
  }
68
77
  ),
69
78
  /* @__PURE__ */ jsx(
@@ -71,7 +80,8 @@ function LoadFlowParametersHeader({
71
80
  {
72
81
  label: /* @__PURE__ */ jsx(FormattedMessage, { id: TabValues.LIMIT_REDUCTIONS }),
73
82
  value: TabValues.LIMIT_REDUCTIONS,
74
- sx: getTabStyle(tabIndexesWithError, TabValues.LIMIT_REDUCTIONS)
83
+ sx: getTabStyle(tabIndexesWithError, TabValues.LIMIT_REDUCTIONS),
84
+ "data-testid": "LfLimitReductionsTab"
75
85
  }
76
86
  )
77
87
  ] }) })
@@ -112,11 +112,26 @@ function LoadFlowParametersInline({
112
112
  LabelledButton,
113
113
  {
114
114
  callback: () => setOpenSelectParameterDialog(true),
115
- label: "settings.button.chooseSettings"
115
+ label: "settings.button.chooseSettings",
116
+ "data-testid": "LfChooseParametersButton"
117
+ }
118
+ ),
119
+ /* @__PURE__ */ jsx(
120
+ LabelledButton,
121
+ {
122
+ callback: () => setOpenCreateParameterDialog(true),
123
+ label: "save",
124
+ "data-testid": "LfSaveButton"
125
+ }
126
+ ),
127
+ /* @__PURE__ */ jsx(
128
+ LabelledButton,
129
+ {
130
+ callback: handleResetAllClick,
131
+ label: "resetToDefault",
132
+ "data-testid": "LfResetToDefaultButton"
116
133
  }
117
134
  ),
118
- /* @__PURE__ */ jsx(LabelledButton, { callback: () => setOpenCreateParameterDialog(true), label: "save" }),
119
- /* @__PURE__ */ jsx(LabelledButton, { callback: handleResetAllClick, label: "resetToDefault" }),
120
135
  /* @__PURE__ */ jsx(
121
136
  SubmitButton,
122
137
  {
@@ -125,6 +140,7 @@ function LoadFlowParametersInline({
125
140
  loadflowMethods.onValidationError
126
141
  ),
127
142
  variant: "outlined",
143
+ "data-testid": "LfValidateButton",
128
144
  children: /* @__PURE__ */ jsx(FormattedMessage, { id: "validate" })
129
145
  }
130
146
  )
@@ -88,7 +88,8 @@ function ShortCircuitFields({ resetAll, isDeveloperMode = true }) {
88
88
  name: `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER}`
89
89
  });
90
90
  const isIccMinFeaturesDefaultConfiguration = useMemo(() => {
91
- return !watchLoads && !watchShuntCompensators && !watchVSC && !watchNeutralPosition && watchOnlyStartedGeneratorsInCalculationCluster;
91
+ return !watchLoads && !watchShuntCompensators && !watchVSC && !watchNeutralPosition && // if watchOnlyStartedGeneratorsInCalculationCluster is undefined, we consider IccMinFeaturesDefaultConfiguration as true
92
+ (watchOnlyStartedGeneratorsInCalculationCluster ?? true);
92
93
  }, [
93
94
  watchLoads,
94
95
  watchShuntCompensators,
@@ -97,7 +98,8 @@ function ShortCircuitFields({ resetAll, isDeveloperMode = true }) {
97
98
  watchOnlyStartedGeneratorsInCalculationCluster
98
99
  ]);
99
100
  const isIccMaxFeaturesDefaultConfiguration = useMemo(() => {
100
- return !watchLoads && !watchShuntCompensators && watchVSC && !watchNeutralPosition && !watchOnlyStartedGeneratorsInCalculationCluster;
101
+ return !watchLoads && !watchShuntCompensators && watchVSC && !watchNeutralPosition && // if watchOnlyStartedGeneratorsInCalculationCluster is undefined, we consider IccMaxFeaturesDefaultConfiguration as true
102
+ !(watchOnlyStartedGeneratorsInCalculationCluster ?? false);
101
103
  }, [
102
104
  watchLoads,
103
105
  watchShuntCompensators,
@@ -32,7 +32,7 @@ import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
32
32
  import "uuid";
33
33
  import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
34
34
  import "react-querybuilder";
35
- import { SHORT_CIRCUIT_PREDEFINED_PARAMS, PredefinedParameters, InitialVoltage, SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, SHORT_CIRCUIT_WITH_LOADS, SHORT_CIRCUIT_WITH_FEEDER_RESULT, SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER, SHORT_CIRCUIT_VOLTAGE_RANGES } from "./constants.js";
35
+ import { SHORT_CIRCUIT_PREDEFINED_PARAMS, PredefinedParameters, SHORT_CIRCUIT_WITH_LOADS, SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS, SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS, SHORT_CIRCUIT_WITH_NEUTRAL_POSITION, SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE, InitialVoltage, SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER, SHORT_CIRCUIT_VOLTAGE_RANGES } from "./constants.js";
36
36
  import "../../filter/HeaderFilterForm.js";
37
37
  import { getNameElementEditorSchema, getNameElementEditorEmptyFormData } from "../common/name-element-editor/name-element-editor-utils.js";
38
38
  import { SPECIFIC_PARAMETERS, COMMON_PARAMETERS, VERSION_PARAMETER, PROVIDER } from "../common/constant.js";
@@ -82,28 +82,32 @@ const useShortCircuitParametersForm = ({
82
82
  const resetAll = useCallback(
83
83
  (predefinedParameter) => {
84
84
  const dirty = { shouldDirty: true };
85
+ setValue(`${COMMON_PARAMETERS}.${SHORT_CIRCUIT_WITH_LOADS}`, false, dirty);
85
86
  setValue(
86
- COMMON_PARAMETERS,
87
- {
88
- ...params?.commonParameters,
89
- // for VERSION_PARAMETER and other non managed params
90
- [SHORT_CIRCUIT_WITH_FEEDER_RESULT]: false,
91
- [SHORT_CIRCUIT_WITH_LOADS]: false,
92
- [SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS]: predefinedParameter !== PredefinedParameters.ICC_MIN_WITH_NOMINAL_VOLTAGE_MAP,
93
- [SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS]: false,
94
- [SHORT_CIRCUIT_WITH_NEUTRAL_POSITION]: false,
95
- [SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE]: predefinedParameter === PredefinedParameters.ICC_MAX_WITH_CEI909 ? InitialVoltage.CEI909 : InitialVoltage.NOMINAL
96
- },
87
+ `${COMMON_PARAMETERS}.${SHORT_CIRCUIT_WITH_VSC_CONVERTER_STATIONS}`,
88
+ predefinedParameter !== PredefinedParameters.ICC_MIN_WITH_NOMINAL_VOLTAGE_MAP,
97
89
  dirty
98
90
  );
99
- setValue(SHORT_CIRCUIT_PREDEFINED_PARAMS, predefinedParameter, dirty);
91
+ setValue(`${COMMON_PARAMETERS}.${SHORT_CIRCUIT_WITH_SHUNT_COMPENSATORS}`, false, dirty);
92
+ setValue(`${COMMON_PARAMETERS}.${SHORT_CIRCUIT_WITH_NEUTRAL_POSITION}`, false, dirty);
100
93
  setValue(
101
- `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER}`,
102
- predefinedParameter === PredefinedParameters.ICC_MIN_WITH_NOMINAL_VOLTAGE_MAP,
94
+ `${COMMON_PARAMETERS}.${SHORT_CIRCUIT_INITIAL_VOLTAGE_PROFILE_MODE}`,
95
+ predefinedParameter === PredefinedParameters.ICC_MAX_WITH_CEI909 ? InitialVoltage.CEI909 : InitialVoltage.NOMINAL,
103
96
  dirty
104
97
  );
98
+ setValue(SHORT_CIRCUIT_PREDEFINED_PARAMS, predefinedParameter, dirty);
99
+ const onlyStartedGeneratorsInCalculationCluster = specificParametersDescriptionForProvider?.find(
100
+ (specificParam) => specificParam.name === SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER
101
+ );
102
+ if (onlyStartedGeneratorsInCalculationCluster) {
103
+ setValue(
104
+ `${SPECIFIC_PARAMETERS}.${SHORT_CIRCUIT_ONLY_STARTED_GENERATORS_IN_CALCULATION_CLUSTER}`,
105
+ predefinedParameter === PredefinedParameters.ICC_MIN_WITH_NOMINAL_VOLTAGE_MAP,
106
+ dirty
107
+ );
108
+ }
105
109
  },
106
- [params?.commonParameters, setValue]
110
+ [setValue, specificParametersDescriptionForProvider]
107
111
  );
108
112
  const formatNewParams = useCallback(
109
113
  (formData) => {
package/dist/index.js CHANGED
@@ -194,7 +194,7 @@ import { OptionalServicesStatus, useParametersBackend } from "./hooks/use-parame
194
194
  import { useCreateRowDataSensi } from "./hooks/use-create-row-data-sensi.js";
195
195
  import { LOGOUT_ERROR, RESET_AUTHENTICATION_ROUTER_ERROR, SHOW_AUTH_INFO_LOGIN, SIGNIN_CALLBACK_ERROR, UNAUTHORIZED_USER_INFO, USER, USER_VALIDATION_ERROR, resetAuthenticationRouterError, setLoggedUser, setLogoutError, setShowAuthenticationRouterLogin, setSignInCallbackError, setUnauthorizedUserInfo, setUserValidationError } from "./redux/actions/authActions.js";
196
196
  import { getUserToken, setCommonStore } from "./redux/commonStore.js";
197
- import { fetchAppsMetadata, fetchBaseVoltages, fetchDefaultCountry, fetchEnv, fetchFavoriteAndDefaultCountries, fetchStudyMetadata, isStudyMetadata } from "./services/appsMetadata.js";
197
+ import { fetchAppsMetadata, fetchBaseVoltages, fetchDefaultCountry, fetchEnv, fetchFavoriteAndDefaultCountries, fetchStudyMetadata, isExploreMetadata, isStudyMetadata } from "./services/appsMetadata.js";
198
198
  import { fetchConfigParameter, fetchConfigParameters, getAppName, updateConfigParameter } from "./services/config.js";
199
199
  import { PermissionType, elementAlreadyExists, fetchDirectoryContent, fetchDirectoryElementPath, fetchRootFolders, hasElementPermission } from "./services/directory.js";
200
200
  import { createFilter, createParameter, fetchElementsInfos, saveFilter, updateParameter } from "./services/explore.js";
@@ -216,7 +216,7 @@ import { COMMON_APP_NAME, COMMON_CONFIG_PARAMS_NAMES, LAST_SELECTED_DIRECTORY, P
216
216
  import { FILTERS, FILTER_ID, FILTER_NAME, ID } from "./utils/constants/filterConstant.js";
217
217
  import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./utils/conversionUtils.js";
218
218
  import { catchErrorHandler, snackWithFallback } from "./utils/error.js";
219
- import { areArrayElementsUnique, arraysContainIdenticalStrings, isObjectEmpty, keyGenerator } from "./utils/functions.js";
219
+ import { areArrayElementsUnique, arraysContainIdenticalStrings, isEmpty, isObjectEmpty, keyGenerator } from "./utils/functions.js";
220
220
  import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM } from "./utils/langs.js";
221
221
  import { getFileIcon } from "./utils/mapper/getFileIcon.js";
222
222
  import { equipmentTypesForPredefinedPropertiesMapper } from "./utils/mapper/equipmentTypesForPredefinedPropertiesMapper.js";
@@ -829,6 +829,8 @@ export {
829
829
  intlInitialVoltageProfileMode,
830
830
  intlPredefinedParametersOptions,
831
831
  isBlankOrEmpty,
832
+ isEmpty,
833
+ isExploreMetadata,
832
834
  isFieldRequired,
833
835
  isFloatNumber,
834
836
  isIntegerNumber,
@@ -1,4 +1,4 @@
1
- import { BaseVoltage, Metadata, StudyMetadata } from '../utils';
1
+ import { BaseVoltage, ExploreMetadata, Metadata, StudyMetadata } from '../utils';
2
2
  export type UrlString = `${string}://${string}` | `/${string}` | `./${string}`;
3
3
  export type Url = UrlString | URL;
4
4
  export type Env = {
@@ -9,6 +9,7 @@ export type Env = {
9
9
  export declare function fetchEnv(): Promise<Env>;
10
10
  export declare function fetchAppsMetadata(): Promise<Metadata[]>;
11
11
  export declare function isStudyMetadata(metadata: Metadata): metadata is StudyMetadata;
12
+ export declare function isExploreMetadata(metadata: Metadata): metadata is ExploreMetadata;
12
13
  export declare function fetchStudyMetadata(): Promise<StudyMetadata>;
13
14
  export declare function fetchBaseVoltages(): Promise<BaseVoltage[]>;
14
15
  export declare function fetchFavoriteAndDefaultCountries(): Promise<{
@@ -10,6 +10,9 @@ async function fetchAppsMetadata() {
10
10
  function isStudyMetadata(metadata) {
11
11
  return metadata.name === "Study";
12
12
  }
13
+ function isExploreMetadata(metadata) {
14
+ return metadata.name === "Explore";
15
+ }
13
16
  async function fetchStudyMetadata() {
14
17
  console.info(`Fetching study metadata...`);
15
18
  const studyMetadata = (await fetchAppsMetadata()).find(isStudyMetadata);
@@ -43,5 +46,6 @@ export {
43
46
  fetchEnv,
44
47
  fetchFavoriteAndDefaultCountries,
45
48
  fetchStudyMetadata,
49
+ isExploreMetadata,
46
50
  isStudyMetadata
47
51
  };
@@ -1,4 +1,4 @@
1
- import { fetchAppsMetadata, fetchBaseVoltages, fetchDefaultCountry, fetchEnv, fetchFavoriteAndDefaultCountries, fetchStudyMetadata, isStudyMetadata } from "./appsMetadata.js";
1
+ import { fetchAppsMetadata, fetchBaseVoltages, fetchDefaultCountry, fetchEnv, fetchFavoriteAndDefaultCountries, fetchStudyMetadata, isExploreMetadata, isStudyMetadata } from "./appsMetadata.js";
2
2
  import { fetchConfigParameter, fetchConfigParameters, getAppName, updateConfigParameter } from "./config.js";
3
3
  import { PermissionType, elementAlreadyExists, fetchDirectoryContent, fetchDirectoryElementPath, fetchRootFolders, hasElementPermission } from "./directory.js";
4
4
  import { createFilter, createParameter, fetchElementsInfos, saveFilter, updateParameter } from "./explore.js";
@@ -62,6 +62,7 @@ export {
62
62
  getVoltageInitUrl,
63
63
  handleNotOkResponse,
64
64
  hasElementPermission,
65
+ isExploreMetadata,
65
66
  isStudyMetadata,
66
67
  parseError,
67
68
  safeEncodeURIComponent,
@@ -30,7 +30,7 @@ const businessErrorsEn = {
30
30
  "study.networkExportFailed": "Failed to export network.",
31
31
  "study.tooManyNadConfigs": "Maximum number of NAD configuration exceeded.",
32
32
  "study.tooManyMapCards": "Maximum number of cards exceeded.",
33
- "study.elementAlreadyExists": "An element with the same name already exists",
33
+ "study.elementAlreadyExists": "An element with the name {fileName} already exists",
34
34
  "useradmin.permissionDenied": "You don't have permission to perform this action.",
35
35
  "useradmin.userNotFound": "User not found.",
36
36
  "useradmin.userAlreadyExists": "User already exists.",
@@ -6,9 +6,9 @@ const businessErrorsFr = {
6
6
  "directory.moveInDescendantNotAllowed": "Impossible de déplacer un élément dans l’un de ses descendants.",
7
7
  "directory.someElementsAreMissing": "Certains des éléments demandés sont manquants.",
8
8
  "directory.elementNotFound": "L'élément du dossier demandé est introuvable.",
9
- "directory.parentPermissionDenied": "Vous n'avez pas les droits d'accès suffisant sur le dossier parent",
10
- "directory.childPermissionDenied": "Le dossier contient au moins un sous-dossier pour lequel vous n'avez pas les droits d'accès suffisant",
11
- "directory.targetPermissionDenied": "Vous n'avez pas les droits d'accès suffisant sur le dossier cible",
9
+ "directory.parentPermissionDenied": "Vous n'avez pas les droits d'accès suffisants sur le dossier parent",
10
+ "directory.childPermissionDenied": "Le dossier contient au moins un sous-dossier pour lequel vous n'avez pas les droits d'accès s",
11
+ "directory.targetPermissionDenied": "Vous n'avez pas les droits d'accès suffisants sur le dossier cible",
12
12
  "explore.permissionDenied": "Vous n'êtes pas autorisé à effectuer cette action.",
13
13
  "explore.maxElementsExceeded": "Vous avez atteint votre quota utilisateur en termes de situations et d'études ({limit} situations et études).",
14
14
  "explore.incorrectCaseFile": "Le fichier réseau fourni est incorrect.",
@@ -30,7 +30,7 @@ const businessErrorsFr = {
30
30
  "study.networkExportFailed": "Échec de l'export de réseau.",
31
31
  "study.tooManyNadConfigs": "Nombre maximal de configurations d'image nodale de zone atteint.",
32
32
  "study.tooManyMapCards": "Nombre maximal de carte atteint.",
33
- "study.elementAlreadyExists": "Un élément avec le même nom est déjà présent",
33
+ "study.elementAlreadyExists": "Un élément avec le nom {fileName} est déjà présent",
34
34
  "useradmin.permissionDenied": "Vous n'avez pas la permission d'effectuer cette action.",
35
35
  "useradmin.userNotFound": "Utilisateur introuvable.",
36
36
  "useradmin.userAlreadyExists": "L'utilisateur existe déjà.",
@@ -14,4 +14,10 @@ export declare function keyGenerator(): () => number;
14
14
  */
15
15
  export declare function arraysContainIdenticalStrings(array1: string[] | undefined, array2: string[] | undefined): boolean;
16
16
  export declare const areArrayElementsUnique: (array: unknown[]) => boolean;
17
+ /**
18
+ * returns true if element is null or undefined
19
+ * for string values return true if element is an empty string
20
+ * for number values return true if element is NaN
21
+ */
22
+ export declare function isEmpty(value: any): boolean;
17
23
  export declare const isObjectEmpty: (object: object) => boolean;
@@ -12,10 +12,14 @@ const areArrayElementsUnique = (array) => {
12
12
  const uniqueValues = [...new Set(array)];
13
13
  return uniqueValues.length === array.length;
14
14
  };
15
+ function isEmpty(value) {
16
+ return value === void 0 || value === null || typeof value === "string" && value.trim() === "" || typeof value === "number" && Number.isNaN(value);
17
+ }
15
18
  const isObjectEmpty = (object) => object && Object.keys(object).length === 0;
16
19
  export {
17
20
  areArrayElementsUnique,
18
21
  arraysContainIdenticalStrings,
22
+ isEmpty,
19
23
  isObjectEmpty,
20
24
  keyGenerator
21
25
  };
@@ -7,7 +7,7 @@ import { COMMON_APP_NAME, COMMON_CONFIG_PARAMS_NAMES, LAST_SELECTED_DIRECTORY, P
7
7
  import { FILTERS, FILTER_ID, FILTER_NAME, ID } from "./constants/filterConstant.js";
8
8
  import { GRIDSUITE_DEFAULT_PRECISION, convertInputValue, convertOutputValue, isBlankOrEmpty, kiloUnitToUnit, microUnitToUnit, roundToDefaultPrecision, roundToPrecision, unitToKiloUnit, unitToMicroUnit } from "./conversionUtils.js";
9
9
  import { catchErrorHandler, snackWithFallback } from "./error.js";
10
- import { areArrayElementsUnique, arraysContainIdenticalStrings, isObjectEmpty, keyGenerator } from "./functions.js";
10
+ import { areArrayElementsUnique, arraysContainIdenticalStrings, isEmpty, isObjectEmpty, keyGenerator } from "./functions.js";
11
11
  import { LANG_ENGLISH, LANG_FRENCH, LANG_SYSTEM } from "./langs.js";
12
12
  import { getFileIcon } from "./mapper/getFileIcon.js";
13
13
  import { equipmentTypesForPredefinedPropertiesMapper } from "./mapper/equipmentTypesForPredefinedPropertiesMapper.js";
@@ -117,6 +117,7 @@ export {
117
117
  getEquipmentsInfosForSearchBar,
118
118
  getFileIcon,
119
119
  isBlankOrEmpty,
120
+ isEmpty,
120
121
  isObjectEmpty,
121
122
  keyGenerator,
122
123
  kiloUnitToUnit,
@@ -27,6 +27,10 @@ export type StudyMetadata = Metadata & {
27
27
  label: string;
28
28
  }[];
29
29
  };
30
+ export type ExploreMetadata = Metadata & {
31
+ name: 'Explore';
32
+ maxFileSizeInMb?: number;
33
+ };
30
34
  type ThemeColors = Record<string, string>;
31
35
  type SldAndNadColors = {
32
36
  darkThemeColors: ThemeColors;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.161.0",
3
+ "version": "0.163.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "author": "gridsuite team",
6
6
  "homepage": "https://github.com/gridsuite",