@centreon/ui 23.10.62 → 23.10.64
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/package.json +1 -1
- package/src/Button/Icon/index.tsx +10 -1
- package/src/Graph/Gauge/AnimatedPie.tsx +31 -20
- package/src/Graph/Gauge/Gauge.stories.tsx +97 -6
- package/src/Graph/Gauge/Gauge.tsx +4 -15
- package/src/Graph/Gauge/PieData.tsx +8 -24
- package/src/Graph/Gauge/ResponsiveGauge.tsx +11 -14
- package/src/Graph/Gauge/Thresholds.tsx +109 -56
- package/src/Graph/Gauge/models.ts +2 -3
- package/src/Graph/LineChart/BasicComponents/ThresholdLine.tsx +64 -0
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +31 -73
- package/src/Graph/LineChart/LineChart.tsx +14 -13
- package/src/Graph/LineChart/index.stories.tsx +67 -3
- package/src/Graph/LineChart/index.tsx +3 -9
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +10 -8
- package/src/Graph/SingleBar/SingleBar.stories.tsx +119 -6
- package/src/Graph/SingleBar/ThresholdLine.tsx +74 -0
- package/src/Graph/SingleBar/Thresholds.tsx +28 -82
- package/src/Graph/SingleBar/models.ts +2 -4
- package/src/Graph/Text/Text.tsx +20 -16
- package/src/Graph/common/models.ts +12 -0
- package/src/Graph/common/utils.ts +59 -6
- package/src/Listing/ActionBar/index.tsx +14 -7
- package/src/Listing/Cell/DataCell.tsx +7 -7
- package/src/Listing/Cell/index.tsx +5 -5
- package/src/Listing/Header/Cell/ListingHeaderCell.styles.ts +3 -3
- package/src/Listing/Header/Cell/ListingHeaderCell.tsx +2 -2
- package/src/Listing/Header/ListingHeader.tsx +4 -4
- package/src/Listing/Listing.styles.ts +1 -1
- package/src/Listing/Row/Row.tsx +3 -3
- package/src/Listing/index.stories.tsx +5 -5
- package/src/Listing/index.tsx +15 -12
- package/src/Listing/tableAtoms.ts +14 -11
- package/src/Listing/useStyleTable.ts +8 -8
- package/src/SortableItems/SortableItem.tsx +2 -1
- package/src/utils/useThresholds.ts +0 -0
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Thresholds } from '../common/models';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export const barHeight = 50;
|
|
3
|
+
import { ThresholdLine } from './ThresholdLine';
|
|
6
4
|
|
|
7
5
|
export const groupMargin = 25;
|
|
8
6
|
|
|
9
|
-
const lineMargin = 10;
|
|
10
|
-
|
|
11
|
-
const thresholdLineHeight = 60 + 2 * lineMargin;
|
|
12
|
-
|
|
13
7
|
interface Props {
|
|
14
8
|
hideTooltip: () => void;
|
|
15
9
|
showTooltip: (args) => void;
|
|
16
|
-
|
|
17
|
-
thresholds: Array<number>;
|
|
10
|
+
thresholds: Thresholds;
|
|
18
11
|
xScale: (value: number) => number;
|
|
19
12
|
}
|
|
20
13
|
|
|
@@ -22,79 +15,32 @@ const Thresholds = ({
|
|
|
22
15
|
xScale,
|
|
23
16
|
thresholds,
|
|
24
17
|
showTooltip,
|
|
25
|
-
hideTooltip
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const onMouseEnter =
|
|
38
|
-
({ label, left }) =>
|
|
39
|
-
(): void =>
|
|
40
|
-
showTooltip({
|
|
41
|
-
tooltipData: label,
|
|
42
|
-
tooltipLeft: left,
|
|
43
|
-
tooltipTop: bottom
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<>
|
|
48
|
-
<line
|
|
49
|
-
data-testid="warning-line"
|
|
50
|
-
stroke={theme.palette.warning.main}
|
|
51
|
-
strokeDasharray={4}
|
|
52
|
-
strokeWidth={2}
|
|
53
|
-
x1={xScale(warningValue)}
|
|
54
|
-
x2={xScale(warningValue)}
|
|
55
|
-
y1={groupMargin + 3 * lineMargin}
|
|
56
|
-
y2={thresholdLineHeight + groupMargin + 3 * lineMargin}
|
|
57
|
-
/>
|
|
58
|
-
<line
|
|
59
|
-
data-testid="critical-line"
|
|
60
|
-
stroke={theme.palette.error.main}
|
|
61
|
-
strokeDasharray={4}
|
|
62
|
-
strokeWidth={2}
|
|
63
|
-
x1={xScale(criticalValue)}
|
|
64
|
-
x2={xScale(criticalValue)}
|
|
65
|
-
y1={groupMargin + 3 * lineMargin}
|
|
66
|
-
y2={thresholdLineHeight + groupMargin + 3 * lineMargin}
|
|
67
|
-
/>
|
|
68
|
-
<line
|
|
69
|
-
data-testid="warning-line-tooltip"
|
|
70
|
-
stroke="transparent"
|
|
71
|
-
strokeWidth={5}
|
|
72
|
-
x1={xScale(warningValue)}
|
|
73
|
-
x2={xScale(warningValue)}
|
|
74
|
-
y1={groupMargin + 3 * lineMargin}
|
|
75
|
-
y2={thresholdLineHeight + groupMargin + 3 * lineMargin}
|
|
76
|
-
onMouseEnter={onMouseEnter({
|
|
77
|
-
label: warningTooltipLabel,
|
|
78
|
-
left: xScale(warningValue)
|
|
79
|
-
})}
|
|
80
|
-
onMouseLeave={hideTooltip}
|
|
18
|
+
hideTooltip
|
|
19
|
+
}: Props): JSX.Element => (
|
|
20
|
+
<>
|
|
21
|
+
{thresholds.warning.map(({ value, label }) => (
|
|
22
|
+
<ThresholdLine
|
|
23
|
+
hideTooltip={hideTooltip}
|
|
24
|
+
key={`warning-${value.toString()}`}
|
|
25
|
+
label={label}
|
|
26
|
+
showTooltip={showTooltip}
|
|
27
|
+
thresholdType="warning"
|
|
28
|
+
value={value}
|
|
29
|
+
xScale={xScale}
|
|
81
30
|
/>
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
left: xScale(criticalValue)
|
|
93
|
-
})}
|
|
94
|
-
onMouseLeave={hideTooltip}
|
|
31
|
+
))}
|
|
32
|
+
{thresholds.critical.map(({ value, label }) => (
|
|
33
|
+
<ThresholdLine
|
|
34
|
+
hideTooltip={hideTooltip}
|
|
35
|
+
key={`critical-${value.toString()}`}
|
|
36
|
+
label={label}
|
|
37
|
+
showTooltip={showTooltip}
|
|
38
|
+
thresholdType="critical"
|
|
39
|
+
value={value}
|
|
40
|
+
xScale={xScale}
|
|
95
41
|
/>
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
42
|
+
))}
|
|
43
|
+
</>
|
|
44
|
+
);
|
|
99
45
|
|
|
100
46
|
export default Thresholds;
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { LineChartData } from '../common/models';
|
|
1
|
+
import { LineChartData, Thresholds } from '../common/models';
|
|
2
2
|
|
|
3
3
|
export interface SingleBarProps {
|
|
4
4
|
data?: LineChartData;
|
|
5
|
-
|
|
6
|
-
thresholdTooltipLabels: Array<string>;
|
|
7
|
-
thresholds: Array<number>;
|
|
5
|
+
thresholds: Thresholds;
|
|
8
6
|
}
|
package/src/Graph/Text/Text.tsx
CHANGED
|
@@ -2,7 +2,7 @@ import { isNil } from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
import { Typography, useTheme } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
import { LineChartData } from '../common/models';
|
|
5
|
+
import { LineChartData, Thresholds } from '../common/models';
|
|
6
6
|
import {
|
|
7
7
|
formatMetricValue,
|
|
8
8
|
getMetricWithLatestData
|
|
@@ -13,19 +13,17 @@ import { useTextStyles } from './Text.styles';
|
|
|
13
13
|
|
|
14
14
|
interface Props {
|
|
15
15
|
data?: LineChartData;
|
|
16
|
-
disabledThresholds?: boolean;
|
|
17
16
|
labels: {
|
|
18
17
|
critical: string;
|
|
19
18
|
warning: string;
|
|
20
19
|
};
|
|
21
|
-
thresholds:
|
|
20
|
+
thresholds: Thresholds;
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export const Text = ({
|
|
25
24
|
thresholds,
|
|
26
25
|
data,
|
|
27
|
-
labels
|
|
28
|
-
disabledThresholds
|
|
26
|
+
labels
|
|
29
27
|
}: Props): JSX.Element | null => {
|
|
30
28
|
const theme = useTheme();
|
|
31
29
|
const { classes } = useTextStyles();
|
|
@@ -44,6 +42,20 @@ export const Text = ({
|
|
|
44
42
|
thresholds
|
|
45
43
|
});
|
|
46
44
|
|
|
45
|
+
const warningThresholdLabels = thresholds.warning.map(({ value }) =>
|
|
46
|
+
formatMetricValue({
|
|
47
|
+
unit: metricUnit,
|
|
48
|
+
value
|
|
49
|
+
})
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const criticalThresholdLabels = thresholds.critical.map(({ value }) =>
|
|
53
|
+
formatMetricValue({
|
|
54
|
+
unit: metricUnit,
|
|
55
|
+
value
|
|
56
|
+
})
|
|
57
|
+
);
|
|
58
|
+
|
|
47
59
|
return (
|
|
48
60
|
<div className={classes.graphText}>
|
|
49
61
|
<Typography sx={{ color }} variant="h3">
|
|
@@ -53,25 +65,17 @@ export const Text = ({
|
|
|
53
65
|
})}{' '}
|
|
54
66
|
{metricUnit}
|
|
55
67
|
</Typography>
|
|
56
|
-
{
|
|
68
|
+
{thresholds.enabled && (
|
|
57
69
|
<div className={classes.thresholds}>
|
|
58
70
|
<Typography sx={{ color: 'warning.main' }} variant="h5">
|
|
59
71
|
{labels.warning}
|
|
60
72
|
{': '}
|
|
61
|
-
{
|
|
62
|
-
unit: metricUnit,
|
|
63
|
-
value: thresholds[0]
|
|
64
|
-
})}{' '}
|
|
65
|
-
{metricUnit}
|
|
73
|
+
{warningThresholdLabels.join(' - ')} {metricUnit}
|
|
66
74
|
</Typography>
|
|
67
75
|
<Typography sx={{ color: 'error.main' }} variant="h5">
|
|
68
76
|
{labels.critical}
|
|
69
77
|
{': '}
|
|
70
|
-
{
|
|
71
|
-
unit: metricUnit,
|
|
72
|
-
value: thresholds[1]
|
|
73
|
-
})}{' '}
|
|
74
|
-
{metricUnit}
|
|
78
|
+
{criticalThresholdLabels.join(' - ')} {metricUnit}
|
|
75
79
|
</Typography>
|
|
76
80
|
</div>
|
|
77
81
|
)}
|
|
@@ -5,3 +5,15 @@ export interface LineChartData {
|
|
|
5
5
|
metrics: Array<Metric>;
|
|
6
6
|
times: Array<string>;
|
|
7
7
|
}
|
|
8
|
+
|
|
9
|
+
export interface Thresholds {
|
|
10
|
+
critical: Array<{
|
|
11
|
+
label: string;
|
|
12
|
+
value: number;
|
|
13
|
+
}>;
|
|
14
|
+
enabled: boolean;
|
|
15
|
+
warning: Array<{
|
|
16
|
+
label: string;
|
|
17
|
+
value: number;
|
|
18
|
+
}>;
|
|
19
|
+
}
|
|
@@ -1,20 +1,73 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
T,
|
|
3
|
+
always,
|
|
4
|
+
cond,
|
|
5
|
+
equals,
|
|
6
|
+
gt,
|
|
7
|
+
gte,
|
|
8
|
+
head,
|
|
9
|
+
length,
|
|
10
|
+
lt,
|
|
11
|
+
lte,
|
|
12
|
+
pluck
|
|
13
|
+
} from 'ramda';
|
|
2
14
|
|
|
3
15
|
import { Theme } from '@mui/material';
|
|
4
16
|
|
|
17
|
+
import { Thresholds } from './models';
|
|
18
|
+
|
|
5
19
|
interface GetColorFromDataAndThresholdsProps {
|
|
6
20
|
data: number;
|
|
7
21
|
theme: Theme;
|
|
8
|
-
thresholds:
|
|
22
|
+
thresholds: Thresholds;
|
|
9
23
|
}
|
|
10
24
|
|
|
11
25
|
export const getColorFromDataAndTresholds = ({
|
|
12
26
|
data,
|
|
13
27
|
thresholds,
|
|
14
28
|
theme
|
|
15
|
-
}: GetColorFromDataAndThresholdsProps): string =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
29
|
+
}: GetColorFromDataAndThresholdsProps): string => {
|
|
30
|
+
if (!thresholds.enabled) {
|
|
31
|
+
return theme.palette.success.main;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const criticalValues = pluck('value', thresholds.critical).sort();
|
|
35
|
+
const warningValues = pluck('value', thresholds.warning).sort();
|
|
36
|
+
|
|
37
|
+
if (
|
|
38
|
+
equals(length(criticalValues), 2) &&
|
|
39
|
+
lte(criticalValues[0], data) &&
|
|
40
|
+
gte(criticalValues[1], data)
|
|
41
|
+
) {
|
|
42
|
+
return theme.palette.error.main;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
if (
|
|
46
|
+
equals(length(warningValues), 2) &&
|
|
47
|
+
lte(warningValues[0], data) &&
|
|
48
|
+
gte(warningValues[1], data)
|
|
49
|
+
) {
|
|
50
|
+
return theme.palette.warning.main;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (equals(length(warningValues), 2)) {
|
|
54
|
+
return theme.palette.success.main;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const criticalValue = head(criticalValues) as number;
|
|
58
|
+
const warningValue = head(warningValues) as number;
|
|
59
|
+
|
|
60
|
+
if (gt(warningValue, criticalValue)) {
|
|
61
|
+
return cond([
|
|
62
|
+
[lt(warningValue), always(theme.palette.success.main)],
|
|
63
|
+
[lt(criticalValue), always(theme.palette.warning.main)],
|
|
64
|
+
[T, always(theme.palette.error.main)]
|
|
65
|
+
])(data);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return cond([
|
|
69
|
+
[gt(warningValue), always(theme.palette.success.main)],
|
|
70
|
+
[gt(criticalValue), always(theme.palette.warning.main)],
|
|
19
71
|
[T, always(theme.palette.error.main)]
|
|
20
72
|
])(data);
|
|
73
|
+
};
|
|
@@ -86,7 +86,7 @@ type Props = Pick<
|
|
|
86
86
|
| 'moveTablePagination'
|
|
87
87
|
| 'widthToMoveTablePagination'
|
|
88
88
|
| 'customPaginationClassName'
|
|
89
|
-
| '
|
|
89
|
+
| 'listingVariant'
|
|
90
90
|
| 'viewerModeConfiguration'
|
|
91
91
|
>;
|
|
92
92
|
|
|
@@ -107,7 +107,8 @@ const MemoListingActionBar = ({
|
|
|
107
107
|
widthToMoveTablePagination = 550,
|
|
108
108
|
actionsBarMemoProps = [],
|
|
109
109
|
viewerModeConfiguration,
|
|
110
|
-
|
|
110
|
+
listingVariant,
|
|
111
|
+
visualizationActions
|
|
111
112
|
}: Props): JSX.Element => {
|
|
112
113
|
const marginWidthTableListing = 30;
|
|
113
114
|
const { classes, cx } = useStyles({
|
|
@@ -136,6 +137,7 @@ const MemoListingActionBar = ({
|
|
|
136
137
|
<div className={classes.actions}>
|
|
137
138
|
<div>{actions}</div>
|
|
138
139
|
</div>
|
|
140
|
+
{visualizationActions && <div>{visualizationActions}</div>}
|
|
139
141
|
<div className={classes.subContainer}>
|
|
140
142
|
{!isEmpty(viewerModeConfiguration) &&
|
|
141
143
|
!isNil(viewerModeConfiguration) && (
|
|
@@ -159,7 +161,10 @@ const MemoListingActionBar = ({
|
|
|
159
161
|
viewerModeConfiguration?.customStyle
|
|
160
162
|
?.customStyleViewerModeIcon,
|
|
161
163
|
{
|
|
162
|
-
[classes.mode]: equals(
|
|
164
|
+
[classes.mode]: equals(
|
|
165
|
+
listingVariant,
|
|
166
|
+
ListingVariant.extended
|
|
167
|
+
)
|
|
163
168
|
}
|
|
164
169
|
)}
|
|
165
170
|
>
|
|
@@ -210,7 +215,7 @@ const MemoListingActionBar = ({
|
|
|
210
215
|
currentPage,
|
|
211
216
|
moveTablePagination,
|
|
212
217
|
widthToMoveTablePagination,
|
|
213
|
-
|
|
218
|
+
listingVariant,
|
|
214
219
|
themeMode,
|
|
215
220
|
limit,
|
|
216
221
|
pick(
|
|
@@ -240,8 +245,9 @@ const ListingActionBar = ({
|
|
|
240
245
|
moveTablePagination,
|
|
241
246
|
widthToMoveTablePagination,
|
|
242
247
|
customPaginationClassName,
|
|
243
|
-
|
|
244
|
-
viewerModeConfiguration
|
|
248
|
+
listingVariant,
|
|
249
|
+
viewerModeConfiguration,
|
|
250
|
+
visualizationActions
|
|
245
251
|
}: Props): JSX.Element | null => {
|
|
246
252
|
if (
|
|
247
253
|
not(paginated) &&
|
|
@@ -260,11 +266,12 @@ const ListingActionBar = ({
|
|
|
260
266
|
currentPage={currentPage}
|
|
261
267
|
customPaginationClassName={customPaginationClassName}
|
|
262
268
|
limit={limit}
|
|
269
|
+
listingVariant={listingVariant}
|
|
263
270
|
moveTablePagination={moveTablePagination}
|
|
264
271
|
paginated={paginated}
|
|
265
272
|
totalRows={totalRows}
|
|
266
|
-
viewMode={viewMode}
|
|
267
273
|
viewerModeConfiguration={viewerModeConfiguration}
|
|
274
|
+
visualizationActions={visualizationActions}
|
|
268
275
|
widthToMoveTablePagination={widthToMoveTablePagination}
|
|
269
276
|
onLimitChange={onLimitChange}
|
|
270
277
|
onPaginate={onPaginate}
|
|
@@ -27,10 +27,10 @@ interface Props {
|
|
|
27
27
|
isRowSelected: boolean;
|
|
28
28
|
labelCollapse?: string;
|
|
29
29
|
labelExpand?: string;
|
|
30
|
+
listingVariant?: ListingVariant;
|
|
30
31
|
row?;
|
|
31
32
|
rowColorConditions?: Array<RowColorCondition>;
|
|
32
33
|
subItemsRowProperty?: string;
|
|
33
|
-
viewMode?: ListingVariant;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const DataCell = ({
|
|
@@ -40,14 +40,14 @@ const DataCell = ({
|
|
|
40
40
|
isRowHovered,
|
|
41
41
|
rowColorConditions,
|
|
42
42
|
disableRowCondition,
|
|
43
|
-
|
|
43
|
+
listingVariant,
|
|
44
44
|
getHighlightRowCondition,
|
|
45
45
|
subItemsRowProperty,
|
|
46
46
|
labelCollapse,
|
|
47
47
|
labelExpand
|
|
48
48
|
}: Props): JSX.Element | null => {
|
|
49
49
|
const { classes } = useStyles();
|
|
50
|
-
const { dataStyle } = useStyleTable({
|
|
50
|
+
const { dataStyle } = useStyleTable({ listingVariant });
|
|
51
51
|
|
|
52
52
|
const commonCellProps = {
|
|
53
53
|
disableRowCondition,
|
|
@@ -85,10 +85,10 @@ const DataCell = ({
|
|
|
85
85
|
<Cell
|
|
86
86
|
className={classes.cell}
|
|
87
87
|
isRowHighlighted={isRowHighlighted}
|
|
88
|
+
listingVariant={listingVariant}
|
|
88
89
|
style={{
|
|
89
90
|
gridColumn
|
|
90
91
|
}}
|
|
91
|
-
viewMode={viewMode}
|
|
92
92
|
{...commonCellProps}
|
|
93
93
|
>
|
|
94
94
|
{isTruncated && (
|
|
@@ -114,7 +114,7 @@ const DataCell = ({
|
|
|
114
114
|
<Cell
|
|
115
115
|
className={classes.cell}
|
|
116
116
|
isRowHighlighted={isRowHighlighted}
|
|
117
|
-
|
|
117
|
+
listingVariant={listingVariant}
|
|
118
118
|
onClick={(e): void => {
|
|
119
119
|
if (!clickable && !column.displaySubItemsCaret) {
|
|
120
120
|
return;
|
|
@@ -222,7 +222,7 @@ const MemoizedDataCell = memo<Props>(
|
|
|
222
222
|
|
|
223
223
|
// Explicitely prevent the component from rendering.
|
|
224
224
|
if (nextRenderComponentCondition === false) {
|
|
225
|
-
return equals(prevProps.
|
|
225
|
+
return equals(prevProps.listingVariant, nextProps.listingVariant);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
228
|
const previousRowProps = previousRowMemoProps
|
|
@@ -255,7 +255,7 @@ const MemoizedDataCell = memo<Props>(
|
|
|
255
255
|
nextProps.disableRowCondition(nextProps.row)
|
|
256
256
|
) &&
|
|
257
257
|
equals(previousIsRowHighlighted, nextIsRowHighlighted) &&
|
|
258
|
-
equals(prevProps.
|
|
258
|
+
equals(prevProps.listingVariant, nextProps.listingVariant) &&
|
|
259
259
|
equals(prevProps.subItemsRowProperty, nextProps.subItemsRowProperty)
|
|
260
260
|
);
|
|
261
261
|
}
|
|
@@ -54,7 +54,7 @@ const getBackgroundColor = ({
|
|
|
54
54
|
|
|
55
55
|
interface StylesProps extends Props {
|
|
56
56
|
isRowHighlighted?: boolean;
|
|
57
|
-
|
|
57
|
+
listingVariant?: ListingVariant;
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
interface GetRowHighlightStyleProps {
|
|
@@ -81,7 +81,7 @@ const useStyles = makeStyles<StylesProps>()(
|
|
|
81
81
|
rowColorConditions,
|
|
82
82
|
disableRowCondition,
|
|
83
83
|
isRowHighlighted,
|
|
84
|
-
|
|
84
|
+
listingVariant
|
|
85
85
|
}
|
|
86
86
|
) => ({
|
|
87
87
|
caret: {
|
|
@@ -115,7 +115,7 @@ const useStyles = makeStyles<StylesProps>()(
|
|
|
115
115
|
},
|
|
116
116
|
height: '100%',
|
|
117
117
|
overflow: 'hidden',
|
|
118
|
-
...getTextStyleByViewMode({
|
|
118
|
+
...getTextStyleByViewMode({ listingVariant, theme }),
|
|
119
119
|
p: getRowHighlightStyle({ isRowHighlighted, theme }),
|
|
120
120
|
padding: theme.spacing(0, 1),
|
|
121
121
|
whiteSpace: 'nowrap'
|
|
@@ -133,8 +133,8 @@ interface Props
|
|
|
133
133
|
isRowHighlighted?: boolean;
|
|
134
134
|
labelCollapse?: string;
|
|
135
135
|
labelExpand?: string;
|
|
136
|
+
listingVariant?: ListingVariant;
|
|
136
137
|
subItemsRowProperty?: string;
|
|
137
|
-
viewMode?: ListingVariant;
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
const isPivotExistInTheList = (
|
|
@@ -193,7 +193,7 @@ const Cell = ({
|
|
|
193
193
|
'rowColorConditions',
|
|
194
194
|
'disableRowCondition',
|
|
195
195
|
'isRowHighlighted',
|
|
196
|
-
'
|
|
196
|
+
'listingVariant'
|
|
197
197
|
],
|
|
198
198
|
props
|
|
199
199
|
)}
|
|
@@ -7,11 +7,11 @@ import { getTextStyleByViewMode } from '../../useStyleTable';
|
|
|
7
7
|
interface StylesProps {
|
|
8
8
|
isDragging?: boolean;
|
|
9
9
|
isInDragOverlay?: boolean;
|
|
10
|
-
|
|
10
|
+
listingVariant?: ListingVariant;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
const useStyles = makeStyles<StylesProps>()(
|
|
14
|
-
(theme, { isDragging, isInDragOverlay,
|
|
14
|
+
(theme, { isDragging, isInDragOverlay, listingVariant }) => ({
|
|
15
15
|
active: {
|
|
16
16
|
'&, &:hover, &:focus': {
|
|
17
17
|
color: theme.palette.common.white
|
|
@@ -54,7 +54,7 @@ const useStyles = makeStyles<StylesProps>()(
|
|
|
54
54
|
borderBottom: 'none',
|
|
55
55
|
height: 'inherit',
|
|
56
56
|
padding: theme.spacing(0, 1),
|
|
57
|
-
...getTextStyleByViewMode({
|
|
57
|
+
...getTextStyleByViewMode({ listingVariant, theme }),
|
|
58
58
|
'&:hover, &:focus-within, &[data-isdragging=true]': {
|
|
59
59
|
'& .dragHandle': {
|
|
60
60
|
opacity: 1
|
|
@@ -38,13 +38,13 @@ const ListingHeaderCell = ({
|
|
|
38
38
|
style,
|
|
39
39
|
isInDragOverlay,
|
|
40
40
|
areColumnsEditable,
|
|
41
|
-
|
|
41
|
+
listingVariant,
|
|
42
42
|
...props
|
|
43
43
|
}: Props): JSX.Element => {
|
|
44
44
|
const { classes, cx } = useStyles({
|
|
45
45
|
isDragging,
|
|
46
46
|
isInDragOverlay,
|
|
47
|
-
|
|
47
|
+
listingVariant
|
|
48
48
|
});
|
|
49
49
|
const columnLabel = column.shortLabel || column.label;
|
|
50
50
|
|
|
@@ -31,9 +31,9 @@ type Props = Pick<
|
|
|
31
31
|
| 'totalRows'
|
|
32
32
|
> & {
|
|
33
33
|
areColumnsEditable: boolean;
|
|
34
|
+
listingVariant?: ListingVariant;
|
|
34
35
|
memoProps: Array<unknown>;
|
|
35
36
|
rowCount: number;
|
|
36
|
-
viewMode?: ListingVariant;
|
|
37
37
|
} & SelectActionListingHeaderCellProps;
|
|
38
38
|
|
|
39
39
|
interface ContentProps extends Pick<Props, 'sortField' | 'sortOrder'> {
|
|
@@ -57,7 +57,7 @@ const ListingHeader = ({
|
|
|
57
57
|
checkable,
|
|
58
58
|
memoProps,
|
|
59
59
|
areColumnsEditable,
|
|
60
|
-
|
|
60
|
+
listingVariant,
|
|
61
61
|
onSelectAllClick,
|
|
62
62
|
selectedRowCount,
|
|
63
63
|
predefinedRowsSelection,
|
|
@@ -92,10 +92,10 @@ const ListingHeader = ({
|
|
|
92
92
|
isDragging={isDragging}
|
|
93
93
|
isInDragOverlay={isInDragOverlay}
|
|
94
94
|
itemRef={itemRef}
|
|
95
|
+
listingVariant={listingVariant}
|
|
95
96
|
sortField={sortField}
|
|
96
97
|
sortOrder={sortOrder}
|
|
97
98
|
style={style}
|
|
98
|
-
viewMode={viewMode}
|
|
99
99
|
onSort={onSort}
|
|
100
100
|
{...listeners}
|
|
101
101
|
{...attributes}
|
|
@@ -160,7 +160,7 @@ const MemoizedListingHeader = React.memo<Props>(
|
|
|
160
160
|
equals(prevProps.columnConfiguration, nextProps.columnConfiguration) &&
|
|
161
161
|
equals(prevProps.memoProps, nextProps.memoProps) &&
|
|
162
162
|
equals(prevProps.areColumnsEditable, nextProps.areColumnsEditable) &&
|
|
163
|
-
equals(prevProps.
|
|
163
|
+
equals(prevProps.listingVariant, nextProps.listingVariant)
|
|
164
164
|
);
|
|
165
165
|
|
|
166
166
|
export { MemoizedListingHeader as ListingHeader };
|
package/src/Listing/Row/Row.tsx
CHANGED
|
@@ -46,11 +46,11 @@ type Props = {
|
|
|
46
46
|
isShiftKeyDown: boolean;
|
|
47
47
|
lastSelectionIndex: number | null;
|
|
48
48
|
limit: number;
|
|
49
|
+
listingVariant?: ListingVariant;
|
|
49
50
|
row;
|
|
50
51
|
rowColorConditions: Array<RowColorCondition>;
|
|
51
52
|
shiftKeyDownRowPivot: number | null;
|
|
52
53
|
subItemsPivots: Array<number | string>;
|
|
53
|
-
viewMode?: ListingVariant;
|
|
54
54
|
visibleColumns: Array<Column>;
|
|
55
55
|
} & TableRowProps;
|
|
56
56
|
|
|
@@ -116,7 +116,7 @@ const Row = memo<RowProps>(
|
|
|
116
116
|
isShiftKeyDown: prevIsShiftKeyDown,
|
|
117
117
|
shiftKeyDownRowPivot: prevShiftKeyDownRowPivot,
|
|
118
118
|
lastSelectionIndex: prevLastSelectionIndex,
|
|
119
|
-
|
|
119
|
+
listingVariant: prevViewMode
|
|
120
120
|
} = prevProps;
|
|
121
121
|
const {
|
|
122
122
|
row: nextRow,
|
|
@@ -127,7 +127,7 @@ const Row = memo<RowProps>(
|
|
|
127
127
|
shiftKeyDownRowPivot: nextShiftKeyDownRowPivot,
|
|
128
128
|
lastSelectionIndex: nextLastSelectionIndex,
|
|
129
129
|
limit: nextLimit,
|
|
130
|
-
|
|
130
|
+
listingVariant: nextViewMode
|
|
131
131
|
} = nextProps;
|
|
132
132
|
|
|
133
133
|
if (
|
|
@@ -177,17 +177,17 @@ const StoryTemplate = ({
|
|
|
177
177
|
export const normal = (): JSX.Element => <StoryTemplate />;
|
|
178
178
|
|
|
179
179
|
export const WithSpecifiedViewMode = (): JSX.Element => {
|
|
180
|
-
const [
|
|
181
|
-
const
|
|
180
|
+
const [listingVariant, setListingVariant] = useState(ListingVariant.extended);
|
|
181
|
+
const newListingVariant = equals(listingVariant, ListingVariant.compact)
|
|
182
182
|
? ListingVariant.extended
|
|
183
183
|
: ListingVariant.compact;
|
|
184
184
|
|
|
185
185
|
return (
|
|
186
186
|
<StoryTemplate
|
|
187
|
-
|
|
187
|
+
listingVariant={listingVariant}
|
|
188
188
|
viewerModeConfiguration={{
|
|
189
|
-
onClick: () =>
|
|
190
|
-
title:
|
|
189
|
+
onClick: () => setListingVariant(newListingVariant),
|
|
190
|
+
title: listingVariant
|
|
191
191
|
}}
|
|
192
192
|
/>
|
|
193
193
|
);
|