Skip to content

Commit 4d062d1

Browse files
Remove SpacedBox as it ill be removed from Core-UI
1 parent f96a333 commit 4d062d1

File tree

2 files changed

+36
-69
lines changed

2 files changed

+36
-69
lines changed

ui/src/components/DashboardMetrics.tsx

Lines changed: 28 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import styled from 'styled-components';
3-
import { Button } from '@scality/core-ui/dist/next';
3+
import { Box, Button } from '@scality/core-ui/dist/next';
44
import { padding } from '@scality/core-ui/dist/style/theme';
55
import { useIntl } from 'react-intl';
66
import { GRAFANA_DASHBOARDS } from '../constants';
@@ -14,7 +14,7 @@ import DashboardChartSystemLoad from './DashboardChartSystemLoad';
1414
import DashboardChartMemory from './DashboardChartMemory';
1515
import { useShowQuantileChart, useTypedSelector } from '../hooks';
1616
import { DashboardScrollableArea } from '../containers/DashboardPage';
17-
import { Tooltip, Icon, SmallerText, SpacedBox } from '@scality/core-ui';
17+
import { Icon, SmallerText, Stack, IconHelp, spacing } from '@scality/core-ui';
1818
const MetricsContainer = styled.div`
1919
padding: 2px ${padding.smaller};
2020
display: flex;
@@ -29,6 +29,29 @@ const PanelActions = styled.div`
2929
justify-content: space-between;
3030
`;
3131

32+
export const QuantileHelpTooltip = () => {
33+
const intl = useIntl();
34+
return (
35+
<IconHelp
36+
placement="bottom"
37+
tooltipMessage={
38+
<Stack direction="vertical" gap="r8">
39+
{intl
40+
.formatMessage({
41+
id: 'metric_quantile_explanation',
42+
})
43+
.split('\n')
44+
.map((line, key) => (
45+
<SmallerText key={`globalheathexplanation-${key}`}>
46+
{line}
47+
</SmallerText>
48+
))}
49+
</Stack>
50+
}
51+
/>
52+
);
53+
};
54+
3255
const DashboardMetrics = () => {
3356
const intl = useIntl();
3457
// App config, used to generated Advanced metrics button link
@@ -38,40 +61,12 @@ const DashboardMetrics = () => {
3861
<MetricsContainer id="dashboard-metrics-container">
3962
<PanelActions>
4063
<PageSubtitle>
41-
<SpacedBox mr={8}>
42-
{' '}
64+
<Box mr={spacing.r8}>
4365
{intl.formatMessage({
4466
id: 'metrics',
4567
})}
46-
</SpacedBox>
47-
{isShowQuantileChart && (
48-
<Tooltip
49-
placement="bottom"
50-
overlay={
51-
<SmallerText
52-
// @ts-expect-error - FIXME when you are working on it
53-
style={{
54-
minWidth: '30rem',
55-
display: 'block',
56-
textAlign: 'left',
57-
}}
58-
>
59-
{intl
60-
.formatMessage({
61-
id: 'metric_quantile_explanation',
62-
})
63-
.split('\n')
64-
.map((line, key) => (
65-
<SpacedBox key={`globalheathexplanation-${key}`} mb={8}>
66-
{line}
67-
</SpacedBox>
68-
))}
69-
</SmallerText>
70-
}
71-
>
72-
<Icon name="Info" color="buttonSecondary" />
73-
</Tooltip>
74-
)}
68+
</Box>
69+
{isShowQuantileChart && <QuantileHelpTooltip />}
7570
</PageSubtitle>
7671

7772
{url_grafana && (

ui/src/components/DashboardNetwork.tsx

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
11
import React from 'react';
22
import styled from 'styled-components';
33
import { useIntl } from 'react-intl';
4-
import { spacing } from '@scality/core-ui/dist/style/theme';
54
import {
65
PageSubtitle,
76
GraphsWrapper,
87
} from '../components/style/CommonLayoutStyle';
98
import DashboardPlaneHealth from './DashboardPlaneHealth';
109
import DashboardBandwidthChart from './DashboardBandwidthChart';
1110
import { DashboardScrollableArea } from '../containers/DashboardPage';
12-
import { SpacedBox } from '@scality/core-ui';
1311
import { useShowQuantileChart } from '../hooks';
14-
import { Tooltip, Icon, SmallerText } from '@scality/core-ui';
12+
import { QuantileHelpTooltip } from './DashboardMetrics';
13+
import { Box } from '@scality/core-ui/dist/next';
14+
import { spacing } from '@scality/core-ui';
1515
export const NetworkContainer = styled.div`
16-
padding: ${spacing.sp2} ${spacing.sp4};
16+
padding: ${spacing.r2} ${spacing.r4};
1717
display: flex;
1818
flex-direction: column;
1919
flex-grow: 1;
2020
max-width: 100%;
2121
`;
2222
export const PanelActions = styled.div`
2323
display: flex;
24-
padding: ${spacing.sp4};
24+
padding: ${spacing.r4};
2525
align-items: center;
2626
justify-content: space-between;
2727
`;
@@ -37,40 +37,12 @@ const DashboardNetwork = () => {
3737
>
3838
<PanelActions>
3939
<PageSubtitle>
40-
<SpacedBox mr={8}>
41-
{' '}
40+
<Box mr={spacing.r8}>
4241
{intl.formatMessage({
4342
id: 'network',
4443
})}
45-
</SpacedBox>
46-
{isShowQuantileChart && (
47-
<Tooltip
48-
placement="bottom"
49-
overlay={
50-
<SmallerText
51-
// @ts-expect-error - FIXME when you are working on it
52-
style={{
53-
minWidth: '30rem',
54-
display: 'block',
55-
textAlign: 'left',
56-
}}
57-
>
58-
{intl
59-
.formatMessage({
60-
id: 'network_quantile_explanation',
61-
})
62-
.split('\n')
63-
.map((line, key) => (
64-
<SpacedBox key={`globalheathexplanation-${key}`} mb={8}>
65-
{line}
66-
</SpacedBox>
67-
))}
68-
</SmallerText>
69-
}
70-
>
71-
<Icon name="Info" color="buttonSecondary" />
72-
</Tooltip>
73-
)}
44+
</Box>
45+
{isShowQuantileChart && <QuantileHelpTooltip />}
7446
</PageSubtitle>
7547
</PanelActions>
7648

0 commit comments

Comments
 (0)