@gridsuite/commons-ui 0.21.0 → 0.22.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.
@@ -227,6 +227,7 @@ var TopBar = function TopBar(_ref) {
227
227
  onEquipmentLabellingClick = _ref.onEquipmentLabellingClick,
228
228
  equipmentLabelling = _ref.equipmentLabelling,
229
229
  withElementsSearch = _ref.withElementsSearch,
230
+ searchDisabled = _ref.searchDisabled,
230
231
  searchingLabel = _ref.searchingLabel,
231
232
  onSearchTermChange = _ref.onSearchTermChange,
232
233
  _onSelectionChange = _ref.onSelectionChange,
@@ -331,15 +332,20 @@ var TopBar = function TopBar(_ref) {
331
332
  };
332
333
 
333
334
  (0, _react.useEffect)(function () {
334
- if (user && withElementsSearch) {
335
- document.addEventListener('keydown', function (e) {
335
+ if (user && withElementsSearch && !searchDisabled) {
336
+ var openSearch = function openSearch(e) {
336
337
  if (e.ctrlKey && e.key === 'f') {
337
338
  e.preventDefault();
338
339
  setDialogSearchOpen(true);
339
340
  }
340
- });
341
+ };
342
+
343
+ document.addEventListener('keydown', openSearch);
344
+ return function () {
345
+ return document.removeEventListener('keydown', openSearch);
346
+ };
341
347
  }
342
- }, [user, withElementsSearch]);
348
+ }, [user, withElementsSearch, searchDisabled]);
343
349
  return /*#__PURE__*/_react["default"].createElement(_AppBar["default"], {
344
350
  position: "static",
345
351
  color: "default",
@@ -383,7 +389,8 @@ var TopBar = function TopBar(_ref) {
383
389
  renderElement: renderElement
384
390
  }), /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
385
391
  color: "inherit",
386
- onClick: handleClickElementSearch
392
+ onClick: handleClickElementSearch,
393
+ disabled: searchDisabled
387
394
  }, /*#__PURE__*/_react["default"].createElement(_Search["default"], null)))), user && /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
388
395
  "aria-controls": "apps-menu",
389
396
  "aria-haspopup": "true",
@@ -616,6 +623,7 @@ TopBar.propTypes = process.env.NODE_ENV !== "production" ? {
616
623
  onEquipmentLabellingClick: _propTypes["default"].func,
617
624
  equipmentLabelling: _propTypes["default"].bool,
618
625
  withElementsSearch: _propTypes["default"].bool,
626
+ searchDisabled: _propTypes["default"].bool,
619
627
  searchingLabel: _propTypes["default"].string,
620
628
  onSearchTermChange: _propTypes["default"].func,
621
629
  onSelectionChange: _propTypes["default"].func,
@@ -74,10 +74,23 @@ function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings) {
74
74
  var expires_in = parseInt(matched_expires[0].split('=')[1]);
75
75
  var now = parseInt(Date.now() / 1000);
76
76
  var exp = decoded.exp;
77
+ var idTokenExpiresIn = exp - now;
78
+ var minAccesstokenOrIdtokenOrIdpSettingsExpiresIn = expires_in;
79
+ var newExpireReplaceReason;
77
80
 
78
- if (exp < now + expires_in) {
79
- var newhash = window.location.hash.replace(matched_expires[0], 'expires_in=' + (exp - now));
80
- console.debug('Replacing expires_in in window.location.hash because idtoken.exp is earlier. Before: ', window.location.hash, 'after: ', newhash);
81
+ if (idTokenExpiresIn < minAccesstokenOrIdtokenOrIdpSettingsExpiresIn) {
82
+ minAccesstokenOrIdtokenOrIdpSettingsExpiresIn = idTokenExpiresIn;
83
+ newExpireReplaceReason = 'idtoken.exp is earlier';
84
+ }
85
+
86
+ if (idpSettings.maxExpiresIn && idpSettings.maxExpiresIn < minAccesstokenOrIdtokenOrIdpSettingsExpiresIn) {
87
+ minAccesstokenOrIdtokenOrIdpSettingsExpiresIn = idpSettings.maxExpiresIn;
88
+ newExpireReplaceReason = 'idpSettings.maxExpiresIn is smaller';
89
+ }
90
+
91
+ if (newExpireReplaceReason) {
92
+ var newhash = window.location.hash.replace(matched_expires[0], 'expires_in=' + minAccesstokenOrIdtokenOrIdpSettingsExpiresIn);
93
+ 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);
81
94
  window.location.hash = newhash;
82
95
  }
83
96
  }
@@ -119,7 +132,11 @@ function logout(dispatch, userManagerInstance) {
119
132
  dispatch((0, _actions.setLoggedUser)(null));
120
133
  sessionStorage.removeItem(hackauthoritykey); //To remove when hack is removed
121
134
 
122
- return userManagerInstance.signoutRedirect().then(function () {
135
+ return userManagerInstance.signoutRedirect({
136
+ extraQueryParams: {
137
+ TargetResource: userManagerInstance.settings.post_logout_redirect_uri
138
+ }
139
+ }).then(function () {
123
140
  return console.debug('logged out');
124
141
  });
125
142
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.21.0",
3
+ "version": "0.22.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": "<=6",