@gridsuite/commons-ui 0.100.0 → 0.102.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/authentication/utils/authService.d.ts +4 -5
- package/dist/components/authentication/utils/authService.js +17 -36
- package/dist/components/parameters/loadflow/load-flow-parameters-content.js +18 -23
- package/dist/components/parameters/loadflow/load-flow-parameters-dialog.d.ts +1 -1
- package/dist/components/parameters/loadflow/load-flow-parameters-dialog.js +6 -0
- package/dist/components/parameters/loadflow/load-flow-parameters-form.js +51 -50
- package/dist/translations/en/parameters.js +1 -1
- package/dist/translations/fr/parameters.js +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Dispatch } from 'react';
|
|
2
2
|
import { Location, NavigateFunction } from 'react-router';
|
|
3
|
-
import { Log,
|
|
3
|
+
import { Log, UserManager } from 'oidc-client';
|
|
4
4
|
import { AuthenticationActions } from '../../../redux/actions/authActions';
|
|
5
|
-
type UserValidationFunc = (user: User) => Promise<boolean>;
|
|
6
5
|
type IdpSettingsGetter = () => Promise<IdpSettings>;
|
|
7
6
|
export type IdpSettings = {
|
|
8
7
|
authority: string;
|
|
@@ -25,10 +24,10 @@ declare global {
|
|
|
25
24
|
}
|
|
26
25
|
export declare function login(location: Location, userManagerInstance: UserManager | null): Promise<void> | undefined;
|
|
27
26
|
export declare function logout(dispatch: Dispatch<AuthenticationActions>, userManagerInstance: UserManager | null): Promise<void> | undefined;
|
|
28
|
-
export declare function dispatchUser(dispatch: Dispatch<AuthenticationActions>, userManagerInstance: CustomUserManager
|
|
27
|
+
export declare function dispatchUser(dispatch: Dispatch<AuthenticationActions>, userManagerInstance: CustomUserManager): Promise<void>;
|
|
29
28
|
export declare function getPreLoginPath(): string | null;
|
|
30
29
|
export declare function handleSigninCallback(dispatch: Dispatch<AuthenticationActions>, navigate: NavigateFunction, userManagerInstance: UserManager): void;
|
|
31
30
|
export declare function handleSilentRenewCallback(userManagerInstance: UserManager): void;
|
|
32
|
-
export declare function initializeAuthenticationDev(dispatch: Dispatch<AuthenticationActions>, isSilentRenew: boolean,
|
|
33
|
-
export declare function initializeAuthenticationProd(dispatch: Dispatch<AuthenticationActions>, isSilentRenew: boolean, idpSettingsGetter: IdpSettingsGetter,
|
|
31
|
+
export declare function initializeAuthenticationDev(dispatch: Dispatch<AuthenticationActions>, isSilentRenew: boolean, isSigninCallback: boolean): Promise<UserManager>;
|
|
32
|
+
export declare function initializeAuthenticationProd(dispatch: Dispatch<AuthenticationActions>, isSilentRenew: boolean, idpSettingsGetter: IdpSettingsGetter, isSigninCallback: boolean): Promise<CustomUserManager>;
|
|
34
33
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jwtDecode } from "jwt-decode";
|
|
2
2
|
import { Log, UserManager } from "oidc-client";
|
|
3
3
|
import { UserManagerMock } from "./userManagerMock.js";
|
|
4
|
-
import { setLoggedUser, setLogoutError,
|
|
4
|
+
import { setLoggedUser, setLogoutError, setSignInCallbackError, setShowAuthenticationRouterLogin, resetAuthenticationRouterError } from "../../../redux/actions/authActions.js";
|
|
5
5
|
window.OIDCLog = Log;
|
|
6
6
|
const hackAuthorityKey = "oidc.hack.authority";
|
|
7
7
|
const oidcHackReloadedKey = "gridsuite-oidc-hack-reloaded";
|
|
@@ -104,40 +104,21 @@ function logout(dispatch, userManagerInstance) {
|
|
|
104
104
|
return Promise.resolve();
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
function dispatchUser(dispatch, userManagerInstance
|
|
107
|
+
function dispatchUser(dispatch, userManagerInstance) {
|
|
108
108
|
return userManagerInstance.getUser().then((user) => {
|
|
109
|
+
var _a;
|
|
109
110
|
if (user) {
|
|
110
111
|
if (getIdTokenExpiresIn(user) < 0) {
|
|
111
112
|
console.debug("User token is expired and will not be dispatched");
|
|
112
113
|
return Promise.resolve();
|
|
113
114
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
console.debug("User has been successfully loaded from store.");
|
|
122
|
-
reloadTimerOnExpiresIn(
|
|
123
|
-
user,
|
|
124
|
-
userManagerInstance,
|
|
125
|
-
computeMinExpiresIn(
|
|
126
|
-
user.expires_in,
|
|
127
|
-
user.id_token,
|
|
128
|
-
(_b = userManagerInstance.idpSettings) == null ? void 0 : _b.maxExpiresIn
|
|
129
|
-
)
|
|
130
|
-
);
|
|
131
|
-
return dispatch(setLoggedUser(user));
|
|
132
|
-
}).catch((e) => {
|
|
133
|
-
var _a;
|
|
134
|
-
console.log("Error in dispatchUser", e);
|
|
135
|
-
return dispatch(
|
|
136
|
-
setUserValidationError((_a = user == null ? void 0 : user.profile) == null ? void 0 : _a.name, {
|
|
137
|
-
error: e
|
|
138
|
-
})
|
|
139
|
-
);
|
|
140
|
-
});
|
|
115
|
+
console.debug("User has been successfully loaded from store.");
|
|
116
|
+
reloadTimerOnExpiresIn(
|
|
117
|
+
user,
|
|
118
|
+
userManagerInstance,
|
|
119
|
+
computeMinExpiresIn(user.expires_in, user.id_token, (_a = userManagerInstance.idpSettings) == null ? void 0 : _a.maxExpiresIn)
|
|
120
|
+
);
|
|
121
|
+
return dispatch(setLoggedUser(user));
|
|
141
122
|
}
|
|
142
123
|
console.debug("You are not logged in.");
|
|
143
124
|
return Promise.resolve();
|
|
@@ -175,10 +156,10 @@ function handleSigninCallback(dispatch, navigate, userManagerInstance) {
|
|
|
175
156
|
function handleSilentRenewCallback(userManagerInstance) {
|
|
176
157
|
userManagerInstance.signinSilentCallback();
|
|
177
158
|
}
|
|
178
|
-
function handleUser(dispatch, userManager
|
|
159
|
+
function handleUser(dispatch, userManager) {
|
|
179
160
|
userManager.events.addUserLoaded((user) => {
|
|
180
161
|
console.debug("user loaded", user);
|
|
181
|
-
dispatchUser(dispatch, userManager
|
|
162
|
+
dispatchUser(dispatch, userManager);
|
|
182
163
|
});
|
|
183
164
|
userManager.events.addSilentRenewError((error) => {
|
|
184
165
|
console.debug(error);
|
|
@@ -223,19 +204,19 @@ function handleUser(dispatch, userManager, validateUser) {
|
|
|
223
204
|
}, accessTokenExpiringNotificationTime * 1e3);
|
|
224
205
|
});
|
|
225
206
|
console.debug("dispatch user");
|
|
226
|
-
dispatchUser(dispatch, userManager
|
|
207
|
+
dispatchUser(dispatch, userManager);
|
|
227
208
|
}
|
|
228
|
-
async function initializeAuthenticationDev(dispatch, isSilentRenew,
|
|
209
|
+
async function initializeAuthenticationDev(dispatch, isSilentRenew, isSigninCallback) {
|
|
229
210
|
const userManager = new UserManagerMock({});
|
|
230
211
|
if (!isSilentRenew) {
|
|
231
|
-
handleUser(dispatch, userManager
|
|
212
|
+
handleUser(dispatch, userManager);
|
|
232
213
|
if (!isSigninCallback) {
|
|
233
214
|
handleSigninSilent(dispatch, userManager);
|
|
234
215
|
}
|
|
235
216
|
}
|
|
236
217
|
return userManager;
|
|
237
218
|
}
|
|
238
|
-
async function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettingsGetter,
|
|
219
|
+
async function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettingsGetter, isSigninCallback) {
|
|
239
220
|
const idpSettings = await idpSettingsGetter();
|
|
240
221
|
try {
|
|
241
222
|
const settings = {
|
|
@@ -252,7 +233,7 @@ async function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings
|
|
|
252
233
|
const userManager = new UserManager(settings);
|
|
253
234
|
userManager.idpSettings = idpSettings;
|
|
254
235
|
if (!isSilentRenew) {
|
|
255
|
-
handleUser(dispatch, userManager
|
|
236
|
+
handleUser(dispatch, userManager);
|
|
256
237
|
if (!isSigninCallback) {
|
|
257
238
|
handleSigninSilent(dispatch, userManager);
|
|
258
239
|
}
|
|
@@ -44,6 +44,11 @@ const styles = {
|
|
|
44
44
|
},
|
|
45
45
|
maxWidth: {
|
|
46
46
|
width: "100%"
|
|
47
|
+
},
|
|
48
|
+
wrapper: {
|
|
49
|
+
flexGrow: 1,
|
|
50
|
+
overflow: "auto",
|
|
51
|
+
paddingLeft: 1
|
|
47
52
|
}
|
|
48
53
|
};
|
|
49
54
|
function LoadFlowParametersContent({
|
|
@@ -53,29 +58,19 @@ function LoadFlowParametersContent({
|
|
|
53
58
|
params,
|
|
54
59
|
defaultLimitReductions
|
|
55
60
|
}) {
|
|
56
|
-
return /* @__PURE__ */ jsx(
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
name: PARAM_LIMIT_REDUCTION,
|
|
70
|
-
label: "LimitReduction",
|
|
71
|
-
marks: alertThresholdMarks,
|
|
72
|
-
minValue: MIN_VALUE_ALLOWED_FOR_LIMIT_REDUCTION,
|
|
73
|
-
maxValue: MAX_VALUE_ALLOWED_FOR_LIMIT_REDUCTION
|
|
74
|
-
}
|
|
75
|
-
) }) })
|
|
76
|
-
] }) })
|
|
77
|
-
}
|
|
78
|
-
);
|
|
61
|
+
return /* @__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: [
|
|
62
|
+
/* @__PURE__ */ jsx(TabPanel, { value: selectedTab, index: TabValues.GENERAL, children: /* @__PURE__ */ jsx(LoadFlowGeneralParameters, { provider: currentProvider, specificParams: specificParameters }) }),
|
|
63
|
+
/* @__PURE__ */ jsx(TabPanel, { value: selectedTab, index: TabValues.LIMIT_REDUCTIONS, children: /* @__PURE__ */ jsx(Grid, { container: true, sx: { width: "100%" }, children: currentProvider === PARAM_PROVIDER_OPENLOADFLOW ? /* @__PURE__ */ jsx(LimitReductionsTableForm, { limits: (params == null ? void 0 : params.limitReductions) ?? defaultLimitReductions }) : /* @__PURE__ */ jsx(
|
|
64
|
+
ParameterLineSlider,
|
|
65
|
+
{
|
|
66
|
+
name: PARAM_LIMIT_REDUCTION,
|
|
67
|
+
label: "LimitReduction",
|
|
68
|
+
marks: alertThresholdMarks,
|
|
69
|
+
minValue: MIN_VALUE_ALLOWED_FOR_LIMIT_REDUCTION,
|
|
70
|
+
maxValue: MAX_VALUE_ALLOWED_FOR_LIMIT_REDUCTION
|
|
71
|
+
}
|
|
72
|
+
) }) })
|
|
73
|
+
] }) }) });
|
|
79
74
|
}
|
|
80
75
|
export {
|
|
81
76
|
LoadFlowParametersContent as default
|
|
@@ -70,6 +70,10 @@ function LoadFlowParametersEditionDialog({
|
|
|
70
70
|
getLoadFlowDefaultLimitReductions
|
|
71
71
|
);
|
|
72
72
|
const loadflowMethods = useLoadFlowParametersForm(parametersBackend, enableDeveloperMode, id, name, description);
|
|
73
|
+
const {
|
|
74
|
+
formState: { errors, dirtyFields }
|
|
75
|
+
} = loadflowMethods.formMethods;
|
|
76
|
+
const disableSave = Object.keys(errors).length > 0 || Object.keys(dirtyFields).length === 0;
|
|
73
77
|
return /* @__PURE__ */ jsx(
|
|
74
78
|
CustomMuiDialog,
|
|
75
79
|
{
|
|
@@ -82,6 +86,7 @@ function LoadFlowParametersEditionDialog({
|
|
|
82
86
|
titleId,
|
|
83
87
|
removeOptional: true,
|
|
84
88
|
language,
|
|
89
|
+
disabledSave: disableSave,
|
|
85
90
|
children: /* @__PURE__ */ jsx(LoadFlowProvider, { children: /* @__PURE__ */ jsx(
|
|
86
91
|
LoadFlowParametersForm,
|
|
87
92
|
{
|
|
@@ -92,6 +97,7 @@ function LoadFlowParametersEditionDialog({
|
|
|
92
97
|
UniqueNameInput,
|
|
93
98
|
{
|
|
94
99
|
name: FieldConstants.NAME,
|
|
100
|
+
currentName: name,
|
|
95
101
|
label: "nameProperty",
|
|
96
102
|
elementType: ElementType.LOADFLOW_PARAMETERS,
|
|
97
103
|
activeDirectory,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Box, LinearProgress } from "@mui/material";
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Box, Grid, LinearProgress } from "@mui/material";
|
|
3
3
|
import LoadFlowParametersHeader from "./load-flow-parameters-header.js";
|
|
4
4
|
import LoadFlowParametersContent from "./load-flow-parameters-content.js";
|
|
5
5
|
import "react-intl";
|
|
@@ -29,6 +29,31 @@ import "../../inputs/reactQueryBuilder/CustomReactQueryBuilder.js";
|
|
|
29
29
|
import "uuid";
|
|
30
30
|
import "../../inputs/reactQueryBuilder/PropertyValueEditor.js";
|
|
31
31
|
import "react-querybuilder";
|
|
32
|
+
const styles = {
|
|
33
|
+
form: {
|
|
34
|
+
height: "100%",
|
|
35
|
+
display: "flex",
|
|
36
|
+
position: "relative",
|
|
37
|
+
flexDirection: "column"
|
|
38
|
+
},
|
|
39
|
+
loadflowParameters: {
|
|
40
|
+
flexGrow: 1,
|
|
41
|
+
paddingLeft: 1,
|
|
42
|
+
overflow: "auto"
|
|
43
|
+
},
|
|
44
|
+
actions: {
|
|
45
|
+
flexGrow: 0
|
|
46
|
+
},
|
|
47
|
+
content: (theme) => ({
|
|
48
|
+
overflowY: "auto",
|
|
49
|
+
overflowX: "hidden",
|
|
50
|
+
maxHeight: "calc(100% - 15vh)",
|
|
51
|
+
paddingRight: theme.spacing(2),
|
|
52
|
+
paddingTop: theme.spacing(2),
|
|
53
|
+
paddingBottom: theme.spacing(1),
|
|
54
|
+
flexGrow: 1
|
|
55
|
+
})
|
|
56
|
+
};
|
|
32
57
|
function LoadFlowParametersForm({
|
|
33
58
|
loadflowMethods,
|
|
34
59
|
renderTitleFields,
|
|
@@ -47,55 +72,31 @@ function LoadFlowParametersForm({
|
|
|
47
72
|
defaultLimitReductions,
|
|
48
73
|
paramsLoaded
|
|
49
74
|
} = loadflowMethods;
|
|
50
|
-
return /* @__PURE__ */
|
|
75
|
+
return /* @__PURE__ */ jsx(CustomFormProvider, { validationSchema: formSchema, ...formMethods, removeOptional: true, children: /* @__PURE__ */ jsxs(Box, { sx: styles.form, children: [
|
|
51
76
|
renderTitleFields == null ? void 0 : renderTitleFields(),
|
|
52
|
-
/* @__PURE__ */ jsxs(
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
selectedTab,
|
|
76
|
-
handleTabChange,
|
|
77
|
-
tabIndexesWithError,
|
|
78
|
-
formattedProviders
|
|
79
|
-
}
|
|
80
|
-
),
|
|
81
|
-
/* @__PURE__ */ jsx(
|
|
82
|
-
LoadFlowParametersContent,
|
|
83
|
-
{
|
|
84
|
-
selectedTab,
|
|
85
|
-
currentProvider: currentProvider ?? "",
|
|
86
|
-
specificParameters,
|
|
87
|
-
params,
|
|
88
|
-
defaultLimitReductions
|
|
89
|
-
}
|
|
90
|
-
)
|
|
91
|
-
]
|
|
92
|
-
}
|
|
93
|
-
) : /* @__PURE__ */ jsx(LinearProgress, {}),
|
|
94
|
-
renderActions == null ? void 0 : renderActions()
|
|
95
|
-
]
|
|
96
|
-
}
|
|
97
|
-
)
|
|
98
|
-
] });
|
|
77
|
+
paramsLoaded ? /* @__PURE__ */ jsxs(Box, { sx: styles.loadflowParameters, children: [
|
|
78
|
+
/* @__PURE__ */ jsx(
|
|
79
|
+
LoadFlowParametersHeader,
|
|
80
|
+
{
|
|
81
|
+
selectedTab,
|
|
82
|
+
handleTabChange,
|
|
83
|
+
tabIndexesWithError,
|
|
84
|
+
formattedProviders
|
|
85
|
+
}
|
|
86
|
+
),
|
|
87
|
+
/* @__PURE__ */ jsx(Grid, { container: true, sx: styles.content, children: /* @__PURE__ */ jsx(
|
|
88
|
+
LoadFlowParametersContent,
|
|
89
|
+
{
|
|
90
|
+
selectedTab,
|
|
91
|
+
currentProvider: currentProvider ?? "",
|
|
92
|
+
specificParameters,
|
|
93
|
+
params,
|
|
94
|
+
defaultLimitReductions
|
|
95
|
+
}
|
|
96
|
+
) })
|
|
97
|
+
] }) : /* @__PURE__ */ jsx(LinearProgress, {}),
|
|
98
|
+
renderActions && /* @__PURE__ */ jsx(Box, { sx: styles.actions, children: renderActions == null ? void 0 : renderActions() })
|
|
99
|
+
] }) });
|
|
99
100
|
}
|
|
100
101
|
export {
|
|
101
102
|
LoadFlowParametersForm
|
|
@@ -44,7 +44,7 @@ const parametersEn = {
|
|
|
44
44
|
descLfCountries: "Countries",
|
|
45
45
|
descLfAllCountries: "All countries",
|
|
46
46
|
descLfCountriesToBalance: "Countries participating in balancing",
|
|
47
|
-
editParameters: "Edit
|
|
47
|
+
editParameters: "Edit parameters",
|
|
48
48
|
RealPercentage: "This value must be between 0 and 1",
|
|
49
49
|
General: "General",
|
|
50
50
|
LimitReductions: "Limit reductions",
|
|
@@ -44,7 +44,7 @@ const parametersFr = {
|
|
|
44
44
|
descLfCountries: "Pays",
|
|
45
45
|
descLfAllCountries: "Tous les pays",
|
|
46
46
|
descLfCountriesToBalance: "Pays participant à la compensation",
|
|
47
|
-
editParameters: "Éditer
|
|
47
|
+
editParameters: "Éditer les paramètres",
|
|
48
48
|
RealPercentage: "Cette valeur doit être comprise entre 0 et 1",
|
|
49
49
|
General: "Général",
|
|
50
50
|
LimitReductions: "Abattements",
|