@centreon/ui 24.4.46 → 24.4.48
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 +14 -23
- package/public/mockServiceWorker.js +1 -1
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Button/Save/index.tsx +5 -9
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dashboard/Layout.tsx +2 -2
- package/src/Dialog/index.tsx +1 -1
- package/src/FallbackPage/FallbackPage.tsx +3 -3
- package/src/FileDropZone/index.tsx +1 -3
- package/src/Form/Inputs/CheckboxGroup.tsx +4 -1
- package/src/Form/Inputs/index.tsx +1 -3
- package/src/Form/Inputs/models.ts +1 -9
- package/src/Graph/Gauge/Gauge.tsx +1 -1
- package/src/Graph/HeatMap/HeatMap.stories.tsx +25 -0
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +2 -8
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +4 -5
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +1 -1
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +3 -2
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- package/src/Graph/LineChart/Legend/Legend.styles.ts +1 -1
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +1 -1
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +2 -2
- package/src/Graph/LineChart/Legend/useLegend.ts +3 -3
- package/src/Graph/LineChart/helpers/doc.ts +13 -16
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +2 -4
- package/src/Graph/LineChart/index.tsx +1 -1
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.stories.tsx +4 -60
- package/src/Graph/Text/Text.tsx +1 -1
- package/src/Graph/common/timeSeries/index.ts +14 -22
- package/src/Graph/common/utils.ts +0 -19
- package/src/Graph/index.ts +0 -3
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -10
- package/src/InputField/Select/Autocomplete/Draggable/SortableList.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/SortableListContent.tsx +1 -1
- package/src/InputField/Select/Autocomplete/Draggable/index.tsx +1 -1
- package/src/InputField/Select/Autocomplete/index.tsx +115 -121
- package/src/InputField/Select/IconPopover/index.tsx +2 -2
- package/src/InputField/Select/index.tsx +1 -1
- package/src/InputField/Text/index.tsx +2 -2
- package/src/Listing/ActionBar/index.tsx +8 -9
- package/src/Listing/Cell/DataCell.styles.ts +0 -3
- package/src/Listing/Cell/DataCell.tsx +5 -23
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.cypress.spec.tsx +4 -80
- package/src/Listing/Listing.styles.ts +7 -4
- package/src/Listing/index.stories.tsx +3 -37
- package/src/Listing/index.test.tsx +1 -1
- package/src/Listing/index.tsx +3 -4
- package/src/Listing/models.ts +0 -1
- package/src/Module/index.tsx +4 -2
- package/src/RichTextEditor/RichTextEditor.tsx +1 -12
- package/src/SortableItems/index.tsx +7 -2
- package/src/ThemeProvider/index.tsx +0 -24
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +7 -6
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +3 -8
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +2 -0
- package/src/TimePeriods/DateTimePickerInput.tsx +19 -56
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +9 -12
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +33 -9
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +4 -12
- package/src/TimePeriods/index.tsx +2 -2
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/TestQueryProvider.tsx +1 -1
- package/src/api/useFetchQuery/index.ts +23 -27
- package/src/api/useMutationQuery/index.test.ts +4 -4
- package/src/api/useMutationQuery/index.ts +25 -60
- package/src/components/Button/Icon/IconButton.tsx +2 -6
- package/src/components/DataTable/DataTable.stories.tsx +0 -40
- package/src/components/DataTable/DataTable.styles.ts +0 -3
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +2 -7
- package/src/components/DataTable/Item/DataTableItem.tsx +4 -4
- package/src/components/DataTable/index.ts +1 -3
- package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +3 -3
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +0 -1
- package/src/components/Form/Dashboard/DashboardForm.tsx +12 -15
- package/src/components/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +0 -1
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +1 -5
- package/src/components/Layout/PageLayout/index.ts +1 -3
- package/src/components/Modal/Modal.styles.ts +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +3 -3
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +1 -1
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +1 -1
- package/src/index.ts +2 -2
- package/src/queryParameters/url/index.ts +1 -5
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +281 -0
- package/src/utils/index.ts +1 -1
- package/src/utils/useDateTimePickerAdapter.ts +309 -0
- package/src/utils/useFullscreen/useFullscreenListener.ts +7 -10
- package/src/utils/{useLicenseExpirationWarning.test.tsx → useLicenseExpirationWarning.cypress.spec.tsx} +37 -48
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/Form/Form.cypress.spec.tsx +0 -133
- package/src/Form/Inputs/List/Content.tsx +0 -62
- package/src/Form/Inputs/List/List.styles.ts +0 -29
- package/src/Form/Inputs/List/List.tsx +0 -58
- package/src/Form/Inputs/List/useList.ts +0 -81
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +0 -154
- package/src/Graph/BarStack/BarStack.stories.tsx +0 -123
- package/src/Graph/BarStack/BarStack.styles.ts +0 -36
- package/src/Graph/BarStack/BarStack.tsx +0 -14
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +0 -208
- package/src/Graph/BarStack/index.ts +0 -1
- package/src/Graph/BarStack/models.ts +0 -19
- package/src/Graph/BarStack/useResponsiveBarStack.ts +0 -139
- package/src/Graph/Gauge/Gauge.cypress.spec.tsx +0 -102
- package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +0 -145
- package/src/Graph/Legend/Legend.tsx +0 -21
- package/src/Graph/Legend/index.ts +0 -1
- package/src/Graph/Legend/models.ts +0 -11
- package/src/Graph/PieChart/PieChart.cypress.spec.tsx +0 -169
- package/src/Graph/PieChart/PieChart.stories.tsx +0 -194
- package/src/Graph/PieChart/PieChart.styles.ts +0 -39
- package/src/Graph/PieChart/PieChart.tsx +0 -14
- package/src/Graph/PieChart/ResponsivePie.tsx +0 -251
- package/src/Graph/PieChart/index.ts +0 -1
- package/src/Graph/PieChart/models.ts +0 -19
- package/src/Graph/PieChart/useResponsivePie.ts +0 -86
- package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +0 -121
- package/src/Graph/Text/Text.cypress.spec.tsx +0 -101
- package/src/Graph/common/testUtils.ts +0 -71
- package/src/Graph/translatedLabels.ts +0 -1
- package/src/Module/Module.cypress.spec.tsx +0 -129
- package/src/components/DataTable/DataListing.tsx +0 -6
- package/src/components/DataTable/DataTable.cypress.spec.tsx +0 -193
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +0 -76
- package/src/components/Layout/PageLayout.cypress.spec.tsx +0 -66
- package/src/utils/usePluralizedTranslation.ts +0 -21
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { pluck } from 'ramda';
|
|
2
|
-
|
|
3
|
-
import { Box, Typography } from '@mui/material';
|
|
4
|
-
|
|
5
|
-
import EllipsisTypography from '../../Typography/EllipsisTypography';
|
|
6
|
-
|
|
7
|
-
import HeatMap from './HeatMap';
|
|
8
|
-
import heatMapData from './HeatMapData.json';
|
|
9
|
-
import { HeatMapProps } from './model';
|
|
10
|
-
|
|
11
|
-
const dataIds = pluck('id', heatMapData);
|
|
12
|
-
|
|
13
|
-
interface Data {
|
|
14
|
-
counter: number;
|
|
15
|
-
host: string;
|
|
16
|
-
service: string;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const TileContent = ({
|
|
20
|
-
isSmallestSize,
|
|
21
|
-
data
|
|
22
|
-
}: {
|
|
23
|
-
data: Data;
|
|
24
|
-
isSmallestSize: boolean;
|
|
25
|
-
}): JSX.Element | false =>
|
|
26
|
-
!isSmallestSize && (
|
|
27
|
-
<Box
|
|
28
|
-
sx={{
|
|
29
|
-
alignItems: 'center',
|
|
30
|
-
color: 'common.black',
|
|
31
|
-
display: 'flex',
|
|
32
|
-
flexDirection: 'column',
|
|
33
|
-
width: '100%'
|
|
34
|
-
}}
|
|
35
|
-
>
|
|
36
|
-
<EllipsisTypography textAlign="center">{data.host}</EllipsisTypography>
|
|
37
|
-
<EllipsisTypography textAlign="center">{data.service}</EllipsisTypography>
|
|
38
|
-
<EllipsisTypography textAlign="center">{data.counter}</EllipsisTypography>
|
|
39
|
-
</Box>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
const initialize = ({
|
|
43
|
-
width = '100vw',
|
|
44
|
-
height = '100vh',
|
|
45
|
-
...args
|
|
46
|
-
}: Omit<HeatMapProps<Data>, 'tiles' | 'children'> & {
|
|
47
|
-
height?: string;
|
|
48
|
-
width?: string;
|
|
49
|
-
}): void => {
|
|
50
|
-
cy.mount({
|
|
51
|
-
Component: (
|
|
52
|
-
<div style={{ height, width }}>
|
|
53
|
-
<HeatMap tiles={heatMapData} {...args}>
|
|
54
|
-
{TileContent}
|
|
55
|
-
</HeatMap>
|
|
56
|
-
</div>
|
|
57
|
-
)
|
|
58
|
-
});
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
describe('HeatMap', () => {
|
|
62
|
-
it('displays tiles', () => {
|
|
63
|
-
initialize({});
|
|
64
|
-
dataIds.forEach((id) => {
|
|
65
|
-
cy.findByTestId(id).should('be.visible');
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('does not display the tooltip when the prop is not set and the tile is hovered', () => {
|
|
70
|
-
initialize({});
|
|
71
|
-
|
|
72
|
-
cy.findByTestId(dataIds[0]).trigger('mouseover');
|
|
73
|
-
|
|
74
|
-
cy.findByTestId(`tooltip-${dataIds[0]}`).should('not.exist');
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
it('displays the tooltip when the prop is set and the tile is hovered', () => {
|
|
78
|
-
initialize({
|
|
79
|
-
tooltipContent: ({ data }) => (
|
|
80
|
-
<Typography>
|
|
81
|
-
This is the tooltip for {data.host}-{data.service}-{data.counter}
|
|
82
|
-
</Typography>
|
|
83
|
-
)
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
cy.findByTestId(dataIds[0]).trigger('mouseover');
|
|
87
|
-
|
|
88
|
-
cy.contains(`This is the tooltip for Server-Service Counter-53`).should(
|
|
89
|
-
'be.visible'
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
it('displays the tooltip conditionally when the prop is set and the tile is hovered', () => {
|
|
94
|
-
initialize({
|
|
95
|
-
displayTooltipCondition: ({ counter }) => counter > 100,
|
|
96
|
-
tooltipContent: ({ data }) => (
|
|
97
|
-
<Typography>
|
|
98
|
-
This is the tooltip for {data.host}-{data.service}-{data.counter}
|
|
99
|
-
</Typography>
|
|
100
|
-
)
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
cy.findByTestId(dataIds[0]).trigger('mouseover');
|
|
104
|
-
|
|
105
|
-
cy.contains(`This is the tooltip for Server-Service Counter-53`).should(
|
|
106
|
-
'not.exist'
|
|
107
|
-
);
|
|
108
|
-
|
|
109
|
-
cy.findByTestId(dataIds[1]).trigger('mouseover');
|
|
110
|
-
|
|
111
|
-
cy.contains(`This is the tooltip for Server-Service Counter-779`).should(
|
|
112
|
-
'be.visible'
|
|
113
|
-
);
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
it('displays tiles with fixed size', () => {
|
|
117
|
-
initialize({ height: '200px', tileSizeFixed: true, width: '590px' });
|
|
118
|
-
dataIds.forEach((id) => {
|
|
119
|
-
cy.findByTestId(id).should('be.visible');
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
it('displays tiles as small when the container width is under the breakpoint', () => {
|
|
124
|
-
initialize({ height: '200px', width: '590px' });
|
|
125
|
-
dataIds.forEach((id) => {
|
|
126
|
-
cy.findByTestId(id).should('be.visible');
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
cy.makeSnapshot();
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('does not display tiles as small when the contains width is 0', () => {
|
|
133
|
-
initialize({ height: '200px', width: '0px' });
|
|
134
|
-
dataIds.forEach((id) => {
|
|
135
|
-
cy.findByTestId(id).should('not.exist');
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
cy.makeSnapshot();
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
it('displays a single tile', () => {
|
|
142
|
-
initialize({ tiles: [heatMapData[0]] });
|
|
143
|
-
cy.findByTestId(dataIds[0]).should('be.visible');
|
|
144
|
-
});
|
|
145
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { LegendOrdinal } from '@visx/legend';
|
|
2
|
-
import { scaleOrdinal } from '@visx/scale';
|
|
3
|
-
|
|
4
|
-
import { LegendProps } from './models';
|
|
5
|
-
|
|
6
|
-
const Legend = ({ scale, direction = 'column' }: LegendProps): JSX.Element => {
|
|
7
|
-
const legendScale = scaleOrdinal({
|
|
8
|
-
domain: scale.domain,
|
|
9
|
-
range: scale.range
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<LegendOrdinal
|
|
14
|
-
direction={direction}
|
|
15
|
-
labelMargin="0 16px 0 0"
|
|
16
|
-
scale={legendScale}
|
|
17
|
-
/>
|
|
18
|
-
);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export default Legend;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Legend } from './Legend';
|
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
import numeral from 'numeral';
|
|
2
|
-
|
|
3
|
-
import PieChart from './PieChart';
|
|
4
|
-
import { ArcType, PieProps } from './models';
|
|
5
|
-
|
|
6
|
-
const defaultData = [
|
|
7
|
-
{ color: '#88B922', label: 'Ok', value: 148 },
|
|
8
|
-
{ color: '#999999', label: 'Unknown', value: 13 },
|
|
9
|
-
{ color: '#F7931A', label: 'Warning', value: 16 },
|
|
10
|
-
{ color: '#FF6666', label: 'Down', value: 62 }
|
|
11
|
-
];
|
|
12
|
-
|
|
13
|
-
const dataWithNullValues = [
|
|
14
|
-
{ color: '#88B922', label: 'Ok', value: 0 },
|
|
15
|
-
{ color: '#999999', label: 'Unknown', value: 0 },
|
|
16
|
-
{ color: '#F7931A', label: 'Warning', value: 0 },
|
|
17
|
-
{ color: '#FF6666', label: 'Down', value: 0 }
|
|
18
|
-
];
|
|
19
|
-
|
|
20
|
-
const total = Math.floor(
|
|
21
|
-
defaultData.reduce((acc, { value }) => acc + value, 0)
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
const TooltipContent = ({ label, color, value }: ArcType): JSX.Element => {
|
|
25
|
-
return (
|
|
26
|
-
<div data-testid={`tooltip-${label}`} style={{ color }}>
|
|
27
|
-
{label} : {value}
|
|
28
|
-
</div>
|
|
29
|
-
);
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
const initialize = ({
|
|
33
|
-
width = '500px',
|
|
34
|
-
height = '500px',
|
|
35
|
-
data = defaultData,
|
|
36
|
-
...args
|
|
37
|
-
}: Omit<PieProps, 'data'> & {
|
|
38
|
-
data?;
|
|
39
|
-
height?: string;
|
|
40
|
-
width?: string;
|
|
41
|
-
}): void => {
|
|
42
|
-
cy.mount({
|
|
43
|
-
Component: (
|
|
44
|
-
<div style={{ height, width }}>
|
|
45
|
-
<PieChart {...args} data={data} />
|
|
46
|
-
</div>
|
|
47
|
-
)
|
|
48
|
-
});
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
describe('Pie chart', () => {
|
|
52
|
-
it('renders pie chart correctly with provided data', () => {
|
|
53
|
-
initialize({});
|
|
54
|
-
|
|
55
|
-
defaultData.forEach(({ label }) => {
|
|
56
|
-
cy.findByTestId(label).should('be.visible');
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
cy.makeSnapshot();
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
it('adjusts size based on the provided width and height', () => {
|
|
63
|
-
initialize({ displayLegend: false, height: '300px', width: '300px' });
|
|
64
|
-
|
|
65
|
-
cy.findByTestId('pieChart')
|
|
66
|
-
.should('have.css', 'width', '300px')
|
|
67
|
-
.and('have.css', 'height', '300px');
|
|
68
|
-
|
|
69
|
-
cy.makeSnapshot();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('renders as a donut when variant is set to "donut"', () => {
|
|
73
|
-
initialize({ variant: 'donut' });
|
|
74
|
-
cy.get('[data-variant="donut"]').should('exist');
|
|
75
|
-
|
|
76
|
-
cy.makeSnapshot();
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it('renders as a pie when variant is set to "pie"', () => {
|
|
80
|
-
initialize({ variant: 'pie' });
|
|
81
|
-
cy.get('[data-variant="pie"]').should('exist');
|
|
82
|
-
|
|
83
|
-
cy.makeSnapshot();
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
it('displays tooltip with correct information on hover', () => {
|
|
87
|
-
initialize({ TooltipContent });
|
|
88
|
-
|
|
89
|
-
defaultData.forEach(({ label, value }) => {
|
|
90
|
-
cy.findByTestId(label).trigger('mouseover', { force: true });
|
|
91
|
-
|
|
92
|
-
cy.findByTestId(`tooltip-${label}`)
|
|
93
|
-
.should('contain', label)
|
|
94
|
-
.and('contain', numeral(value).format('0a').toUpperCase());
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
cy.makeSnapshot();
|
|
98
|
-
});
|
|
99
|
-
it('conditionally displays values on arcs based on displayValues prop', () => {
|
|
100
|
-
initialize({ displayValues: true });
|
|
101
|
-
defaultData.forEach(({ value }, index) => {
|
|
102
|
-
cy.findAllByTestId('value')
|
|
103
|
-
.eq(index)
|
|
104
|
-
.children()
|
|
105
|
-
.eq(0)
|
|
106
|
-
.should('have.text', value);
|
|
107
|
-
});
|
|
108
|
-
|
|
109
|
-
initialize({ displayValues: false });
|
|
110
|
-
cy.findAllByTestId('value').should('not.exist');
|
|
111
|
-
|
|
112
|
-
cy.makeSnapshot();
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('displays values on arcs in percentage unit when displayValues is set to true and unit to percentage', () => {
|
|
116
|
-
initialize({ displayValues: true, unit: 'percentage' });
|
|
117
|
-
defaultData.forEach(({ value }, index) => {
|
|
118
|
-
cy.findAllByTestId('value')
|
|
119
|
-
.eq(index)
|
|
120
|
-
.children()
|
|
121
|
-
.eq(0)
|
|
122
|
-
.should('have.text', `${((value * 100) / total).toFixed(1)}%`);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
cy.makeSnapshot();
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
it('displays Legend component based on displayLegend prop', () => {
|
|
129
|
-
initialize({ displayLegend: true });
|
|
130
|
-
cy.findByTestId('Legend').should('be.visible');
|
|
131
|
-
|
|
132
|
-
initialize({ displayLegend: false });
|
|
133
|
-
cy.findByTestId('Legend').should('not.exist');
|
|
134
|
-
|
|
135
|
-
cy.makeSnapshot();
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
it('displays the title when the title is giving', () => {
|
|
139
|
-
initialize({ title: 'host' });
|
|
140
|
-
cy.findByTestId('Title').should('be.visible');
|
|
141
|
-
|
|
142
|
-
initialize({});
|
|
143
|
-
cy.findByTestId('Title').should('not.exist');
|
|
144
|
-
|
|
145
|
-
cy.makeSnapshot();
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
it('adjusts outer radius when chart dimensions are too small', () => {
|
|
149
|
-
initialize({
|
|
150
|
-
displayLegend: false,
|
|
151
|
-
height: '120px',
|
|
152
|
-
title: 'hosts',
|
|
153
|
-
variant: 'donut',
|
|
154
|
-
width: '120px'
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
cy.get('[data-variant="donut"]').should('have.css', 'width', '100px');
|
|
158
|
-
|
|
159
|
-
cy.makeSnapshot();
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it('displays a message "No Data Available" when all values are null', () => {
|
|
163
|
-
initialize({ data: dataWithNullValues, title: 'host' });
|
|
164
|
-
|
|
165
|
-
cy.contains('No Data Available');
|
|
166
|
-
|
|
167
|
-
cy.makeSnapshot();
|
|
168
|
-
});
|
|
169
|
-
});
|
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
import { Meta, StoryObj } from '@storybook/react';
|
|
2
|
-
|
|
3
|
-
import { ArcType } from './models';
|
|
4
|
-
|
|
5
|
-
import { PieChart } from '.';
|
|
6
|
-
|
|
7
|
-
const data = [
|
|
8
|
-
{ color: '#88B922', label: 'Ok', value: 148 },
|
|
9
|
-
{ color: '#999999', label: 'Unknown', value: 13 },
|
|
10
|
-
{ color: '#F7931A', label: 'Warning', value: 16 },
|
|
11
|
-
{ color: '#FF6666', label: 'Down', value: 62 }
|
|
12
|
-
];
|
|
13
|
-
|
|
14
|
-
const dataWithBigNumbers = [
|
|
15
|
-
{ color: '#88B922', label: 'Ok', value: 260000 },
|
|
16
|
-
{ color: '#999999', label: 'Unknown', value: 1010900 },
|
|
17
|
-
{ color: '#F7931A', label: 'Warning', value: 63114 },
|
|
18
|
-
{ color: '#FF6666', label: 'Down', value: 122222 }
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
const meta: Meta<typeof PieChart> = {
|
|
22
|
-
component: PieChart
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
export default meta;
|
|
26
|
-
type Story = StoryObj<typeof PieChart>;
|
|
27
|
-
|
|
28
|
-
const Template = (args): JSX.Element => {
|
|
29
|
-
return (
|
|
30
|
-
<div style={{ height: '350px', width: '350px' }}>
|
|
31
|
-
<PieChart {...args} />
|
|
32
|
-
</div>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export const Pie: Story = {
|
|
37
|
-
args: {
|
|
38
|
-
data,
|
|
39
|
-
title: 'hosts'
|
|
40
|
-
},
|
|
41
|
-
render: Template
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const Donut: Story = {
|
|
45
|
-
args: {
|
|
46
|
-
data,
|
|
47
|
-
title: 'hosts',
|
|
48
|
-
variant: 'donut'
|
|
49
|
-
},
|
|
50
|
-
render: Template
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export const WithPencentage: Story = {
|
|
54
|
-
args: {
|
|
55
|
-
data,
|
|
56
|
-
title: 'hosts',
|
|
57
|
-
unit: 'percentage',
|
|
58
|
-
variant: 'donut'
|
|
59
|
-
},
|
|
60
|
-
render: Template
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export const WithBigNumbers: Story = {
|
|
64
|
-
args: {
|
|
65
|
-
data: dataWithBigNumbers,
|
|
66
|
-
title: 'hosts',
|
|
67
|
-
unit: 'number',
|
|
68
|
-
variant: 'donut'
|
|
69
|
-
},
|
|
70
|
-
render: Template
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const WithoutLegend: Story = {
|
|
74
|
-
args: {
|
|
75
|
-
data,
|
|
76
|
-
displayLegend: false,
|
|
77
|
-
title: 'hosts',
|
|
78
|
-
variant: 'donut'
|
|
79
|
-
},
|
|
80
|
-
render: Template
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export const DonutWithoutTitle: Story = {
|
|
84
|
-
args: {
|
|
85
|
-
data,
|
|
86
|
-
variant: 'donut'
|
|
87
|
-
},
|
|
88
|
-
render: Template
|
|
89
|
-
};
|
|
90
|
-
|
|
91
|
-
export const PieWithoutTitle: Story = {
|
|
92
|
-
args: {
|
|
93
|
-
data
|
|
94
|
-
},
|
|
95
|
-
render: Template
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const DonutWithDisplayedValues: Story = {
|
|
99
|
-
args: {
|
|
100
|
-
data,
|
|
101
|
-
displayValues: true,
|
|
102
|
-
variant: 'donut'
|
|
103
|
-
},
|
|
104
|
-
render: Template
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
export const PieWithDisplayedValues: Story = {
|
|
108
|
-
args: {
|
|
109
|
-
data,
|
|
110
|
-
displayValues: true
|
|
111
|
-
},
|
|
112
|
-
render: Template
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
const TooltipContent = ({ label, color, value }: ArcType): JSX.Element => {
|
|
116
|
-
return (
|
|
117
|
-
<div style={{ color }}>
|
|
118
|
-
{label} : {value}
|
|
119
|
-
</div>
|
|
120
|
-
);
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export const PieWithTooltip: Story = {
|
|
124
|
-
args: {
|
|
125
|
-
TooltipContent,
|
|
126
|
-
data,
|
|
127
|
-
displayValues: true,
|
|
128
|
-
unit: 'percentage'
|
|
129
|
-
},
|
|
130
|
-
render: Template
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
export const DonutWithTooltip: Story = {
|
|
134
|
-
args: {
|
|
135
|
-
TooltipContent,
|
|
136
|
-
data,
|
|
137
|
-
displayValues: true,
|
|
138
|
-
variant: 'donut'
|
|
139
|
-
},
|
|
140
|
-
render: Template
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
const TemplateForSmallDimensions = (args): JSX.Element => {
|
|
144
|
-
return (
|
|
145
|
-
<div style={{ height: '130px', width: '130px' }}>
|
|
146
|
-
<PieChart {...args} />
|
|
147
|
-
</div>
|
|
148
|
-
);
|
|
149
|
-
};
|
|
150
|
-
|
|
151
|
-
export const PieWithSmallDimensions: Story = {
|
|
152
|
-
args: {
|
|
153
|
-
data,
|
|
154
|
-
displayLegend: false
|
|
155
|
-
},
|
|
156
|
-
render: TemplateForSmallDimensions
|
|
157
|
-
};
|
|
158
|
-
|
|
159
|
-
export const DonutWithSmallDimensions: Story = {
|
|
160
|
-
args: {
|
|
161
|
-
data,
|
|
162
|
-
displayLegend: false,
|
|
163
|
-
title: 'hosts',
|
|
164
|
-
variant: 'donut'
|
|
165
|
-
},
|
|
166
|
-
render: TemplateForSmallDimensions
|
|
167
|
-
};
|
|
168
|
-
|
|
169
|
-
const dataWidthOneNoZeroValue = [
|
|
170
|
-
{ color: '#88B922', label: 'Ok', value: 13 },
|
|
171
|
-
{ color: '#999999', label: 'Unknown', value: 0 },
|
|
172
|
-
{ color: '#F7931A', label: 'Warning', value: 0 },
|
|
173
|
-
{ color: '#FF6666', label: 'Down', value: 0 }
|
|
174
|
-
];
|
|
175
|
-
|
|
176
|
-
export const PieWithOneNoZeroValue: Story = {
|
|
177
|
-
args: {
|
|
178
|
-
data: dataWidthOneNoZeroValue,
|
|
179
|
-
displayLegend: false,
|
|
180
|
-
title: 'hosts',
|
|
181
|
-
variant: 'pie'
|
|
182
|
-
},
|
|
183
|
-
render: Template
|
|
184
|
-
};
|
|
185
|
-
|
|
186
|
-
export const donutWithOneNoZeroValue: Story = {
|
|
187
|
-
args: {
|
|
188
|
-
data: dataWidthOneNoZeroValue,
|
|
189
|
-
displayLegend: false,
|
|
190
|
-
title: 'hosts',
|
|
191
|
-
variant: 'donut'
|
|
192
|
-
},
|
|
193
|
-
render: Template
|
|
194
|
-
};
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { lt } from 'ramda';
|
|
2
|
-
import { makeStyles } from 'tss-react/mui';
|
|
3
|
-
|
|
4
|
-
export const usePieStyles = makeStyles<{ svgSize: number }>()(
|
|
5
|
-
(theme, { svgSize }) => ({
|
|
6
|
-
container: {
|
|
7
|
-
alignItems: 'center',
|
|
8
|
-
display: 'flex',
|
|
9
|
-
gap: theme.spacing(2),
|
|
10
|
-
justifyContent: 'center'
|
|
11
|
-
},
|
|
12
|
-
pieChartTooltip: {
|
|
13
|
-
backgroundColor: theme.palette.background.paper,
|
|
14
|
-
color: theme.palette.text.primary,
|
|
15
|
-
padding: 0,
|
|
16
|
-
position: 'relative'
|
|
17
|
-
},
|
|
18
|
-
svgContainer: {
|
|
19
|
-
alignItems: 'center',
|
|
20
|
-
backgroundColor: theme.palette.background.panelGroups,
|
|
21
|
-
borderRadius: '100%',
|
|
22
|
-
display: 'flex',
|
|
23
|
-
justifyContent: 'center'
|
|
24
|
-
},
|
|
25
|
-
svgWrapper: {
|
|
26
|
-
alignItems: 'center',
|
|
27
|
-
display: 'flex',
|
|
28
|
-
flexDirection: 'column',
|
|
29
|
-
gap: theme.spacing(1),
|
|
30
|
-
justifyContent: 'center'
|
|
31
|
-
},
|
|
32
|
-
title: {
|
|
33
|
-
fontSize: lt(svgSize, 150)
|
|
34
|
-
? theme.typography.body1.fontSize
|
|
35
|
-
: theme.typography.h6.fontSize,
|
|
36
|
-
fontWeight: theme.typography.fontWeightMedium
|
|
37
|
-
}
|
|
38
|
-
})
|
|
39
|
-
);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { ParentSize } from '../..';
|
|
2
|
-
|
|
3
|
-
import ResponsivePie from './ResponsivePie';
|
|
4
|
-
import { PieProps } from './models';
|
|
5
|
-
|
|
6
|
-
const PieChart = (props: PieProps): JSX.Element => (
|
|
7
|
-
<ParentSize>
|
|
8
|
-
{({ width, height }) => (
|
|
9
|
-
<ResponsivePie {...props} height={height} width={width} />
|
|
10
|
-
)}
|
|
11
|
-
</ParentSize>
|
|
12
|
-
);
|
|
13
|
-
|
|
14
|
-
export default PieChart;
|