@centreon/ui 24.4.1-MON-38194-widgets-display-optimizations-2.2 → 24.4.1-MON-38245-ba-tree-widget.7
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/Dashboard/Dashboard.styles.ts +5 -6
- package/src/Graph/LineChart/BasicComponents/LoadingProgress.tsx +46 -0
- package/src/Graph/LineChart/BasicComponents/ThresholdLine.tsx +1 -3
- package/src/Graph/LineChart/InteractiveComponents/index.tsx +2 -1
- package/src/Graph/LineChart/Legend/Legend.styles.ts +8 -4
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +18 -3
- package/src/Graph/LineChart/LineChart.tsx +13 -2
- package/src/Graph/LineChart/LoadingSkeleton.tsx +2 -2
- package/src/Graph/LineChart/index.tsx +6 -2
- package/src/Graph/LineChart/models.ts +1 -0
- package/src/Graph/Text/Text.styles.ts +1 -12
- package/src/Graph/Text/Text.tsx +11 -16
- package/src/Graph/Tree/DescendantNodes.tsx +1 -0
- package/src/Graph/Tree/Links.tsx +15 -2
- package/src/Graph/Tree/Tree.cypress.spec.tsx +24 -0
- package/src/Graph/Tree/Tree.stories.tsx +17 -1
- package/src/Graph/Tree/models.ts +3 -0
- package/src/components/Zoom/Minimap.tsx +4 -2
- package/src/components/Zoom/Zoom.cypress.spec.tsx +13 -13
- package/src/components/Zoom/Zoom.tsx +4 -1
- package/src/components/Zoom/ZoomContent.tsx +5 -2
package/package.json
CHANGED
|
@@ -76,12 +76,11 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
|
76
76
|
border: 'none',
|
|
77
77
|
borderRadius: theme.spacing(1),
|
|
78
78
|
height: '100%',
|
|
79
|
+
paddingBottom: theme.spacing(2),
|
|
79
80
|
width: '100%'
|
|
80
81
|
},
|
|
81
82
|
widgetContent: {
|
|
82
|
-
height:
|
|
83
|
-
? `calc(100% - ${theme.spacing(3.5)} - ${theme.spacing(0.5)})`
|
|
84
|
-
: `calc(100% - ${theme.spacing(3.5)})`
|
|
83
|
+
height: '100%'
|
|
85
84
|
},
|
|
86
85
|
widgetHeader: {
|
|
87
86
|
'&:hover': {
|
|
@@ -93,17 +92,17 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
|
93
92
|
'&[data-canMove="true"]': {
|
|
94
93
|
cursor: 'move'
|
|
95
94
|
},
|
|
96
|
-
padding: theme.spacing(0,
|
|
95
|
+
padding: theme.spacing(0.5, 2),
|
|
97
96
|
position: 'relative'
|
|
98
97
|
},
|
|
99
98
|
widgetHeaderDraggable: {
|
|
100
99
|
height: '100%',
|
|
101
100
|
position: 'absolute',
|
|
102
|
-
width: '
|
|
101
|
+
width: '100%'
|
|
103
102
|
},
|
|
104
103
|
widgetPadding: {
|
|
105
104
|
overflowX: 'auto',
|
|
106
|
-
padding: theme.spacing(0.
|
|
105
|
+
padding: hasHeader ? theme.spacing(1, 2, 0) : theme.spacing(1, 2)
|
|
107
106
|
}
|
|
108
107
|
})
|
|
109
108
|
);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { makeStyles } from 'tss-react/mui';
|
|
2
|
+
|
|
3
|
+
import { CircularProgress, alpha } from '@mui/material';
|
|
4
|
+
|
|
5
|
+
interface StyleProps {
|
|
6
|
+
height: number;
|
|
7
|
+
width: number;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const useStyles = makeStyles<StyleProps>()((theme, { height, width }) => ({
|
|
11
|
+
graphLoader: {
|
|
12
|
+
alignItems: 'center',
|
|
13
|
+
backgroundColor: alpha(theme.palette.common.white, 0.5),
|
|
14
|
+
display: 'flex',
|
|
15
|
+
height,
|
|
16
|
+
justifyContent: 'center',
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
width
|
|
19
|
+
}
|
|
20
|
+
}));
|
|
21
|
+
|
|
22
|
+
interface LoadingProgress {
|
|
23
|
+
display: boolean;
|
|
24
|
+
height: number;
|
|
25
|
+
width: number;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const LoadingProgress = ({
|
|
29
|
+
display,
|
|
30
|
+
height,
|
|
31
|
+
width
|
|
32
|
+
}: LoadingProgress): JSX.Element | null => {
|
|
33
|
+
const { classes } = useStyles({ height, width });
|
|
34
|
+
|
|
35
|
+
if (!display) {
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
return (
|
|
40
|
+
<div className={classes.graphLoader}>
|
|
41
|
+
<CircularProgress />
|
|
42
|
+
</div>
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export default LoadingProgress;
|
|
@@ -2,8 +2,6 @@ import { equals } from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
import { useTheme } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
import { margin } from '../common';
|
|
6
|
-
|
|
7
5
|
interface Props {
|
|
8
6
|
hideTooltip: () => void;
|
|
9
7
|
label: string;
|
|
@@ -30,7 +28,7 @@ export const ThresholdLine = ({
|
|
|
30
28
|
const onMouseEnter = (): void =>
|
|
31
29
|
showTooltip({
|
|
32
30
|
tooltipData: label,
|
|
33
|
-
tooltipLeft:
|
|
31
|
+
tooltipLeft: 0,
|
|
34
32
|
tooltipTop: scaledValue
|
|
35
33
|
});
|
|
36
34
|
|
|
@@ -70,6 +70,7 @@ interface CommonData {
|
|
|
70
70
|
|
|
71
71
|
interface TimeShiftZonesData extends InteractedZone {
|
|
72
72
|
graphInterval: GraphInterval;
|
|
73
|
+
loading: boolean;
|
|
73
74
|
}
|
|
74
75
|
|
|
75
76
|
interface Props {
|
|
@@ -233,7 +234,7 @@ const InteractionWithGraph = ({
|
|
|
233
234
|
value: timeValue?.[metric_id]
|
|
234
235
|
}),
|
|
235
236
|
linesData
|
|
236
|
-
).filter(({ value }) =>
|
|
237
|
+
).filter(({ value }) => value)
|
|
237
238
|
});
|
|
238
239
|
};
|
|
239
240
|
|
|
@@ -28,11 +28,10 @@ export const useStyles = makeStyles<MakeStylesProps>()(
|
|
|
28
28
|
columnGap: theme.spacing(3),
|
|
29
29
|
display: 'grid',
|
|
30
30
|
gridAutoRows: theme.spacing(legendItemHeight),
|
|
31
|
-
gridTemplateColumns: `repeat(auto-fit,
|
|
31
|
+
gridTemplateColumns: `repeat(auto-fit, ${theme.spacing(legendWidth)})`,
|
|
32
32
|
maxHeight: limitLegendRows
|
|
33
33
|
? theme.spacing(legendItemHeight * 2 + 1)
|
|
34
34
|
: 'unset',
|
|
35
|
-
overflowX: 'hidden',
|
|
36
35
|
overflowY: 'auto',
|
|
37
36
|
rowGap: theme.spacing(1),
|
|
38
37
|
width: '100%'
|
|
@@ -64,6 +63,9 @@ interface StylesProps {
|
|
|
64
63
|
export const useLegendHeaderStyles = makeStyles<StylesProps>()(
|
|
65
64
|
(theme, { color }) => ({
|
|
66
65
|
container: {
|
|
66
|
+
display: 'flex',
|
|
67
|
+
flexDirection: 'row',
|
|
68
|
+
gap: theme.spacing(0.5),
|
|
67
69
|
width: '100%'
|
|
68
70
|
},
|
|
69
71
|
disabled: {
|
|
@@ -77,7 +79,10 @@ export const useLegendHeaderStyles = makeStyles<StylesProps>()(
|
|
|
77
79
|
width: theme.spacing(1.5)
|
|
78
80
|
},
|
|
79
81
|
legendName: {
|
|
80
|
-
|
|
82
|
+
'&[data-mode="compact"]': {
|
|
83
|
+
maxWidth: theme.spacing(legendWidth * 0.5)
|
|
84
|
+
},
|
|
85
|
+
maxWidth: theme.spacing(legendWidth * 0.75)
|
|
81
86
|
},
|
|
82
87
|
markerAndLegendName: {
|
|
83
88
|
alignItems: 'center',
|
|
@@ -92,7 +97,6 @@ export const useLegendHeaderStyles = makeStyles<StylesProps>()(
|
|
|
92
97
|
whiteSpace: 'nowrap'
|
|
93
98
|
},
|
|
94
99
|
text: {
|
|
95
|
-
fontSize: '0.75rem',
|
|
96
100
|
fontWeight: theme.typography.fontWeightMedium,
|
|
97
101
|
lineHeight: 1
|
|
98
102
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isEmpty } from 'ramda';
|
|
2
|
+
|
|
1
3
|
import { Typography } from '@mui/material';
|
|
2
4
|
|
|
3
5
|
import {
|
|
@@ -29,11 +31,21 @@ const LegendHeader = ({
|
|
|
29
31
|
}: Props): JSX.Element => {
|
|
30
32
|
const { classes, cx } = useLegendHeaderStyles({ color });
|
|
31
33
|
|
|
32
|
-
const { name, legend } = line;
|
|
34
|
+
const { unit, name, legend } = line;
|
|
33
35
|
|
|
34
36
|
const metricName = formatMetricName({ legend, name });
|
|
35
37
|
|
|
36
38
|
const legendName = legend || name;
|
|
39
|
+
const hasUnit = !isEmpty(unit);
|
|
40
|
+
const unitName = `(${unit})`;
|
|
41
|
+
|
|
42
|
+
const getEndText = (): string => {
|
|
43
|
+
if (value) {
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return hasUnit ? ` ${unitName}` : '';
|
|
48
|
+
};
|
|
37
49
|
|
|
38
50
|
return (
|
|
39
51
|
<div className={classes.container}>
|
|
@@ -42,7 +54,7 @@ const LegendHeader = ({
|
|
|
42
54
|
label={
|
|
43
55
|
minMaxAvg ? (
|
|
44
56
|
<div>
|
|
45
|
-
<Typography>{legendName}</Typography>
|
|
57
|
+
<Typography>{`${legendName} ${unitName}`}</Typography>
|
|
46
58
|
<div className={classes.minMaxAvgContainer}>
|
|
47
59
|
{minMaxAvg.map(({ label, value: subValue }) => (
|
|
48
60
|
<LegendContent
|
|
@@ -57,7 +69,7 @@ const LegendHeader = ({
|
|
|
57
69
|
</div>
|
|
58
70
|
</div>
|
|
59
71
|
) : (
|
|
60
|
-
legendName
|
|
72
|
+
`${legendName} ${unitName}`
|
|
61
73
|
)
|
|
62
74
|
}
|
|
63
75
|
placement="top"
|
|
@@ -74,6 +86,9 @@ const LegendHeader = ({
|
|
|
74
86
|
</EllipsisTypography>
|
|
75
87
|
</div>
|
|
76
88
|
</Tooltip>
|
|
89
|
+
{hasUnit && (
|
|
90
|
+
<Typography className={classes.text}>{getEndText()}</Typography>
|
|
91
|
+
)}
|
|
77
92
|
</div>
|
|
78
93
|
);
|
|
79
94
|
};
|
|
@@ -14,6 +14,7 @@ import Axes from './BasicComponents/Axes';
|
|
|
14
14
|
import Grids from './BasicComponents/Grids';
|
|
15
15
|
import Lines from './BasicComponents/Lines';
|
|
16
16
|
import { canDisplayThreshold } from './BasicComponents/Lines/Threshold/models';
|
|
17
|
+
import LoadingProgress from './BasicComponents/LoadingProgress';
|
|
17
18
|
import useFilterLines from './BasicComponents/useFilterLines';
|
|
18
19
|
import { useStyles } from './LineChart.styles';
|
|
19
20
|
import Header from './Header';
|
|
@@ -44,6 +45,7 @@ interface Props extends LineChartProps {
|
|
|
44
45
|
graphRef: MutableRefObject<HTMLDivElement | null>;
|
|
45
46
|
legend?: LegendModel;
|
|
46
47
|
limitLegend?: false | number;
|
|
48
|
+
marginBottom: number;
|
|
47
49
|
shapeLines?: GlobalAreaLines;
|
|
48
50
|
thresholdUnit?: string;
|
|
49
51
|
thresholds?: ThresholdsModel;
|
|
@@ -61,6 +63,7 @@ const LineChart = ({
|
|
|
61
63
|
shapeLines,
|
|
62
64
|
axis,
|
|
63
65
|
displayAnchor,
|
|
66
|
+
loading,
|
|
64
67
|
zoomPreview,
|
|
65
68
|
graphInterval,
|
|
66
69
|
timeShiftZones,
|
|
@@ -70,6 +73,7 @@ const LineChart = ({
|
|
|
70
73
|
graphRef,
|
|
71
74
|
header,
|
|
72
75
|
curve,
|
|
76
|
+
marginBottom,
|
|
73
77
|
thresholds,
|
|
74
78
|
thresholdUnit,
|
|
75
79
|
limitLegend
|
|
@@ -100,7 +104,8 @@ const LineChart = ({
|
|
|
100
104
|
(height || 0) > 0
|
|
101
105
|
? (height || 0) -
|
|
102
106
|
margin.top -
|
|
103
|
-
|
|
107
|
+
margin.bottom -
|
|
108
|
+
marginBottom -
|
|
104
109
|
(legendRef.current?.getBoundingClientRect().height || 0)
|
|
105
110
|
: 0;
|
|
106
111
|
|
|
@@ -191,6 +196,11 @@ const LineChart = ({
|
|
|
191
196
|
title={<GraphValueTooltip base={baseAxis} />}
|
|
192
197
|
>
|
|
193
198
|
<div className={classes.container}>
|
|
199
|
+
<LoadingProgress
|
|
200
|
+
display={loading}
|
|
201
|
+
height={graphHeight}
|
|
202
|
+
width={width}
|
|
203
|
+
/>
|
|
194
204
|
<svg
|
|
195
205
|
height={graphHeight + margin.top}
|
|
196
206
|
ref={graphSvgRef}
|
|
@@ -249,7 +259,8 @@ const LineChart = ({
|
|
|
249
259
|
}}
|
|
250
260
|
timeShiftZonesData={{
|
|
251
261
|
...timeShiftZones,
|
|
252
|
-
graphInterval
|
|
262
|
+
graphInterval,
|
|
263
|
+
loading
|
|
253
264
|
}}
|
|
254
265
|
zoomData={{ ...zoomPreview }}
|
|
255
266
|
/>
|
|
@@ -13,8 +13,8 @@ const useSkeletonStyles = makeStyles<Props>()(
|
|
|
13
13
|
display: 'grid',
|
|
14
14
|
gridGap: theme.spacing(1),
|
|
15
15
|
gridTemplateRows: `${
|
|
16
|
-
displayTitleSkeleton ? '
|
|
17
|
-
} ${graphHeight}px ${theme.spacing(
|
|
16
|
+
displayTitleSkeleton ? '1fr' : ''
|
|
17
|
+
} ${graphHeight}px ${theme.spacing(7)}`,
|
|
18
18
|
height: '100%'
|
|
19
19
|
},
|
|
20
20
|
loadingSkeletonLine: {
|
|
@@ -30,6 +30,7 @@ interface Props extends Partial<LineChartProps> {
|
|
|
30
30
|
legend: LegendModel;
|
|
31
31
|
limitLegend?: false | number;
|
|
32
32
|
loading: boolean;
|
|
33
|
+
marginBottom?: number;
|
|
33
34
|
shapeLines?: GlobalAreaLines;
|
|
34
35
|
start: string;
|
|
35
36
|
thresholdUnit?: string;
|
|
@@ -53,6 +54,7 @@ const WrapperLineChart = ({
|
|
|
53
54
|
legend,
|
|
54
55
|
header,
|
|
55
56
|
curve = Curve.curveLinear,
|
|
57
|
+
marginBottom = 0,
|
|
56
58
|
thresholds,
|
|
57
59
|
thresholdUnit,
|
|
58
60
|
limitLegend
|
|
@@ -63,7 +65,7 @@ const WrapperLineChart = ({
|
|
|
63
65
|
if (loading && !adjustedData) {
|
|
64
66
|
return (
|
|
65
67
|
<LoadingSkeleton
|
|
66
|
-
displayTitleSkeleton={header?.displayTitle ??
|
|
68
|
+
displayTitleSkeleton={header?.displayTitle ?? true}
|
|
67
69
|
graphHeight={height || 200}
|
|
68
70
|
/>
|
|
69
71
|
);
|
|
@@ -76,7 +78,7 @@ const WrapperLineChart = ({
|
|
|
76
78
|
return (
|
|
77
79
|
<div
|
|
78
80
|
ref={lineChartRef as MutableRefObject<HTMLDivElement>}
|
|
79
|
-
style={{ height: '100%',
|
|
81
|
+
style={{ height: '100%', overflowY: 'hidden', width: '100%' }}
|
|
80
82
|
>
|
|
81
83
|
<ParentSize>
|
|
82
84
|
{({
|
|
@@ -96,6 +98,8 @@ const WrapperLineChart = ({
|
|
|
96
98
|
height={height || responsiveHeight}
|
|
97
99
|
legend={legend}
|
|
98
100
|
limitLegend={limitLegend}
|
|
101
|
+
loading={loading}
|
|
102
|
+
marginBottom={marginBottom}
|
|
99
103
|
shapeLines={shapeLines}
|
|
100
104
|
thresholdUnit={thresholdUnit}
|
|
101
105
|
thresholds={thresholds}
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { makeStyles } from 'tss-react/mui';
|
|
2
2
|
|
|
3
3
|
export const useTextStyles = makeStyles()((theme) => ({
|
|
4
|
-
critical: {
|
|
5
|
-
color: theme.palette.error.main
|
|
6
|
-
},
|
|
7
4
|
graphText: {
|
|
8
5
|
alignItems: 'center',
|
|
9
6
|
display: 'flex',
|
|
@@ -12,17 +9,9 @@ export const useTextStyles = makeStyles()((theme) => ({
|
|
|
12
9
|
height: '100%',
|
|
13
10
|
justifyContent: 'center'
|
|
14
11
|
},
|
|
15
|
-
threshold: {
|
|
16
|
-
textAlign: 'center'
|
|
17
|
-
},
|
|
18
12
|
thresholds: {
|
|
19
13
|
display: 'flex',
|
|
20
14
|
flexDirection: 'row',
|
|
21
|
-
gap: theme.spacing(5)
|
|
22
|
-
whiteSpace: 'nowrap',
|
|
23
|
-
width: '100%'
|
|
24
|
-
},
|
|
25
|
-
warning: {
|
|
26
|
-
color: theme.palette.warning.main
|
|
15
|
+
gap: theme.spacing(5)
|
|
27
16
|
}
|
|
28
17
|
}));
|
package/src/Graph/Text/Text.tsx
CHANGED
|
@@ -2,7 +2,6 @@ import { isNil } from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
import { Typography, useTheme } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
import FluidTypography from '../../Typography/FluidTypography';
|
|
6
5
|
import { LineChartData, Thresholds } from '../common/models';
|
|
7
6
|
import {
|
|
8
7
|
formatMetricValueWithUnit,
|
|
@@ -31,7 +30,7 @@ export const Text = ({
|
|
|
31
30
|
baseColor
|
|
32
31
|
}: Props): JSX.Element | null => {
|
|
33
32
|
const theme = useTheme();
|
|
34
|
-
const { classes
|
|
33
|
+
const { classes } = useTextStyles();
|
|
35
34
|
|
|
36
35
|
if (isNil(data)) {
|
|
37
36
|
return null;
|
|
@@ -75,20 +74,16 @@ export const Text = ({
|
|
|
75
74
|
</Typography>
|
|
76
75
|
{thresholds.enabled && (
|
|
77
76
|
<div className={classes.thresholds}>
|
|
78
|
-
<
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
pref={14}
|
|
89
|
-
text={`${labels.critical}: ${criticalThresholdLabels.join(' - ')}`}
|
|
90
|
-
variant="h5"
|
|
91
|
-
/>
|
|
77
|
+
<Typography sx={{ color: 'warning.main' }} variant="h5">
|
|
78
|
+
{labels.warning}
|
|
79
|
+
{': '}
|
|
80
|
+
{warningThresholdLabels.join(' - ')}
|
|
81
|
+
</Typography>
|
|
82
|
+
<Typography sx={{ color: 'error.main' }} variant="h5">
|
|
83
|
+
{labels.critical}
|
|
84
|
+
{': '}
|
|
85
|
+
{criticalThresholdLabels.join(' - ')}
|
|
86
|
+
</Typography>
|
|
92
87
|
</div>
|
|
93
88
|
)}
|
|
94
89
|
</div>
|
package/src/Graph/Tree/Links.tsx
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
LinkHorizontal,
|
|
3
|
+
LinkHorizontalStep,
|
|
4
|
+
LinkHorizontalLine
|
|
5
|
+
} from '@visx/shape';
|
|
2
6
|
import { HierarchyPointLink } from '@visx/hierarchy/lib/types';
|
|
7
|
+
import { always, cond, equals, T } from 'ramda';
|
|
3
8
|
|
|
4
9
|
import { useTheme } from '@mui/material';
|
|
5
10
|
|
|
@@ -9,6 +14,12 @@ interface Props<TData> extends Pick<TreeProps<TData>, 'treeLink'> {
|
|
|
9
14
|
links: Array<HierarchyPointLink<Node<TData>>>;
|
|
10
15
|
}
|
|
11
16
|
|
|
17
|
+
const getLinkComponent = cond([
|
|
18
|
+
[equals('line'), always(LinkHorizontalLine)],
|
|
19
|
+
[equals('step'), always(LinkHorizontalStep)],
|
|
20
|
+
[T, always(LinkHorizontal)]
|
|
21
|
+
]);
|
|
22
|
+
|
|
12
23
|
const Links = <TData extends BaseProp>({
|
|
13
24
|
links,
|
|
14
25
|
treeLink
|
|
@@ -24,10 +35,12 @@ const Links = <TData extends BaseProp>({
|
|
|
24
35
|
.descendants()
|
|
25
36
|
.map((ancestor) => ancestor.data.data.id);
|
|
26
37
|
|
|
38
|
+
const LinkComponent = getLinkComponent(treeLink?.type);
|
|
39
|
+
|
|
27
40
|
const key = `${link.source.data.data.id}-${link.source.data.data.name}-${ancestorIds}_${link.target.data.data.id}-${link.target.data.data.name}-${descendantIds}`;
|
|
28
41
|
|
|
29
42
|
return (
|
|
30
|
-
<
|
|
43
|
+
<LinkComponent
|
|
31
44
|
data={link}
|
|
32
45
|
data-testid={`${link.source.data.data.id}_to_${link.target.data.data.id}`}
|
|
33
46
|
fill="none"
|
|
@@ -168,4 +168,28 @@ describe('Complex data tree', () => {
|
|
|
168
168
|
|
|
169
169
|
cy.makeSnapshot();
|
|
170
170
|
});
|
|
171
|
+
|
|
172
|
+
it('displays the tree with step links when a prop is set', () => {
|
|
173
|
+
initializeStandaloneTree({
|
|
174
|
+
treeLink: {
|
|
175
|
+
type: 'step'
|
|
176
|
+
}
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
cy.contains('T').should('be.visible');
|
|
180
|
+
|
|
181
|
+
cy.makeSnapshot();
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it('displays the tree with line links when a prop is set', () => {
|
|
185
|
+
initializeStandaloneTree({
|
|
186
|
+
treeLink: {
|
|
187
|
+
type: 'line'
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
|
|
191
|
+
cy.contains('T').should('be.visible');
|
|
192
|
+
|
|
193
|
+
cy.makeSnapshot();
|
|
194
|
+
});
|
|
171
195
|
});
|
|
@@ -82,6 +82,21 @@ export const WithDefaultExpandFilter: Story = {
|
|
|
82
82
|
render: StandaloneTreeTemplate
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
export const WithStepLink: Story = {
|
|
86
|
+
args: {
|
|
87
|
+
children: SimpleContent,
|
|
88
|
+
node: {
|
|
89
|
+
height: 90,
|
|
90
|
+
width: 90
|
|
91
|
+
},
|
|
92
|
+
tree: simpleData,
|
|
93
|
+
treeLink: {
|
|
94
|
+
type: 'step'
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
render: StandaloneTreeTemplate
|
|
98
|
+
};
|
|
99
|
+
|
|
85
100
|
export const WithCustomLinks: Story = {
|
|
86
101
|
args: {
|
|
87
102
|
children: SimpleContent,
|
|
@@ -95,7 +110,8 @@ export const WithCustomLinks: Story = {
|
|
|
95
110
|
getStrokeDasharray: ({ target }) =>
|
|
96
111
|
target.status === 'ok' ? '5,5' : '0',
|
|
97
112
|
getStrokeOpacity: ({ target }) => (target.status === 'ok' ? 0.8 : 1),
|
|
98
|
-
getStrokeWidth: ({ target }) => (target.status === 'ok' ? 1 : 2)
|
|
113
|
+
getStrokeWidth: ({ target }) => (target.status === 'ok' ? 1 : 2),
|
|
114
|
+
type: 'line'
|
|
99
115
|
}
|
|
100
116
|
},
|
|
101
117
|
render: StandaloneTreeTemplate
|
package/src/Graph/Tree/models.ts
CHANGED
|
@@ -14,6 +14,8 @@ export interface BaseProp {
|
|
|
14
14
|
name: string;
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export type Link = 'curve' | 'line' | 'step';
|
|
18
|
+
|
|
17
19
|
export interface ChildrenProps<TData> {
|
|
18
20
|
ancestors: Array<Node<TData>>;
|
|
19
21
|
depth: number;
|
|
@@ -48,5 +50,6 @@ export interface TreeProps<TData> {
|
|
|
48
50
|
) => string | number | undefined;
|
|
49
51
|
getStrokeOpacity?: (props: LinkProps<TData>) => string | number | undefined;
|
|
50
52
|
getStrokeWidth?: (props: LinkProps<TData>) => string | number | undefined;
|
|
53
|
+
type?: Link;
|
|
51
54
|
};
|
|
52
55
|
}
|
|
@@ -16,6 +16,7 @@ interface Props extends Omit<UseMinimapProps, 'minimapScale' | 'scale'> {
|
|
|
16
16
|
left: number;
|
|
17
17
|
top: number;
|
|
18
18
|
};
|
|
19
|
+
id?: number | string;
|
|
19
20
|
isDraggingFromContainer: boolean;
|
|
20
21
|
}
|
|
21
22
|
|
|
@@ -26,7 +27,8 @@ const Minimap = ({
|
|
|
26
27
|
width,
|
|
27
28
|
contentClientRect,
|
|
28
29
|
isDraggingFromContainer,
|
|
29
|
-
diffBetweenContentAndSvg
|
|
30
|
+
diffBetweenContentAndSvg,
|
|
31
|
+
id
|
|
30
32
|
}: Props): JSX.Element => {
|
|
31
33
|
const { classes } = useZoomStyles();
|
|
32
34
|
|
|
@@ -82,7 +84,7 @@ const Minimap = ({
|
|
|
82
84
|
);
|
|
83
85
|
|
|
84
86
|
return (
|
|
85
|
-
<g className={classes.minimap} clipPath=
|
|
87
|
+
<g className={classes.minimap} clipPath={`url(#zoom-clip-${id})`}>
|
|
86
88
|
<rect
|
|
87
89
|
className={classes.minimapBackground}
|
|
88
90
|
height={finalHeight}
|
|
@@ -63,7 +63,7 @@ describe('Zoom', () => {
|
|
|
63
63
|
it('displays the minimap when the prop is set', () => {
|
|
64
64
|
initialize({ showMinimap: true });
|
|
65
65
|
|
|
66
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
66
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
67
67
|
|
|
68
68
|
cy.makeSnapshot();
|
|
69
69
|
});
|
|
@@ -72,7 +72,7 @@ describe('Zoom', () => {
|
|
|
72
72
|
initialize({ showMinimap: true });
|
|
73
73
|
|
|
74
74
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
75
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
75
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
76
76
|
|
|
77
77
|
cy.findByTestId('zoom in').click();
|
|
78
78
|
cy.findByTestId('zoom-content')
|
|
@@ -86,7 +86,7 @@ describe('Zoom', () => {
|
|
|
86
86
|
initialize({ showMinimap: true });
|
|
87
87
|
|
|
88
88
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
89
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
89
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
90
90
|
|
|
91
91
|
cy.findByTestId('zoom out').click();
|
|
92
92
|
|
|
@@ -101,7 +101,7 @@ describe('Zoom', () => {
|
|
|
101
101
|
initialize({ showMinimap: true });
|
|
102
102
|
|
|
103
103
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
104
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
104
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
105
105
|
|
|
106
106
|
cy.findByTestId('zoom-content').realMouseWheel({ deltaY: 20 });
|
|
107
107
|
|
|
@@ -116,7 +116,7 @@ describe('Zoom', () => {
|
|
|
116
116
|
initialize({ showMinimap: true });
|
|
117
117
|
|
|
118
118
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
119
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
119
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
120
120
|
|
|
121
121
|
cy.findByTestId('zoom-content').realMouseWheel({ deltaY: -20 });
|
|
122
122
|
|
|
@@ -131,7 +131,7 @@ describe('Zoom', () => {
|
|
|
131
131
|
initialize({ showMinimap: true });
|
|
132
132
|
|
|
133
133
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
134
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
134
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
135
135
|
|
|
136
136
|
cy.findByTestId('zoom-content').realMouseWheel({ deltaY: -20 });
|
|
137
137
|
|
|
@@ -150,7 +150,7 @@ describe('Zoom', () => {
|
|
|
150
150
|
initialize({ showMinimap: false });
|
|
151
151
|
|
|
152
152
|
cy.get('g[transform="matrix(1, 0, 0, 1, 0, 0)"]');
|
|
153
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('not.exist');
|
|
153
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('not.exist');
|
|
154
154
|
|
|
155
155
|
cy.makeSnapshot();
|
|
156
156
|
});
|
|
@@ -158,7 +158,7 @@ describe('Zoom', () => {
|
|
|
158
158
|
it('zooms in when the minimap is scrolled up', () => {
|
|
159
159
|
initialize({ showMinimap: true });
|
|
160
160
|
|
|
161
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
161
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
162
162
|
|
|
163
163
|
cy.findByTestId('minimap-interaction').realMouseWheel({ deltaY: -20 });
|
|
164
164
|
|
|
@@ -172,7 +172,7 @@ describe('Zoom', () => {
|
|
|
172
172
|
it('zooms out when the minimap is scrolled down', () => {
|
|
173
173
|
initialize({ showMinimap: true });
|
|
174
174
|
|
|
175
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
175
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
176
176
|
|
|
177
177
|
cy.findByTestId('minimap-interaction').realMouseWheel({ deltaY: 20 });
|
|
178
178
|
|
|
@@ -186,7 +186,7 @@ describe('Zoom', () => {
|
|
|
186
186
|
it('moves the view when the mouse is hover the content with the corresponding button pressed down', () => {
|
|
187
187
|
initialize({ showMinimap: true });
|
|
188
188
|
|
|
189
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
189
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
190
190
|
cy.get('svg').should('have.attr', 'height', '400');
|
|
191
191
|
|
|
192
192
|
cy.findByTestId('zoom-container')
|
|
@@ -205,7 +205,7 @@ describe('Zoom', () => {
|
|
|
205
205
|
it('displays the minimap in the bottom right when the prop to the corresponding value', () => {
|
|
206
206
|
initialize({ minimapPosition: 'bottom-right', showMinimap: true });
|
|
207
207
|
|
|
208
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
208
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
209
209
|
cy.get('svg').should('have.attr', 'height', '400');
|
|
210
210
|
|
|
211
211
|
cy.makeSnapshot();
|
|
@@ -214,7 +214,7 @@ describe('Zoom', () => {
|
|
|
214
214
|
it('applies a scale down on the minimap when the content is higher than the original height', () => {
|
|
215
215
|
initialize({ showMinimap: true, template: ContentWithMultipleShapes });
|
|
216
216
|
|
|
217
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
217
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
218
218
|
cy.get('svg').should('have.attr', 'height', '400');
|
|
219
219
|
|
|
220
220
|
cy.findByTestId('minimap-interaction')
|
|
@@ -232,7 +232,7 @@ describe('Zoom', () => {
|
|
|
232
232
|
template: ContentWithMultipleShapesWithNegativeTranslations
|
|
233
233
|
});
|
|
234
234
|
|
|
235
|
-
cy.get('g[clip-path="url(#zoom-clip)"]').should('be.visible');
|
|
235
|
+
cy.get('g[clip-path="url(#zoom-clip-0)"]').should('be.visible');
|
|
236
236
|
cy.get('svg').should('have.attr', 'height', '400');
|
|
237
237
|
|
|
238
238
|
cy.findByTestId('minimap-interaction')
|
|
@@ -7,6 +7,7 @@ import { MinimapPosition } from './models';
|
|
|
7
7
|
|
|
8
8
|
export interface ZoomProps {
|
|
9
9
|
children: JSX.Element | (({ width, height }) => JSX.Element);
|
|
10
|
+
id?: number | string;
|
|
10
11
|
minimapPosition?: MinimapPosition;
|
|
11
12
|
scaleMax?: number;
|
|
12
13
|
scaleMin?: number;
|
|
@@ -27,7 +28,8 @@ const Zoom = ({
|
|
|
27
28
|
scaleMin = 0.5,
|
|
28
29
|
scaleMax = 4,
|
|
29
30
|
showMinimap = false,
|
|
30
|
-
minimapPosition = 'top-left'
|
|
31
|
+
minimapPosition = 'top-left',
|
|
32
|
+
id = 0
|
|
31
33
|
}: ZoomProps): JSX.Element => {
|
|
32
34
|
return (
|
|
33
35
|
<ParentSize>
|
|
@@ -44,6 +46,7 @@ const Zoom = ({
|
|
|
44
46
|
{(zoom) => (
|
|
45
47
|
<ZoomContent
|
|
46
48
|
height={height}
|
|
49
|
+
id={id}
|
|
47
50
|
minimapPosition={minimapPosition}
|
|
48
51
|
showMinimap={showMinimap}
|
|
49
52
|
width={width}
|
|
@@ -18,6 +18,7 @@ import { ChildrenProps, MinimapPosition, ZoomState } from './models';
|
|
|
18
18
|
export interface Props {
|
|
19
19
|
children: ({ width, height, transformMatrix }: ChildrenProps) => JSX.Element;
|
|
20
20
|
height: number;
|
|
21
|
+
id?: number | string;
|
|
21
22
|
minimapPosition: MinimapPosition;
|
|
22
23
|
showMinimap?: boolean;
|
|
23
24
|
width: number;
|
|
@@ -30,7 +31,8 @@ const ZoomContent = ({
|
|
|
30
31
|
height,
|
|
31
32
|
children,
|
|
32
33
|
showMinimap,
|
|
33
|
-
minimapPosition
|
|
34
|
+
minimapPosition,
|
|
35
|
+
id
|
|
34
36
|
}: Props): JSX.Element => {
|
|
35
37
|
const { classes } = useZoomStyles();
|
|
36
38
|
const contentRef = useRef<SVGGElement | null>(null);
|
|
@@ -92,7 +94,7 @@ const ZoomContent = ({
|
|
|
92
94
|
>
|
|
93
95
|
<RectClipPath
|
|
94
96
|
height={Math.max(contentClientRect?.height || 0, height)}
|
|
95
|
-
id=
|
|
97
|
+
id={`zoom-clip-${id}`}
|
|
96
98
|
rx={radius}
|
|
97
99
|
width={Math.max(contentClientRect?.width || 0, width)}
|
|
98
100
|
/>
|
|
@@ -124,6 +126,7 @@ const ZoomContent = ({
|
|
|
124
126
|
diffBetweenContentAndSvg || { left: 0, top: 0 }
|
|
125
127
|
}
|
|
126
128
|
height={height}
|
|
129
|
+
id={id}
|
|
127
130
|
isDraggingFromContainer={isDragging}
|
|
128
131
|
width={width}
|
|
129
132
|
zoom={zoom}
|