@gridsuite/commons-ui 0.31.1 → 0.32.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.
Files changed (65) hide show
  1. package/lib/components/AuthenticationRouter/AuthenticationRouter.js +7 -22
  2. package/lib/components/AuthenticationRouter/index.js +0 -4
  3. package/lib/components/CardErrorBoundary/card-error-boundary.js +13 -39
  4. package/lib/components/CardErrorBoundary/index.js +0 -4
  5. package/lib/components/ElementSearchDialog/element-search-dialog.js +18 -29
  6. package/lib/components/ElementSearchDialog/equipment-item.js +12 -22
  7. package/lib/components/ElementSearchDialog/index.js +0 -5
  8. package/lib/components/ElementSearchDialog/tag-renderer.js +8 -13
  9. package/lib/components/FlatParameters/FlatParameters.js +312 -0
  10. package/lib/components/FlatParameters/index.js +8 -0
  11. package/lib/components/Login/Login.js +2 -17
  12. package/lib/components/Login/Logout.js +2 -17
  13. package/lib/components/Login/index.js +0 -4
  14. package/lib/components/MuiVirtualizedTable/ColumnHeader.js +18 -32
  15. package/lib/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +104 -153
  16. package/lib/components/MuiVirtualizedTable/MuiVirtualizedTable.js +63 -189
  17. package/lib/components/MuiVirtualizedTable/index.js +0 -5
  18. package/lib/components/OverflowableText/index.js +0 -4
  19. package/lib/components/OverflowableText/overflowable-text.js +15 -25
  20. package/lib/components/ReportViewer/index.js +0 -4
  21. package/lib/components/ReportViewer/log-report-item.js +11 -22
  22. package/lib/components/ReportViewer/log-report.js +0 -17
  23. package/lib/components/ReportViewer/log-table.js +7 -28
  24. package/lib/components/ReportViewer/report-item.js +9 -22
  25. package/lib/components/ReportViewer/report-tree-view-context.js +1 -4
  26. package/lib/components/ReportViewer/report-viewer.js +18 -47
  27. package/lib/components/ReportViewerDialog/index.js +0 -4
  28. package/lib/components/ReportViewerDialog/report-viewer-dialog.js +6 -25
  29. package/lib/components/SignInCallbackHandler/SignInCallbackHandler.js +2 -6
  30. package/lib/components/SignInCallbackHandler/index.js +0 -4
  31. package/lib/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +2 -6
  32. package/lib/components/SilentRenewCallbackHandler/index.js +0 -4
  33. package/lib/components/SnackbarProvider/SnackbarProvider.js +6 -10
  34. package/lib/components/SnackbarProvider/index.js +0 -4
  35. package/lib/components/TopBar/TopBar.js +38 -101
  36. package/lib/components/TopBar/index.js +0 -4
  37. package/lib/components/TreeViewFinder/TreeViewFinder.js +73 -84
  38. package/lib/components/TreeViewFinder/index.js +0 -4
  39. package/lib/components/translations/card-error-boundary-en.js +1 -1
  40. package/lib/components/translations/card-error-boundary-fr.js +1 -1
  41. package/lib/components/translations/element-search-en.js +1 -1
  42. package/lib/components/translations/element-search-fr.js +1 -1
  43. package/lib/components/translations/equipment-search-en.js +1 -1
  44. package/lib/components/translations/equipment-search-fr.js +1 -1
  45. package/lib/components/translations/login-en.js +1 -1
  46. package/lib/components/translations/login-fr.js +1 -1
  47. package/lib/components/translations/report-viewer-en.js +1 -1
  48. package/lib/components/translations/report-viewer-fr.js +1 -1
  49. package/lib/components/translations/table-en.js +1 -1
  50. package/lib/components/translations/table-fr.js +1 -1
  51. package/lib/components/translations/top-bar-en.js +1 -1
  52. package/lib/components/translations/top-bar-fr.js +1 -1
  53. package/lib/components/translations/treeview-finder-en.js +1 -1
  54. package/lib/components/translations/treeview-finder-fr.js +1 -1
  55. package/lib/hooks/useImportExportParams.js +126 -168
  56. package/lib/hooks/useIntlRef.js +1 -3
  57. package/lib/hooks/useSnackMessage.js +5 -18
  58. package/lib/index.js +5 -76
  59. package/lib/utils/AuthService.js +14 -49
  60. package/lib/utils/ElementType.js +5 -15
  61. package/lib/utils/EquipmentType.js +3 -7
  62. package/lib/utils/UserManagerMock.js +8 -23
  63. package/lib/utils/actions.js +1 -14
  64. package/lib/utils/algos.js +13 -7
  65. package/package.json +5 -2
