@gridsuite/commons-ui 0.22.0 → 0.24.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.
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+
6
+ var React = _interopRequireWildcard(require("react"));
7
+
8
+ var _Box = _interopRequireDefault(require("@mui/material/Box"));
9
+
10
+ var _Card = _interopRequireDefault(require("@mui/material/Card"));
11
+
12
+ var _CardHeader = _interopRequireDefault(require("@mui/material/CardHeader"));
13
+
14
+ var _CardContent = _interopRequireDefault(require("@mui/material/CardContent"));
15
+
16
+ var _CardActions = _interopRequireDefault(require("@mui/material/CardActions"));
17
+
18
+ var _Collapse = _interopRequireDefault(require("@mui/material/Collapse"));
19
+
20
+ var _IconButton = _interopRequireDefault(require("@mui/material/IconButton"));
21
+
22
+ var _ExpandMore = _interopRequireDefault(require("@mui/icons-material/ExpandMore"));
23
+
24
+ var _Replay = _interopRequireDefault(require("@mui/icons-material/Replay"));
25
+
26
+ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
27
+
28
+ var _styles = require("@mui/material/styles");
29
+
30
+ var _reactIntl = require("react-intl");
31
+
32
+ var _excluded = ["expand"];
33
+
34
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
35
+
36
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
+
38
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
39
+
40
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
41
+
42
+ function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
43
+
44
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
45
+
46
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
47
+
48
+ var ExpandMore = (0, _styles.styled)(function (props) {
49
+ var expand = props.expand,
50
+ other = _objectWithoutPropertiesLoose(props, _excluded);
51
+
52
+ return /*#__PURE__*/React.createElement(_IconButton["default"], other);
53
+ })(function (_ref) {
54
+ var theme = _ref.theme,
55
+ expand = _ref.expand;
56
+ return {
57
+ transform: !expand ? 'rotate(0deg)' : 'rotate(180deg)',
58
+ marginLeft: 'auto',
59
+ transition: theme.transitions.create('transform', {
60
+ duration: theme.transitions.duration.shortest
61
+ })
62
+ };
63
+ });
64
+
65
+ var CardErrorBoundary = /*#__PURE__*/function (_React$Component) {
66
+ _inheritsLoose(CardErrorBoundary, _React$Component);
67
+
68
+ function CardErrorBoundary(props) {
69
+ var _this;
70
+
71
+ _this = _React$Component.call(this, props) || this;
72
+ _this.state = {
73
+ hasError: false,
74
+ expanded: false,
75
+ error: undefined
76
+ };
77
+ _this.handleExpandClick = _this.handleExpandClick.bind(_assertThisInitialized(_this));
78
+ _this.handleReloadClick = _this.handleReloadClick.bind(_assertThisInitialized(_this));
79
+ return _this;
80
+ }
81
+
82
+ CardErrorBoundary.getDerivedStateFromError = function getDerivedStateFromError(error) {
83
+ // Update state so the next render will show the fallback UI.
84
+ return {
85
+ hasError: true,
86
+ error: error
87
+ };
88
+ };
89
+
90
+ var _proto = CardErrorBoundary.prototype;
91
+
92
+ _proto.componentDidCatch = function componentDidCatch(error, errorInfo) {
93
+ // You can also log the error to an error reporting service
94
+ console.error('CardErrorBoundary caught: ', error, errorInfo);
95
+ };
96
+
97
+ _proto.handleExpandClick = function handleExpandClick() {
98
+ this.setState(function (state) {
99
+ return {
100
+ expanded: !state.expanded
101
+ };
102
+ });
103
+ };
104
+
105
+ _proto.handleReloadClick = function handleReloadClick() {
106
+ this.setState(function (state) {
107
+ return {
108
+ hasError: false,
109
+ expanded: false,
110
+ error: undefined
111
+ };
112
+ });
113
+ };
114
+
115
+ _proto.render = function render() {
116
+ if (this.state.hasError) {
117
+ var _this$state = this.state,
118
+ error = _this$state.error,
119
+ expanded = _this$state.expanded;
120
+ return /*#__PURE__*/React.createElement(_Box["default"], {
121
+ sx: {
122
+ p: 4
123
+ }
124
+ }, /*#__PURE__*/React.createElement(_Card["default"], {
125
+ sx: {
126
+ mx: 'auto',
127
+ maxWidth: 600
128
+ }
129
+ }, /*#__PURE__*/React.createElement(_CardHeader["default"], {
130
+ title: /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, {
131
+ id: "card_error_boundary/title",
132
+ defaultMessage: "Sorry, Unexpected error :("
133
+ })
134
+ }), /*#__PURE__*/React.createElement(_CardContent["default"], null, /*#__PURE__*/React.createElement(_Typography["default"], {
135
+ variant: "body2",
136
+ color: "text.secondary"
137
+ }, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, {
138
+ id: "card_error_boundary/content",
139
+ defaultMessage: "Please reload, or close and reopen this application, or contact support."
140
+ }))), /*#__PURE__*/React.createElement(_CardActions["default"], {
141
+ disableSpacing: true
142
+ }, /*#__PURE__*/React.createElement(_IconButton["default"], {
143
+ onClick: this.handleReloadClick,
144
+ "aria-label": "reload"
145
+ }, /*#__PURE__*/React.createElement(_Replay["default"], null)), /*#__PURE__*/React.createElement(ExpandMore, {
146
+ expand: expanded,
147
+ onClick: this.handleExpandClick,
148
+ "aria-expanded": expanded,
149
+ "aria-label": "show more"
150
+ }, /*#__PURE__*/React.createElement(_ExpandMore["default"], null))), /*#__PURE__*/React.createElement(_Collapse["default"], {
151
+ "in": expanded
152
+ }, /*#__PURE__*/React.createElement(_CardContent["default"], null, /*#__PURE__*/React.createElement(_Typography["default"], {
153
+ variant: "body2",
154
+ color: "text.secondary"
155
+ }, /*#__PURE__*/React.createElement(_reactIntl.FormattedMessage, {
156
+ id: "card_error_boundary/expandederrorheader",
157
+ defaultMessage: "Error message (and see more information in the developper console):"
158
+ })), /*#__PURE__*/React.createElement(_Typography["default"], {
159
+ variant: "caption"
160
+ }, error.message)))));
161
+ }
162
+
163
+ return this.props.children;
164
+ };
165
+
166
+ return CardErrorBoundary;
167
+ }(React.Component);
168
+
169
+ var _default = CardErrorBoundary;
170
+ exports["default"] = _default;
171
+ module.exports = exports.default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+
6
+ var _cardErrorBoundary = _interopRequireDefault(require("./card-error-boundary.js"));
7
+
8
+ exports["default"] = _cardErrorBoundary["default"];
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+
12
+ module.exports = exports.default;
@@ -33,21 +33,16 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
33
33
  elementsFound = props.elementsFound,
