@gridsuite/commons-ui 0.46.0 → 0.47.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/README.md +0 -17
- package/dist/components/AuthenticationRouter/AuthenticationRouter.js +147 -0
- package/dist/components/CardErrorBoundary/card-error-boundary.js +110 -0
- package/dist/components/ElementSearchDialog/element-search-dialog.js +139 -0
- package/dist/components/ElementSearchDialog/equipment-item.js +77 -0
- package/dist/components/ElementSearchDialog/tag-renderer.js +34 -0
- package/dist/components/FlatParameters/FlatParameters.js +411 -0
- package/dist/components/Login/Login.js +78 -0
- package/dist/components/Login/Logout.js +69 -0
- package/dist/components/MuiVirtualizedTable/ColumnHeader.js +127 -0
- package/dist/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +548 -0
- package/dist/components/MuiVirtualizedTable/MuiVirtualizedTable.js +790 -0
- package/dist/components/MultipleSelectionDialog/MultipleSelectionDialog.js +87 -0
- package/dist/components/OverflowableText/overflowable-text.js +87 -0
- package/dist/components/ReportViewer/filter-button.js +64 -0
- package/dist/components/ReportViewer/log-report-item.js +95 -0
- package/dist/components/ReportViewer/log-report.js +49 -0
- package/dist/components/ReportViewer/log-table.js +131 -0
- package/dist/components/ReportViewer/multi-select-list.js +40 -0
- package/dist/components/ReportViewer/report-item.js +112 -0
- package/dist/components/ReportViewer/report-tree-view-context.js +8 -0
- package/dist/components/ReportViewer/report-viewer.js +158 -0
- package/dist/components/ReportViewerDialog/report-viewer-dialog.js +61 -0
- package/dist/components/SignInCallbackHandler/SignInCallbackHandler.js +13 -0
- package/dist/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +16 -0
- package/dist/components/SnackbarProvider/SnackbarProvider.js +28 -0
- package/dist/components/TopBar/AboutDialog.js +467 -0
- package/dist/components/TopBar/GridLogo.js +71 -0
- package/dist/components/TopBar/TopBar.js +679 -0
- package/dist/components/TreeViewFinder/TreeViewFinder.js +288 -0
- package/dist/components/react-hook-form/autocomplete-input.js +96 -0
- package/dist/components/react-hook-form/booleans/boolean-input.js +49 -0
- package/dist/components/react-hook-form/booleans/checkbox-input.js +24 -0
- package/dist/components/react-hook-form/booleans/switch-input.js +24 -0
- package/dist/components/react-hook-form/error-management/error-input.js +42 -0
- package/dist/components/react-hook-form/error-management/field-error-alert.js +9 -0
- package/dist/components/react-hook-form/error-management/mid-form-error.js +20 -0
- package/dist/components/react-hook-form/numbers/float-input.js +51 -0
- package/dist/components/react-hook-form/numbers/integer-input.js +36 -0
- package/dist/components/react-hook-form/numbers/utils.js +10 -0
- package/dist/components/react-hook-form/radio-input.js +44 -0
- package/dist/components/react-hook-form/select-input.js +31 -0
- package/dist/components/react-hook-form/slider-input.js +43 -0
- package/dist/components/react-hook-form/text-input.js +94 -0
- package/dist/components/react-hook-form/utils/cancel-button.js +16 -0
- package/dist/components/react-hook-form/utils/field-label.js +12 -0
- package/dist/components/react-hook-form/utils/functions.js +36 -0
- package/dist/components/react-hook-form/utils/submit-button.js +23 -0
- package/dist/components/react-hook-form/utils/text-field-with-adornment.js +96 -0
- package/dist/components/translations/card-error-boundary-en.js +8 -0
- package/dist/components/translations/card-error-boundary-fr.js +8 -0
- package/dist/components/translations/common-button-en.js +7 -0
- package/dist/components/translations/common-button-fr.js +7 -0
- package/dist/components/translations/element-search-en.js +7 -0
- package/dist/components/translations/element-search-fr.js +7 -0
- package/dist/components/translations/equipment-search-en.js +21 -0
- package/dist/components/translations/equipment-search-fr.js +21 -0
- package/dist/components/translations/flat-parameters-en.js +8 -0
- package/dist/components/translations/flat-parameters-fr.js +8 -0
- package/dist/components/translations/login-en.js +14 -0
- package/dist/components/translations/login-fr.js +14 -0
- package/dist/components/translations/multiple-selection-dialog-en.js +8 -0
- package/dist/components/translations/multiple-selection-dialog-fr.js +8 -0
- package/dist/components/translations/report-viewer-en.js +8 -0
- package/dist/components/translations/report-viewer-fr.js +8 -0
- package/dist/components/translations/table-en.js +6 -0
- package/dist/components/translations/table-fr.js +6 -0
- package/dist/components/translations/top-bar-en.js +27 -0
- package/dist/components/translations/top-bar-fr.js +27 -0
- package/dist/components/translations/treeview-finder-en.js +12 -0
- package/dist/components/translations/treeview-finder-fr.js +12 -0
- package/dist/hooks/useDebounce.js +17 -0
- package/{es/components/ElementSearchDialog/index.js → dist/hooks/useIntlRef.d.ts} +2 -2
- package/dist/hooks/useIntlRef.js +13 -0
- package/dist/hooks/useSnackMessage.js +81 -0
- package/dist/index.d.ts +225 -0
- package/dist/index.js +154 -0
- package/dist/utils/AuthService.js +336 -0
- package/dist/utils/ElementType.js +38 -0
- package/dist/utils/EquipmentType.js +132 -0
- package/dist/utils/UserManagerMock.js +85 -0
- package/dist/utils/actions.js +71 -0
- package/dist/utils/algos.js +24 -0
- package/dist/utils/styles.js +13 -0
- package/package.json +36 -21
- package/es/components/AuthenticationRouter/AuthenticationRouter.js +0 -102
- package/es/components/AuthenticationRouter/index.js +0 -7
- package/es/components/CardErrorBoundary/card-error-boundary.js +0 -138
- package/es/components/CardErrorBoundary/index.js +0 -7
- package/es/components/ElementSearchDialog/element-search-dialog.js +0 -153
- package/es/components/ElementSearchDialog/equipment-item.js +0 -63
- package/es/components/ElementSearchDialog/tag-renderer.js +0 -29
- package/es/components/FlatParameters/FlatParameters.js +0 -448
- package/es/components/FlatParameters/index.js +0 -8
- package/es/components/Login/Login.js +0 -79
- package/es/components/Login/Logout.js +0 -78
- package/es/components/Login/index.js +0 -7
- package/es/components/MuiVirtualizedTable/ColumnHeader.js +0 -125
- package/es/components/MuiVirtualizedTable/KeyedColumnsRowIndexer.js +0 -619
- package/es/components/MuiVirtualizedTable/MuiVirtualizedTable.js +0 -780
- package/es/components/MuiVirtualizedTable/index.js +0 -9
- package/es/components/MultipleSelectionDialog/MultipleSelectionDialog.js +0 -95
- package/es/components/MultipleSelectionDialog/index.js +0 -8
- package/es/components/OverflowableText/index.js +0 -7
- package/es/components/OverflowableText/overflowable-text.js +0 -81
- package/es/components/ReportViewer/filter-button.js +0 -77
- package/es/components/ReportViewer/index.js +0 -7
- package/es/components/ReportViewer/log-report-item.js +0 -97
- package/es/components/ReportViewer/log-report.js +0 -63
- package/es/components/ReportViewer/log-table.js +0 -130
- package/es/components/ReportViewer/multi-select-list.js +0 -56
- package/es/components/ReportViewer/report-item.js +0 -131
- package/es/components/ReportViewer/report-tree-view-context.js +0 -13
- package/es/components/ReportViewer/report-viewer.js +0 -167
- package/es/components/ReportViewerDialog/index.js +0 -7
- package/es/components/ReportViewerDialog/report-viewer-dialog.js +0 -67
- package/es/components/SignInCallbackHandler/SignInCallbackHandler.js +0 -19
- package/es/components/SignInCallbackHandler/index.js +0 -7
- package/es/components/SilentRenewCallbackHandler/SilentRenewCallbackHandler.js +0 -19
- package/es/components/SilentRenewCallbackHandler/index.js +0 -7
- package/es/components/SnackbarProvider/SnackbarProvider.js +0 -39
- package/es/components/SnackbarProvider/index.js +0 -7
- package/es/components/TopBar/AboutDialog.js +0 -456
- package/es/components/TopBar/GridLogo.js +0 -73
- package/es/components/TopBar/TopBar.js +0 -487
- package/es/components/TopBar/index.js +0 -9
- package/es/components/TreeViewFinder/TreeViewFinder.js +0 -341
- package/es/components/TreeViewFinder/index.js +0 -7
- package/es/components/images/powsybl_logo.svg +0 -35
- package/es/components/react-hook-form/autocomplete-input.js +0 -110
- package/es/components/react-hook-form/booleans/boolean-input.js +0 -56
- package/es/components/react-hook-form/booleans/checkbox-input.js +0 -28
- package/es/components/react-hook-form/booleans/switch-input.js +0 -28
- package/es/components/react-hook-form/error-management/error-input.js +0 -50
- package/es/components/react-hook-form/error-management/field-error-alert.js +0 -22
- package/es/components/react-hook-form/error-management/mid-form-error.js +0 -25
- package/es/components/react-hook-form/numbers/float-input.js +0 -105
- package/es/components/react-hook-form/numbers/integer-input.js +0 -35
- package/es/components/react-hook-form/numbers/utils.js +0 -6
- package/es/components/react-hook-form/radio-input.js +0 -55
- package/es/components/react-hook-form/select-input.js +0 -40
- package/es/components/react-hook-form/slider-input.js +0 -48
- package/es/components/react-hook-form/text-input.js +0 -100
- package/es/components/react-hook-form/utils/cancel-button.js +0 -28
- package/es/components/react-hook-form/utils/field-label.js +0 -15
- package/es/components/react-hook-form/utils/functions.js +0 -42
- package/es/components/react-hook-form/utils/submit-button.js +0 -29
- package/es/components/react-hook-form/utils/text-field-with-adornment.js +0 -92
- package/es/components/translations/card-error-boundary-en.js +0 -13
- package/es/components/translations/card-error-boundary-fr.js +0 -13
- package/es/components/translations/common-button-en.js +0 -12
- package/es/components/translations/common-button-fr.js +0 -12
- package/es/components/translations/element-search-en.js +0 -12
- package/es/components/translations/element-search-fr.js +0 -12
- package/es/components/translations/equipment-search-en.js +0 -26
- package/es/components/translations/equipment-search-fr.js +0 -26
- package/es/components/translations/flat-parameters-en.js +0 -13
- package/es/components/translations/flat-parameters-fr.js +0 -13
- package/es/components/translations/inputs-en.js +0 -25
- package/es/components/translations/inputs-fr.js +0 -25
- package/es/components/translations/login-en.js +0 -19
- package/es/components/translations/login-fr.js +0 -19
- package/es/components/translations/multiple-selection-dialog-en.js +0 -13
- package/es/components/translations/multiple-selection-dialog-fr.js +0 -13
- package/es/components/translations/report-viewer-en.js +0 -13
- package/es/components/translations/report-viewer-fr.js +0 -13
- package/es/components/translations/table-en.js +0 -11
- package/es/components/translations/table-fr.js +0 -11
- package/es/components/translations/top-bar-en.js +0 -32
- package/es/components/translations/top-bar-fr.js +0 -32
- package/es/components/translations/treeview-finder-en.js +0 -17
- package/es/components/translations/treeview-finder-fr.js +0 -17
- package/es/hooks/useDebounce.js +0 -26
- package/es/hooks/useIntlRef.js +0 -22
- package/es/hooks/useSnackMessage.js +0 -81
- package/es/index.js +0 -71
- package/es/utils/AuthService.js +0 -312
- package/es/utils/ElementType.js +0 -53
- package/es/utils/EquipmentType.js +0 -133
- package/es/utils/UserManagerMock.js +0 -81
- package/es/utils/actions.js +0 -65
- package/es/utils/algos.js +0 -29
- package/es/utils/styles.js +0 -35
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { Dialog, DialogTitle, DialogContent, Grid, FormControlLabel, Checkbox, List, DialogActions, Button } from "@mui/material";
|
|
3
|
+
import { FormattedMessage } from "react-intl";
|
|
4
|
+
import React, { useState } from "react";
|
|
5
|
+
const MultipleSelectionDialog = ({
|
|
6
|
+
options,
|
|
7
|
+
selectedOptions,
|
|
8
|
+
open,
|
|
9
|
+
getOptionLabel,
|
|
10
|
+
handleClose,
|
|
11
|
+
handleValidate,
|
|
12
|
+
titleId
|
|
13
|
+
}) => {
|
|
14
|
+
const [selectedIds, setSelectedIds] = useState(selectedOptions ?? []);
|
|
15
|
+
const handleSelectAll = () => {
|
|
16
|
+
if (selectedIds.length !== options.length) {
|
|
17
|
+
setSelectedIds(options);
|
|
18
|
+
} else {
|
|
19
|
+
setSelectedIds([]);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const handleOptionSelection = (option) => {
|
|
23
|
+
setSelectedIds((oldValues) => {
|
|
24
|
+
if (oldValues.includes(option)) {
|
|
25
|
+
return oldValues.filter((o) => o !== option);
|
|
26
|
+
}
|
|
27
|
+
return [...oldValues, option];
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
return /* @__PURE__ */ jsxs(Dialog, { open, children: [
|
|
31
|
+
/* @__PURE__ */ jsx(DialogTitle, { children: titleId }),
|
|
32
|
+
/* @__PURE__ */ jsx(DialogContent, { children: /* @__PURE__ */ jsxs(Grid, { container: true, spacing: 2, flexDirection: "column", children: [
|
|
33
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
34
|
+
FormControlLabel,
|
|
35
|
+
{
|
|
36
|
+
label: /* @__PURE__ */ jsx(
|
|
37
|
+
FormattedMessage,
|
|
38
|
+
{
|
|
39
|
+
id: "multiple_selection_dialog/selectAll"
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
control: /* @__PURE__ */ jsx(
|
|
43
|
+
Checkbox,
|
|
44
|
+
{
|
|
45
|
+
checked: selectedIds.length === options.length,
|
|
46
|
+
indeterminate: !!selectedIds.length && selectedIds.length !== options.length,
|
|
47
|
+
onChange: handleSelectAll
|
|
48
|
+
}
|
|
49
|
+
)
|
|
50
|
+
}
|
|
51
|
+
) }),
|
|
52
|
+
/* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(List, { children: options.map((option) => {
|
|
53
|
+
const optionId = (option == null ? void 0 : option.id) ?? option;
|
|
54
|
+
const label = getOptionLabel(option);
|
|
55
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: /* @__PURE__ */ jsx(Grid, { item: true, children: /* @__PURE__ */ jsx(
|
|
56
|
+
FormControlLabel,
|
|
57
|
+
{
|
|
58
|
+
label,
|
|
59
|
+
control: /* @__PURE__ */ jsx(
|
|
60
|
+
Checkbox,
|
|
61
|
+
{
|
|
62
|
+
checked: selectedIds.includes(
|
|
63
|
+
optionId
|
|
64
|
+
),
|
|
65
|
+
onChange: () => handleOptionSelection(
|
|
66
|
+
optionId
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
) }) }, optionId);
|
|
72
|
+
}) }) })
|
|
73
|
+
] }) }),
|
|
74
|
+
/* @__PURE__ */ jsxs(DialogActions, { children: [
|
|
75
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => handleClose(), children: /* @__PURE__ */ jsx(FormattedMessage, { id: "multiple_selection_dialog/cancel" }) }),
|
|
76
|
+
/* @__PURE__ */ jsx(Button, { onClick: () => handleValidate(selectedIds), children: /* @__PURE__ */ jsx(
|
|
77
|
+
FormattedMessage,
|
|
78
|
+
{
|
|
79
|
+
id: "multiple_selection_dialog/validate"
|
|
80
|
+
}
|
|
81
|
+
) })
|
|
82
|
+
] })
|
|
83
|
+
] });
|
|
84
|
+
};
|
|
85
|
+
export {
|
|
86
|
+
MultipleSelectionDialog as default
|
|
87
|
+
};
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useCallback, useLayoutEffect } from "react";
|
|
3
|
+
import { Tooltip, Box } from "@mui/material";
|
|
4
|
+
import PropTypes from "prop-types";
|
|
5
|
+
import { styled } from "@mui/system";
|
|
6
|
+
const overflowStyle = {
|
|
7
|
+
overflow: {
|
|
8
|
+
display: "inline-block",
|
|
9
|
+
whiteSpace: "pre",
|
|
10
|
+
textOverflow: "ellipsis",
|
|
11
|
+
overflow: "hidden"
|
|
12
|
+
},
|
|
13
|
+
tooltip: {
|
|
14
|
+
whiteSpace: "pre",
|
|
15
|
+
width: "fit-content",
|
|
16
|
+
maxWidth: "fit-content"
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
const OverflowableText = styled(
|
|
20
|
+
({ text, tooltipStyle, tooltipSx, className, children, ...props }) => {
|
|
21
|
+
var _a, _b;
|
|
22
|
+
const element = useRef();
|
|
23
|
+
const [overflowed, setOverflowed] = useState(false);
|
|
24
|
+
const checkOverflow = useCallback(() => {
|
|
25
|
+
if (!element.current) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setOverflowed(
|
|
29
|
+
element.current.scrollWidth > element.current.clientWidth
|
|
30
|
+
);
|
|
31
|
+
}, [setOverflowed, element]);
|
|
32
|
+
useLayoutEffect(() => {
|
|
33
|
+
checkOverflow();
|
|
34
|
+
}, [
|
|
35
|
+
checkOverflow,
|
|
36
|
+
text,
|
|
37
|
+
(_a = element.current) == null ? void 0 : _a.scrollWidth,
|
|
38
|
+
(_b = element.current) == null ? void 0 : _b.clientWidth
|
|
39
|
+
]);
|
|
40
|
+
const defaultTooltipSx = !tooltipStyle ? overflowStyle.tooltip : false;
|
|
41
|
+
const finalTooltipSx = tooltipSx || defaultTooltipSx;
|
|
42
|
+
const tooltipStyleProps = {
|
|
43
|
+
...tooltipStyle && { classes: { tooltip: tooltipStyle } },
|
|
44
|
+
...finalTooltipSx && {
|
|
45
|
+
slotProps: { tooltip: { sx: finalTooltipSx } }
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
return /* @__PURE__ */ jsx(
|
|
49
|
+
Tooltip,
|
|
50
|
+
{
|
|
51
|
+
title: text || "",
|
|
52
|
+
disableHoverListener: !overflowed,
|
|
53
|
+
...tooltipStyleProps,
|
|
54
|
+
children: /* @__PURE__ */ jsx(
|
|
55
|
+
Box,
|
|
56
|
+
{
|
|
57
|
+
...props,
|
|
58
|
+
ref: element,
|
|
59
|
+
children: children || text,
|
|
60
|
+
className,
|
|
61
|
+
sx: overflowStyle.overflow
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
)({});
|
|
68
|
+
OverflowableText.propTypes = {
|
|
69
|
+
children: PropTypes.array,
|
|
70
|
+
text: PropTypes.oneOfType([
|
|
71
|
+
PropTypes.string,
|
|
72
|
+
PropTypes.number,
|
|
73
|
+
PropTypes.node
|
|
74
|
+
]),
|
|
75
|
+
tooltipStyle: PropTypes.string,
|
|
76
|
+
tooltipSx: PropTypes.object,
|
|
77
|
+
sx: PropTypes.oneOfType([
|
|
78
|
+
PropTypes.object,
|
|
79
|
+
PropTypes.array,
|
|
80
|
+
PropTypes.func
|
|
81
|
+
]),
|
|
82
|
+
className: PropTypes.string
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
OverflowableText,
|
|
86
|
+
OverflowableText as default
|
|
87
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo } from "react";
|
|
3
|
+
import { Box, IconButton } from "@mui/material";
|
|
4
|
+
import { Menu } from "@mui/icons-material";
|
|
5
|
+
import { MultiSelectList } from "./multi-select-list.js";
|
|
6
|
+
const styles = {
|
|
7
|
+
notificationDot: {
|
|
8
|
+
height: "6px",
|
|
9
|
+
width: "6px",
|
|
10
|
+
backgroundColor: "#cc70a0",
|
|
11
|
+
borderRadius: "50%",
|
|
12
|
+
position: "absolute",
|
|
13
|
+
top: "5px",
|
|
14
|
+
left: "23px"
|
|
15
|
+
},
|
|
16
|
+
container: {
|
|
17
|
+
position: "relative"
|
|
18
|
+
},
|
|
19
|
+
icon: {
|
|
20
|
+
width: "0.7em",
|
|
21
|
+
height: "0.7em"
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
const FilterButton = ({ selectedItems, setSelectedItems }) => {
|
|
25
|
+
const [initialState] = useState(selectedItems);
|
|
26
|
+
const [anchorEl, setAnchorEl] = useState();
|
|
27
|
+
const handleClick = (event) => {
|
|
28
|
+
setAnchorEl(event.currentTarget);
|
|
29
|
+
};
|
|
30
|
+
const handleClose = () => {
|
|
31
|
+
setAnchorEl(null);
|
|
32
|
+
};
|
|
33
|
+
const handleChange = (event) => {
|
|
34
|
+
setSelectedItems((previousSelection) => {
|
|
35
|
+
return {
|
|
36
|
+
...previousSelection,
|
|
37
|
+
[event.target.name]: !selectedItems[event.target.name]
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
};
|
|
41
|
+
const isInitialStateModified = useMemo(() => {
|
|
42
|
+
return Object.keys(selectedItems).some(
|
|
43
|
+
(key) => initialState[key] !== selectedItems[key]
|
|
44
|
+
);
|
|
45
|
+
}, [initialState, selectedItems]);
|
|
46
|
+
return /* @__PURE__ */ jsxs(Box, { sx: styles.container, children: [
|
|
47
|
+
/* @__PURE__ */ jsxs(IconButton, { onClick: handleClick, children: [
|
|
48
|
+
/* @__PURE__ */ jsx(Menu, { sx: styles.icon }),
|
|
49
|
+
isInitialStateModified && /* @__PURE__ */ jsx(Box, { sx: styles.notificationDot })
|
|
50
|
+
] }),
|
|
51
|
+
/* @__PURE__ */ jsx(
|
|
52
|
+
MultiSelectList,
|
|
53
|
+
{
|
|
54
|
+
selectedItems,
|
|
55
|
+
handleChange,
|
|
56
|
+
handleClose,
|
|
57
|
+
anchor: anchorEl
|
|
58
|
+
}
|
|
59
|
+
)
|
|
60
|
+
] });
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
FilterButton
|
|
64
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
const _LogReportItem = class _LogReportItem {
|
|
8
|
+
static resolveTemplateMessage(templateMessage, templateValues) {
|
|
9
|
+
const templateVars = {};
|
|
10
|
+
for (const [key, value] of Object.entries(templateValues)) {
|
|
11
|
+
templateVars[key] = value.value;
|
|
12
|
+
}
|
|
13
|
+
return templateMessage.replace(/\${([^{}]*)}/g, function(a, b) {
|
|
14
|
+
let r = templateVars[b];
|
|
15
|
+
return typeof r === "string" || typeof r === "number" ? r : a;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
constructor(jsonReport, reportId) {
|
|
19
|
+
this.key = jsonReport.reportKey;
|
|
20
|
+
this.log = _LogReportItem.resolveTemplateMessage(
|
|
21
|
+
jsonReport.defaultMessage,
|
|
22
|
+
jsonReport.values
|
|
23
|
+
);
|
|
24
|
+
this.reportId = reportId;
|
|
25
|
+
this.severity = this.initSeverity(jsonReport.values.reportSeverity);
|
|
26
|
+
}
|
|
27
|
+
getLog() {
|
|
28
|
+
return this.log;
|
|
29
|
+
}
|
|
30
|
+
getReportId() {
|
|
31
|
+
return this.reportId;
|
|
32
|
+
}
|
|
33
|
+
getSeverity() {
|
|
34
|
+
return this.severity;
|
|
35
|
+
}
|
|
36
|
+
getSeverityName() {
|
|
37
|
+
return this.severity.name;
|
|
38
|
+
}
|
|
39
|
+
getColorName() {
|
|
40
|
+
return this.severity.colorName;
|
|
41
|
+
}
|
|
42
|
+
getColorHexCode() {
|
|
43
|
+
return this.severity.colorHexCode;
|
|
44
|
+
}
|
|
45
|
+
initSeverity(jsonSeverity) {
|
|
46
|
+
let severity = _LogReportItem.SEVERITY.UNKNOWN;
|
|
47
|
+
if (!jsonSeverity) {
|
|
48
|
+
return severity;
|
|
49
|
+
}
|
|
50
|
+
Object.values(_LogReportItem.SEVERITY).some((value) => {
|
|
51
|
+
let severityFound = jsonSeverity.value.includes(value.name);
|
|
52
|
+
if (severityFound) {
|
|
53
|
+
severity = value;
|
|
54
|
+
}
|
|
55
|
+
return severityFound;
|
|
56
|
+
});
|
|
57
|
+
return severity;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
__publicField(_LogReportItem, "SEVERITY", {
|
|
61
|
+
UNKNOWN: {
|
|
62
|
+
name: "UNKNOWN",
|
|
63
|
+
level: 0,
|
|
64
|
+
colorName: "cornflowerblue",
|
|
65
|
+
colorHexCode: "#6495ED"
|
|
66
|
+
},
|
|
67
|
+
INFO: {
|
|
68
|
+
name: "INFO",
|
|
69
|
+
level: 1,
|
|
70
|
+
colorName: "mediumseagreen",
|
|
71
|
+
colorHexCode: "#3CB371"
|
|
72
|
+
},
|
|
73
|
+
WARN: {
|
|
74
|
+
name: "WARN",
|
|
75
|
+
level: 2,
|
|
76
|
+
colorName: "orange",
|
|
77
|
+
colorHexCode: "#FFA500"
|
|
78
|
+
},
|
|
79
|
+
ERROR: {
|
|
80
|
+
name: "ERROR",
|
|
81
|
+
level: 3,
|
|
82
|
+
colorName: "crimson",
|
|
83
|
+
colorHexCode: "#DC143C"
|
|
84
|
+
},
|
|
85
|
+
FATAL: {
|
|
86
|
+
name: "FATAL",
|
|
87
|
+
level: 4,
|
|
88
|
+
colorName: "mediumorchid",
|
|
89
|
+
colorHexCode: "#BA55D3"
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
let LogReportItem = _LogReportItem;
|
|
93
|
+
export {
|
|
94
|
+
LogReportItem as default
|
|
95
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import LogReportItem from "./log-report-item.js";
|
|
2
|
+
import { v4 } from "uuid";
|
|
3
|
+
class LogReport {
|
|
4
|
+
constructor(jsonReporter, parentReportId) {
|
|
5
|
+
this.id = v4();
|
|
6
|
+
this.key = jsonReporter.taskKey;
|
|
7
|
+
this.title = LogReportItem.resolveTemplateMessage(
|
|
8
|
+
jsonReporter.defaultName,
|
|
9
|
+
jsonReporter.taskValues
|
|
10
|
+
);
|
|
11
|
+
this.subReports = [];
|
|
12
|
+
this.logs = [];
|
|
13
|
+
this.parentReportId = parentReportId;
|
|
14
|
+
this.init(jsonReporter);
|
|
15
|
+
}
|
|
16
|
+
getId() {
|
|
17
|
+
return this.id;
|
|
18
|
+
}
|
|
19
|
+
getTitle() {
|
|
20
|
+
return this.title;
|
|
21
|
+
}
|
|
22
|
+
getSubReports() {
|
|
23
|
+
return this.subReports;
|
|
24
|
+
}
|
|
25
|
+
getLogs() {
|
|
26
|
+
return this.logs;
|
|
27
|
+
}
|
|
28
|
+
getAllLogs() {
|
|
29
|
+
return this.getLogs().concat(
|
|
30
|
+
this.getSubReports().flatMap((r) => r.getAllLogs())
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
init(jsonReporter) {
|
|
34
|
+
jsonReporter.subReporters.map(
|
|
35
|
+
(value) => this.subReports.push(new LogReport(value, this.id))
|
|
36
|
+
);
|
|
37
|
+
jsonReporter.reports.map(
|
|
38
|
+
(value) => this.logs.push(new LogReportItem(value, this.id))
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
getHighestSeverity(currentSeverity = LogReportItem.SEVERITY.UNKNOWN) {
|
|
42
|
+
let reduceFct = (p, c) => p.level < c.level ? c : p;
|
|
43
|
+
let highestSeverity = this.getLogs().map((r) => r.getSeverity()).reduce(reduceFct, currentSeverity);
|
|
44
|
+
return this.getSubReports().map((r) => r.getHighestSeverity(highestSeverity)).reduce(reduceFct, highestSeverity);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
LogReport as default
|
|
49
|
+
};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { memo, useState, useEffect, useCallback } from "react";
|
|
3
|
+
import { useIntl } from "react-intl";
|
|
4
|
+
import { useTheme, TableCell } from "@mui/material";
|
|
5
|
+
import { styled } from "@mui/system";
|
|
6
|
+
import MuiVirtualizedTable from "../MuiVirtualizedTable/MuiVirtualizedTable.js";
|
|
7
|
+
import { FilterButton } from "./filter-button.js";
|
|
8
|
+
const SEVERITY_COLUMN_FIXED_WIDTH = 115;
|
|
9
|
+
const styles = {
|
|
10
|
+
flexContainer: {
|
|
11
|
+
display: "flex",
|
|
12
|
+
alignItems: "center",
|
|
13
|
+
boxSizing: "border-box"
|
|
14
|
+
},
|
|
15
|
+
table: (theme) => ({
|
|
16
|
+
// temporary right-to-left patch, waiting for
|
|
17
|
+
// https://github.com/bvaughn/react-virtualized/issues/454
|
|
18
|
+
"& .ReactVirtualized__Table__headerRow": {
|
|
19
|
+
flip: false,
|
|
20
|
+
paddingRight: theme.direction === "rtl" ? "0 !important" : void 0
|
|
21
|
+
}
|
|
22
|
+
}),
|
|
23
|
+
header: { variant: "header" }
|
|
24
|
+
};
|
|
25
|
+
const VirtualizedTable = styled(MuiVirtualizedTable)(styles);
|
|
26
|
+
const LogTable = ({
|
|
27
|
+
logs,
|
|
28
|
+
onRowClick,
|
|
29
|
+
selectedSeverity,
|
|
30
|
+
setSelectedSeverity
|
|
31
|
+
}) => {
|
|
32
|
+
const intl = useIntl();
|
|
33
|
+
const theme = useTheme();
|
|
34
|
+
const [selectedRowIndex, setSelectedRowIndex] = useState(-1);
|
|
35
|
+
const severityCellRender = (cellData) => {
|
|
36
|
+
return /* @__PURE__ */ jsx(
|
|
37
|
+
TableCell,
|
|
38
|
+
{
|
|
39
|
+
component: "div",
|
|
40
|
+
variant: "body",
|
|
41
|
+
style: {
|
|
42
|
+
display: "flex",
|
|
43
|
+
flex: "1",
|
|
44
|
+
backgroundColor: cellData.rowData.backgroundColor
|
|
45
|
+
},
|
|
46
|
+
align: "center",
|
|
47
|
+
children: cellData.rowData.severity
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
};
|
|
51
|
+
const COLUMNS_DEFINITIONS = [
|
|
52
|
+
{
|
|
53
|
+
label: intl.formatMessage({ id: "report_viewer/severity" }).toUpperCase(),
|
|
54
|
+
id: "severity",
|
|
55
|
+
dataKey: "severity",
|
|
56
|
+
maxWidth: SEVERITY_COLUMN_FIXED_WIDTH,
|
|
57
|
+
minWidth: SEVERITY_COLUMN_FIXED_WIDTH,
|
|
58
|
+
cellRenderer: severityCellRender,
|
|
59
|
+
extra: /* @__PURE__ */ jsx(
|
|
60
|
+
FilterButton,
|
|
61
|
+
{
|
|
62
|
+
selectedItems: selectedSeverity,
|
|
63
|
+
setSelectedItems: setSelectedSeverity
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
label: intl.formatMessage({ id: "report_viewer/message" }).toUpperCase(),
|
|
69
|
+
id: "message",
|
|
70
|
+
dataKey: "message"
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
const generateTableColumns = () => {
|
|
74
|
+
return Object.values(COLUMNS_DEFINITIONS).map((c) => {
|
|
75
|
+
return c;
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
const generateTableRows = () => {
|
|
79
|
+
return logs.map((log) => {
|
|
80
|
+
return {
|
|
81
|
+
severity: log.getSeverityName(),
|
|
82
|
+
message: log.getLog(),
|
|
83
|
+
backgroundColor: log.getColorName(),
|
|
84
|
+
reportId: log.getReportId()
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
const handleRowClick = (event) => {
|
|
89
|
+
setSelectedRowIndex(event.index);
|
|
90
|
+
onRowClick(event.rowData);
|
|
91
|
+
};
|
|
92
|
+
const rowStyleFormat = (row) => {
|
|
93
|
+
if (row.index < 0) {
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
if (selectedRowIndex === row.index) {
|
|
97
|
+
return {
|
|
98
|
+
backgroundColor: theme.palette.action.selected
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
setSelectedRowIndex(-1);
|
|
104
|
+
}, [logs]);
|
|
105
|
+
const filter = useCallback(
|
|
106
|
+
(row) => {
|
|
107
|
+
return row.severity && Object.entries(selectedSeverity).some(
|
|
108
|
+
([key, value]) => key === row.severity && value
|
|
109
|
+
);
|
|
110
|
+
},
|
|
111
|
+
[selectedSeverity]
|
|
112
|
+
);
|
|
113
|
+
return (
|
|
114
|
+
//TODO do we need to useMemo/useCallback these props to avoid rerenders ?
|
|
115
|
+
/* @__PURE__ */ jsx(
|
|
116
|
+
VirtualizedTable,
|
|
117
|
+
{
|
|
118
|
+
columns: generateTableColumns(),
|
|
119
|
+
rows: generateTableRows(),
|
|
120
|
+
sortable: false,
|
|
121
|
+
onRowClick: handleRowClick,
|
|
122
|
+
rowStyle: rowStyleFormat,
|
|
123
|
+
filter
|
|
124
|
+
}
|
|
125
|
+
)
|
|
126
|
+
);
|
|
127
|
+
};
|
|
128
|
+
const LogTable$1 = memo(LogTable);
|
|
129
|
+
export {
|
|
130
|
+
LogTable$1 as default
|
|
131
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import "react";
|
|
3
|
+
import { Menu, MenuItem, FormControlLabel, Checkbox } from "@mui/material";
|
|
4
|
+
const styles = {
|
|
5
|
+
label: {
|
|
6
|
+
width: "100%",
|
|
7
|
+
margin: 0
|
|
8
|
+
},
|
|
9
|
+
menuItem: {
|
|
10
|
+
padding: "0 10px 0 0"
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
const MultiSelectList = ({
|
|
14
|
+
selectedItems,
|
|
15
|
+
handleChange,
|
|
16
|
+
handleClose,
|
|
17
|
+
anchor
|
|
18
|
+
}) => {
|
|
19
|
+
const open = Boolean(anchor);
|
|
20
|
+
return /* @__PURE__ */ jsx(Menu, { open, onClose: handleClose, anchorEl: anchor, children: Object.entries(selectedItems).map(([key, value]) => {
|
|
21
|
+
return /* @__PURE__ */ jsx(MenuItem, { sx: styles.menuItem, children: /* @__PURE__ */ jsx(
|
|
22
|
+
FormControlLabel,
|
|
23
|
+
{
|
|
24
|
+
control: /* @__PURE__ */ jsx(
|
|
25
|
+
Checkbox,
|
|
26
|
+
{
|
|
27
|
+
checked: value,
|
|
28
|
+
onChange: handleChange,
|
|
29
|
+
name: key
|
|
30
|
+
}
|
|
31
|
+
),
|
|
32
|
+
label: key,
|
|
33
|
+
sx: styles.label
|
|
34
|
+
}
|
|
35
|
+
) }, key);
|
|
36
|
+
}) });
|
|
37
|
+
};
|
|
38
|
+
export {
|
|
39
|
+
MultiSelectList
|
|
40
|
+
};
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { Box, Typography } from "@mui/material";
|
|
4
|
+
import { styled, alpha } from "@mui/system";
|
|
5
|
+
import PropTypes from "prop-types";
|
|
6
|
+
import { TreeItem } from "@mui/lab";
|
|
7
|
+
import { Label } from "@mui/icons-material";
|
|
8
|
+
import ReportTreeViewContext from "./report-tree-view-context.js";
|
|
9
|
+
const styles = {
|
|
10
|
+
root: (theme) => ({
|
|
11
|
+
color: theme.palette.text.secondary,
|
|
12
|
+
"&:hover > .MuiTreeItem-content": {
|
|
13
|
+
backgroundColor: theme.palette.action.hover
|
|
14
|
+
}
|
|
15
|
+
}),
|
|
16
|
+
content: (theme) => ({
|
|
17
|
+
color: theme.palette.text.secondary,
|
|
18
|
+
borderRadius: theme.spacing(2),
|
|
19
|
+
width: "fit-content",
|
|
20
|
+
paddingRight: theme.spacing(1),
|
|
21
|
+
fontWeight: theme.typography.fontWeightMedium,
|
|
22
|
+
"&.Mui-expanded": {
|
|
23
|
+
fontWeight: theme.typography.fontWeightRegular
|
|
24
|
+
},
|
|
25
|
+
/* &.MuiTreeItem-content.Mui-focused to increase specifity because mui5 has a rule for &.Mui-selected.Mui-focused */
|
|
26
|
+
"&.MuiTreeItem-content.Mui-focused, &.Mui-selected": {
|
|
27
|
+
backgroundColor: `var(--tree-view-bg-color, ${theme.palette.action.selected})`,
|
|
28
|
+
color: "var(--tree-view-color)"
|
|
29
|
+
},
|
|
30
|
+
// same as mui v4 behavior on label text only right after clicking in contrast to after moving away with arrow keys.
|
|
31
|
+
"&.Mui-selected .MuiTreeItem-label:hover, &.Mui-selected.Mui-focused .MuiTreeItem-label": {
|
|
32
|
+
borderRadius: theme.spacing(2),
|
|
33
|
+
backgroundColor: alpha(
|
|
34
|
+
theme.palette.primary.main,
|
|
35
|
+
theme.palette.action.selectedOpacity + theme.palette.action.hoverOpacity
|
|
36
|
+
)
|
|
37
|
+
},
|
|
38
|
+
"&.Mui-focused .MuiTreeItem-label, &:hover .MuiTreeItem-label, &Mui-selected .MuiTreeItem-label": {
|
|
39
|
+
backgroundColor: "transparent"
|
|
40
|
+
}
|
|
41
|
+
}),
|
|
42
|
+
group: (theme) => ({
|
|
43
|
+
marginLeft: "10px",
|
|
44
|
+
"& .MuiTreeItem-content": {
|
|
45
|
+
paddingLeft: theme.spacing(2)
|
|
46
|
+
}
|
|
47
|
+
}),
|
|
48
|
+
expanded: {},
|
|
49
|
+
selected: {},
|
|
50
|
+
label: {
|
|
51
|
+
fontWeight: "inherit",
|
|
52
|
+
color: "inherit"
|
|
53
|
+
},
|
|
54
|
+
labelRoot: (theme) => ({
|
|
55
|
+
display: "flex",
|
|
56
|
+
alignItems: "center",
|
|
57
|
+
padding: theme.spacing(0.5, 0)
|
|
58
|
+
}),
|
|
59
|
+
labelRootHighlighted: (theme) => ({
|
|
60
|
+
display: "flex",
|
|
61
|
+
alignItems: "center",
|
|
62
|
+
padding: theme.spacing(0.5, 0),
|
|
63
|
+
backgroundColor: theme.palette.action.selected
|
|
64
|
+
}),
|
|
65
|
+
labelIcon: (theme) => ({
|
|
66
|
+
marginRight: theme.spacing(1)
|
|
67
|
+
}),
|
|
68
|
+
labelText: (theme) => ({
|
|
69
|
+
fontWeight: "inherit",
|
|
70
|
+
marginRight: theme.spacing(2)
|
|
71
|
+
})
|
|
72
|
+
};
|
|
73
|
+
const ReportItem = (props) => {
|
|
74
|
+
const { isHighlighted } = useContext(ReportTreeViewContext);
|
|
75
|
+
const highlighted = isHighlighted ? isHighlighted(props.nodeId) : false;
|
|
76
|
+
const { labelText, labelIconColor, className, ...other } = props;
|
|
77
|
+
return /* @__PURE__ */ jsx(
|
|
78
|
+
TreeItem,
|
|
79
|
+
{
|
|
80
|
+
className,
|
|
81
|
+
sx: {
|
|
82
|
+
"&": styles.root,
|
|
83
|
+
"& .MuiTreeItem-content": styles.content,
|
|
84
|
+
"& .Mui-expanded": styles.expanded,
|
|
85
|
+
"& .Mui-selected": styles.selected,
|
|
86
|
+
"& .MuiTreeItem-group": styles.group,
|
|
87
|
+
"& .MuiTreeItem-label": styles.label
|
|
88
|
+
},
|
|
89
|
+
label: /* @__PURE__ */ jsxs(
|
|
90
|
+
Box,
|
|
91
|
+
{
|
|
92
|
+
sx: highlighted ? styles.labelRootHighlighted : styles.labelRoot,
|
|
93
|
+
children: [
|
|
94
|
+
/* @__PURE__ */ jsx(Label, { htmlColor: labelIconColor, sx: styles.labelIcon }),
|
|
95
|
+
/* @__PURE__ */ jsx(Typography, { variant: "body2", sx: styles.labelText, children: labelText })
|
|
96
|
+
]
|
|
97
|
+
}
|
|
98
|
+
),
|
|
99
|
+
...other
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
};
|
|
103
|
+
ReportItem.propTypes = {
|
|
104
|
+
bgColor: PropTypes.string,
|
|
105
|
+
color: PropTypes.string,
|
|
106
|
+
labelInfo: PropTypes.string,
|
|
107
|
+
labelText: PropTypes.string.isRequired
|
|
108
|
+
};
|
|
109
|
+
const ReportItem$1 = styled(ReportItem)({});
|
|
110
|
+
export {
|
|
111
|
+
ReportItem$1 as default
|
|
112
|
+
};
|