@gridsuite/commons-ui 0.29.2 → 0.30.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/lib/components/ElementSearchDialog/element-search-dialog.js +1 -3
- package/lib/components/MuiVirtualizedTable/ColumnHeader.js +142 -0
- package/lib/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +667 -0
- package/lib/components/MuiVirtualizedTable/MuiVirtualizedTable.js +496 -227
- package/lib/components/MuiVirtualizedTable/index.js +6 -3
- package/lib/index.js +5 -2
- package/lib/utils/AuthService.js +28 -16
- package/lib/utils/EquipmentType.js +3 -3
- package/lib/utils/algos.js +27 -0
- package/package.json +1 -1
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports["default"] = void 0;
|
|
4
|
+
exports["default"] = exports.KeyedColumnsRowIndexer = exports.CHANGE_WAYS = void 0;
|
|
5
5
|
|
|
6
6
|
var _MuiVirtualizedTable = _interopRequireDefault(require("./MuiVirtualizedTable"));
|
|
7
7
|
|
|
8
8
|
exports["default"] = _MuiVirtualizedTable["default"];
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var _KeyedColumnsRowIndexer = require("./KeyedColumnsRowIndexer");
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
exports.KeyedColumnsRowIndexer = _KeyedColumnsRowIndexer.KeyedColumnsRowIndexer;
|
|
13
|
+
exports.CHANGE_WAYS = _KeyedColumnsRowIndexer.CHANGE_WAYS;
|
|
14
|
+
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.useSnackMessage = exports.useIntlRef = exports.useImportExportParams = exports.treeview_finder_fr = exports.treeview_finder_en = exports.top_bar_fr = exports.top_bar_en = exports.table_fr = exports.table_en = exports.setSignInCallbackError = exports.setShowAuthenticationRouterLogin = exports.setLoggedUser = exports.report_viewer_fr = exports.report_viewer_en = exports.logout = exports.login_fr = exports.login_en = exports.initializeAuthenticationProd = exports.initializeAuthenticationDev = exports.getPreLoginPath = exports.getFileIcon = exports.getEquipmentsInfosForSearchBar = exports.equipment_search_fr = exports.equipment_search_en = exports.equipmentStyles = exports.element_search_fr = exports.element_search_en = exports.elementType = exports.dispatchUser = exports.card_error_boundary_fr = exports.card_error_boundary_en = exports.USER_VALIDATION_ERROR = exports.USER = exports.UNAUTHORIZED_USER_INFO = exports.TreeViewFinder = exports.TopBar = exports.TagRenderer = exports.SnackbarProvider = exports.SIGNIN_CALLBACK_ERROR = exports.SHOW_AUTH_INFO_LOGIN = exports.ReportViewerDialog = exports.ReportViewer = exports.RESET_AUTHENTICATION_ROUTER_ERROR = exports.OverflowableText = exports.MuiVirtualizedTable = exports.LOGOUT_ERROR = exports.LIGHT_THEME = exports.LANG_SYSTEM = exports.LANG_FRENCH = exports.LANG_ENGLISH = exports.EquipmentItem = exports.ElementSearchDialog = exports.EQUIPMENT_TYPE = exports.DEFAULT_ROW_HEIGHT = exports.DEFAULT_HEADER_HEIGHT = exports.DEFAULT_CELL_PADDING = exports.DARK_THEME = exports.CardErrorBoundary = exports.AuthenticationRouter = void 0;
|
|
4
|
+
exports.useSnackMessage = exports.useIntlRef = exports.useImportExportParams = exports.treeview_finder_fr = exports.treeview_finder_en = exports.top_bar_fr = exports.top_bar_en = exports.table_fr = exports.table_en = exports.setSignInCallbackError = exports.setShowAuthenticationRouterLogin = exports.setLoggedUser = exports.report_viewer_fr = exports.report_viewer_en = exports.logout = exports.login_fr = exports.login_en = exports.initializeAuthenticationProd = exports.initializeAuthenticationDev = exports.getPreLoginPath = exports.getIdTokenExpiresIn = exports.getFileIcon = exports.getEquipmentsInfosForSearchBar = exports.equipment_search_fr = exports.equipment_search_en = exports.equipmentStyles = exports.element_search_fr = exports.element_search_en = exports.elementType = exports.dispatchUser = exports.card_error_boundary_fr = exports.card_error_boundary_en = exports.USER_VALIDATION_ERROR = exports.USER = exports.UNAUTHORIZED_USER_INFO = exports.TreeViewFinder = exports.TopBar = exports.TagRenderer = exports.SnackbarProvider = exports.SIGNIN_CALLBACK_ERROR = exports.SHOW_AUTH_INFO_LOGIN = exports.ReportViewerDialog = exports.ReportViewer = exports.RESET_AUTHENTICATION_ROUTER_ERROR = exports.OverflowableText = exports.MuiVirtualizedTable = exports.LOGOUT_ERROR = exports.LIGHT_THEME = exports.LANG_SYSTEM = exports.LANG_FRENCH = exports.LANG_ENGLISH = exports.KeyedColumnsRowIndexer = exports.EquipmentItem = exports.ElementSearchDialog = exports.EQUIPMENT_TYPE = exports.DEFAULT_ROW_HEIGHT = exports.DEFAULT_HEADER_HEIGHT = exports.DEFAULT_CELL_PADDING = exports.DARK_THEME = exports.CardErrorBoundary = exports.CHANGE_WAYS = exports.AuthenticationRouter = void 0;
|
|
5
5
|
|
|
6
6
|
var _TreeViewFinder = _interopRequireDefault(require("./components/TreeViewFinder"));
|
|
7
7
|
|
|
@@ -19,9 +19,11 @@ var _AuthenticationRouter = _interopRequireDefault(require("./components/Authent
|
|
|
19
19
|
|
|
20
20
|
exports.AuthenticationRouter = _AuthenticationRouter["default"];
|
|
21
21
|
|
|
22
|
-
var _MuiVirtualizedTable =
|
|
22
|
+
var _MuiVirtualizedTable = _interopRequireWildcard(require("./components/MuiVirtualizedTable"));
|
|
23
23
|
|
|
24
24
|
exports.MuiVirtualizedTable = _MuiVirtualizedTable["default"];
|
|
25
|
+
exports.KeyedColumnsRowIndexer = _MuiVirtualizedTable.KeyedColumnsRowIndexer;
|
|
26
|
+
exports.CHANGE_WAYS = _MuiVirtualizedTable.CHANGE_WAYS;
|
|
25
27
|
|
|
26
28
|
var _ReportViewer = _interopRequireDefault(require("./components/ReportViewer"));
|
|
27
29
|
|
|
@@ -53,6 +55,7 @@ exports.initializeAuthenticationProd = _AuthService.initializeAuthenticationProd
|
|
|
53
55
|
exports.logout = _AuthService.logout;
|
|
54
56
|
exports.dispatchUser = _AuthService.dispatchUser;
|
|
55
57
|
exports.getPreLoginPath = _AuthService.getPreLoginPath;
|
|
58
|
+
exports.getIdTokenExpiresIn = _AuthService.getIdTokenExpiresIn;
|
|
56
59
|
|
|
57
60
|
var _ElementType = require("./utils/ElementType");
|
|
58
61
|
|
package/lib/utils/AuthService.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports.dispatchUser = dispatchUser;
|
|
5
|
+
exports.getIdTokenExpiresIn = getIdTokenExpiresIn;
|
|
5
6
|
exports.getPreLoginPath = getPreLoginPath;
|
|
6
7
|
exports.handleSigninCallback = handleSigninCallback;
|
|
7
8
|
exports.handleSilentRenewCallback = handleSilentRenewCallback;
|
|
@@ -136,6 +137,7 @@ function logout(dispatch, userManagerInstance) {
|
|
|
136
137
|
|
|
137
138
|
return userManagerInstance.getUser().then(function (user) {
|
|
138
139
|
if (user) {
|
|
140
|
+
// We don't need to check if token is valid at this point
|
|
139
141
|
return userManagerInstance.signoutRedirect({
|
|
140
142
|
extraQueryParams: {
|
|
141
143
|
TargetResource: userManagerInstance.settings.post_logout_redirect_uri
|
|
@@ -158,10 +160,24 @@ function logout(dispatch, userManagerInstance) {
|
|
|
158
160
|
});
|
|
159
161
|
}
|
|
160
162
|
|
|
163
|
+
function getIdTokenExpiresIn(user) {
|
|
164
|
+
var now = parseInt(Date.now() / 1000);
|
|
165
|
+
var exp = (0, _jwtDecode["default"])(user.id_token).exp;
|
|
166
|
+
return exp - now;
|
|
167
|
+
}
|
|
168
|
+
|
|
161
169
|
function dispatchUser(dispatch, userManagerInstance, validateUser) {
|
|
162
170
|
return userManagerInstance.getUser().then(function (user) {
|
|
163
171
|
if (user) {
|
|
164
|
-
//
|
|
172
|
+
// If session storage contains a expired token at initialization
|
|
173
|
+
// We do not dispatch the user
|
|
174
|
+
// Our explicit SigninSilent will attempt to connect once
|
|
175
|
+
if (getIdTokenExpiresIn(user) < 0) {
|
|
176
|
+
console.debug('User token is expired and will not be dispatched');
|
|
177
|
+
return;
|
|
178
|
+
} // without validateUser defined, valid user by default
|
|
179
|
+
|
|
180
|
+
|
|
165
181
|
var validateUserPromise = validateUser && validateUser(user) || Promise.resolve(true);
|
|
166
182
|
return validateUserPromise.then(function (valid) {
|
|
167
183
|
if (!valid) {
|
|
@@ -171,15 +187,6 @@ function dispatchUser(dispatch, userManagerInstance, validateUser) {
|
|
|
171
187
|
return dispatch((0, _actions.setUnauthorizedUserInfo)(user === null || user === void 0 ? void 0 : (_user$profile2 = user.profile) === null || _user$profile2 === void 0 ? void 0 : _user$profile2.name, {}));
|
|
172
188
|
}
|
|
173
189
|
|
|
174
|
-
var now = parseInt(Date.now() / 1000);
|
|
175
|
-
var exp = (0, _jwtDecode["default"])(user.id_token).exp;
|
|
176
|
-
var idTokenExpiresIn = exp - now;
|
|
177
|
-
|
|
178
|
-
if (idTokenExpiresIn < 0) {
|
|
179
|
-
console.debug('User token is expired and will not be dispatched');
|
|
180
|
-
return;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
190
|
console.debug('User has been successfully loaded from store.');
|
|
184
191
|
return dispatch((0, _actions.setLoggedUser)(user));
|
|
185
192
|
})["catch"](function (e) {
|
|
@@ -226,13 +233,14 @@ function handleUser(dispatch, userManager, validateUser) {
|
|
|
226
233
|
|
|
227
234
|
window.setTimeout(function () {
|
|
228
235
|
userManager.getUser().then(function (user) {
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
236
|
+
if (!user) {
|
|
237
|
+
console.error("user is null at silent renew error, it shouldn't happen.");
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
var idTokenExpiresIn = getIdTokenExpiresIn(user);
|
|
232
241
|
|
|
233
242
|
if (idTokenExpiresIn < 0) {
|
|
234
|
-
console.log('Error in silent renew, idtoken expired: ' + idTokenExpiresIn + ' => Logging out.', error); //
|
|
235
|
-
// remove the user from our app, but don't sso logout on all other apps
|
|
243
|
+
console.log('Error in silent renew, idtoken expired: ' + idTokenExpiresIn + ' => Logging out.', error); // remove the user from our app, but don't sso logout on all other apps
|
|
236
244
|
|
|
237
245
|
dispatch((0, _actions.setShowAuthenticationRouterLogin)(true)); // logout during token expiration, show login without errors
|
|
238
246
|
|
|
@@ -258,7 +266,11 @@ function handleUser(dispatch, userManager, validateUser) {
|
|
|
258
266
|
console.log('Error in silent renew, unsupported configuration: token still valid for ' + idTokenExpiresIn + ' but maxExpiresIn is not configured:' + userManager.idpSettings.maxExpiresIn, error);
|
|
259
267
|
}
|
|
260
268
|
});
|
|
261
|
-
}, accessTokenExpiringNotificationTime * 1000);
|
|
269
|
+
}, accessTokenExpiringNotificationTime * 1000); // Should be min(accessTokenExpiringNotificationTime * 1000, idTokenExpiresIn) to avoid rare case
|
|
270
|
+
// when user connection is dying and you refresh the page between expiring and expired.
|
|
271
|
+
// but gateway has a DEFAULT_MAX_CLOCK_SKEW = 60s then the token is still valid for this time
|
|
272
|
+
// even if expired
|
|
273
|
+
// We accept to not manage this case further
|
|
262
274
|
});
|
|
263
275
|
console.debug('dispatch user');
|
|
264
276
|
dispatchUser(dispatch, userManager, validateUser);
|
|
@@ -123,9 +123,9 @@ var EQUIPMENT_TYPE = {
|
|
|
123
123
|
};
|
|
124
124
|
exports.EQUIPMENT_TYPE = EQUIPMENT_TYPE;
|
|
125
125
|
|
|
126
|
-
var getEquipmentsInfosForSearchBar = function getEquipmentsInfosForSearchBar(equipmentsInfos,
|
|
126
|
+
var getEquipmentsInfosForSearchBar = function getEquipmentsInfosForSearchBar(equipmentsInfos, getNameOrId) {
|
|
127
127
|
return equipmentsInfos.flatMap(function (e) {
|
|
128
|
-
var label =
|
|
128
|
+
var label = getNameOrId(e);
|
|
129
129
|
return e.type === 'SUBSTATION' ? [{
|
|
130
130
|
label: label,
|
|
131
131
|
id: e.id,
|
|
@@ -137,7 +137,7 @@ var getEquipmentsInfosForSearchBar = function getEquipmentsInfosForSearchBar(equ
|
|
|
137
137
|
id: e.id,
|
|
138
138
|
key: e.id + '_' + vli.id,
|
|
139
139
|
type: e.type,
|
|
140
|
-
voltageLevelLabel:
|
|
140
|
+
voltageLevelLabel: getNameOrId(vli),
|
|
141
141
|
voltageLevelId: vli.id
|
|
142
142
|
};
|
|
143
143
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.equalsArray = equalsArray;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
8
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
9
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
10
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
11
|
+
*/
|
|
12
|
+
function equalsArray(a, b) {
|
|
13
|
+
if (b === a) return true;
|
|
14
|
+
if (!b || !a) return false;
|
|
15
|
+
if (a.length !== b.length) return false;
|
|
16
|
+
|
|
17
|
+
for (var i = 0, l = a.length; i < l; i++) {
|
|
18
|
+
if (a[i] instanceof Array && b[i] instanceof Array) {
|
|
19
|
+
if (!equalsArray(a[i], b[i])) return false;
|
|
20
|
+
} else if (a[i] !== b[i]) {
|
|
21
|
+
// Warning - two different object instances will never be equal: {x:20} != {x:20}
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return true;
|
|
27
|
+
}
|