34
34
  renderElement = props.renderElement;
35
35
 
36
- var _useState = (0, _react.useState)([]),
37
- elements = _useState[0],
38
- setElements = _useState[1];
36
+ var _useState = (0, _react.useState)(false),
37
+ expanded = _useState[0],
38
+ setExpanded = _useState[1];
39
39
 
40
40
  var _useState2 = (0, _react.useState)(false),
41
- expanded = _useState2[0],
42
- setExpanded = _useState2[1];
43
-
44
- var _useState3 = (0, _react.useState)(false),
45
- loading = _useState3[0],
46
- setLoading = _useState3[1];
41
+ loading = _useState2[0],
42
+ setLoading = _useState2[1];
47
43
 
48
44
  (0, _react.useEffect)(function () {
49
45
  setLoading(false);
50
- setElements(elementsFound);
51
46
  }, [elementsFound]);
52
47
 
53
48
  var handleSearchTermChange = function handleSearchTermChange(term) {
@@ -56,14 +51,12 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
56
51
  onSearchTermChange(term);
57
52
  setExpanded(true);
58
53
  } else {
59
- setElements([]);
60
54
  setExpanded(false);
61
55
  }
62
56
  };
63
57
 
64
58
  var handleClose = (0, _react.useCallback)(function () {
65
59
  setExpanded(false);
66
- setElements([]);
67
60
  onClose();
68
61
  }, [onClose]);
