@gridsuite/commons-ui 0.27.2 → 0.29.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/AuthenticationRouter/AuthenticationRouter.js +32 -15
- package/lib/components/Login/Logout.js +102 -0
- package/lib/components/MuiVirtualizedTable/MuiVirtualizedTable.js +42 -26
- package/lib/components/ReportViewer/log-report-item.js +6 -1
- package/lib/components/ReportViewer/log-report.js +4 -3
- package/lib/components/ReportViewer/log-table.js +40 -7
- package/lib/components/ReportViewer/report-item.js +19 -2
- package/lib/components/ReportViewer/report-tree-view-context.js +22 -0
- package/lib/components/ReportViewer/report-viewer.js +43 -2
- package/lib/components/translations/login-en.js +4 -0
- package/lib/components/translations/login-fr.js +4 -0
- package/lib/hooks/useIntlRef.js +27 -0
- package/lib/hooks/useSnackMessage.js +98 -0
- package/lib/index.js +11 -1
- package/lib/utils/AuthService.js +30 -15
- package/lib/utils/actions.js +34 -3
- package/package.json +1 -1
|
@@ -15,6 +15,8 @@ var _SilentRenewCallbackHandler = _interopRequireDefault(require("../SilentRenew
|
|
|
15
15
|
|
|
16
16
|
var _Login = _interopRequireDefault(require("../Login"));
|
|
17
17
|
|
|
18
|
+
var _Logout = _interopRequireDefault(require("../Login/Logout"));
|
|
19
|
+
|
|
18
20
|
var _material = require("@mui/material");
|
|
19
21
|
|
|
20
22
|
var _Alert = _interopRequireDefault(require("@mui/material/Alert"));
|
|
@@ -23,8 +25,6 @@ var _AlertTitle = _interopRequireDefault(require("@mui/material/AlertTitle"));
|
|
|
23
25
|
|
|
24
26
|
var _reactIntl = require("react-intl");
|
|
25
27
|
|
|
26
|
-
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
27
|
-
|
|
28
28
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
29
29
|
|
|
30
30
|
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); }
|
|
@@ -40,7 +40,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
40
40
|
var AuthenticationRouter = function AuthenticationRouter(_ref) {
|
|
41
41
|
var userManager = _ref.userManager,
|
|
42
42
|
signInCallbackError = _ref.signInCallbackError,
|
|
43
|
-
|
|
43
|
+
authenticationRouterError = _ref.authenticationRouterError,
|
|
44
44
|
showAuthenticationRouterLogin = _ref.showAuthenticationRouterLogin,
|
|
45
45
|
dispatch = _ref.dispatch,
|
|
46
46
|
navigate = _ref.navigate,
|
|
@@ -75,31 +75,48 @@ var AuthenticationRouter = function AuthenticationRouter(_ref) {
|
|
|
75
75
|
})
|
|
76
76
|
}), /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Route, {
|
|
77
77
|
path: "*",
|
|
78
|
-
element: showAuthenticationRouterLogin && /*#__PURE__*/_react["default"].createElement(_Login["default"], {
|
|
78
|
+
element: showAuthenticationRouterLogin && authenticationRouterError == null && /*#__PURE__*/_react["default"].createElement(_Login["default"], {
|
|
79
79
|
disabled: userManager.instance === null,
|
|
80
80
|
onLoginClick: function onLoginClick() {
|
|
81
81
|
return (0, _AuthService.login)(location, userManager.instance);
|
|
82
82
|
}
|
|
83
83
|
})
|
|
84
|
-
})),
|
|
84
|
+
})), authenticationRouterError !== null && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_material.Grid, {
|
|
85
85
|
item: true
|
|
86
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
(0, _AuthService.logout)(
|
|
86
|
+
}, /*#__PURE__*/_react["default"].createElement(_Logout["default"], {
|
|
87
|
+
disabled: userManager.instance === null,
|
|
88
|
+
onLogoutClick: function onLogoutClick() {
|
|
89
|
+
return (0, _AuthService.logout)(location, userManager.instance);
|
|
90
90
|
}
|
|
91
|
-
}, /*#__PURE__*/_react["default"].createElement(
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
91
|
+
})), /*#__PURE__*/_react["default"].createElement(_material.Grid, {
|
|
92
|
+
item: true,
|
|
93
|
+
xs: 4
|
|
94
|
+
}, authenticationRouterError.logoutError != null && /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
95
|
+
severity: "error"
|
|
96
|
+
}, /*#__PURE__*/_react["default"].createElement(_AlertTitle["default"], null, /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
97
|
+
id: "login/errorInLogout"
|
|
98
|
+
})), /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
99
|
+
id: "login/errorInLogoutMessage",
|
|
100
|
+
values: {
|
|
101
|
+
userName: authenticationRouterError.userName
|
|
102
|
+
}
|
|
103
|
+
}), /*#__PURE__*/_react["default"].createElement("p", null, authenticationRouterError.logoutError.error.message)), (authenticationRouterError === null || authenticationRouterError === void 0 ? void 0 : authenticationRouterError.userValidationError) != null && /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
104
|
+
severity: "error"
|
|
105
|
+
}, /*#__PURE__*/_react["default"].createElement(_AlertTitle["default"], null, /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
106
|
+
id: "login/errorInUserValidation"
|
|
107
|
+
})), /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
108
|
+
id: "login/errorInUserValidationMessage",
|
|
109
|
+
values: {
|
|
110
|
+
userName: authenticationRouterError.userName
|
|
111
|
+
}
|
|
112
|
+
}), /*#__PURE__*/_react["default"].createElement("p", null, authenticationRouterError.userValidationError.error.message)), (authenticationRouterError === null || authenticationRouterError === void 0 ? void 0 : authenticationRouterError.unauthorizedUserInfo) != null && /*#__PURE__*/_react["default"].createElement(_Alert["default"], {
|
|
96
113
|
severity: "info"
|
|
97
114
|
}, /*#__PURE__*/_react["default"].createElement(_AlertTitle["default"], null, /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
98
115
|
id: "login/unauthorizedAccess"
|
|
99
116
|
})), /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
100
117
|
id: "login/unauthorizedAccessMessage",
|
|
101
118
|
values: {
|
|
102
|
-
userName:
|
|
119
|
+
userName: authenticationRouterError.userName
|
|
103
120
|
}
|
|
104
121
|
}))))));
|
|
105
122
|
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = _interopRequireDefault(require("react"));
|
|
7
|
+
|
|
8
|
+
var _Avatar = _interopRequireDefault(require("@mui/material/Avatar"));
|
|
9
|
+
|
|
10
|
+
var _Button = _interopRequireDefault(require("@mui/material/Button"));
|
|
11
|
+
|
|
12
|
+
var _Link = _interopRequireDefault(require("@mui/material/Link"));
|
|
13
|
+
|
|
14
|
+
var _Box = _interopRequireDefault(require("@mui/material/Box"));
|
|
15
|
+
|
|
16
|
+
var _LogoutOutlined = _interopRequireDefault(require("@mui/icons-material/LogoutOutlined"));
|
|
17
|
+
|
|
18
|
+
var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
19
|
+
|
|
20
|
+
var _makeStyles = _interopRequireDefault(require("@mui/styles/makeStyles"));
|
|
21
|
+
|
|
22
|
+
var _Container = _interopRequireDefault(require("@mui/material/Container"));
|
|
23
|
+
|
|
24
|
+
var _reactIntl = require("react-intl");
|
|
25
|
+
|
|
26
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Copyright (c) 2020, RTE (http://www.rte-france.com)
|
|
30
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
31
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
32
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
33
|
+
*/
|
|
34
|
+
var useStyles = (0, _makeStyles["default"])(function (theme) {
|
|
35
|
+
return {
|
|
36
|
+
paper: {
|
|
37
|
+
marginTop: theme.spacing(8),
|
|
38
|
+
display: 'flex',
|
|
39
|
+
flexDirection: 'column',
|
|
40
|
+
alignItems: 'center'
|
|
41
|
+
},
|
|
42
|
+
avatar: {
|
|
43
|
+
margin: theme.spacing(1),
|
|
44
|
+
backgroundColor: theme.palette.error.main
|
|
45
|
+
},
|
|
46
|
+
submit: {
|
|
47
|
+
margin: theme.spacing(3, 0, 2),
|
|
48
|
+
borderRadius: '30px'
|
|
49
|
+
},
|
|
50
|
+
logo: {
|
|
51
|
+
width: 64,
|
|
52
|
+
height: 64
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
var Logout = function Logout(_ref) {
|
|
58
|
+
var onLogoutClick = _ref.onLogoutClick,
|
|
59
|
+
disabled = _ref.disabled;
|
|
60
|
+
var classes = useStyles();
|
|
61
|
+
|
|
62
|
+
function Copyright() {
|
|
63
|
+
return /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
64
|
+
variant: "body2",
|
|
65
|
+
color: "textSecondary",
|
|
66
|
+
align: "center"
|
|
67
|
+
}, 'Copyright © ', /*#__PURE__*/_react["default"].createElement(_Link["default"], {
|
|
68
|
+
color: "inherit",
|
|
69
|
+
href: "#"
|
|
70
|
+
}, "GridSuite"), ' ', new Date().getFullYear(), '.');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
return /*#__PURE__*/_react["default"].createElement(_Container["default"], {
|
|
74
|
+
component: "main",
|
|
75
|
+
maxWidth: "xs"
|
|
76
|
+
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
77
|
+
className: classes.paper
|
|
78
|
+
}, /*#__PURE__*/_react["default"].createElement(_Avatar["default"], {
|
|
79
|
+
className: classes.avatar
|
|
80
|
+
}, /*#__PURE__*/_react["default"].createElement(_LogoutOutlined["default"], null)), /*#__PURE__*/_react["default"].createElement(_Typography["default"], {
|
|
81
|
+
component: "h1",
|
|
82
|
+
variant: "h5"
|
|
83
|
+
}, /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
84
|
+
id: "login/logout",
|
|
85
|
+
defaultMessage: 'logout'
|
|
86
|
+
}), ' ', "?"), /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
87
|
+
disabled: disabled,
|
|
88
|
+
fullWidth: true,
|
|
89
|
+
variant: "contained",
|
|
90
|
+
className: classes.submit,
|
|
91
|
+
onClick: onLogoutClick
|
|
92
|
+
}, /*#__PURE__*/_react["default"].createElement(_reactIntl.FormattedMessage, {
|
|
93
|
+
id: "login/logout",
|
|
94
|
+
defaultMessage: 'logout'
|
|
95
|
+
}))), /*#__PURE__*/_react["default"].createElement(_Box["default"], {
|
|
96
|
+
mt: 2
|
|
97
|
+
}, /*#__PURE__*/_react["default"].createElement(Copyright, null)));
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
var _default = Logout;
|
|
101
|
+
exports["default"] = _default;
|
|
102
|
+
module.exports = exports.default;
|
|
@@ -217,22 +217,32 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
_defineProperty(_assertThisInitialized(_this), "getRowClassName", function (_ref2) {
|
|
220
|
-
var _rowGetter, _clsx;
|
|
220
|
+
var _rowGetter, _rowGetter2, _clsx;
|
|
221
221
|
|
|
222
222
|
var index = _ref2.index,
|
|
223
223
|
rowGetter = _ref2.rowGetter;
|
|
224
224
|
var _this$props2 = _this.props,
|
|
225
225
|
classes = _this$props2.classes,
|
|
226
226
|
onRowClick = _this$props2.onRowClick;
|
|
227
|
-
return (0, _clsx3["default"])(classes.tableRow, classes.flexContainer, index % 2 === 0 && classes.rowBackgroundDark, index % 2 !== 0 && classes.rowBackgroundLight, ((_rowGetter = rowGetter(index)) === null || _rowGetter === void 0 ? void 0 : _rowGetter.notClickable) === true && classes.noClick, (_clsx = {}, _clsx[classes.tableRowHover] = index !== -1 && onRowClick != null, _clsx));
|
|
227
|
+
return (0, _clsx3["default"])(classes.tableRow, classes.flexContainer, index % 2 === 0 && classes.rowBackgroundDark, index % 2 !== 0 && classes.rowBackgroundLight, ((_rowGetter = rowGetter(index)) === null || _rowGetter === void 0 ? void 0 : _rowGetter.notClickable) === true && classes.noClick, (_clsx = {}, _clsx[classes.tableRowHover] = index !== -1 && onRowClick != null && !(((_rowGetter2 = rowGetter(index)) === null || _rowGetter2 === void 0 ? void 0 : _rowGetter2.notClickable) === true), _clsx));
|
|
228
228
|
});
|
|
229
229
|
|
|
230
|
-
_defineProperty(_assertThisInitialized(_this), "
|
|
231
|
-
var
|
|
230
|
+
_defineProperty(_assertThisInitialized(_this), "onClickableRowClick", function (_ref3) {
|
|
231
|
+
var e = _ref3.e,
|
|
232
|
+
index = _ref3.index,
|
|
233
|
+
rowData = _ref3.rowData;
|
|
232
234
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
235
|
+
if (!((rowData === null || rowData === void 0 ? void 0 : rowData.notClickable) === true)) {
|
|
236
|
+
_this.props.onRowClick(e, index, rowData);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
_defineProperty(_assertThisInitialized(_this), "cellRenderer", function (_ref4) {
|
|
241
|
+
var _rows$rowIndex, _rows$rowIndex2, _clsx2;
|
|
242
|
+
|
|
243
|
+
var cellData = _ref4.cellData,
|
|
244
|
+
columnIndex = _ref4.columnIndex,
|
|
245
|
+
rowIndex = _ref4.rowIndex;
|
|
236
246
|
var _this$props3 = _this.props,
|
|
237
247
|
columns = _this$props3.columns,
|
|
238
248
|
classes = _this$props3.classes,
|
|
@@ -244,7 +254,7 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
244
254
|
|
|
245
255
|
return /*#__PURE__*/_react["default"].createElement(_TableCell["default"], {
|
|
246
256
|
component: "div",
|
|
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)),
|
|
257
|
+
className: (0, _clsx3["default"])(classes.tableCell, classes.flexContainer, (_clsx2 = {}, _clsx2[classes.noClick] = displayedValue === undefined || ((_rows$rowIndex = rows[rowIndex]) === null || _rows$rowIndex === void 0 ? void 0 : _rows$rowIndex.notClickable) === true || onCellClick == null || columns[columnIndex].clickable === undefined || !columns[columnIndex].clickable, _clsx2[classes.tableCellColor] = displayedValue === undefined || onCellClick !== null && !((_rows$rowIndex2 = rows[rowIndex]) === null || _rows$rowIndex2 === void 0 ? void 0 : _rows$rowIndex2.notClickable) === true && columns[columnIndex].clickable !== undefined && columns[columnIndex].clickable, _clsx2)),
|
|
248
258
|
variant: "body",
|
|
249
259
|
style: {
|
|
250
260
|
height: rowHeight,
|
|
@@ -252,7 +262,9 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
252
262
|
},
|
|
253
263
|
align: columnIndex != null && columns[columnIndex].numeric || false ? 'right' : 'left',
|
|
254
264
|
onClick: function onClick() {
|
|
255
|
-
|
|
265
|
+
var _rows$rowIndex3;
|
|
266
|
+
|
|
267
|
+
if (onCellClick && columns[columnIndex].clickable !== undefined && !((_rows$rowIndex3 = rows[rowIndex]) === null || _rows$rowIndex3 === void 0 ? void 0 : _rows$rowIndex3.notClickable) === true && columns[columnIndex].clickable) {
|
|
256
268
|
onCellClick(rows[rowIndex], columns[columnIndex]);
|
|
257
269
|
}
|
|
258
270
|
}
|
|
@@ -262,9 +274,9 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
262
274
|
}));
|
|
263
275
|
});
|
|
264
276
|
|
|
265
|
-
_defineProperty(_assertThisInitialized(_this), "headerRenderer", function (
|
|
266
|
-
var label =
|
|
267
|
-
columnIndex =
|
|
277
|
+
_defineProperty(_assertThisInitialized(_this), "headerRenderer", function (_ref5) {
|
|
278
|
+
var label = _ref5.label,
|
|
279
|
+
columnIndex = _ref5.columnIndex;
|
|
268
280
|
var _this$props4 = _this.props,
|
|
269
281
|
columns = _this$props4.columns,
|
|
270
282
|
classes = _this$props4.classes;
|
|
@@ -434,17 +446,21 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
434
446
|
enableExportCSV = _this$props5.enableExportCSV,
|
|
435
447
|
tableProps = _objectWithoutPropertiesLoose(_this$props5, _excluded);
|
|
436
448
|
|
|
449
|
+
if (tableProps.onRowClick) {
|
|
450
|
+
tableProps.onRowClick = this.onClickableRowClick;
|
|
451
|
+
}
|
|
452
|
+
|
|
437
453
|
var reorderedIndex = this.reorderIndex(this.state.key, this.state.direction, this.props.filter, this.props.rows);
|
|
438
454
|
|
|
439
455
|
var getIndexFor = function getIndexFor(index) {
|
|
440
456
|
return index < reorderedIndex.length ? reorderedIndex[index] : 0;
|
|
441
457
|
};
|
|
442
458
|
|
|
443
|
-
var
|
|
459
|
+
var _rowGetter3 = function rowGetter(index) {
|
|
444
460
|
return _this2.props.rows[getIndexFor(index)];
|
|
445
461
|
};
|
|
446
462
|
|
|
447
|
-
var sizes = this.sizes(this.props.columns, this.props.rows,
|
|
463
|
+
var sizes = this.sizes(this.props.columns, this.props.rows, _rowGetter3);
|
|
448
464
|
var csvHeaders = this.csvHeaders(this.props.columns, this.props.exportCSVDataKeys);
|
|
449
465
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
450
466
|
style: {
|
|
@@ -471,9 +487,9 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
471
487
|
style: {
|
|
472
488
|
flexGrow: 1
|
|
473
489
|
}
|
|
474
|
-
}, /*#__PURE__*/_react["default"].createElement(_reactVirtualized.AutoSizer, null, function (
|
|
475
|
-
var height =
|
|
476
|
-
width =
|
|
490
|
+
}, /*#__PURE__*/_react["default"].createElement(_reactVirtualized.AutoSizer, null, function (_ref6) {
|
|
491
|
+
var height = _ref6.height,
|
|
492
|
+
width = _ref6.width;
|
|
477
493
|
return /*#__PURE__*/_react["default"].createElement(_reactVirtualized.Table, _extends({
|
|
478
494
|
height: height,
|
|
479
495
|
width: width,
|
|
@@ -485,20 +501,20 @@ var MuiVirtualizedTable = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
485
501
|
className: classes.table
|
|
486
502
|
}, tableProps, {
|
|
487
503
|
rowCount: reorderedIndex.length,
|
|
488
|
-
rowClassName: function rowClassName(
|
|
489
|
-
var index =
|
|
504
|
+
rowClassName: function rowClassName(_ref7) {
|
|
505
|
+
var index = _ref7.index;
|
|
490
506
|
return _this2.getRowClassName({
|
|
491
507
|
index: index,
|
|
492
|
-
rowGetter:
|
|
508
|
+
rowGetter: _rowGetter3
|
|
493
509
|
});
|
|
494
510
|
},
|
|
495
|
-
rowGetter: function rowGetter(
|
|
496
|
-
var index =
|
|
497
|
-
return
|
|
511
|
+
rowGetter: function rowGetter(_ref8) {
|
|
512
|
+
var index = _ref8.index;
|
|
513
|
+
return _rowGetter3(index);
|
|
498
514
|
}
|
|
499
|
-
}), columns.map(function (
|
|
500
|
-
var dataKey =
|
|
501
|
-
other = _objectWithoutPropertiesLoose(
|
|
515
|
+
}), columns.map(function (_ref9, index) {
|
|
516
|
+
var dataKey = _ref9.dataKey,
|
|
517
|
+
other = _objectWithoutPropertiesLoose(_ref9, _excluded2);
|
|
502
518
|
|
|
503
519
|
return /*#__PURE__*/_react["default"].createElement(_reactVirtualized.Column, _extends({
|
|
504
520
|
key: dataKey,
|
|
@@ -28,9 +28,10 @@ var LogReportItem = /*#__PURE__*/function () {
|
|
|
28
28
|
});
|
|
29
29
|
};
|
|
30
30
|
|
|
31
|
-
function LogReportItem(jsonReport) {
|
|
31
|
+
function LogReportItem(jsonReport, reportId) {
|
|
32
32
|
this.key = jsonReport.reportKey;
|
|
33
33
|
this.log = LogReportItem.resolveTemplateMessage(jsonReport.defaultMessage, jsonReport.values);
|
|
34
|
+
this.reportId = reportId;
|
|
34
35
|
this.severity = this.initSeverity(jsonReport.values.reportSeverity);
|
|
35
36
|
}
|
|
36
37
|
|
|
@@ -40,6 +41,10 @@ var LogReportItem = /*#__PURE__*/function () {
|
|
|
40
41
|
return this.log;
|
|
41
42
|
};
|
|
42
43
|
|
|
44
|
+
_proto.getReportId = function getReportId() {
|
|
45
|
+
return this.reportId;
|
|
46
|
+
};
|
|
47
|
+
|
|
43
48
|
_proto.getSeverity = function getSeverity() {
|
|
44
49
|
return this.severity;
|
|
45
50
|
};
|
|
@@ -16,12 +16,13 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
16
16
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
17
17
|
*/
|
|
18
18
|
var LogReport = /*#__PURE__*/function () {
|
|
19
|
-
function LogReport(jsonReporter) {
|
|
19
|
+
function LogReport(jsonReporter, parentReportId) {
|
|
20
20
|
this.id = (0, _uuid.v4)();
|
|
21
21
|
this.key = jsonReporter.taskKey;
|
|
22
22
|
this.title = _logReportItem["default"].resolveTemplateMessage(jsonReporter.defaultName, jsonReporter.taskValues);
|
|
23
23
|
this.subReports = [];
|
|
24
24
|
this.logs = [];
|
|
25
|
+
this.parentReportId = parentReportId;
|
|
25
26
|
this.init(jsonReporter);
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -53,10 +54,10 @@ var LogReport = /*#__PURE__*/function () {
|
|
|
53
54
|
var _this = this;
|
|
54
55
|
|
|
55
56
|
jsonReporter.subReporters.map(function (value) {
|
|
56
|
-
return _this.subReports.push(new LogReport(value));
|
|
57
|
+
return _this.subReports.push(new LogReport(value, _this.id));
|
|
57
58
|
});
|
|
58
59
|
jsonReporter.reports.map(function (value) {
|
|
59
|
-
return _this.logs.push(new _logReportItem["default"](value));
|
|
60
|
+
return _this.logs.push(new _logReportItem["default"](value, _this.id));
|
|
60
61
|
});
|
|
61
62
|
};
|
|
62
63
|
|
|
@@ -13,6 +13,8 @@ var _TableCell = _interopRequireDefault(require("@mui/material/TableCell"));
|
|
|
13
13
|
|
|
14
14
|
var _MuiVirtualizedTable = _interopRequireDefault(require("../MuiVirtualizedTable"));
|
|
15
15
|
|
|
16
|
+
var _styles = require("@mui/material/styles");
|
|
17
|
+
|
|
16
18
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
19
|
|
|
18
20
|
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); }
|
|
@@ -51,8 +53,14 @@ var styles = function styles(theme) {
|
|
|
51
53
|
var VirtualizedTable = (0, _withStyles["default"])(styles)(_MuiVirtualizedTable["default"]);
|
|
52
54
|
|
|
53
55
|
var LogTable = function LogTable(_ref) {
|
|
54
|
-
var logs = _ref.logs
|
|
56
|
+
var logs = _ref.logs,
|
|
57
|
+
onRowClick = _ref.onRowClick;
|
|
55
58
|
var intl = (0, _reactIntl.useIntl)();
|
|
59
|
+
var theme = (0, _styles.useTheme)();
|
|
60
|
+
|
|
61
|
+
var _useState = (0, _react.useState)(-1),
|
|
62
|
+
selectedRowIndex = _useState[0],
|
|
63
|
+
setSelectedRowIndex = _useState[1];
|
|
56
64
|
|
|
57
65
|
var severityCellRender = function severityCellRender(cellData) {
|
|
58
66
|
return /*#__PURE__*/_react["default"].createElement(_TableCell["default"], {
|
|
@@ -95,16 +103,41 @@ var LogTable = function LogTable(_ref) {
|
|
|
95
103
|
return {
|
|
96
104
|
severity: log.getSeverityName(),
|
|
97
105
|
message: log.getLog(),
|
|
98
|
-
backgroundColor: log.getColorName()
|
|
106
|
+
backgroundColor: log.getColorName(),
|
|
107
|
+
reportId: log.getReportId()
|
|
99
108
|
};
|
|
100
109
|
});
|
|
101
110
|
};
|
|
102
111
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
112
|
+
var handleRowClick = function handleRowClick(event, index, data) {
|
|
113
|
+
setSelectedRowIndex(index);
|
|
114
|
+
onRowClick(data);
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
var rowStyleFormat = function rowStyleFormat(row) {
|
|
118
|
+
if (row.index < 0) return;
|
|
119
|
+
|
|
120
|
+
if (selectedRowIndex === row.index) {
|
|
121
|
+
return {
|
|
122
|
+
backgroundColor: theme.palette.action.selected
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
(0, _react.useEffect)(function () {
|
|
128
|
+
setSelectedRowIndex(-1);
|
|
129
|
+
}, [logs]);
|
|
130
|
+
return (
|
|
131
|
+
/*#__PURE__*/
|
|
132
|
+
//TODO do we need to useMemo/useCallback these props to avoid rerenders ?
|
|
133
|
+
_react["default"].createElement(VirtualizedTable, {
|
|
134
|
+
columns: generateTableColumns(),
|
|
135
|
+
rows: generateTableRows(),
|
|
136
|
+
sortable: false,
|
|
137
|
+
onRowClick: handleRowClick,
|
|
138
|
+
rowStyle: rowStyleFormat
|
|
139
|
+
})
|
|
140
|
+
);
|
|
108
141
|
};
|
|
109
142
|
|
|
110
143
|
var _default = (0, _react.memo)(LogTable);
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
4
|
exports["default"] = void 0;
|
|
5
5
|
|
|
6
|
-
var _react =
|
|
6
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
7
7
|
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
|
|
@@ -15,10 +15,16 @@ var _Typography = _interopRequireDefault(require("@mui/material/Typography"));
|
|
|
15
15
|
|
|
16
16
|
var _Label = _interopRequireDefault(require("@mui/icons-material/Label"));
|
|
17
17
|
|
|
18
|
+
var _reportTreeViewContext = _interopRequireDefault(require("./report-tree-view-context"));
|
|
19
|
+
|
|
18
20
|
var _excluded = ["labelText", "labelIconColor"];
|
|
19
21
|
|
|
20
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
21
23
|
|
|
24
|
+
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); }
|
|
25
|
+
|
|
26
|
+
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; }
|
|
27
|
+
|
|
22
28
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
23
29
|
|
|
24
30
|
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; }
|
|
@@ -65,6 +71,12 @@ var useReportItemStyles = (0, _makeStyles["default"])(function (theme) {
|
|
|
65
71
|
alignItems: 'center',
|
|
66
72
|
padding: theme.spacing(0.5, 0)
|
|
67
73
|
},
|
|
74
|
+
labelRootHighlighted: {
|
|
75
|
+
display: 'flex',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
padding: theme.spacing(0.5, 0),
|
|
78
|
+
backgroundColor: theme.palette.action.selected
|
|
79
|
+
},
|
|
68
80
|
labelIcon: {
|
|
69
81
|
marginRight: theme.spacing(1)
|
|
70
82
|
},
|
|
@@ -76,6 +88,11 @@ var useReportItemStyles = (0, _makeStyles["default"])(function (theme) {
|
|
|
76
88
|
});
|
|
77
89
|
|
|
78
90
|
var ReportItem = function ReportItem(props) {
|
|
91
|
+
// using a context because TreeItem uses useMemo on this. See report-viewer.js for the provider
|
|
92
|
+
var _useContext = (0, _react.useContext)(_reportTreeViewContext["default"]),
|
|
93
|
+
isHighlighted = _useContext.isHighlighted;
|
|
94
|
+
|
|
95
|
+
var highlighted = isHighlighted ? isHighlighted(props.nodeId) : false;
|
|
79
96
|
var classes = useReportItemStyles();
|
|
80
97
|
|
|
81
98
|
var labelText = props.labelText,
|
|
@@ -92,7 +109,7 @@ var ReportItem = function ReportItem(props) {
|
|
|
92
109
|
label: classes.label
|
|
93
110
|
},
|
|
94
111
|
label: /*#__PURE__*/_react["default"].createElement("div", {
|
|
95
|
-
className: classes.labelRoot
|
|
112
|
+
className: highlighted ? classes.labelRootHighlighted : classes.labelRoot
|
|
96
113
|
}, /*#__PURE__*/_react["default"].createElement(_Label["default"], {
|
|
97
114
|
htmlColor: labelIconColor,
|
|
98
115
|
className: classes.labelIcon
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
var _react = require("react");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Copyright (c) 2022, RTE (http://www.rte-france.com)
|
|
10
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
11
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
12
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
13
|
+
*/
|
|
14
|
+
var ReportTreeViewContext = (0, _react.createContext)({});
|
|
15
|
+
|
|
16
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
17
|
+
ReportTreeViewContext.displayName = 'ReportTreeViewContext';
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
var _default = ReportTreeViewContext;
|
|
21
|
+
exports["default"] = _default;
|
|
22
|
+
module.exports = exports.default;
|
|
@@ -21,6 +21,8 @@ var _Grid = _interopRequireDefault(require("@mui/material/Grid"));
|
|
|
21
21
|
|
|
22
22
|
var _logTable = _interopRequireDefault(require("./log-table"));
|
|
23
23
|
|
|
24
|
+
var _reportTreeViewContext = _interopRequireDefault(require("./report-tree-view-context"));
|
|
25
|
+
|
|
24
26
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
27
|
|
|
26
28
|
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); }
|
|
@@ -62,6 +64,10 @@ function ReportViewer(_ref) {
|
|
|
62
64
|
logs = _useState3[0],
|
|
63
65
|
setLogs = _useState3[1];
|
|
64
66
|
|
|
67
|
+
var _useState4 = (0, _react.useState)(),
|
|
68
|
+
highlightedReportId = _useState4[0],
|
|
69
|
+
setHighlightedReportId = _useState4[1];
|
|
70
|
+
|
|
65
71
|
var rootReport = (0, _react.useRef)(null);
|
|
66
72
|
var allReports = (0, _react.useRef)({});
|
|
67
73
|
var treeView = (0, _react.useRef)(null);
|
|
@@ -108,7 +114,39 @@ function ReportViewer(_ref) {
|
|
|
108
114
|
if (selectedNode !== nodeId) {
|
|
109
115
|
setSelectedNode(nodeId);
|
|
110
116
|
setLogs(allReports.current[nodeId].getAllLogs());
|
|
117
|
+
setHighlightedReportId(null);
|
|
111
118
|
}
|
|
119
|
+
}; // The MUI TreeView/TreeItems use useMemo on our items, so it's important to avoid changing the context
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
var isHighlighted = (0, _react.useMemo)(function () {
|
|
123
|
+
return {
|
|
124
|
+
isHighlighted: function isHighlighted(reportId) {
|
|
125
|
+
return highlightedReportId === reportId;
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
}, [highlightedReportId]);
|
|
129
|
+
|
|
130
|
+
var onRowClick = function onRowClick(data) {
|
|
131
|
+
setExpandedNodes(function (previouslyExpandedNodes) {
|
|
132
|
+
var nodesToExpand = [];
|
|
133
|
+
var reportId = data.reportId;
|
|
134
|
+
|
|
135
|
+
while ((_allReports$current$r = allReports.current[reportId]) === null || _allReports$current$r === void 0 ? void 0 : _allReports$current$r.parentReportId) {
|
|
136
|
+
var _allReports$current$r;
|
|
137
|
+
|
|
138
|
+
var parentReportId = allReports.current[reportId].parentReportId;
|
|
139
|
+
|
|
140
|
+
if (!previouslyExpandedNodes.includes(parentReportId)) {
|
|
141
|
+
nodesToExpand.push(parentReportId);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
reportId = parentReportId;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (nodesToExpand.length > 0) return nodesToExpand.concat(previouslyExpandedNodes);else return previouslyExpandedNodes;
|
|
148
|
+
});
|
|
149
|
+
setHighlightedReportId(data.reportId);
|
|
112
150
|
};
|
|
113
151
|
|
|
114
152
|
return rootReport.current && /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
|
|
@@ -124,6 +162,8 @@ function ReportViewer(_ref) {
|
|
|
124
162
|
height: '95%',
|
|
125
163
|
borderRight: '1px solid rgba(81, 81, 81, 1)'
|
|
126
164
|
}
|
|
165
|
+
}, /*#__PURE__*/_react["default"].createElement(_reportTreeViewContext["default"].Provider, {
|
|
166
|
+
value: isHighlighted
|
|
127
167
|
}, /*#__PURE__*/_react["default"].createElement(_TreeView["default"], {
|
|
128
168
|
className: classes.treeView,
|
|
129
169
|
defaultCollapseIcon: /*#__PURE__*/_react["default"].createElement(_ArrowDropDown["default"], null),
|
|
@@ -137,7 +177,7 @@ function ReportViewer(_ref) {
|
|
|
137
177
|
onNodeSelect: handleSelectNode,
|
|
138
178
|
selected: selectedNode,
|
|
139
179
|
expanded: expandedNodes
|
|
140
|
-
}, treeView.current)), /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
|
|
180
|
+
}, treeView.current))), /*#__PURE__*/_react["default"].createElement(_Grid["default"], {
|
|
141
181
|
item: true,
|
|
142
182
|
xs: 12,
|
|
143
183
|
sm: 9,
|
|
@@ -145,7 +185,8 @@ function ReportViewer(_ref) {
|
|
|
145
185
|
height: '95%'
|
|
146
186
|
}
|
|
147
187
|
}, /*#__PURE__*/_react["default"].createElement(_logTable["default"], {
|
|
148
|
-
logs: logs
|
|
188
|
+
logs: logs,
|
|
189
|
+
onRowClick: onRowClick
|
|
149
190
|
})));
|
|
150
191
|
}
|
|
151
192
|
|
|
@@ -14,6 +14,10 @@ var login_en = {
|
|
|
14
14
|
'login/connection': 'Connection',
|
|
15
15
|
'login/unauthorizedAccess': 'Unauthorized access',
|
|
16
16
|
'login/unauthorizedAccessMessage': "The user {userName} isn't granted yet",
|
|
17
|
+
'login/errorInUserValidation': 'Error during user validation',
|
|
18
|
+
'login/errorInUserValidationMessage': 'An unexpected error occured during user validation for {userName}.',
|
|
19
|
+
'login/errorInLogout': 'Error during user logout',
|
|
20
|
+
'login/errorInLogoutMessage': 'An unexpected error occured during user logout for {userName}.',
|
|
17
21
|
'login/logout': 'Logout'
|
|
18
22
|
};
|
|
19
23
|
var _default = login_en;
|
|
@@ -14,6 +14,10 @@ var login_fr = {
|
|
|
14
14
|
'login/connection': 'Connexion',
|
|
15
15
|
'login/unauthorizedAccess': 'Accès non autorisé',
|
|
16
16
|
'login/unauthorizedAccessMessage': "L'utilisateur {userName} n'a pas encore accès à GridSuite",
|
|
17
|
+
'login/errorInUserValidation': "Erreur lors de la validation de l'utilisateur",
|
|
18
|
+
'login/errorInUserValidationMessage': "Une erreur s'est produite pendant la validation de l'utilisateur {userName}.",
|
|
19
|
+
'login/errorInLogout': "Erreur lors de la déconnexion de l'utilisateur",
|
|
20
|
+
'login/errorInLogoutMessage': "Une erreur s'est produite pendant la déconnexion de l'utilisateur {userName}.",
|
|
17
21
|
'login/logout': 'Se déconnecter'
|
|
18
22
|
};
|
|
19
23
|
var _default = login_fr;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useIntlRef = useIntlRef;
|
|
5
|
+
|
|
6
|
+
var _react = require("react");
|
|
7
|
+
|
|
8
|
+
var _reactIntl = require("react-intl");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Copyright (c) 2021, RTE (http://www.rte-france.com)
|
|
12
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
13
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
14
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
15
|
+
*/
|
|
16
|
+
//This useEffect must be at the beginning to be executed before other useEffects which use intlRef.
|
|
17
|
+
//This ref is used to avoid redoing other useEffects when the language (intl) is changed for things that produce temporary messages using the snackbar.
|
|
18
|
+
//The drawback to this custom hook is that a ref and a useEffect are created in each component that needs this hook.
|
|
19
|
+
//Can we avoid this overhead ?
|
|
20
|
+
function useIntlRef() {
|
|
21
|
+
var intl = (0, _reactIntl.useIntl)();
|
|
22
|
+
var intlRef = (0, _react.useRef)();
|
|
23
|
+
(0, _react.useEffect)(function () {
|
|
24
|
+
intlRef.current = intl;
|
|
25
|
+
}, [intl]);
|
|
26
|
+
return intlRef;
|
|
27
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports.useSnackMessage = useSnackMessage;
|
|
5
|
+
|
|
6
|
+
var _react = require("react");
|
|
7
|
+
|
|
8
|
+
var _notistack = require("notistack");
|
|
9
|
+
|
|
10
|
+
var _useIntlRef = require("./useIntlRef");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Copyright (c) 2021, RTE (http://www.rte-france.com)
|
|
14
|
+
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
15
|
+
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
16
|
+
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
17
|
+
*/
|
|
18
|
+
function useSnackMessage() {
|
|
19
|
+
var intlRef = (0, _useIntlRef.useIntlRef)();
|
|
20
|
+
|
|
21
|
+
var _useSnackbar = (0, _notistack.useSnackbar)(),
|
|
22
|
+
enqueueSnackbar = _useSnackbar.enqueueSnackbar;
|
|
23
|
+
/*
|
|
24
|
+
There is two kind of messages : the message itself (bottom of snackbar), and the header (top of snackbar).
|
|
25
|
+
As inputs, you can give either a text message, or an ID with optional values (for translation with intl).
|
|
26
|
+
snackInputs: {
|
|
27
|
+
messageTxt,
|
|
28
|
+
messageId,
|
|
29
|
+
messageValues,
|
|
30
|
+
headerTxt,
|
|
31
|
+
headerId,
|
|
32
|
+
headerValues,
|
|
33
|
+
}
|
|
34
|
+
*/
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
var snackError = (0, _react.useCallback)(function (snackInputs) {
|
|
38
|
+
return makeSnackbar(snackInputs, intlRef, enqueueSnackbar, 'error', true);
|
|
39
|
+
}, [enqueueSnackbar, intlRef]);
|
|
40
|
+
/* see snackError */
|
|
41
|
+
|
|
42
|
+
var snackWarning = (0, _react.useCallback)(function (snackInputs) {
|
|
43
|
+
return makeSnackbar(snackInputs, intlRef, enqueueSnackbar, 'warning', true);
|
|
44
|
+
}, [enqueueSnackbar, intlRef]);
|
|
45
|
+
/* see snackError */
|
|
46
|
+
|
|
47
|
+
var snackInfo = (0, _react.useCallback)(function (snackInputs) {
|
|
48
|
+
return makeSnackbar(snackInputs, intlRef, enqueueSnackbar, 'info', false);
|
|
49
|
+
}, [enqueueSnackbar, intlRef]);
|
|
50
|
+
return {
|
|
51
|
+
snackError: snackError,
|
|
52
|
+
snackInfo: snackInfo,
|
|
53
|
+
snackWarning: snackWarning
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function makeSnackbar(snackInputs, intlRef, enqueueSnackbar, level, persistent) {
|
|
58
|
+
var message = checkAndTranslateIfNecessary(snackInputs.messageTxt, snackInputs.messageId, snackInputs.messageValues, intlRef);
|
|
59
|
+
var header = checkAndTranslateIfNecessary(snackInputs.headerTxt, snackInputs.headerId, snackInputs.headerValues, intlRef);
|
|
60
|
+
displayMessageWithSnackbar(message, header, enqueueSnackbar, level, persistent);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function checkAndTranslateIfNecessary(txt, id, values, intlRef) {
|
|
64
|
+
checkInputs(txt, id, values);
|
|
65
|
+
return txt !== null && txt !== void 0 ? txt : id ? intlRef.current.formatMessage({
|
|
66
|
+
id: id
|
|
67
|
+
}, values) : null;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function checkInputs(txt, id, values) {
|
|
71
|
+
if (txt && (id || values)) {
|
|
72
|
+
console.warn('Snack inputs should be [*Txt] OR [*Id, *Values]');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function displayMessageWithSnackbar(message, header, enqueueSnackbar, level, persistent) {
|
|
77
|
+
var fullMessage = '';
|
|
78
|
+
|
|
79
|
+
if (header) {
|
|
80
|
+
fullMessage += header;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (message) {
|
|
84
|
+
if (header) {
|
|
85
|
+
fullMessage += '\n\n';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
fullMessage += message;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
enqueueSnackbar(fullMessage, {
|
|
92
|
+
variant: level,
|
|
93
|
+
persist: persistent,
|
|
94
|
+
style: {
|
|
95
|
+
whiteSpace: 'pre-line'
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
}
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
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 = 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.OverflowableText = exports.MuiVirtualizedTable = 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.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.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;
|
|
5
5
|
|
|
6
6
|
var _TreeViewFinder = _interopRequireDefault(require("./components/TreeViewFinder"));
|
|
7
7
|
|
|
@@ -80,6 +80,8 @@ exports.setLoggedUser = _actions.setLoggedUser;
|
|
|
80
80
|
exports.SIGNIN_CALLBACK_ERROR = _actions.SIGNIN_CALLBACK_ERROR;
|
|
81
81
|
exports.setSignInCallbackError = _actions.setSignInCallbackError;
|
|
82
82
|
exports.UNAUTHORIZED_USER_INFO = _actions.UNAUTHORIZED_USER_INFO;
|
|
83
|
+
exports.LOGOUT_ERROR = _actions.LOGOUT_ERROR;
|
|
84
|
+
exports.USER_VALIDATION_ERROR = _actions.USER_VALIDATION_ERROR;
|
|
83
85
|
exports.setShowAuthenticationRouterLogin = _actions.setShowAuthenticationRouterLogin;
|
|
84
86
|
exports.SHOW_AUTH_INFO_LOGIN = _actions.SHOW_AUTH_INFO_LOGIN;
|
|
85
87
|
|
|
@@ -159,6 +161,14 @@ var _useImportExportParams = require("./hooks/useImportExportParams");
|
|
|
159
161
|
|
|
160
162
|
exports.useImportExportParams = _useImportExportParams.useImportExportParams;
|
|
161
163
|
|
|
164
|
+
var _useIntlRef = require("./hooks/useIntlRef");
|
|
165
|
+
|
|
166
|
+
exports.useIntlRef = _useIntlRef.useIntlRef;
|
|
167
|
+
|
|
168
|
+
var _useSnackMessage = require("./hooks/useSnackMessage");
|
|
169
|
+
|
|
170
|
+
exports.useSnackMessage = _useSnackMessage.useSnackMessage;
|
|
171
|
+
|
|
162
172
|
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); }
|
|
163
173
|
|
|
164
174
|
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; }
|
package/lib/utils/AuthService.js
CHANGED
|
@@ -132,15 +132,29 @@ function login(location, userManagerInstance) {
|
|
|
132
132
|
}
|
|
133
133
|
|
|
134
134
|
function logout(dispatch, userManagerInstance) {
|
|
135
|
-
dispatch((0, _actions.setLoggedUser)(null));
|
|
136
135
|
sessionStorage.removeItem(hackauthoritykey); //To remove when hack is removed
|
|
137
136
|
|
|
138
|
-
return userManagerInstance.
|
|
139
|
-
|
|
140
|
-
|
|
137
|
+
return userManagerInstance.getUser().then(function (user) {
|
|
138
|
+
if (user) {
|
|
139
|
+
return userManagerInstance.signoutRedirect({
|
|
140
|
+
extraQueryParams: {
|
|
141
|
+
TargetResource: userManagerInstance.settings.post_logout_redirect_uri
|
|
142
|
+
}
|
|
143
|
+
}).then(function () {
|
|
144
|
+
console.debug('logged out, window is closing...');
|
|
145
|
+
})["catch"](function (e) {
|
|
146
|
+
var _user$profile;
|
|
147
|
+
|
|
148
|
+
console.log('Error during logout :', e); // An error occured, window may not be closed, reset the user state
|
|
149
|
+
|
|
150
|
+
dispatch((0, _actions.setLoggedUser)(null));
|
|
151
|
+
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, {
|
|
152
|
+
error: e
|
|
153
|
+
}));
|
|
154
|
+
});
|
|
155
|
+
} else {
|
|
156
|
+
console.log('Error nobody to logout ');
|
|
141
157
|
}
|
|
142
|
-
}).then(function () {
|
|
143
|
-
return console.debug('logged out');
|
|
144
158
|
});
|
|
145
159
|
}
|
|
146
160
|
|
|
@@ -151,12 +165,10 @@ function dispatchUser(dispatch, userManagerInstance, validateUser) {
|
|
|
151
165
|
var validateUserPromise = validateUser && validateUser(user) || Promise.resolve(true);
|
|
152
166
|
return validateUserPromise.then(function (valid) {
|
|
153
167
|
if (!valid) {
|
|
154
|
-
var _user$
|
|
168
|
+
var _user$profile2;
|
|
155
169
|
|
|
156
170
|
console.debug("User isn't authorized to log in and will not be dispatched");
|
|
157
|
-
return dispatch((0, _actions.setUnauthorizedUserInfo)({
|
|
158
|
-
userName: user === null || user === void 0 ? void 0 : (_user$profile = user.profile) === null || _user$profile === void 0 ? void 0 : _user$profile.name
|
|
159
|
-
}));
|
|
171
|
+
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, {}));
|
|
160
172
|
}
|
|
161
173
|
|
|
162
174
|
var now = parseInt(Date.now() / 1000);
|
|
@@ -170,6 +182,13 @@ function dispatchUser(dispatch, userManagerInstance, validateUser) {
|
|
|
170
182
|
|
|
171
183
|
console.debug('User has been successfully loaded from store.');
|
|
172
184
|
return dispatch((0, _actions.setLoggedUser)(user));
|
|
185
|
+
})["catch"](function (e) {
|
|
186
|
+
var _user$profile3;
|
|
187
|
+
|
|
188
|
+
console.log('Error in dispatchUser', e);
|
|
189
|
+
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, {
|
|
190
|
+
error: e
|
|
191
|
+
}));
|
|
173
192
|
});
|
|
174
193
|
} else {
|
|
175
194
|
console.debug('You are not logged in.');
|
|
@@ -199,11 +218,7 @@ function handleSilentRenewCallback(userManagerInstance) {
|
|
|
199
218
|
function handleUser(dispatch, userManager, validateUser) {
|
|
200
219
|
userManager.events.addUserLoaded(function (user) {
|
|
201
220
|
console.debug('user loaded', user);
|
|
202
|
-
dispatchUser(dispatch, userManager, validateUser)
|
|
203
|
-
// For now we log it to avoid uncaught Promise for good practice.
|
|
204
|
-
["catch"](function (e) {
|
|
205
|
-
console.log('Error in dispatchUser in addUserLoaded event', e);
|
|
206
|
-
});
|
|
221
|
+
dispatchUser(dispatch, userManager, validateUser);
|
|
207
222
|
});
|
|
208
223
|
userManager.events.addSilentRenewError(function (error) {
|
|
209
224
|
console.debug(error); // wait for accessTokenExpiringNotificationTime so that the user is expired
|
package/lib/utils/actions.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.USER = exports.UNAUTHORIZED_USER_INFO = exports.SIGNIN_CALLBACK_ERROR = exports.SHOW_AUTH_INFO_LOGIN = void 0;
|
|
4
|
+
exports.USER_VALIDATION_ERROR = exports.USER = exports.UNAUTHORIZED_USER_INFO = exports.SIGNIN_CALLBACK_ERROR = exports.SHOW_AUTH_INFO_LOGIN = exports.LOGOUT_ERROR = void 0;
|
|
5
5
|
exports.setLoggedUser = setLoggedUser;
|
|
6
|
+
exports.setLogoutError = setLogoutError;
|
|
6
7
|
exports.setShowAuthenticationRouterLogin = setShowAuthenticationRouterLogin;
|
|
7
8
|
exports.setSignInCallbackError = setSignInCallbackError;
|
|
8
9
|
exports.setUnauthorizedUserInfo = setUnauthorizedUserInfo;
|
|
10
|
+
exports.setUserValidationError = setUserValidationError;
|
|
9
11
|
|
|
10
12
|
/**
|
|
11
13
|
* Copyright (c) 2020, RTE (http://www.rte-france.com)
|
|
@@ -36,10 +38,39 @@ function setSignInCallbackError(signInCallbackError) {
|
|
|
36
38
|
var UNAUTHORIZED_USER_INFO = 'UNAUTHORIZED_USER_INFO';
|
|
37
39
|
exports.UNAUTHORIZED_USER_INFO = UNAUTHORIZED_USER_INFO;
|
|
38
40
|
|
|
39
|
-
function setUnauthorizedUserInfo(unauthorizedUserInfo) {
|
|
41
|
+
function setUnauthorizedUserInfo(userName, unauthorizedUserInfo) {
|
|
40
42
|
return {
|
|
41
43
|
type: UNAUTHORIZED_USER_INFO,
|
|
42
|
-
|
|
44
|
+
authenticationRouterError: {
|
|
45
|
+
userName: userName,
|
|
46
|
+
unauthorizedUserInfo: unauthorizedUserInfo
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var LOGOUT_ERROR = 'LOGOUT_ERROR';
|
|
52
|
+
exports.LOGOUT_ERROR = LOGOUT_ERROR;
|
|
53
|
+
|
|
54
|
+
function setLogoutError(userName, logoutError) {
|
|
55
|
+
return {
|
|
56
|
+
type: LOGOUT_ERROR,
|
|
57
|
+
authenticationRouterError: {
|
|
58
|
+
userName: userName,
|
|
59
|
+
logoutError: logoutError
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
var USER_VALIDATION_ERROR = 'USER_VALIDATION_ERROR';
|
|
65
|
+
exports.USER_VALIDATION_ERROR = USER_VALIDATION_ERROR;
|
|
66
|
+
|
|
67
|
+
function setUserValidationError(userName, userValidationError) {
|
|
68
|
+
return {
|
|
69
|
+
type: USER_VALIDATION_ERROR,
|
|
70
|
+
authenticationRouterError: {
|
|
71
|
+
userName: userName,
|
|
72
|
+
userValidationError: userValidationError
|
|
73
|
+
}
|
|
43
74
|
};
|
|
44
75
|
}
|
|
45
76
|
|