@centreon/ui 24.4.1-sync-release-34022.1 → 24.4.1-test-code-coverage.1
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 +48 -40
- package/src/ActionsList/ActionsList.styles.ts +40 -71
- package/src/Button/Icon/index.stories.tsx +1 -1
- package/src/Button/Icon/index.tsx +1 -1
- package/src/Dashboard/Dashboard.styles.ts +6 -5
- package/src/Dialog/Confirm/index.tsx +10 -2
- package/src/Dialog/UnsavedChanges/index.tsx +21 -20
- package/src/Dialog/UnsavedChanges/translatedLabels.ts +4 -6
- package/src/Dialog/index.tsx +8 -1
- package/src/Form/Inputs/CheckboxGroup.tsx +4 -1
- package/src/Form/Inputs/Text.tsx +3 -1
- package/src/Form/Inputs/models.ts +1 -0
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +139 -0
- package/src/Graph/BarStack/BarStack.stories.tsx +123 -0
- package/src/Graph/BarStack/BarStack.styles.ts +37 -0
- package/src/Graph/BarStack/BarStack.tsx +14 -0
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +209 -0
- package/src/Graph/BarStack/index.ts +1 -0
- package/src/Graph/BarStack/models.ts +19 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +131 -0
- package/src/Graph/Gauge/Gauge.cypress.spec.tsx +102 -0
- package/src/Graph/Gauge/Gauge.tsx +1 -1
- package/src/Graph/HeatMap/HeatMap.cypress.spec.tsx +145 -0
- package/src/Graph/HeatMap/HeatMap.stories.tsx +0 -25
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +8 -2
- package/src/Graph/Legend/Legend.tsx +21 -0
- package/src/Graph/Legend/index.ts +1 -0
- package/src/Graph/Legend/models.ts +11 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +4 -5
- package/src/Graph/LineChart/BasicComponents/ThresholdLine.tsx +3 -1
- package/src/Graph/LineChart/Header/index.tsx +3 -31
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/useTickGraph.ts +9 -11
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +3 -2
- package/src/Graph/LineChart/InteractiveComponents/GraphValueTooltip/GraphValueTooltip.tsx +68 -0
- package/src/Graph/LineChart/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +27 -0
- package/src/Graph/LineChart/InteractiveComponents/GraphValueTooltip/useGraphValueTooltipStyles.ts +31 -0
- package/src/Graph/LineChart/InteractiveComponents/index.tsx +132 -17
- package/src/Graph/LineChart/InteractiveComponents/interactionWithGraphAtoms.ts +7 -27
- package/src/Graph/LineChart/Legend/Legend.styles.ts +5 -9
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +10 -22
- package/src/Graph/LineChart/Legend/index.tsx +17 -55
- package/src/Graph/LineChart/LineChart.cypress.spec.tsx +91 -0
- package/src/Graph/LineChart/LineChart.styles.ts +8 -0
- package/src/Graph/LineChart/LineChart.tsx +106 -116
- package/src/Graph/LineChart/LoadingSkeleton.tsx +2 -2
- package/src/Graph/LineChart/index.tsx +6 -7
- package/src/Graph/LineChart/mockedData/lastDayWithIncompleteValues.json +1320 -0
- package/src/Graph/LineChart/mockedData/lastDayWithNullValues.json +1314 -0
- package/src/Graph/LineChart/models.ts +12 -1
- package/src/Graph/PieChart/PieChart.cypress.spec.tsx +154 -0
- package/src/Graph/PieChart/PieChart.stories.tsx +194 -0
- package/src/Graph/PieChart/PieChart.styles.ts +39 -0
- package/src/Graph/PieChart/PieChart.tsx +14 -0
- package/src/Graph/PieChart/ResponsivePie.tsx +243 -0
- package/src/Graph/PieChart/index.ts +1 -0
- package/src/Graph/PieChart/models.ts +19 -0
- package/src/Graph/PieChart/useResponsivePie.ts +81 -0
- package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +121 -0
- package/src/Graph/Text/Text.cypress.spec.tsx +101 -0
- package/src/Graph/Text/Text.styles.ts +12 -1
- package/src/Graph/Text/Text.tsx +17 -12
- package/src/Graph/Tree/DescendantNodes.tsx +89 -0
- package/src/Graph/Tree/Links.tsx +77 -0
- package/src/Graph/Tree/StandaloneTree.tsx +32 -0
- package/src/Graph/Tree/Tree.cypress.spec.tsx +195 -0
- package/src/Graph/Tree/Tree.stories.tsx +160 -0
- package/src/Graph/Tree/Tree.tsx +116 -0
- package/src/Graph/Tree/constants.ts +2 -0
- package/src/Graph/Tree/index.ts +4 -0
- package/src/Graph/Tree/models.ts +55 -0
- package/src/Graph/Tree/stories/contents.tsx +164 -0
- package/src/Graph/Tree/stories/datas.ts +305 -0
- package/src/Graph/Tree/utils.ts +49 -0
- package/src/Graph/common/testUtils.ts +71 -0
- package/src/Graph/common/timeSeries/index.ts +50 -12
- package/src/Graph/common/utils.ts +19 -0
- package/src/Graph/index.ts +4 -0
- package/src/InputField/Number/Number.cypress.spec.tsx +85 -0
- package/src/InputField/Number/Number.stories.tsx +66 -0
- package/src/InputField/Number/Number.tsx +74 -0
- package/src/InputField/Search/index.tsx +2 -2
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +4 -2
- package/src/InputField/Select/Autocomplete/index.tsx +10 -3
- package/src/InputField/Select/IconPopover/index.tsx +1 -1
- package/src/InputField/Select/index.tsx +14 -1
- package/src/InputField/Text/index.tsx +38 -38
- package/src/Listing/ActionBar/index.tsx +10 -10
- package/src/Listing/Cell/DataCell.styles.ts +3 -0
- package/src/Listing/Cell/DataCell.tsx +8 -4
- package/src/Listing/Listing.cypress.spec.tsx +217 -33
- package/src/Listing/Listing.styles.ts +3 -5
- package/src/Listing/Row/Row.tsx +7 -3
- package/src/Listing/index.stories.tsx +25 -2
- package/src/Listing/index.test.tsx +1 -1
- package/src/Listing/index.tsx +202 -143
- package/src/Listing/models.ts +1 -0
- package/src/Listing/useStyleTable.ts +1 -0
- package/src/Panel/index.tsx +1 -1
- package/src/PopoverMenu/index.tsx +6 -5
- package/src/ThemeProvider/index.tsx +3 -0
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +6 -7
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +12 -9
- package/src/Typography/FluidTypography/FluidTypography.cypress.spec.tsx +27 -0
- package/src/Typography/FluidTypography/index.stories.tsx +2 -2
- package/src/Typography/FluidTypography/index.tsx +21 -28
- package/src/api/index.ts +3 -3
- package/src/api/useGraphQuery/index.ts +26 -5
- package/src/api/useGraphQuery/models.ts +5 -0
- package/src/api/useMutationQuery/index.test.ts +4 -4
- package/src/api/useMutationQuery/index.ts +24 -13
- package/src/components/CollapsibleItem/CollapsibleItem.cypress.spec.tsx +76 -0
- package/src/components/CollapsibleItem/CollapsibleItem.stories.tsx +26 -0
- package/src/components/CollapsibleItem/CollapsibleItem.tsx +43 -14
- package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +24 -1
- package/src/components/DataTable/DataTable.cypress.spec.tsx +14 -33
- package/src/components/DataTable/Item/DataTableItem.tsx +4 -60
- package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.cypress.spec.tsx +36 -13
- package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ContactSwitch.tsx +11 -3
- package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ShareInput.styles.ts +8 -0
- package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/ShareInput.tsx +1 -0
- package/src/components/Form/{AccessRightsV2 → AccessRights}/ShareInput/useShareInput.tsx +4 -0
- package/src/components/Form/{AccessRightsV2 → AccessRights}/models.ts +1 -0
- package/src/components/Form/{AccessRightsV2 → AccessRights}/storiesData.ts +23 -22
- package/src/components/Form/Dashboard/DashboardDuplicationForm.tsx +85 -0
- package/src/components/Form/Dashboard/index.ts +1 -0
- package/src/components/Form/FormActions.tsx +7 -2
- package/src/components/Form/index.ts +2 -2
- package/src/components/ItemComposition/Item.tsx +1 -1
- package/src/components/ItemComposition/ItemComposition.cypress.spec.tsx +113 -0
- package/src/components/ItemComposition/ItemComposition.stories.tsx +14 -0
- package/src/components/ItemComposition/ItemComposition.styles.ts +36 -3
- package/src/components/ItemComposition/ItemComposition.tsx +41 -17
- package/src/components/List/Item/ListItem.tsx +3 -3
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.cypress.spec.tsx +168 -0
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.stories.tsx +62 -0
- package/src/components/Modal/ConfirmationModal/ConfirmationModal.tsx +87 -0
- package/src/components/Modal/Modal.styles.ts +8 -3
- package/src/components/Modal/index.ts +2 -0
- 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/components/Zoom/Minimap.tsx +129 -0
- package/src/components/Zoom/Zoom.cypress.spec.tsx +246 -0
- package/src/components/Zoom/Zoom.stories.tsx +115 -0
- package/src/components/Zoom/Zoom.styles.tsx +68 -0
- package/src/components/Zoom/Zoom.tsx +64 -0
- package/src/components/Zoom/ZoomContent.tsx +170 -0
- package/src/components/Zoom/constants.ts +2 -0
- package/src/components/Zoom/localPoint.ts +51 -0
- package/src/components/Zoom/models.ts +25 -0
- package/src/components/Zoom/useMinimap.ts +156 -0
- package/src/components/Zoom/useZoom.ts +70 -0
- package/src/components/Zoom/utils.ts +55 -0
- package/src/components/index.ts +1 -0
- package/src/index.ts +1 -0
- package/src/utils/index.ts +3 -0
- package/src/utils/resourcesStatusURL.ts +166 -0
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +130 -0
- package/src/utils/useFullscreen/atoms.ts +3 -0
- package/src/utils/useFullscreen/index.ts +2 -0
- package/src/utils/useFullscreen/translatedLabels.ts +1 -0
- package/src/utils/useFullscreen/useFullscreen.ts +73 -0
- package/src/utils/useFullscreen/useFullscreenListener.ts +62 -0
- package/src/utils/useInfiniteScrollListing.ts +4 -1
- package/src/Graph/LineChart/BasicComponents/LoadingProgress.tsx +0 -46
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/TooltipAnchorPoint.tsx +0 -96
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/useTooltipAnchorPoint.ts +0 -107
- package/src/Graph/LineChart/Legend/InteractiveValue.tsx +0 -22
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +0 -99
- package/src/Typography/FluidTypography/useFluidResizeObserver.ts +0 -56
- package/src/components/Form/AccessRights/AccessRights.resource.ts +0 -45
- package/src/components/Form/AccessRights/AccessRightsForm.stories.tsx +0 -59
- package/src/components/Form/AccessRights/AccessRightsForm.styles.ts +0 -21
- package/src/components/Form/AccessRights/AccessRightsForm.tsx +0 -67
- package/src/components/Form/AccessRights/AccessRightsFormActions.tsx +0 -80
- package/src/components/Form/AccessRights/Input/AddAction.tsx +0 -31
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.stories.tsx +0 -54
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.tsx +0 -72
- package/src/components/Form/AccessRights/Input/ContactAccessRightsInput.styles.ts +0 -22
- package/src/components/Form/AccessRights/Input/ContactInputField.tsx +0 -105
- package/src/components/Form/AccessRights/Input/RoleInputField.tsx +0 -29
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.stories.tsx +0 -97
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.styles.ts +0 -71
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.tsx +0 -51
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.stories.tsx +0 -116
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.tsx +0 -118
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItemSkeleton.tsx +0 -26
- package/src/components/Form/AccessRights/List/ContactAccessRightsListSkeleton.tsx +0 -28
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.styles.ts +0 -18
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.tsx +0 -41
- package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +0 -54
- package/src/components/Form/AccessRights/common/GroupLabel.styles.ts +0 -18
- package/src/components/Form/AccessRights/common/GroupLabel.tsx +0 -15
- package/src/components/Form/AccessRights/common/Input.styles.ts +0 -48
- package/src/components/Form/AccessRights/common/RoleInputSelect.styles.ts +0 -11
- package/src/components/Form/AccessRights/common/RoleInputSelect.tsx +0 -57
- package/src/components/Form/AccessRights/index.ts +0 -3
- package/src/components/Form/AccessRights/useAccessRightsForm.test.tsx +0 -531
- package/src/components/Form/AccessRights/useAccessRightsForm.tsx +0 -282
- package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +0 -41
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.stories.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.styles.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/AccessRights.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/Actions.styles.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/Actions.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Actions/useActions.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/Item.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/List.styles.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/List.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/ListItemSkeleton.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/ListSkeleton.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/RemoveAccessRight.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/StateChip.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/List/useItem.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Provider.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/Stats/Stats.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/atoms.ts +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/common/RoleSelectField.styles.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/common/RoleSelectField.tsx +0 -0
- /package/src/components/Form/{AccessRightsV2 → AccessRights}/useAccessRightsInitValues.ts +0 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { equals, pluck, reject } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import { LegendScale } from '../Legend/models';
|
|
4
|
+
import { getValueByUnit } from '../common/utils';
|
|
5
|
+
|
|
6
|
+
import { ArcType } from './models';
|
|
7
|
+
|
|
8
|
+
interface ResponsivePieProps {
|
|
9
|
+
data: Array<ArcType>;
|
|
10
|
+
defaultInnerRadius: number;
|
|
11
|
+
height: number;
|
|
12
|
+
legendRef;
|
|
13
|
+
titleRef;
|
|
14
|
+
unit: 'percentage' | 'number';
|
|
15
|
+
width: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
interface ResponsivePieState {
|
|
19
|
+
half: number;
|
|
20
|
+
innerRadius: number;
|
|
21
|
+
isContainsExactlyOneNonZeroValue: boolean;
|
|
22
|
+
legendScale: LegendScale;
|
|
23
|
+
svgContainerSize: number;
|
|
24
|
+
svgSize: number;
|
|
25
|
+
svgWrapperWidth: number;
|
|
26
|
+
total: number;
|
|
27
|
+
}
|
|
28
|
+
export const useResponsivePie = ({
|
|
29
|
+
titleRef,
|
|
30
|
+
legendRef,
|
|
31
|
+
height,
|
|
32
|
+
width,
|
|
33
|
+
data,
|
|
34
|
+
unit,
|
|
35
|
+
defaultInnerRadius
|
|
36
|
+
}: ResponsivePieProps): ResponsivePieState => {
|
|
37
|
+
const heightOfTitle = titleRef.current?.offsetHeight || 0;
|
|
38
|
+
const widthOfLegend = legendRef.current?.offsetWidth || 0;
|
|
39
|
+
|
|
40
|
+
const horizontalGap = widthOfLegend > 0 ? 16 : 0;
|
|
41
|
+
const verticalGap = heightOfTitle > 0 ? 8 : 0;
|
|
42
|
+
|
|
43
|
+
const svgContainerSize = Math.min(
|
|
44
|
+
height - heightOfTitle - verticalGap,
|
|
45
|
+
width - widthOfLegend - horizontalGap
|
|
46
|
+
);
|
|
47
|
+
const svgWrapperWidth = svgContainerSize;
|
|
48
|
+
|
|
49
|
+
const outerRadius = Math.min(32, svgContainerSize / 6);
|
|
50
|
+
|
|
51
|
+
const svgSize = svgContainerSize - outerRadius;
|
|
52
|
+
|
|
53
|
+
const half = svgSize / 2;
|
|
54
|
+
|
|
55
|
+
const total = Math.floor(data.reduce((acc, { value }) => acc + value, 0));
|
|
56
|
+
|
|
57
|
+
const innerRadius = Math.min(defaultInnerRadius, svgSize / 5);
|
|
58
|
+
|
|
59
|
+
const legendScale = {
|
|
60
|
+
domain: data.map(({ value }) => getValueByUnit({ total, unit, value })),
|
|
61
|
+
range: pluck('color', data)
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const values = pluck('value', data);
|
|
65
|
+
|
|
66
|
+
const isContainsExactlyOneNonZeroValue = equals(
|
|
67
|
+
reject((value) => equals(value, 0), values).length,
|
|
68
|
+
1
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
return {
|
|
72
|
+
half,
|
|
73
|
+
innerRadius,
|
|
74
|
+
isContainsExactlyOneNonZeroValue,
|
|
75
|
+
legendScale,
|
|
76
|
+
svgContainerSize,
|
|
77
|
+
svgSize,
|
|
78
|
+
svgWrapperWidth,
|
|
79
|
+
total
|
|
80
|
+
};
|
|
81
|
+
};
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import dataLastWeek from '../LineChart/mockedData/lastWeek.json';
|
|
2
|
+
import {
|
|
3
|
+
criticalThresholds,
|
|
4
|
+
rangedThresholds,
|
|
5
|
+
successThresholds,
|
|
6
|
+
warningThresholds
|
|
7
|
+
} from '../common/testUtils';
|
|
8
|
+
|
|
9
|
+
import SingleBar from './SingleBar';
|
|
10
|
+
import { SingleBarProps } from './models';
|
|
11
|
+
|
|
12
|
+
const initialize = (
|
|
13
|
+
args: Omit<SingleBarProps, 'data' | 'labels' | 'baseColor'>
|
|
14
|
+
): void => {
|
|
15
|
+
cy.mount({
|
|
16
|
+
Component: (
|
|
17
|
+
<div style={{ height: '100vh', width: '100vw' }}>
|
|
18
|
+
<SingleBar
|
|
19
|
+
baseColor="#000"
|
|
20
|
+
data={dataLastWeek}
|
|
21
|
+
labels={{
|
|
22
|
+
critical: 'Critical',
|
|
23
|
+
warning: 'Warning'
|
|
24
|
+
}}
|
|
25
|
+
{...args}
|
|
26
|
+
/>
|
|
27
|
+
</div>
|
|
28
|
+
)
|
|
29
|
+
});
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
describe('Single bar', () => {
|
|
33
|
+
it('displays the single bar as success when corresponding thresholds are set', () => {
|
|
34
|
+
initialize({ thresholds: successThresholds });
|
|
35
|
+
|
|
36
|
+
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(136, 185, 34)');
|
|
37
|
+
cy.findByTestId('warning-line-0.5').should('be.visible');
|
|
38
|
+
cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
|
|
39
|
+
cy.findByTestId('critical-line-1.5').should('be.visible');
|
|
40
|
+
cy.findByTestId('critical-line-1.5-tooltip').should('be.visible');
|
|
41
|
+
|
|
42
|
+
cy.makeSnapshot();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('displays the single bar as warning when corresponding thresholds are set', () => {
|
|
46
|
+
initialize({ thresholds: warningThresholds });
|
|
47
|
+
|
|
48
|
+
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(253, 155, 39)');
|
|
49
|
+
cy.findByTestId('warning-line-0.4').should('be.visible');
|
|
50
|
+
cy.findByTestId('warning-line-0.4-tooltip').should('be.visible');
|
|
51
|
+
cy.findByTestId('critical-line-1.5').should('be.visible');
|
|
52
|
+
cy.findByTestId('critical-line-1.5-tooltip').should('be.visible');
|
|
53
|
+
|
|
54
|
+
cy.makeSnapshot();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it('displays the single bar as critical when corresponding thresholds are set', () => {
|
|
58
|
+
initialize({ thresholds: criticalThresholds });
|
|
59
|
+
|
|
60
|
+
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(255, 74, 74)');
|
|
61
|
+
cy.findByTestId('warning-line-0.2').should('be.visible');
|
|
62
|
+
cy.findByTestId('warning-line-0.2-tooltip').should('be.visible');
|
|
63
|
+
cy.findByTestId('critical-line-0.3').should('be.visible');
|
|
64
|
+
cy.findByTestId('critical-line-0.3-tooltip').should('be.visible');
|
|
65
|
+
|
|
66
|
+
cy.makeSnapshot();
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
it('displays ranged thresholds', () => {
|
|
70
|
+
initialize({ thresholds: rangedThresholds });
|
|
71
|
+
|
|
72
|
+
cy.findByTestId('warning-line-0.13').should('be.visible');
|
|
73
|
+
cy.findByTestId('warning-line-0.13-tooltip').should('be.visible');
|
|
74
|
+
cy.findByTestId('warning-line-0.5').should('be.visible');
|
|
75
|
+
cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
|
|
76
|
+
cy.findByTestId('critical-line-0.55').should('be.visible');
|
|
77
|
+
cy.findByTestId('critical-line-0.55-tooltip').should('be.visible');
|
|
78
|
+
cy.findByTestId('critical-line-0.65').should('be.visible');
|
|
79
|
+
cy.findByTestId('critical-line-0.65-tooltip').should('be.visible');
|
|
80
|
+
|
|
81
|
+
cy.makeSnapshot();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('displays the threshold tooltip when a threshold is hovered', () => {
|
|
85
|
+
initialize({ thresholds: successThresholds });
|
|
86
|
+
|
|
87
|
+
cy.findByTestId('warning-line-0.5-tooltip').trigger('mouseover');
|
|
88
|
+
|
|
89
|
+
cy.contains('Warning').should('be.visible');
|
|
90
|
+
|
|
91
|
+
cy.findByTestId('critical-line-1.5-tooltip').trigger('mouseover');
|
|
92
|
+
|
|
93
|
+
cy.contains('Critical').should('be.visible');
|
|
94
|
+
|
|
95
|
+
cy.makeSnapshot();
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('displays single bar as small when the props is set', () => {
|
|
99
|
+
initialize({ size: 'small', thresholds: successThresholds });
|
|
100
|
+
|
|
101
|
+
cy.findByTestId('warning-line-0.5-tooltip').should('be.visible');
|
|
102
|
+
|
|
103
|
+
cy.makeSnapshot();
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it('displays the value as raw when the prop is set', () => {
|
|
107
|
+
initialize({ displayAsRaw: true, thresholds: successThresholds });
|
|
108
|
+
|
|
109
|
+
cy.contains('0.40663333333 s').should('be.visible');
|
|
110
|
+
|
|
111
|
+
cy.makeSnapshot();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it('does not display the value when the prop is set', () => {
|
|
115
|
+
initialize({ showLabels: false, thresholds: successThresholds });
|
|
116
|
+
|
|
117
|
+
cy.contains('0.41 s').should('not.exist');
|
|
118
|
+
|
|
119
|
+
cy.makeSnapshot();
|
|
120
|
+
});
|
|
121
|
+
});
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import dataLastWeek from '../LineChart/mockedData/lastWeek.json';
|
|
2
|
+
import {
|
|
3
|
+
criticalThresholds,
|
|
4
|
+
rangedThresholds,
|
|
5
|
+
successThresholds,
|
|
6
|
+
warningThresholds
|
|
7
|
+
} from '../common/testUtils';
|
|
8
|
+
|
|
9
|
+
import { Text, Props } from './Text';
|
|
10
|
+
|
|
11
|
+
const initialize = (
|
|
12
|
+
args: Omit<Props, 'data' | 'labels' | 'baseColor'>
|
|
13
|
+
): void => {
|
|
14
|
+
cy.mount({
|
|
15
|
+
Component: (
|
|
16
|
+
<div style={{ height: '100vh', width: '100vw' }}>
|
|
17
|
+
<Text
|
|
18
|
+
baseColor="#000"
|
|
19
|
+
data={dataLastWeek}
|
|
20
|
+
labels={{
|
|
21
|
+
critical: 'Critical',
|
|
22
|
+
warning: 'Warning'
|
|
23
|
+
}}
|
|
24
|
+
{...args}
|
|
25
|
+
/>
|
|
26
|
+
</div>
|
|
27
|
+
)
|
|
28
|
+
});
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
describe('Text', () => {
|
|
32
|
+
it('displays the text as success when corresponding thresholds are set', () => {
|
|
33
|
+
initialize({ thresholds: successThresholds });
|
|
34
|
+
|
|
35
|
+
cy.contains('0.41 s').should('have.css', 'color', 'rgb(136, 185, 34)');
|
|
36
|
+
cy.contains('Warning: 0.5 s').should('be.visible');
|
|
37
|
+
cy.contains('Critical: 1.5 s').should('be.visible');
|
|
38
|
+
|
|
39
|
+
cy.makeSnapshot();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('displays the text as warning when corresponding thresholds are set', () => {
|
|
43
|
+
initialize({ thresholds: warningThresholds });
|
|
44
|
+
|
|
45
|
+
cy.contains('0.41 s').should('have.css', 'color', 'rgb(253, 155, 39)');
|
|
46
|
+
cy.contains('Warning: 0.4 s').should('be.visible');
|
|
47
|
+
cy.contains('Critical: 1.5 s').should('be.visible');
|
|
48
|
+
|
|
49
|
+
cy.makeSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('displays the text as critical when corresponding thresholds are set', () => {
|
|
53
|
+
initialize({ thresholds: criticalThresholds });
|
|
54
|
+
|
|
55
|
+
cy.contains('0.41 s').should('have.css', 'color', 'rgb(255, 74, 74)');
|
|
56
|
+
cy.contains('Warning: 0.2 s').should('be.visible');
|
|
57
|
+
cy.contains('Critical: 0.3 s').should('be.visible');
|
|
58
|
+
|
|
59
|
+
cy.makeSnapshot();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('displays ranged thresholds', () => {
|
|
63
|
+
initialize({ thresholds: rangedThresholds });
|
|
64
|
+
|
|
65
|
+
cy.contains('Warning: 0.13 s - 0.5 s').should('be.visible');
|
|
66
|
+
cy.contains('Critical: 0.55 s - 0.65 s').should('be.visible');
|
|
67
|
+
|
|
68
|
+
cy.makeSnapshot();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it('displays the value as raw when the prop is set', () => {
|
|
72
|
+
initialize({ displayAsRaw: true, thresholds: successThresholds });
|
|
73
|
+
|
|
74
|
+
cy.contains('0.40663333333 s').should('be.visible');
|
|
75
|
+
|
|
76
|
+
cy.makeSnapshot();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('does not display the text', () => {
|
|
80
|
+
initialize({ data: undefined, thresholds: successThresholds });
|
|
81
|
+
|
|
82
|
+
cy.contains('0.41 s').should('not.exist');
|
|
83
|
+
|
|
84
|
+
cy.makeSnapshot();
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('displays text with default values when the data is empty', () => {
|
|
88
|
+
initialize({
|
|
89
|
+
data: {
|
|
90
|
+
global: {},
|
|
91
|
+
metrics: [],
|
|
92
|
+
times: []
|
|
93
|
+
},
|
|
94
|
+
thresholds: successThresholds
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
cy.contains('0').should('be.visible');
|
|
98
|
+
|
|
99
|
+
cy.makeSnapshot();
|
|
100
|
+
});
|
|
101
|
+
});
|
|
@@ -1,6 +1,9 @@
|
|
|
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
|
+
},
|
|
4
7
|
graphText: {
|
|
5
8
|
alignItems: 'center',
|
|
6
9
|
display: 'flex',
|
|
@@ -9,9 +12,17 @@ export const useTextStyles = makeStyles()((theme) => ({
|
|
|
9
12
|
height: '100%',
|
|
10
13
|
justifyContent: 'center'
|
|
11
14
|
},
|
|
15
|
+
threshold: {
|
|
16
|
+
textAlign: 'center'
|
|
17
|
+
},
|
|
12
18
|
thresholds: {
|
|
13
19
|
display: 'flex',
|
|
14
20
|
flexDirection: 'row',
|
|
15
|
-
gap: theme.spacing(5)
|
|
21
|
+
gap: theme.spacing(5),
|
|
22
|
+
whiteSpace: 'nowrap',
|
|
23
|
+
width: '100%'
|
|
24
|
+
},
|
|
25
|
+
warning: {
|
|
26
|
+
color: theme.palette.warning.main
|
|
16
27
|
}
|
|
17
28
|
}));
|
package/src/Graph/Text/Text.tsx
CHANGED
|
@@ -2,6 +2,7 @@ import { isNil } from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
import { Typography, useTheme } from '@mui/material';
|
|
4
4
|
|
|
5
|
+
import FluidTypography from '../../Typography/FluidTypography';
|
|
5
6
|
import { LineChartData, Thresholds } from '../common/models';
|
|
6
7
|
import {
|
|
7
8
|
formatMetricValueWithUnit,
|
|
@@ -11,7 +12,7 @@ import { getColorFromDataAndTresholds } from '../common/utils';
|
|
|
11
12
|
|
|
12
13
|
import { useTextStyles } from './Text.styles';
|
|
13
14
|
|
|
14
|
-
interface Props {
|
|
15
|
+
export interface Props {
|
|
15
16
|
baseColor?: string;
|
|
16
17
|
data?: LineChartData;
|
|
17
18
|
displayAsRaw?: boolean;
|
|
@@ -30,7 +31,7 @@ export const Text = ({
|
|
|
30
31
|
baseColor
|
|
31
32
|
}: Props): JSX.Element | null => {
|
|
32
33
|
const theme = useTheme();
|
|
33
|
-
const { classes } = useTextStyles();
|
|
34
|
+
const { classes, cx } = useTextStyles();
|
|
34
35
|
|
|
35
36
|
if (isNil(data)) {
|
|
36
37
|
return null;
|
|
@@ -74,16 +75,20 @@ export const Text = ({
|
|
|
74
75
|
</Typography>
|
|
75
76
|
{thresholds.enabled && (
|
|
76
77
|
<div className={classes.thresholds}>
|
|
77
|
-
<
|
|
78
|
-
{
|
|
79
|
-
|
|
80
|
-
{
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
{
|
|
86
|
-
|
|
78
|
+
<FluidTypography
|
|
79
|
+
containerClassName={cx(classes.threshold, classes.warning)}
|
|
80
|
+
max="30px"
|
|
81
|
+
pref={14}
|
|
82
|
+
text={`${labels.warning}: ${warningThresholdLabels.join(' - ')}`}
|
|
83
|
+
variant="h5"
|
|
84
|
+
/>
|
|
85
|
+
<FluidTypography
|
|
86
|
+
containerClassName={cx(classes.threshold, classes.critical)}
|
|
87
|
+
max="30px"
|
|
88
|
+
pref={14}
|
|
89
|
+
text={`${labels.critical}: ${criticalThresholdLabels.join(' - ')}`}
|
|
90
|
+
variant="h5"
|
|
91
|
+
/>
|
|
87
92
|
</div>
|
|
88
93
|
)}
|
|
89
94
|
</div>
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { HierarchyPointNode } from '@visx/hierarchy/lib/types';
|
|
4
|
+
import { Group } from '@visx/group';
|
|
5
|
+
import { gt, isNil, pluck } from 'ramda';
|
|
6
|
+
|
|
7
|
+
import { BaseProp, Node, TreeProps } from './models';
|
|
8
|
+
|
|
9
|
+
interface Props<TData> extends Pick<TreeProps<TData>, 'children'> {
|
|
10
|
+
descendants: Array<HierarchyPointNode<Node<TData>>>;
|
|
11
|
+
expandCollapseNode: (targetNode: Node<TData>) => void;
|
|
12
|
+
getExpanded: (d: Node<TData>) => Array<Node<TData>> | undefined;
|
|
13
|
+
nodeSize: {
|
|
14
|
+
height: number;
|
|
15
|
+
width: number;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const DescendantNodes = <TData extends BaseProp>({
|
|
20
|
+
descendants,
|
|
21
|
+
children,
|
|
22
|
+
expandCollapseNode,
|
|
23
|
+
getExpanded,
|
|
24
|
+
nodeSize
|
|
25
|
+
}: Props<TData>): Array<JSX.Element> => {
|
|
26
|
+
const [pressEventTimeStamp, setPressEventTimeStamp] = useState<number | null>(
|
|
27
|
+
null
|
|
28
|
+
);
|
|
29
|
+
|
|
30
|
+
const mouseDown = (e: MouseEvent): void => {
|
|
31
|
+
setPressEventTimeStamp(e.timeStamp);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const mouseUp =
|
|
35
|
+
(callback) =>
|
|
36
|
+
(e: MouseEvent): void => {
|
|
37
|
+
if (isNil(pressEventTimeStamp)) {
|
|
38
|
+
callback();
|
|
39
|
+
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const diffTimeStamp = e.timeStamp - pressEventTimeStamp;
|
|
44
|
+
|
|
45
|
+
if (gt(diffTimeStamp, 120)) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
callback();
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return descendants.map((node) => {
|
|
53
|
+
const top = node.x;
|
|
54
|
+
const left = node.y;
|
|
55
|
+
const ancestorIds = node
|
|
56
|
+
.ancestors()
|
|
57
|
+
.map((ancestor) => ancestor.data.data.id);
|
|
58
|
+
const descendantIds = node
|
|
59
|
+
.descendants()
|
|
60
|
+
.map((ancestor) => ancestor.data.data.id);
|
|
61
|
+
|
|
62
|
+
const key = `${node.data.data.id}-${node.data.data.name}-${ancestorIds.toString()}-${descendantIds.toString()}`;
|
|
63
|
+
|
|
64
|
+
return (
|
|
65
|
+
<Group key={key} left={left} top={top}>
|
|
66
|
+
<foreignObject
|
|
67
|
+
height={nodeSize.height}
|
|
68
|
+
style={{ userSelect: 'none' }}
|
|
69
|
+
width={nodeSize.width}
|
|
70
|
+
x={-nodeSize.width / 2}
|
|
71
|
+
y={-nodeSize.height / 2}
|
|
72
|
+
>
|
|
73
|
+
{children({
|
|
74
|
+
ancestors: pluck('data', node.ancestors()),
|
|
75
|
+
depth: node.depth,
|
|
76
|
+
expandCollapseNode,
|
|
77
|
+
isExpanded: !!getExpanded(node.data),
|
|
78
|
+
node: node.data,
|
|
79
|
+
nodeSize,
|
|
80
|
+
onMouseDown: mouseDown,
|
|
81
|
+
onMouseUp: mouseUp
|
|
82
|
+
})}
|
|
83
|
+
</foreignObject>
|
|
84
|
+
</Group>
|
|
85
|
+
);
|
|
86
|
+
});
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export default DescendantNodes;
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import {
|
|
2
|
+
LinkHorizontal,
|
|
3
|
+
LinkHorizontalStep,
|
|
4
|
+
LinkHorizontalLine
|
|
5
|
+
} from '@visx/shape';
|
|
6
|
+
import { HierarchyPointLink } from '@visx/hierarchy/lib/types';
|
|
7
|
+
import { always, cond, equals, T } from 'ramda';
|
|
8
|
+
|
|
9
|
+
import { useTheme } from '@mui/material';
|
|
10
|
+
|
|
11
|
+
import { TreeProps, Node, BaseProp } from './models';
|
|
12
|
+
|
|
13
|
+
interface Props<TData> extends Pick<TreeProps<TData>, 'treeLink'> {
|
|
14
|
+
links: Array<HierarchyPointLink<Node<TData>>>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const getLinkComponent = cond([
|
|
18
|
+
[equals('line'), always(LinkHorizontalLine)],
|
|
19
|
+
[equals('step'), always(LinkHorizontalStep)],
|
|
20
|
+
[T, always(LinkHorizontal)]
|
|
21
|
+
]);
|
|
22
|
+
|
|
23
|
+
const Links = <TData extends BaseProp>({
|
|
24
|
+
links,
|
|
25
|
+
treeLink
|
|
26
|
+
}: Props<TData>): Array<JSX.Element> => {
|
|
27
|
+
const theme = useTheme();
|
|
28
|
+
|
|
29
|
+
return links.map((link) => {
|
|
30
|
+
const ancestorIds = link.target
|
|
31
|
+
.ancestors()
|
|
32
|
+
.map((ancestor) => ancestor.data.data.id);
|
|
33
|
+
|
|
34
|
+
const descendantIds = link.target
|
|
35
|
+
.descendants()
|
|
36
|
+
.map((ancestor) => ancestor.data.data.id);
|
|
37
|
+
|
|
38
|
+
const LinkComponent = getLinkComponent(treeLink?.type);
|
|
39
|
+
|
|
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}`;
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<LinkComponent
|
|
44
|
+
data={link}
|
|
45
|
+
data-testid={`${link.source.data.data.id}_to_${link.target.data.data.id}`}
|
|
46
|
+
fill="none"
|
|
47
|
+
key={key}
|
|
48
|
+
stroke={
|
|
49
|
+
treeLink?.getStroke?.({
|
|
50
|
+
source: link.source.data.data,
|
|
51
|
+
target: link.target.data.data
|
|
52
|
+
}) || theme.palette.text.primary
|
|
53
|
+
}
|
|
54
|
+
strokeDasharray={
|
|
55
|
+
treeLink?.getStrokeDasharray?.({
|
|
56
|
+
source: link.source.data.data,
|
|
57
|
+
target: link.target.data.data
|
|
58
|
+
}) || '0'
|
|
59
|
+
}
|
|
60
|
+
strokeOpacity={
|
|
61
|
+
treeLink?.getStrokeOpacity?.({
|
|
62
|
+
source: link.source.data.data,
|
|
63
|
+
target: link.target.data.data
|
|
64
|
+
}) || 1
|
|
65
|
+
}
|
|
66
|
+
strokeWidth={
|
|
67
|
+
treeLink?.getStrokeWidth?.({
|
|
68
|
+
source: link.source.data.data,
|
|
69
|
+
target: link.target.data.data
|
|
70
|
+
}) || '2'
|
|
71
|
+
}
|
|
72
|
+
/>
|
|
73
|
+
);
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default Links;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { ParentSize } from '../..';
|
|
4
|
+
|
|
5
|
+
import { BaseProp, TreeProps } from './models';
|
|
6
|
+
import { Tree } from './Tree';
|
|
7
|
+
|
|
8
|
+
export const StandaloneTree = <TData extends BaseProp>({
|
|
9
|
+
tree,
|
|
10
|
+
...props
|
|
11
|
+
}: Omit<
|
|
12
|
+
TreeProps<TData>,
|
|
13
|
+
'containerHeight' | 'containerWidth'
|
|
14
|
+
>): JSX.Element => {
|
|
15
|
+
const [currentTree, setTree] = useState(tree);
|
|
16
|
+
|
|
17
|
+
return (
|
|
18
|
+
<ParentSize>
|
|
19
|
+
{({ width, height }) => (
|
|
20
|
+
<svg height={height} width={width}>
|
|
21
|
+
<Tree
|
|
22
|
+
{...props}
|
|
23
|
+
changeTree={setTree}
|
|
24
|
+
containerHeight={height}
|
|
25
|
+
containerWidth={width}
|
|
26
|
+
tree={currentTree}
|
|
27
|
+
/>
|
|
28
|
+
</svg>
|
|
29
|
+
)}
|
|
30
|
+
</ParentSize>
|
|
31
|
+
);
|
|
32
|
+
};
|