69
62
  return /*#__PURE__*/_react["default"].createElement(_material.Dialog, {
@@ -76,9 +69,6 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
76
69
  id: "element-search",
77
70
  forcePopupIcon: false,
78
71
  open: expanded,
79
- onOpen: function onOpen() {
80
- setElements([]);
81
- },
82
72
  onClose: function onClose() {
83
73
  setExpanded(false);
84
74
  },
@@ -95,7 +85,7 @@ var ElementSearchDialog = function ElementSearchDialog(props) {
95
85
  isOptionEqualToValue: function isOptionEqualToValue(option, value) {
96
86
  return option.id === value.id;
97
87
  },
98
- options: elements,
88
+ options: loading ? [] : elementsFound,
99
89
  loading: loading,
100
90
  autoHighlight: true,
101
91
  noOptionsText: intl.formatMessage({
@@ -27,6 +27,8 @@ var _reactIntl = require("react-intl");
27
27
 
28
28
  var _withStyles = _interopRequireDefault(require("@mui/styles/withStyles"));
29
29
 
30
+ var _overflowableText = _interopRequireDefault(require("../OverflowableText/overflowable-text"));
31
+
30
32
  var _excluded = ["name", "classes", "rows", "columns", "rowHeight", "headerHeight", "rowCount", "sortable", "enableExportCSV"],
31
33
  _excluded2 = ["dataKey"];
32
34
 
@@ -93,7 +95,11 @@ var defaultStyles = {
93
95
  fontWeight: 'bold'
94
96
  },
95
97
  rowBackgroundDark: {},
96
- rowBackgroundLight: {}
98
+ rowBackgroundLight: {},
99
+ cellTooltip: {
100
+ maxWidth: '1260px',
101
+ fontSize: '0.9rem'
102
+ }
97
103
  };
98
104
 
99
105
  var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
@@ -241,7 +247,8 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
241
247
  className: (0, _clsx3["default"])(classes.tableCell, classes.flexContainer, (_clsx2 = {}, _clsx2[classes.noClick] = displayedValue === undefined || onCellClick == null || columns[columnIndex].clickable === undefined || !columns[columnIndex].clickable, _clsx2[classes.tableCellColor] = displayedValue === undefined || onCellClick !== null && columns[columnIndex].clickable !== undefined && columns[columnIndex].clickable, _clsx2)),
242
248
  variant: "body",
243
249
  style: {
244
- height: rowHeight
250
+ height: rowHeight,
251
+ width: '100%'
245
252
  },
246
253
  align: columnIndex != null && columns[columnIndex].numeric || false ? 'right' : 'left',
247
254
  onClick: function onClick() {
@@ -249,7 +256,10 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
249
256
  onCellClick(rows[rowIndex], columns[columnIndex]);
250
257
  }
251
258
  }
252
- }, displayedValue);
259
+ }, /*#__PURE__*/_react["default"].createElement(_overflowableText["default"], {
260
+ text: displayedValue,
261
+ tooltipStyle: classes.cellTooltip
262
+ }));
253
263
  });
254
264
 
