@gridsuite/commons-ui 0.162.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.
- package/dist/components/inputs/reactHookForm/selectInputs/CountriesInput.d.ts +2 -1
- package/dist/components/inputs/reactHookForm/selectInputs/CountriesInput.js +12 -2
- package/dist/components/inputs/reactHookForm/text/TextInput.d.ts +2 -1
- package/dist/components/inputs/reactHookForm/text/TextInput.js +3 -1
- package/dist/components/parameters/loadflow/load-flow-parameter-field.js +25 -7
- package/dist/components/parameters/loadflow/load-flow-parameters-header.js +13 -3
- package/dist/components/parameters/loadflow/load-flow-parameters-inline.js +19 -3
- package/dist/index.js +2 -1
- package/dist/services/appsMetadata.d.ts +2 -1
- package/dist/services/appsMetadata.js +4 -0
- package/dist/services/index.js +2 -1
- package/dist/utils/types/metadata.d.ts +4 -0
- package/package.json +1 -1
|
@@ -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(
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
)
|
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";
|
|
@@ -830,6 +830,7 @@ export {
|
|
|
830
830
|
intlPredefinedParametersOptions,
|
|
831
831
|
isBlankOrEmpty,
|
|
832
832
|
isEmpty,
|
|
833
|
+
isExploreMetadata,
|
|
833
834
|
isFieldRequired,
|
|
834
835
|
isFloatNumber,
|
|
835
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
|
};
|
package/dist/services/index.js
CHANGED
|
@@ -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,
|
|
@@ -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;
|