@@ -9,35 +9,28 @@ exports.initializeAuthenticationDev = initializeAuthenticationDev;
9
9
  exports.initializeAuthenticationProd = initializeAuthenticationProd;
10
10
  exports.login = login;
11
11
  exports.logout = logout;
12
-
13
12
  var _oidcClient = require("oidc-client");
14
-
15
13
  var _UserManagerMock = require("./UserManagerMock");
16
-
17
14
  var _actions = require("./actions");
18
-
19
15
  var _jwtDecode = _interopRequireDefault(require("jwt-decode"));
20
-
21
16
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
22
-
23
17
  /**
24
18
  * Copyright (c) 2020, RTE (http://www.rte-france.com)
25
19
  * This Source Code Form is subject to the terms of the Mozilla Public
26
20
  * License, v. 2.0. If a copy of the MPL was not distributed with this
27
21
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
28
22
  */
23
+
29
24
  // set as a global variable to allow log level configuration at runtime
30
25
  window.OIDCLog = _oidcClient.Log;
31
26
  var hackauthoritykey = 'oidc.hack.authority';
32
27
  var pathKey = 'powsybl-gridsuite-current-path';
33
-
34
28
  function handleSigninSilent(dispatch, userManager) {
35
29
  userManager.getUser().then(function (user) {
36
30
  if (user == null || getIdTokenExpiresIn(user) < 0) {
37
31
  return userManager.signinSilent()["catch"](function (error) {
38
32
  dispatch((0, _actions.setShowAuthenticationRouterLogin)(true));
39
33
  var oidcHackReloaded = 'gridsuite-oidc-hack-reloaded';
40
-
41
34
  if (!sessionStorage.getItem(oidcHackReloaded) && error.message === 'authority mismatch on settings vs. signin state') {
42
35
  sessionStorage.setItem(oidcHackReloaded, true);
43
36
  console.log('Hack oidc, reload page to make login work');
@@ -47,18 +40,14 @@ function handleSigninSilent(dispatch, userManager) {
47
40
  }
48
41
  });
49
42
  }
50
-
51
43
  function initializeAuthenticationDev(dispatch, isSilentRenew, validateUser) {
52
44
  var userManager = new _UserManagerMock.UserManagerMock({});
53
-
54
45
  if (!isSilentRenew) {
55
46
  handleUser(dispatch, userManager, validateUser);
56
47
  handleSigninSilent(dispatch, userManager);
57
48
  }
58
-
59
49
  return Promise.resolve(userManager);
60
50
  }
61
-
62
51
  var accessTokenExpiringNotificationTime = 60; // seconds
63
52
 
64
53
  function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings, validateUser) {
@@ -70,16 +59,13 @@ function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings, vali
70
59
  var regexstate = /state=[^&]*/;
71
60
  var regexexpires = /expires_in=[^&]*/;
72
61
  var authority;
73
-
74
62
  if (window.location.hash) {
75
63
  var matched_id_token = window.location.hash.match(regextoken);
76
64
  var matched_state = window.location.hash.match(regexstate);
77
-
78
65
  if (matched_id_token != null && matched_state != null) {
79
66
  var id_token = matched_id_token[0].split('=')[1];
80
67
  var state = matched_state[0].split('=')[1];
81
68
  var strState = localStorage.getItem('oidc.' + state);
82
-
83
69
  if (strState != null) {
84
70
  var decoded = (0, _jwtDecode["default"])(id_token);
85
71
  authority = decoded.iss;
@@ -89,7 +75,6 @@ function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings, vali
89
75
  localStorage.setItem('oidc.' + state, JSON.stringify(storedState));
90
76
  sessionStorage.setItem(hackauthoritykey, authority);
91
77
  var matched_expires = window.location.hash.match(regexexpires);
92
-
93
78
  if (matched_expires != null) {
94
79
  var expires_in = parseInt(matched_expires[0].split('=')[1]);
95
80
  var now = parseInt(Date.now() / 1000);
@@ -97,17 +82,14 @@ function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings, vali
97
82
  var idTokenExpiresIn = exp - now;
98
83
  var minAccesstokenOrIdtokenOrIdpSettingsExpiresIn = expires_in;
99
84
  var newExpireReplaceReason;
100
-
101
85
  if (idTokenExpiresIn < minAccesstokenOrIdtokenOrIdpSettingsExpiresIn) {
102
86
  minAccesstokenOrIdtokenOrIdpSettingsExpiresIn = idTokenExpiresIn;
103
87
  newExpireReplaceReason = 'idtoken.exp is earlier';
104
88
  }
105
-
106
89
  if (idpSettings.maxExpiresIn && idpSettings.maxExpiresIn < minAccesstokenOrIdtokenOrIdpSettingsExpiresIn) {
107
90
  minAccesstokenOrIdtokenOrIdpSettingsExpiresIn = idpSettings.maxExpiresIn;
108
91
  newExpireReplaceReason = 'idpSettings.maxExpiresIn is smaller';
109
92
  }
110
-
111
93
  if (newExpireReplaceReason) {
112
94
  var newhash = window.location.hash.replace(matched_expires[0], 'expires_in=' + minAccesstokenOrIdtokenOrIdpSettingsExpiresIn);
113
95
  console.debug('Replacing expires_in in window.location.hash to ' + minAccesstokenOrIdtokenOrIdpSettingsExpiresIn + ' because ' + newExpireReplaceReason + '. ', 'debug:', 'original expires_in: ' + expires_in + ', ', 'idTokenExpiresIn: ' + idTokenExpiresIn + '(idtoken exp: ' + exp + '), ', 'idpSettings maxExpiresIn: ' + idpSettings.maxExpiresIn);
@@ -117,7 +99,6 @@ function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings, vali
117
99
  }
118
100
  }
119
101
  }
120
-
121
102
  authority = authority || sessionStorage.getItem(hackauthoritykey) || idpSettings.authority;
122
103
  var settings = {
123
104
  authority: authority,
@@ -133,12 +114,10 @@ function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings, vali
133
114
  };
134
115
  var userManager = new _oidcClient.UserManager(settings);
135
116
  userManager.idpSettings = idpSettings; //store our settings in there as well to use it later
136
-
137
117
  if (!isSilentRenew) {
138
118
  handleUser(dispatch, userManager, validateUser);
139
119
  handleSigninSilent(dispatch, userManager);
140
120
  }
141
-
142
121
  return userManager;
143
122
  })["catch"](function (error) {
144
123
  console.debug('error when importing the idp settings', error);
@@ -146,17 +125,14 @@ function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings, vali
146
125
  throw error;
147
126
  });
148
127
  }
149
-
150
128
  function login(location, userManagerInstance) {
151
129
  sessionStorage.setItem(pathKey, location.pathname + location.search);
152
130
  return userManagerInstance.signinRedirect().then(function () {
153
131
  return console.debug('login');
154
132
  });
155
133
  }
156
-
157
134
  function logout(dispatch, userManagerInstance) {
158
135
  sessionStorage.removeItem(hackauthoritykey); //To remove when hack is removed
159
-
160
136
  return userManagerInstance.getUser().then(function (user) {
161
137
  if (user) {
162
138
  // We don't need to check if token is valid at this point
@@ -168,9 +144,8 @@ function logout(dispatch, userManagerInstance) {
168
144
  console.debug('logged out, window is closing...');
169
145
  })["catch"](function (e) {
170
146
  var _user$profile;
171
-
172
- console.log('Error during logout :', e); // An error occured, window may not be closed, reset the user state
173
-
147
+ console.log('Error during logout :', e);
148
+ // An error occured, window may not be closed, reset the user state
174
149
  dispatch((0, _actions.setLoggedUser)(null));
175
150
  dispatch((0, _actions.setLogoutError)(user === null || user === void 0 ? void 0 : (_user$profile = user.profile) === null || _user$profile === void 0 ? void 0 : _user$profile.name, {
176
151
  error: e
@@ -181,13 +156,11 @@ function logout(dispatch, userManagerInstance) {
181
156
  }
182
157
  });
183
158
  }
184
-
185
159
  function getIdTokenExpiresIn(user) {
186
160
  var now = parseInt(Date.now() / 1000);
187
161
  var exp = (0, _jwtDecode["default"])(user.id_token).exp;
188
162
  return exp - now;
189
163
  }
190
-
191
164
  function dispatchUser(dispatch, userManagerInstance, validateUser) {
192
165
  return userManagerInstance.getUser().then(function (user) {
193
166
  if (user) {
@@ -197,23 +170,19 @@ function dispatchUser(dispatch, userManagerInstance, validateUser) {
197
170
  if (getIdTokenExpiresIn(user) < 0) {
198
171
  console.debug('User token is expired and will not be dispatched');
199
172
  return;
200
- } // without validateUser defined, valid user by default
201
-
202
-
173
+ }
174
+ // without validateUser defined, valid user by default
203
175
  var validateUserPromise = validateUser && validateUser(user) || Promise.resolve(true);
204
176
  return validateUserPromise.then(function (valid) {
205
177
  if (!valid) {
206
178
  var _user$profile2;
207
-
208
179
  console.debug("User isn't authorized to log in and will not be dispatched");
209
180
  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, {}));
210
181
  }
211
-
212
182
  console.debug('User has been successfully loaded from store.');
213
183
  return dispatch((0, _actions.setLoggedUser)(user));
214
184
  })["catch"](function (e) {
215
185
  var _user$profile3;
216
-
217
186
  console.log('Error in dispatchUser', e);
218
187
  return dispatch((0, _actions.setUserValidationError)(user === null || user === void 0 ? void 0 : (_user$profile3 = user.profile) === null || _user$profile3 === void 0 ? void 0 : _user$profile3.name, {
219
188
  error: e
@@ -224,11 +193,9 @@ function dispatchUser(dispatch, userManagerInstance, validateUser) {
224
193
  }
225
194
  });
226
195
  }
227
-
228
196
  function getPreLoginPath() {
229
197
  return sessionStorage.getItem(pathKey);
230
198
  }
231
-
232
199
  function handleSigninCallback(dispatch, navigate, userManagerInstance) {
233
200
  userManagerInstance.signinRedirectCallback().then(function () {
234
201
  dispatch((0, _actions.setSignInCallbackError)(null));
@@ -239,33 +206,29 @@ function handleSigninCallback(dispatch, navigate, userManagerInstance) {
239
206
  console.error(e);
240
207
  });
241
208
  }
242
-
243
209
  function handleSilentRenewCallback(userManagerInstance) {
244
210
  userManagerInstance.signinSilentCallback();
245
211
  }
246
-
247
212
  function handleUser(dispatch, userManager, validateUser) {
248
213
  userManager.events.addUserLoaded(function (user) {
249
214
  console.debug('user loaded', user);
250
215
  dispatchUser(dispatch, userManager, validateUser);
251
216
  });
252
217
  userManager.events.addSilentRenewError(function (error) {
253
- console.debug(error); // wait for accessTokenExpiringNotificationTime so that the user is expired
218
+ console.debug(error);
219
+ // wait for accessTokenExpiringNotificationTime so that the user is expired
254
220
  // otherwise the library tries to signin immediately when we do getUser()
255
-
256
221
  window.setTimeout(function () {
257
222
  userManager.getUser().then(function (user) {
258
223
  if (!user) {
259
224
  console.error("user is null at silent renew error, it shouldn't happen.");
260
225
  }
261
-
262
226
  var idTokenExpiresIn = getIdTokenExpiresIn(user);
263
-
264
227
  if (idTokenExpiresIn < 0) {
265
- 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
266
-
267
- dispatch((0, _actions.setShowAuthenticationRouterLogin)(true)); // logout during token expiration, show login without errors
268
-
228
+ console.log('Error in silent renew, idtoken expired: ' + idTokenExpiresIn + ' => Logging out.', error);
229
+ // remove the user from our app, but don't sso logout on all other apps
230
+ dispatch((0, _actions.setShowAuthenticationRouterLogin)(true));
231
+ // logout during token expiration, show login without errors
269
232
  dispatch((0, _actions.resetAuthenticationRouterError)());
270
233
  return dispatch((0, _actions.setLoggedUser)(null));
271
234
  } else if (userManager.idpSettings.maxExpiresIn) {
@@ -288,12 +251,14 @@ function handleUser(dispatch, userManager, validateUser) {
288
251
  console.log('Error in silent renew, unsupported configuration: token still valid for ' + idTokenExpiresIn + ' but maxExpiresIn is not configured:' + userManager.idpSettings.maxExpiresIn, error);
289
252
  }
290
253
  });
291
- }, accessTokenExpiringNotificationTime * 1000); // Should be min(accessTokenExpiringNotificationTime * 1000, idTokenExpiresIn) to avoid rare case
254
+ }, accessTokenExpiringNotificationTime * 1000);
255
+ // Should be min(accessTokenExpiringNotificationTime * 1000, idTokenExpiresIn) to avoid rare case
292
256
  // when user connection is dying and you refresh the page between expiring and expired.
293
257
  // but gateway has a DEFAULT_MAX_CLOCK_SKEW = 60s then the token is still valid for this time
294
258
  // even if expired
295
259
  // We accept to not manage this case further
296
260
  });
261
+
297
262
  console.debug('dispatch user');
298
263
  dispatchUser(dispatch, userManager, validateUser);
299
264
  }
@@ -3,23 +3,18 @@
3
3
  exports.__esModule = true;
4
4
  exports.elementType = void 0;
5
5
  exports.getFileIcon = getFileIcon;
6
-
7
6
  var _react = _interopRequireDefault(require("react"));
8
-
9
7
  var _LibraryBooksOutlined = _interopRequireDefault(require("@mui/icons-material/LibraryBooksOutlined"));
10
-
11
- var _Description = _interopRequireDefault(require("@mui/icons-material/Description"));
12
-
13
- var _FilterList = _interopRequireDefault(require("@mui/icons-material/FilterList"));
14
-
8
+ var _OfflineBolt = _interopRequireDefault(require("@mui/icons-material/OfflineBolt"));
9
+ var _Article = _interopRequireDefault(require("@mui/icons-material/Article"));
15
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
16
-
17
11
  /**
18
12
  * Copyright (c) 2021, RTE (http://www.rte-france.com)
19
13
  * This Source Code Form is subject to the terms of the Mozilla Public
20
14
  * License, v. 2.0. If a copy of the MPL was not distributed with this
21
15
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
22
16
  */
17
+
23
18
  var elementType = {
24
19
  DIRECTORY: 'DIRECTORY',
25
20
  STUDY: 'STUDY',
@@ -27,28 +22,23 @@ var elementType = {
27
22
  CONTINGENCY_LIST: 'CONTINGENCY_LIST'
28
23
  };
29
24
  exports.elementType = elementType;
30
-
31
25
  function getFileIcon(type, theme) {
32
26
  switch (type) {
33
27
  case elementType.STUDY:
34
28
  return /*#__PURE__*/_react["default"].createElement(_LibraryBooksOutlined["default"], {
35
29
  className: theme
36
30
  });
37
-
38
31
  case elementType.CONTINGENCY_LIST:
39
- return /*#__PURE__*/_react["default"].createElement(_Description["default"], {
32
+ return /*#__PURE__*/_react["default"].createElement(_OfflineBolt["default"], {
40
33
  className: theme
41
34
  });
42
-
43
35
  case elementType.FILTER:
44
- return /*#__PURE__*/_react["default"].createElement(_FilterList["default"], {
36
+ return /*#__PURE__*/_react["default"].createElement(_Article["default"], {
45
37
  className: theme
46
38
  });
47
-
48
39
  case elementType.DIRECTORY:
49
40
  // to easily use in TreeView we do not give icons for directories
50
41
  return;
51
-
52
42
  default:
53
43
  console.warn('unknown type [' + type + ']');
54
44
  }
@@ -2,20 +2,18 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.getEquipmentsInfosForSearchBar = exports.equipmentStyles = exports.VL_TAG_MAX_SIZE = exports.TYPE_TAG_MAX_SIZE = exports.EQUIPMENT_TYPE = void 0;
5
-
6
5
  var _TopBar = require("../components/TopBar/TopBar");
7
-
8
6
  /**
9
7
  * Copyright (c) 2021, RTE (http://www.rte-france.com)
10
8
  * This Source Code Form is subject to the terms of the Mozilla Public
11
9
  * License, v. 2.0. If a copy of the MPL was not distributed with this
12
10
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
13
11
  */
12
+
14
13
  var TYPE_TAG_MAX_SIZE = '90px';
15
14
  exports.TYPE_TAG_MAX_SIZE = TYPE_TAG_MAX_SIZE;
16
15
  var VL_TAG_MAX_SIZE = '100px';
17
16
  exports.VL_TAG_MAX_SIZE = VL_TAG_MAX_SIZE;
18
-
19
17
  var equipmentStyles = function equipmentStyles(theme) {
20
18
  return {
21
19
  equipmentOption: {
@@ -51,9 +49,9 @@ var equipmentStyles = function equipmentStyles(theme) {
51
49
  padding: '2px'
52
50
  }
53
51
  };
54
- }; // Must be equivalent as the back enum
55
-
52
+ };
56
53
 
54
+ // Must be equivalent as the back enum
57
55
  exports.equipmentStyles = equipmentStyles;
58
56
  var EQUIPMENT_TYPE = {
59
57
  SUBSTATION: {
@@ -122,7 +120,6 @@ var EQUIPMENT_TYPE = {
122
120
  }
123
121
  };
124
122
  exports.EQUIPMENT_TYPE = EQUIPMENT_TYPE;
125
-
126
123
  var getEquipmentsInfosForSearchBar = function getEquipmentsInfosForSearchBar(equipmentsInfos, getNameOrId) {
127
124
  return equipmentsInfos.flatMap(function (e) {
128
125
  var label = getNameOrId(e);
@@ -143,5 +140,4 @@ var getEquipmentsInfosForSearchBar = function getEquipmentsInfosForSearchBar(equ
143
140
  });
144
141
  });
145
142
  };
146
-
147
143
  exports.getEquipmentsInfosForSearchBar = getEquipmentsInfosForSearchBar;
@@ -2,9 +2,9 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.UserManagerMock = void 0;
5
-
6
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
7
-
5
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
6
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
7
+ function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
8
8
  /**
9
9
  * Copyright (c) 2020, RTE (http://www.rte-france.com)
10
10
  * This Source Code Form is subject to the terms of the Mozilla Public
@@ -15,25 +15,19 @@ var Events = /*#__PURE__*/function () {
15
15
  function Events() {
16
16
  _defineProperty(this, "userLoadedCallbacks", []);
17
17
  }
18
-
19
18
  var _proto = Events.prototype;
20
-
21
19
  _proto.addUserLoaded = function addUserLoaded(callback) {
22
20
  this.userLoadedCallbacks.push(callback);
23
21
  };
24
-
25
- _proto.addSilentRenewError = function addSilentRenewError(callback) {// Nothing to do
22
+ _proto.addSilentRenewError = function addSilentRenewError(callback) {
23
+ // Nothing to do
26
24
  };
27
-
28
25
  return Events;
29
26
  }();
30
-
31
27
  var UserManagerMock = /*#__PURE__*/function () {
32
28
  function UserManagerMock(settings) {
33
29
  _defineProperty(this, "settings", void 0);
34
-
35
30
  _defineProperty(this, "events", void 0);
36
-
37
31
  _defineProperty(this, "user", {
38
32
  profile: {
39
33
  name: 'John Doe',
@@ -45,57 +39,48 @@ var UserManagerMock = /*#__PURE__*/function () {
45
39
  token_type: 'Bearer',
46
40
  scope: 'scopes'
47
41
  });
48
-
49
42
  this.settings = settings;
50
43
  this.events = new Events();
51
44
  }
52
-
53
45
  var _proto2 = UserManagerMock.prototype;
54
-
55
46
  _proto2.getUser = function getUser() {
56
47
  return Promise.resolve(JSON.parse(sessionStorage.getItem('powsybl-gridsuite-mock-user')));
57
48
  };
58
-
59
49
  _proto2.signinSilent = function signinSilent() {
60
50
  console.info('signinSilent..............');
61
51
  var localStorageUser = JSON.parse(localStorage.getItem('powsybl-gridsuite-mock-user'));
62
- if (localStorageUser === null) return Promise.reject(new Error('End-User authentication required'));
52
+ if (localStorageUser === null) {
53
+ return Promise.reject(new Error('End-User authentication required'));
54
+ }
63
55
  sessionStorage.setItem('powsybl-gridsuite-mock-user', JSON.stringify(localStorageUser));
64
56
  this.events.userLoadedCallbacks.forEach(function (c) {
65
57
  return c(localStorageUser);
66
58
  });
67
59
  return Promise.resolve(localStorageUser);
68
60
  };
69
-
70
61
  _proto2.signinSilentCallback = function signinSilentCallback() {
71
62
  console.error('Unsupported, iframe signinSilentCallback in UserManagerMock (dev mode)');
72
63
  return Promise.reject();
73
64
  };
74
-
75
65
  _proto2.signinRedirect = function signinRedirect() {
76
66
  localStorage.setItem('powsybl-gridsuite-mock-user', JSON.stringify(this.user));
77
67
  window.location = './sign-in-callback';
78
68
  return Promise.resolve(null);
79
69
  };
80
-
81
70
  _proto2.signoutRedirect = function signoutRedirect() {
82
71
  sessionStorage.removeItem('powsybl-gridsuite-mock-user');
83
72
  localStorage.removeItem('powsybl-gridsuite-mock-user');
84
73
  window.location = '.';
85
74
  return Promise.resolve(null);
86
75
  };
87
-
88
76
  _proto2.signinRedirectCallback = function signinRedirectCallback() {
89
77
  var _this = this;
90
-
91
78
  sessionStorage.setItem('powsybl-gridsuite-mock-user', JSON.stringify(this.user));
92
79
  this.events.userLoadedCallbacks.forEach(function (c) {
93
80
  return c(_this.user);
94
81
  });
95
82
  return Promise.resolve('');
96
83
  };
97
-
98
84
  return UserManagerMock;
99
85
  }();
100
-
101
86
  exports.UserManagerMock = UserManagerMock;
@@ -9,36 +9,31 @@ exports.setShowAuthenticationRouterLogin = setShowAuthenticationRouterLogin;
9
9
  exports.setSignInCallbackError = setSignInCallbackError;
10
10
  exports.setUnauthorizedUserInfo = setUnauthorizedUserInfo;
11
11
  exports.setUserValidationError = setUserValidationError;
12
-
13
12
  /**
14
13
  * Copyright (c) 2020, RTE (http://www.rte-france.com)
15
14
  * This Source Code Form is subject to the terms of the Mozilla Public
16
15
  * License, v. 2.0. If a copy of the MPL was not distributed with this
17
16
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
18
17
  */
18
+
19
19
  var USER = 'USER';
20
20
  exports.USER = USER;
21
-
22
21
  function setLoggedUser(user) {
23
22
  return {
24
23
  type: USER,
25
24
  user: user
26
25
  };
27
26
  }
28
-
29
27
  var SIGNIN_CALLBACK_ERROR = 'SIGNIN_CALLBACK_ERROR';
30
28
  exports.SIGNIN_CALLBACK_ERROR = SIGNIN_CALLBACK_ERROR;
31
-
32
29
  function setSignInCallbackError(signInCallbackError) {
33
30
  return {
34
31
  type: SIGNIN_CALLBACK_ERROR,
35
32
  signInCallbackError: signInCallbackError
36
33
  };
37
34
  }
38
-
39
35
  var UNAUTHORIZED_USER_INFO = 'UNAUTHORIZED_USER_INFO';
40
36
  exports.UNAUTHORIZED_USER_INFO = UNAUTHORIZED_USER_INFO;
41
-
42
37
  function setUnauthorizedUserInfo(userName, unauthorizedUserInfo) {
43
38
  return {
44
39
  type: UNAUTHORIZED_USER_INFO,
@@ -48,10 +43,8 @@ function setUnauthorizedUserInfo(userName, unauthorizedUserInfo) {
48
43
  }
49
44
  };
50
45
  }
51
-
52
46
  var LOGOUT_ERROR = 'LOGOUT_ERROR';
53
47
  exports.LOGOUT_ERROR = LOGOUT_ERROR;
54
-
55
48
  function setLogoutError(userName, logoutError) {
56
49
  return {
57
50
  type: LOGOUT_ERROR,
@@ -61,10 +54,8 @@ function setLogoutError(userName, logoutError) {
61
54
  }
62
55
  };
63
56
  }
64
-
65
57
  var USER_VALIDATION_ERROR = 'USER_VALIDATION_ERROR';
66
58
  exports.USER_VALIDATION_ERROR = USER_VALIDATION_ERROR;
67
-
68
59
  function setUserValidationError(userName, userValidationError) {
69
60
  return {
70
61
  type: USER_VALIDATION_ERROR,
@@ -74,20 +65,16 @@ function setUserValidationError(userName, userValidationError) {
74
65
  }
75
66
  };
76
67
  }
77
-
78
68
  var RESET_AUTHENTICATION_ROUTER_ERROR = 'RESET_AUTHENTICATION_ROUTER_ERROR';
79
69
  exports.RESET_AUTHENTICATION_ROUTER_ERROR = RESET_AUTHENTICATION_ROUTER_ERROR;
80
-
81
70
  function resetAuthenticationRouterError() {
82
71
  return {
83
72
  type: RESET_AUTHENTICATION_ROUTER_ERROR,
84
73
  authenticationRouterError: null
85
74
  };
86
75
  }
87
-
88
76
  var SHOW_AUTH_INFO_LOGIN = 'SHOW_AUTH_INFO_LOGIN';
89
77
  exports.SHOW_AUTH_INFO_LOGIN = SHOW_AUTH_INFO_LOGIN;
90
-
91
78
  function setShowAuthenticationRouterLogin(showAuthenticationRouterLogin) {
92
79
  return {
93
80
  type: SHOW_AUTH_INFO_LOGIN,
@@ -2,26 +2,32 @@
2
2
 
3
3
  exports.__esModule = true;
4
4
  exports.equalsArray = equalsArray;
5
-
6
5
  /**
7
6
  * Copyright (c) 2022, RTE (http://www.rte-france.com)
8
7
  * This Source Code Form is subject to the terms of the Mozilla Public
9
8
  * License, v. 2.0. If a copy of the MPL was not distributed with this
10
9
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
11
10
  */
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
11
 
12
+ function equalsArray(a, b) {
13
+ if (b === a) {
14
+ return true;
15
+ }
16
+ if (!b || !a) {
17
+ return false;
18
+ }
19
+ if (a.length !== b.length) {
20
+ return false;
21
+ }
17
22
  for (var i = 0, l = a.length; i < l; i++) {
18
23
  if (a[i] instanceof Array && b[i] instanceof Array) {
19
- if (!equalsArray(a[i], b[i])) return false;
24
+ if (!equalsArray(a[i], b[i])) {
25
+ return false;
26
+ }
20
27
  } else if (a[i] !== b[i]) {
21
28
  // Warning - two different object instances will never be equal: {x:20} != {x:20}
22
29
  return false;
23
30
  }
24
31
  }
25
-
26
32
  return true;
27
33
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.31.1",
3
+ "version": "0.32.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": "<=6",
@@ -77,7 +77,9 @@
77
77
  "react-router-dom": "^6.0.0",
78
78
  "type-fest": "^2.0.0",
79
79
  "utf-8-validate": "^5.0.2",
80
- "webpack-plugin-serve": "^1.0.1"
80
+ "webpack-plugin-serve": "^1.0.1",
81
+ "@react-hook/window-size": "^3.1.1",
82
+ "react-resizable": "^3.0.4"
81
83
  },
82
84
  "eslintConfig": {
83
85
  "extends": [
@@ -86,6 +88,7 @@
86
88
  ],
87
89
  "rules": {
88
90
  "prettier/prettier": "warn",
91
+ "curly": "error",
89
92
  "import/no-webpack-loader-syntax": "off"
90
93
  }
91
94
  },