255
265
  _defineProperty(_assertThisInitialized(_this), "headerRenderer", function (_ref4) {
@@ -13,7 +13,7 @@ var _makeStyles = _interopRequireDefault(require("@mui/styles/makeStyles"));
13
13
 
14
14
  var _clsx = _interopRequireDefault(require("clsx"));
15
15
 
16
- var _excluded = ["text", "className", "children"];
16
+ var _excluded = ["text", "tooltipStyle", "className", "children"];
17
17
 
18
18
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
19
 
@@ -45,6 +45,7 @@ var useStyles = (0, _makeStyles["default"])(overflowStyle);
45
45
 
46
46
  var OverflowableText = function OverflowableText(_ref) {
47
47
  var text = _ref.text,
48
+ tooltipStyle = _ref.tooltipStyle,
48
49
  className = _ref.className,
49
50
  children = _ref.children,
50
51
  props = _objectWithoutPropertiesLoose(_ref, _excluded);
@@ -67,7 +68,7 @@ var OverflowableText = function OverflowableText(_ref) {
67
68
  title: text || '',
68
69
  disableHoverListener: !overflowed,
69
70
  classes: {
70
- tooltip: classes.tooltip
71
+ tooltip: tooltipStyle ? tooltipStyle : classes.tooltip
71
72
  }
72
73
  }, /*#__PURE__*/_react["default"].createElement("div", _extends({}, props, {
73
74
  ref: element,
@@ -80,6 +81,7 @@ exports.OverflowableText = OverflowableText;
80
81
  OverflowableText.propTypes = process.env.NODE_ENV !== "production" ? {
81
82
  children: _propTypes["default"].array,
82
83
  text: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].number, _propTypes["default"].node]),
84
+ tooltipStyle: _propTypes["default"].string,
83
85
  className: _propTypes["default"].string
84
86
  } : {};
85
87
  var _default = OverflowableText;
@@ -74,6 +74,7 @@ var LogTable = function LogTable(_ref) {
74
74
  id: 'severity',
75
75
  dataKey: 'severity',
76
76
  maxWidth: SEVERITY_COLUMN_FIXED_WIDTH,
77
+ minWidth: SEVERITY_COLUMN_FIXED_WIDTH,
77
78
  cellRenderer: severityCellRender
78
79
  }, {
79
80
  label: intl.formatMessage({
@@ -121,7 +121,7 @@ function ReportViewer(_ref) {
121
121
  xs: 12,
122
122
  sm: 3,
123
123
  style: {
124
- height: '100%',
124
+ height: '95%',
125
125
  borderRight: '1px solid rgba(81, 81, 81, 1)'
126
126
  }
127
127
  }, /*#__PURE__*/_react["default"].createElement(_TreeView["default"], {
@@ -142,7 +142,7 @@ function ReportViewer(_ref) {
142
142
  xs: 12,
143
143
  sm: 9,
144
144
  style: {
145
- height: '100%'
145
+ height: '95%'
146
146
  }
147
147
  }, /*#__PURE__*/_react["default"].createElement(_logTable["default"], {
148
148
  logs: logs
@@ -87,7 +87,8 @@ var useStyles = (0, _makeStyles["default"])(function (theme) {
87
87
  return {
88
88
  grow: {
89
89
  flexGrow: 1,
90
- display: 'flex'
90
+ display: 'flex',
91
+ overflow: 'hidden'
91
92
  },
92
93
  logo: {
93
94
  flexShrink: 0,
@@ -113,7 +113,8 @@ var TreeViewFinder = function TreeViewFinder(props) {
113
113
  onTreeBrowse = props.onTreeBrowse,
114
114
  validationButtonText = props.validationButtonText,
115
115
  onlyLeaves = props.onlyLeaves,
116
- multiselect = props.multiselect;
116
+ multiselect = props.multiselect,
117
+ sortMethod = props.sortMethod;
117
118
 
118
119
  var _useState = (0, _react.useState)({}),
119
120
  mapPrintedNodes = _useState[0],
@@ -225,7 +226,7 @@ var TreeViewFinder = function TreeViewFinder(props) {
225
226
  key: node.id,
226
227
  nodeId: node.id,
227
228
  label: renderTreeItemLabel(node)
228
- }, Array.isArray(node.children) ? node.children.length ? node.children.map(function (child) {
229
+ }, Array.isArray(node.children) ? node.children.length ? node.children.sort(sortMethod).map(function (child) {
229
230
  return renderTree(child);
230
231
  }) : [false] // Pass non empty Array here to simulate a child then this node isn't considered as a leaf.
231
232
  : null);
@@ -269,7 +270,7 @@ var TreeViewFinder = function TreeViewFinder(props) {
269
270
  className: classes.icon
270
271
  }),
271
272
  multiSelect: multiselect
272
- }, data && Array.isArray(data) ? data.map(function (child) {
273
+ }, data && Array.isArray(data) ? data.sort(sortMethod).map(function (child) {
273
274
  return renderTree(child);
274
275
  }) : null)), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, /*#__PURE__*/_react["default"].createElement(_Button["default"], {
275
276
  variant: "contained",
@@ -319,7 +320,8 @@ TreeViewFinder.propTypes = process.env.NODE_ENV !== "production" ? {
319
320
  defaultSelected: _propTypes["default"].arrayOf(_propTypes["default"].string),
320
321
  defaultExpanded: _propTypes["default"].arrayOf(_propTypes["default"].string),
321
322
  onlyLeaves: _propTypes["default"].bool,
322
- multiselect: _propTypes["default"].bool
323
+ multiselect: _propTypes["default"].bool,
324
+ sortMethod: _propTypes["default"].func
323
325
  } : {};
324
326
  /* TreeViewFinder props default values */
325
327
 
@@ -327,7 +329,8 @@ TreeViewFinder.defaultProps = {
327
329
  defaultSelected: [],
328
330
  defaultExpanded: [],
329
331
  onlyLeaves: true,
330
- multiselect: false
332
+ multiselect: false,
333
+ sortMethod: undefined
331
334
  };
332
335
 
333
336
  var _default = (0, _withStyles["default"])(defaultStyles)(TreeViewFinder);
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+ var card_error_boundary_en = {
6
+ 'card_error_boundary/title': 'Sorry, unexpected error :(',
7
+ 'card_error_boundary/content': 'Please reload, or close and reopen this application, or contact support.',
8
+ 'card_error_boundary/expandederrorheader': 'Error message (and see more information in the developper console):'
9
+ };
10
+ var _default = card_error_boundary_en;
11
+ exports["default"] = _default;
12
+ module.exports = exports.default;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+ var card_error_boundary_fr = {
6
+ 'card_error_boundary/title': 'Désolé, erreur inattendue :(',
7
+ 'card_error_boundary/content': 'Veuillez recharger, ou fermer et réouvrir cette application, ou contacter le support.',
8
+ 'card_error_boundary/expandederrorheader': "Message d'erreur (et voir plus d'informations dans la console developpeur):"
9
+ };
10
+ var _default = card_error_boundary_fr;
11
+ exports["default"] = _default;
12
+ module.exports = exports.default;
package/lib/index.js CHANGED
@@ -136,10 +136,22 @@ var _equipmentSearchFr = _interopRequireDefault(require("./components/translatio
136
136
 
137
137
  exports.equipment_search_fr = _equipmentSearchFr["default"];
138
138
 
139
+ var _cardErrorBoundaryEn = _interopRequireDefault(require("./components/translations/card-error-boundary-en"));
140
+
141
+ exports.card_error_boundary_en = _cardErrorBoundaryEn["default"];
142
+
143
+ var _cardErrorBoundaryFr = _interopRequireDefault(require("./components/translations/card-error-boundary-fr"));
144
+
145
+ exports.card_error_boundary_fr = _cardErrorBoundaryFr["default"];
146
+
139
147
  var _equipmentItem = require("./components/ElementSearchDialog/equipment-item");
140
148
 
141
149
  exports.EquipmentItem = _equipmentItem.EquipmentItem;
142
150
 
151
+ var _CardErrorBoundary2 = _interopRequireDefault(require("./components/CardErrorBoundary"));
152
+
153
+ exports.CardErrorBoundary = _CardErrorBoundary2["default"];
154
+
143
155
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
144
156
 
145
157
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -41,6 +41,8 @@ function initializeAuthenticationDev(dispatch, isSilentRenew) {
41
41
  return Promise.resolve(userManager);
42
42
  }
43
43
 
44
+ var accessTokenExpiringNotificationTime = 60; // seconds
45
+
44
46
  function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings) {
45
47
  return idpSettings.then(function (r) {
46
48
  return r.json();
@@ -109,9 +111,10 @@ function initializeAuthenticationProd(dispatch, isSilentRenew, idpSettings) {
109
111
  response_type: 'id_token token',
110
112
  scope: idpSettings.scope,
111
113
  automaticSilentRenew: !isSilentRenew,
112
- accessTokenExpiringNotificationTime: 60
114
+ accessTokenExpiringNotificationTime: accessTokenExpiringNotificationTime
113
115
  };
114
116
  var userManager = new _oidcClient.UserManager(settings);
117
+ userManager.idpSettings = idpSettings; //store our settings in there as well to use it later
115
118
 
116
119
  if (!isSilentRenew) {
117
120
  handleUser(dispatch, userManager);
@@ -177,8 +180,41 @@ function handleUser(dispatch, userManager) {
177
180
  dispatchUser(dispatch, userManager);
178
181
  });
179
182
  userManager.events.addSilentRenewError(function (error) {
180
- console.debug(error);
181
- logout(dispatch, userManager);
183
+ console.debug(error); // wait for accessTokenExpiringNotificationTime so that the user is expired
184
+ // otherwise the library tries to signin immediately when we do getUser()
185
+
186
+ window.setTimeout(function () {
187
+ userManager.getUser().then(function (user) {
188
+ var now = parseInt(Date.now() / 1000);
189
+ var exp = (0, _jwtDecode["default"])(user.id_token).exp;
190
+ var idTokenExpiresIn = exp - now;
191
+
192
+ if (idTokenExpiresIn < 0) {
193
+ console.log('Error in silent renew, idtoken expired: ' + idTokenExpiresIn + ' => Logging out.', error); // TODO here allow to continue to use the app but in some kind of frozen state because we can't make API calls anymore
194
+ // remove the user from our app, but don't sso logout on all other apps
195
+
196
+ return dispatch((0, _actions.setLoggedUser)(null));
197
+ } else if (userManager.idpSettings.maxExpiresIn) {
198
+ if (idTokenExpiresIn < userManager.idpSettings.maxExpiresIn) {
199
+ // TODO here attempt last chance login ? snackbar to notify the user ? Popup ?
200
+ // for now we do the same thing as in the else block
201
+ console.log('Error in silent renew, but idtoken ALMOST expiring (expiring in' + idTokenExpiresIn + ') => last chance' + userManager.idpSettings.maxExpiresIn, error);
202
+ user.expires_in = userManager.idpSettings.maxExpiresIn;
203
+ userManager.storeUser(user).then(function () {
204
+ userManager.getUser();
205
+ });
206
+ } else {
207
+ console.log('Error in silent renew, but idtoken NOT expiring (expiring in' + idTokenExpiresIn + ') => postponing expiration to' + userManager.idpSettings.maxExpiresIn, error);
208
+ user.expires_in = userManager.idpSettings.maxExpiresIn;
209
+ userManager.storeUser(user).then(function () {
210
+ userManager.getUser();
211
+ });
212
+ }
213
+ } else {
214
+ console.log('Error in silent renew, unsupported configuration: token still valid for ' + idTokenExpiresIn + ' but maxExpiresIn is not configured:' + userManager.idpSettings.maxExpiresIn, error);
215
+ }
216
+ });
217
+ }, accessTokenExpiringNotificationTime * 1000);
182
218
  });
183
219
  console.debug('dispatch user');
184
220
  dispatchUser(dispatch, userManager);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gridsuite/commons-ui",
3
- "version": "0.22.0",
3
+ "version": "0.24.0",
4
4
  "description": "common react components for gridsuite applications",
5
5
  "engines": {
6
6
  "npm": "<=6",