@centreon/ui 23.10.121 → 24.4.0
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 +64 -45
- package/public/mockServiceWorker.js +2 -2
- package/src/ActionsList/ActionsList.styles.ts +40 -71
- package/src/Button/Icon/index.stories.tsx +1 -1
- package/src/Button/Icon/index.tsx +2 -2
- package/src/Button/Save/StartIcon.tsx +3 -3
- package/src/Button/Save/index.tsx +9 -5
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup/index.tsx +2 -2
- package/src/Checkbox/fonts/roboto-bold-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-bold-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-bold-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-light-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-medium-webfont.woff2 +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.ttf +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.woff +0 -0
- package/src/Checkbox/fonts/roboto-regular-webfont.woff2 +0 -0
- package/src/Dashboard/Dashboard.styles.ts +6 -5
- package/src/Dashboard/Item.tsx +1 -1
- package/src/Dashboard/Layout.tsx +2 -2
- package/src/Dashboard/utils.ts +1 -1
- 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 +9 -2
- package/src/FallbackPage/FallbackPage.tsx +3 -3
- package/src/FileDropZone/index.tsx +3 -1
- package/src/Form/Form.cypress.spec.tsx +133 -0
- package/src/Form/Inputs/Grid.tsx +8 -4
- package/src/Form/Inputs/List/Content.tsx +62 -0
- package/src/Form/Inputs/List/List.styles.ts +29 -0
- package/src/Form/Inputs/List/List.tsx +58 -0
- package/src/Form/Inputs/List/useList.ts +81 -0
- package/src/Form/Inputs/Text.tsx +3 -1
- package/src/Form/Inputs/index.tsx +3 -1
- package/src/Form/Inputs/models.ts +23 -13
- package/src/Graph/BarStack/BarStack.cypress.spec.tsx +217 -0
- package/src/Graph/BarStack/BarStack.stories.tsx +125 -0
- package/src/Graph/BarStack/BarStack.styles.ts +66 -0
- package/src/Graph/BarStack/BarStack.tsx +14 -0
- package/src/Graph/BarStack/Graph.tsx +176 -0
- package/src/Graph/BarStack/GraphAndLegend.tsx +119 -0
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +114 -0
- package/src/Graph/BarStack/constants.ts +5 -0
- package/src/Graph/BarStack/index.ts +1 -0
- package/src/Graph/BarStack/models.ts +19 -0
- package/src/Graph/BarStack/useGraphAndLegend.ts +86 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +106 -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/HeatMap.styles.tsx +1 -0
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +39 -12
- package/src/Graph/HeatMap/model.ts +6 -1
- package/src/Graph/Legend/Legend.styles.ts +10 -0
- package/src/Graph/Legend/Legend.tsx +26 -0
- package/src/Graph/Legend/index.ts +1 -0
- package/src/Graph/Legend/models.ts +11 -0
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +2 -1
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +3 -4
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/ThresholdLine.tsx +3 -1
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +2 -2
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +3 -5
- package/src/Graph/LineChart/Header/index.tsx +3 -31
- package/src/Graph/LineChart/Icons/Downtime.tsx +3 -3
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +2 -2
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/useTickGraph.ts +9 -11
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +1 -1
- 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/ZoomPreview/index.tsx +2 -1
- 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 +85 -32
- package/src/Graph/LineChart/Legend/LegendContent.tsx +12 -6
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +66 -27
- package/src/Graph/LineChart/Legend/index.tsx +43 -46
- package/src/Graph/LineChart/Legend/models.ts +5 -0
- package/src/Graph/LineChart/Legend/useLegend.ts +12 -13
- package/src/Graph/LineChart/LineChart.cypress.spec.tsx +144 -0
- package/src/Graph/LineChart/LineChart.styles.ts +8 -0
- package/src/Graph/LineChart/LineChart.tsx +125 -123
- package/src/Graph/LineChart/LoadingSkeleton.tsx +2 -2
- package/src/Graph/LineChart/helpers/doc.ts +16 -13
- package/src/Graph/LineChart/helpers/index.ts +1 -1
- package/src/Graph/LineChart/index.stories.tsx +17 -2
- package/src/Graph/LineChart/index.tsx +6 -7
- package/src/Graph/LineChart/mockedData/curvesWithSameColor.json +252 -0
- 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/LineChart/useLineChartData.ts +68 -18
- 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 +245 -0
- package/src/Graph/PieChart/index.ts +1 -0
- package/src/Graph/PieChart/models.ts +20 -0
- package/src/Graph/PieChart/useResponsivePie.ts +81 -0
- package/src/Graph/SingleBar/SingleBar.cypress.spec.tsx +121 -0
- package/src/Graph/SingleBar/Thresholds.tsx +2 -2
- package/src/Graph/Text/Text.cypress.spec.tsx +101 -0
- package/src/Graph/Text/Text.stories.tsx +60 -4
- package/src/Graph/Text/Text.styles.ts +12 -1
- package/src/Graph/Text/Text.tsx +17 -12
- package/src/Graph/Tree/DescendantNodes.tsx +88 -0
- package/src/Graph/Tree/Links.tsx +64 -0
- package/src/Graph/Tree/StandaloneTree.tsx +32 -0
- package/src/Graph/Tree/Tree.cypress.spec.tsx +171 -0
- package/src/Graph/Tree/Tree.stories.tsx +144 -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 +52 -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 +53 -15
- package/src/Graph/common/utils.ts +69 -1
- package/src/Graph/index.ts +4 -0
- package/src/Icon/BaseIcon.tsx +32 -0
- package/src/Icon/DowntimeIcon.tsx +14 -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/Connected/Multi/index.test.tsx +22 -1
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +3 -2
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +35 -17
- 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/Multi/index.stories.tsx +19 -0
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +12 -7
- package/src/InputField/Select/Autocomplete/index.tsx +129 -116
- package/src/InputField/Select/IconPopover/index.tsx +3 -3
- package/src/InputField/Select/index.tsx +15 -2
- package/src/InputField/Text/index.tsx +53 -46
- package/src/Listing/ActionBar/index.tsx +11 -10
- package/src/Listing/Cell/DataCell.styles.ts +3 -0
- package/src/Listing/Cell/DataCell.tsx +23 -5
- package/src/Listing/Header/ListingHeader.tsx +1 -1
- package/src/Listing/Listing.cypress.spec.tsx +218 -33
- package/src/Listing/Listing.styles.ts +4 -7
- package/src/Listing/Row/Row.tsx +7 -3
- package/src/Listing/index.stories.tsx +39 -5
- package/src/Listing/index.test.tsx +1 -1
- package/src/Listing/index.tsx +207 -149
- package/src/Listing/models.ts +1 -0
- package/src/Listing/useStyleTable.ts +1 -0
- package/src/Module/LicensedModule/LicenseCheck/index.tsx +24 -9
- package/src/Module/LicensedModule/index.tsx +7 -1
- package/src/Module/Module.cypress.spec.tsx +129 -0
- package/src/Module/index.tsx +2 -4
- package/src/Panel/index.tsx +1 -1
- package/src/PopoverMenu/index.tsx +9 -8
- package/src/RichTextEditor/ContentEditable.tsx +195 -195
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +100 -52
- package/src/RichTextEditor/RichTextEditor.tsx +21 -4
- package/src/RichTextEditor/plugins/ToolbarPlugin/AlignPicker.tsx +21 -20
- package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +35 -77
- package/src/RichTextEditor/plugins/ToolbarPlugin/FormatButtons.tsx +29 -83
- package/src/RichTextEditor/plugins/ToolbarPlugin/LinkButton.tsx +106 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/ListButton.tsx +155 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +23 -39
- package/src/RichTextEditor/plugins/ToolbarPlugin/ToolbarPlugin.styles.ts +24 -14
- package/src/RichTextEditor/plugins/ToolbarPlugin/UndoRedoButtons.tsx +6 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +5 -10
- package/src/RichTextEditor/translatedLabels.ts +3 -0
- package/src/SortableItems/index.tsx +2 -7
- package/src/StoryBookThemeProvider/index.tsx +35 -36
- package/src/ThemeProvider/index.tsx +39 -12
- package/src/ThemeProvider/palettes.ts +15 -12
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +6 -7
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +10 -6
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -2
- package/src/TimePeriods/DateTimePickerInput.tsx +59 -19
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +12 -9
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +9 -33
- package/src/TimePeriods/helpers/index.ts +1 -1
- package/src/TimePeriods/index.stories.tsx +12 -4
- package/src/TimePeriods/index.tsx +2 -2
- package/src/TopCounterElements/TopCounterLayout.tsx +3 -0
- package/src/TopCounterElements/useCloseOnLegacyPage.tsx +42 -0
- 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/Typography/Subtitle.tsx +55 -0
- package/src/api/QueryProvider.tsx +1 -1
- package/src/api/TestQueryProvider.tsx +1 -1
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +7 -1
- package/src/api/buildListingEndpoint/models.ts +3 -1
- package/src/api/customFetch.ts +12 -3
- package/src/api/index.ts +3 -3
- package/src/api/useFetchQuery/index.ts +49 -28
- 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 +65 -20
- package/src/components/Button/Icon/IconButton.tsx +6 -2
- 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/DataListing.tsx +6 -0
- package/src/components/DataTable/DataTable.cypress.spec.tsx +174 -0
- package/src/components/DataTable/DataTable.stories.tsx +40 -0
- package/src/components/DataTable/DataTable.styles.ts +3 -0
- package/src/components/DataTable/DataTable.tsx +3 -3
- package/src/components/DataTable/Item/DataTableItem.styles.ts +7 -2
- package/src/components/DataTable/Item/DataTableItem.tsx +4 -60
- package/src/components/DataTable/index.ts +3 -1
- package/src/components/Form/AccessRights/AccessRights.cypress.spec.tsx +373 -0
- package/src/components/Form/AccessRights/AccessRights.stories.tsx +119 -0
- package/src/components/Form/AccessRights/AccessRights.styles.ts +10 -0
- package/src/components/Form/AccessRights/AccessRights.tsx +60 -0
- package/src/components/Form/AccessRights/Actions/Actions.styles.ts +14 -0
- package/src/components/Form/AccessRights/Actions/Actions.tsx +81 -0
- package/src/components/Form/AccessRights/Actions/useActions.ts +79 -0
- package/src/components/Form/AccessRights/List/Item.tsx +90 -0
- package/src/components/Form/AccessRights/List/List.styles.tsx +45 -0
- package/src/components/Form/AccessRights/List/List.tsx +52 -0
- package/src/components/Form/AccessRights/List/ListItemSkeleton.tsx +18 -0
- package/src/components/Form/AccessRights/List/ListSkeleton.tsx +22 -0
- package/src/components/Form/AccessRights/List/RemoveAccessRight.tsx +38 -0
- package/src/components/Form/AccessRights/List/StateChip.tsx +28 -0
- package/src/components/Form/AccessRights/List/useItem.ts +64 -0
- package/src/components/Form/AccessRights/Provider.tsx +15 -0
- package/src/components/Form/AccessRights/ShareInput/ContactSwitch.tsx +50 -0
- package/src/components/Form/AccessRights/ShareInput/ShareInput.styles.ts +17 -0
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +78 -0
- package/src/components/Form/AccessRights/ShareInput/useShareInput.tsx +113 -0
- package/src/components/Form/AccessRights/Stats/Stats.tsx +36 -0
- package/src/components/Form/AccessRights/atoms.ts +97 -0
- package/src/components/Form/AccessRights/common/RoleSelectField.styles.tsx +7 -0
- package/src/components/Form/AccessRights/common/RoleSelectField.tsx +45 -0
- package/src/components/Form/AccessRights/models.ts +55 -0
- package/src/components/Form/AccessRights/storiesData.ts +222 -0
- package/src/components/Form/AccessRights/useAccessRightsInitValues.ts +51 -0
- package/src/components/Form/Dashboard/DashboardDuplicationForm.tsx +85 -0
- package/src/components/Form/Dashboard/DashboardForm.tsx +15 -12
- package/src/components/Form/Dashboard/index.ts +1 -0
- package/src/components/Form/FormActions.tsx +7 -2
- package/src/components/Form/index.ts +2 -1
- 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/Layout/PageLayout/PageLayout.tsx +1 -1
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +1 -0
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +5 -1
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +76 -0
- package/src/components/Layout/PageLayout/index.ts +3 -1
- package/src/components/Layout/PageLayout.cypress.spec.tsx +66 -0
- package/src/components/List/Item/ListItem.styles.ts +6 -0
- package/src/components/List/Item/ListItem.tsx +6 -4
- package/src/components/List/Item/Text.tsx +5 -3
- package/src/components/Menu/Button/MenuButton.tsx +4 -2
- package/src/components/Menu/MenuItem.tsx +5 -3
- package/src/components/Menu/MenuItems.tsx +4 -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 +10 -2
- package/src/components/Modal/ModalActions.tsx +4 -2
- 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 +127 -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 +61 -0
- package/src/components/Zoom/ZoomContent.tsx +167 -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/fonts/roboto-bold-webfont.ttf +0 -0
- package/src/fonts/roboto-bold-webfont.woff +0 -0
- package/src/fonts/roboto-bold-webfont.woff2 +0 -0
- package/src/fonts/roboto-light-webfont.ttf +0 -0
- package/src/fonts/roboto-light-webfont.woff +0 -0
- package/src/fonts/roboto-light-webfont.woff2 +0 -0
- package/src/fonts/roboto-medium-webfont.ttf +0 -0
- package/src/fonts/roboto-medium-webfont.woff +0 -0
- package/src/fonts/roboto-medium-webfont.woff2 +0 -0
- package/src/fonts/roboto-regular-webfont.ttf +0 -0
- package/src/fonts/roboto-regular-webfont.woff +0 -0
- package/src/fonts/roboto-regular-webfont.woff2 +0 -0
- package/src/index.ts +6 -0
- package/src/queryParameters/url/index.ts +5 -1
- package/src/utils/index.ts +25 -22
- package/src/utils/useFullscreen/Fullscreen.cypress.spec.tsx +133 -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 +31 -8
- package/src/utils/{useLicenseExpirationWarning.cypress.spec.tsx → useLicenseExpirationWarning.test.tsx} +48 -37
- package/src/utils/useLicenseExpirationWarning.ts +18 -18
- package/src/utils/useLocale/index.ts +10 -0
- package/src/utils/useLocale/useLocale.cypress.spec.tsx +40 -0
- package/src/utils/useLocaleDateTimeFormat/index.ts +8 -2
- package/src/utils/usePluralizedTranslation.ts +21 -0
- package/src/@assets/icons/downtime.icon.svg +0 -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/Marker.tsx +0 -43
- 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 -52
- 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/screens/dashboard/DashboardsDetail.stories.tsx +0 -108
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +0 -281
- package/src/utils/useDateTimePickerAdapter.ts +0 -309
- /package/{public → src/Button}/fonts/roboto-bold-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-bold-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-bold-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-light-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-medium-webfont.woff2 +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.ttf +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.woff +0 -0
- /package/{public → src/Button}/fonts/roboto-regular-webfont.woff2 +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { memo, useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { equals, props } from 'ramda';
|
|
4
|
+
|
|
5
|
+
import { useGraphAndLegendStyles } from './BarStack.styles';
|
|
6
|
+
import Graph from './Graph';
|
|
7
|
+
import { gap, legendMaxHeight, legendMaxWidth } from './constants';
|
|
8
|
+
import { BarStackProps } from './models';
|
|
9
|
+
|
|
10
|
+
interface Props
|
|
11
|
+
extends Pick<
|
|
12
|
+
BarStackProps,
|
|
13
|
+
| 'data'
|
|
14
|
+
| 'displayValues'
|
|
15
|
+
| 'onSingleBarClick'
|
|
16
|
+
| 'unit'
|
|
17
|
+
| 'TooltipContent'
|
|
18
|
+
| 'tooltipProps'
|
|
19
|
+
> {
|
|
20
|
+
colorScale;
|
|
21
|
+
displayLegend: boolean;
|
|
22
|
+
height: number;
|
|
23
|
+
isVerticalBar: boolean;
|
|
24
|
+
legend: JSX.Element;
|
|
25
|
+
total: number;
|
|
26
|
+
width: number;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const GraphAndLegend = ({
|
|
30
|
+
isVerticalBar,
|
|
31
|
+
legend,
|
|
32
|
+
displayLegend,
|
|
33
|
+
height,
|
|
34
|
+
width,
|
|
35
|
+
colorScale,
|
|
36
|
+
total,
|
|
37
|
+
unit,
|
|
38
|
+
data,
|
|
39
|
+
displayValues,
|
|
40
|
+
onSingleBarClick,
|
|
41
|
+
tooltipProps,
|
|
42
|
+
TooltipContent
|
|
43
|
+
}: Props): JSX.Element => {
|
|
44
|
+
const { classes } = useGraphAndLegendStyles();
|
|
45
|
+
|
|
46
|
+
const isSmall = useMemo(
|
|
47
|
+
() =>
|
|
48
|
+
(!isVerticalBar && Math.floor(height) <= 80) ||
|
|
49
|
+
(isVerticalBar && Math.floor(width) <= 150),
|
|
50
|
+
[isVerticalBar, height, width]
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const mustDisplayLegend = useMemo(
|
|
54
|
+
() => displayLegend && !isSmall,
|
|
55
|
+
[isSmall, displayLegend]
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
const graphWidth = useMemo(
|
|
59
|
+
() =>
|
|
60
|
+
isVerticalBar ? width - (isSmall ? 0 : legendMaxWidth - gap) : width,
|
|
61
|
+
[width, isVerticalBar, isSmall]
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const graphHeight = useMemo(
|
|
65
|
+
() =>
|
|
66
|
+
isVerticalBar ? height : height - (isSmall ? 0 : legendMaxHeight - gap),
|
|
67
|
+
[height, isVerticalBar, isSmall]
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<div
|
|
72
|
+
className={classes.graphAndLegend}
|
|
73
|
+
data-display-legend={mustDisplayLegend}
|
|
74
|
+
data-is-vertical={isVerticalBar}
|
|
75
|
+
style={{ height }}
|
|
76
|
+
>
|
|
77
|
+
<Graph
|
|
78
|
+
TooltipContent={TooltipContent}
|
|
79
|
+
colorScale={colorScale}
|
|
80
|
+
data={data}
|
|
81
|
+
displayValues={displayValues}
|
|
82
|
+
height={graphHeight}
|
|
83
|
+
isVerticalBar={isVerticalBar}
|
|
84
|
+
tooltipProps={tooltipProps}
|
|
85
|
+
total={total}
|
|
86
|
+
unit={unit}
|
|
87
|
+
width={graphWidth}
|
|
88
|
+
onSingleBarClick={onSingleBarClick}
|
|
89
|
+
/>
|
|
90
|
+
{mustDisplayLegend && (
|
|
91
|
+
<div
|
|
92
|
+
className={classes.legend}
|
|
93
|
+
data-is-vertical={isVerticalBar}
|
|
94
|
+
data-testid="Legend"
|
|
95
|
+
>
|
|
96
|
+
{legend}
|
|
97
|
+
</div>
|
|
98
|
+
)}
|
|
99
|
+
</div>
|
|
100
|
+
);
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
const propsToMemoize = [
|
|
104
|
+
'width',
|
|
105
|
+
'height',
|
|
106
|
+
'isVerticalBar',
|
|
107
|
+
'colorScale',
|
|
108
|
+
'data',
|
|
109
|
+
'total',
|
|
110
|
+
'unit',
|
|
111
|
+
'displayValues',
|
|
112
|
+
'tooltipProps',
|
|
113
|
+
'displayLegend',
|
|
114
|
+
'legend'
|
|
115
|
+
];
|
|
116
|
+
|
|
117
|
+
export default memo(GraphAndLegend, (prevProps, nextProps) =>
|
|
118
|
+
equals(props(propsToMemoize, prevProps), props(propsToMemoize, nextProps))
|
|
119
|
+
);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import numeral from 'numeral';
|
|
4
|
+
import { equals } from 'ramda';
|
|
5
|
+
import { useTranslation } from 'react-i18next';
|
|
6
|
+
|
|
7
|
+
import { Typography } from '@mui/material';
|
|
8
|
+
|
|
9
|
+
import { Legend as LegendComponent } from '../Legend';
|
|
10
|
+
import { LegendProps } from '../Legend/models';
|
|
11
|
+
|
|
12
|
+
import { useStyles } from './BarStack.styles';
|
|
13
|
+
import GraphAndLegend from './GraphAndLegend';
|
|
14
|
+
import { gap, smallTitleHeight, titleHeight } from './constants';
|
|
15
|
+
import { BarStackProps } from './models';
|
|
16
|
+
import useResponsiveBarStack from './useResponsiveBarStack';
|
|
17
|
+
|
|
18
|
+
const DefaultLengd = ({ scale, direction }: LegendProps): JSX.Element => (
|
|
19
|
+
<LegendComponent direction={direction} scale={scale} />
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
const BarStack = ({
|
|
23
|
+
title,
|
|
24
|
+
data,
|
|
25
|
+
height,
|
|
26
|
+
width,
|
|
27
|
+
onSingleBarClick,
|
|
28
|
+
displayLegend = true,
|
|
29
|
+
TooltipContent,
|
|
30
|
+
Legend = DefaultLengd,
|
|
31
|
+
unit = 'number',
|
|
32
|
+
displayValues,
|
|
33
|
+
variant = 'vertical',
|
|
34
|
+
legendDirection,
|
|
35
|
+
tooltipProps = {}
|
|
36
|
+
}: BarStackProps & { height: number; width: number }): JSX.Element => {
|
|
37
|
+
const { classes, cx } = useStyles();
|
|
38
|
+
const { t } = useTranslation();
|
|
39
|
+
|
|
40
|
+
const {
|
|
41
|
+
total,
|
|
42
|
+
titleVariant,
|
|
43
|
+
legendScale,
|
|
44
|
+
isVerticalBar,
|
|
45
|
+
colorScale,
|
|
46
|
+
formattedLegendDirection
|
|
47
|
+
} = useResponsiveBarStack({
|
|
48
|
+
data,
|
|
49
|
+
height,
|
|
50
|
+
legendDirection,
|
|
51
|
+
unit,
|
|
52
|
+
variant,
|
|
53
|
+
width
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
const graphAndLegendHeight = useMemo(() => {
|
|
57
|
+
if (equals(titleVariant, 'xs')) {
|
|
58
|
+
return height - 2 * smallTitleHeight - gap;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (equals(titleVariant, 'sm')) {
|
|
62
|
+
return height - smallTitleHeight - gap;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return height - titleHeight - gap;
|
|
66
|
+
}, [titleVariant, height]);
|
|
67
|
+
|
|
68
|
+
return (
|
|
69
|
+
<div
|
|
70
|
+
className={classes.container}
|
|
71
|
+
data-has-title={!!title}
|
|
72
|
+
data-title-variant={titleVariant}
|
|
73
|
+
data-variant={variant}
|
|
74
|
+
>
|
|
75
|
+
{title && (
|
|
76
|
+
<Typography
|
|
77
|
+
className={cx(equals(titleVariant, 'md') && classes.clippedTitle)}
|
|
78
|
+
data-testid="Title"
|
|
79
|
+
fontWeight="bold"
|
|
80
|
+
textAlign="center"
|
|
81
|
+
variant={equals(titleVariant, 'md') ? 'h6' : 'body1'}
|
|
82
|
+
>
|
|
83
|
+
{`${numeral(total).format('0a')}`} {t(title)}
|
|
84
|
+
</Typography>
|
|
85
|
+
)}
|
|
86
|
+
<GraphAndLegend
|
|
87
|
+
TooltipContent={TooltipContent}
|
|
88
|
+
colorScale={colorScale}
|
|
89
|
+
data={data}
|
|
90
|
+
displayLegend={displayLegend}
|
|
91
|
+
displayValues={displayValues}
|
|
92
|
+
height={graphAndLegendHeight}
|
|
93
|
+
isVerticalBar={isVerticalBar}
|
|
94
|
+
legend={
|
|
95
|
+
<Legend
|
|
96
|
+
data={data}
|
|
97
|
+
direction={formattedLegendDirection}
|
|
98
|
+
scale={legendScale}
|
|
99
|
+
title={title}
|
|
100
|
+
total={total}
|
|
101
|
+
unit={unit}
|
|
102
|
+
/>
|
|
103
|
+
}
|
|
104
|
+
tooltipProps={tooltipProps}
|
|
105
|
+
total={total}
|
|
106
|
+
unit={unit}
|
|
107
|
+
width={width}
|
|
108
|
+
onSingleBarClick={onSingleBarClick}
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
);
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
export default BarStack;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as BarStack } from './BarStack';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export interface BarType {
|
|
2
|
+
color: string;
|
|
3
|
+
label: string;
|
|
4
|
+
value: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export type BarStackProps = {
|
|
8
|
+
Legend?: ({ scale, data, title, total, unit, direction }) => JSX.Element;
|
|
9
|
+
TooltipContent?: (barData) => JSX.Element | boolean | null;
|
|
10
|
+
data: Array<BarType>;
|
|
11
|
+
displayLegend?: boolean;
|
|
12
|
+
displayValues?: boolean;
|
|
13
|
+
legendDirection?: 'row' | 'column';
|
|
14
|
+
onSingleBarClick?: (barData) => void;
|
|
15
|
+
title?: string;
|
|
16
|
+
tooltipProps?: object;
|
|
17
|
+
unit?: 'percentage' | 'number';
|
|
18
|
+
variant?: 'vertical' | 'horizontal';
|
|
19
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { scaleBand, scaleLinear } from '@visx/scale';
|
|
4
|
+
import { pluck } from 'ramda';
|
|
5
|
+
|
|
6
|
+
import { BarType } from './models';
|
|
7
|
+
|
|
8
|
+
interface UseGraphandLegendProps {
|
|
9
|
+
data: Array<BarType>;
|
|
10
|
+
height: number;
|
|
11
|
+
isVerticalBar: boolean;
|
|
12
|
+
total: number;
|
|
13
|
+
width: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface UseGraphAndLegendState {
|
|
17
|
+
barStackData: Record<string, number>;
|
|
18
|
+
keys: Array<string>;
|
|
19
|
+
xScale;
|
|
20
|
+
yScale;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const useGraphAndLegend = ({
|
|
24
|
+
data,
|
|
25
|
+
isVerticalBar,
|
|
26
|
+
total,
|
|
27
|
+
width,
|
|
28
|
+
height
|
|
29
|
+
}: UseGraphandLegendProps): UseGraphAndLegendState => {
|
|
30
|
+
const dataWithNonEmptyValue = useMemo(
|
|
31
|
+
() => data.filter(({ value }) => value),
|
|
32
|
+
[data]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const keys = useMemo(
|
|
36
|
+
() => pluck('label', dataWithNonEmptyValue),
|
|
37
|
+
[dataWithNonEmptyValue]
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
const barStackData = useMemo(
|
|
41
|
+
() =>
|
|
42
|
+
dataWithNonEmptyValue.reduce((acc, { label, value }) => {
|
|
43
|
+
acc[label] = value;
|
|
44
|
+
|
|
45
|
+
return acc;
|
|
46
|
+
}, {}),
|
|
47
|
+
[dataWithNonEmptyValue]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const yScale = useMemo(
|
|
51
|
+
() =>
|
|
52
|
+
isVerticalBar
|
|
53
|
+
? scaleLinear({
|
|
54
|
+
domain: [0, total],
|
|
55
|
+
range: [height, 0]
|
|
56
|
+
})
|
|
57
|
+
: scaleBand({
|
|
58
|
+
domain: [0, 0],
|
|
59
|
+
padding: 0,
|
|
60
|
+
range: [height, 0]
|
|
61
|
+
}),
|
|
62
|
+
[isVerticalBar, total, height]
|
|
63
|
+
);
|
|
64
|
+
|
|
65
|
+
const xScale = useMemo(
|
|
66
|
+
() =>
|
|
67
|
+
isVerticalBar
|
|
68
|
+
? scaleBand({
|
|
69
|
+
domain: [0, 0],
|
|
70
|
+
padding: 0,
|
|
71
|
+
range: [0, width]
|
|
72
|
+
})
|
|
73
|
+
: scaleLinear({
|
|
74
|
+
domain: [0, total],
|
|
75
|
+
range: [0, width]
|
|
76
|
+
}),
|
|
77
|
+
[total, width, isVerticalBar]
|
|
78
|
+
);
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
barStackData,
|
|
82
|
+
keys,
|
|
83
|
+
xScale,
|
|
84
|
+
yScale
|
|
85
|
+
};
|
|
86
|
+
};
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
|
|
3
|
+
import { scaleOrdinal } from '@visx/scale';
|
|
4
|
+
import { equals, isNil, pluck } from 'ramda';
|
|
5
|
+
|
|
6
|
+
import { LegendScale } from '../Legend/models';
|
|
7
|
+
import { getValueByUnit } from '../common/utils';
|
|
8
|
+
|
|
9
|
+
import { BarType } from './models';
|
|
10
|
+
|
|
11
|
+
interface UseBarStackProps {
|
|
12
|
+
data: Array<BarType>;
|
|
13
|
+
height: number;
|
|
14
|
+
legendDirection?: 'column' | 'row';
|
|
15
|
+
unit?: 'percentage' | 'number';
|
|
16
|
+
variant?: 'vertical' | 'horizontal';
|
|
17
|
+
width: number;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface UseBarStackState {
|
|
21
|
+
colorScale;
|
|
22
|
+
formattedLegendDirection: 'column' | 'row';
|
|
23
|
+
isSmall: boolean;
|
|
24
|
+
isVerticalBar: boolean;
|
|
25
|
+
legendScale: LegendScale;
|
|
26
|
+
titleVariant: 'xs' | 'sm' | 'md';
|
|
27
|
+
total: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const useResponsiveBarStack = ({
|
|
31
|
+
data,
|
|
32
|
+
variant,
|
|
33
|
+
height,
|
|
34
|
+
width,
|
|
35
|
+
unit = 'number',
|
|
36
|
+
legendDirection
|
|
37
|
+
}: UseBarStackProps): UseBarStackState => {
|
|
38
|
+
const total = useMemo(
|
|
39
|
+
() => Math.floor(data.reduce((acc, { value }) => acc + value, 0)),
|
|
40
|
+
[data]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const isVerticalBar = useMemo(() => equals(variant, 'vertical'), [variant]);
|
|
44
|
+
|
|
45
|
+
const isSmall = useMemo(
|
|
46
|
+
() => Math.floor(height) < 90,
|
|
47
|
+
[isVerticalBar, height]
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const titleVariant = useMemo(() => {
|
|
51
|
+
if (width <= 105) {
|
|
52
|
+
return 'xs';
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
if (width <= 150 || isSmall) {
|
|
56
|
+
return 'sm';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return 'md';
|
|
60
|
+
}, [isSmall, width]);
|
|
61
|
+
|
|
62
|
+
const keys = useMemo(() => pluck('label', data), [data]);
|
|
63
|
+
|
|
64
|
+
const colorsRange = useMemo(() => pluck('color', data), [data]);
|
|
65
|
+
|
|
66
|
+
const colorScale = useMemo(
|
|
67
|
+
() =>
|
|
68
|
+
scaleOrdinal({
|
|
69
|
+
domain: keys,
|
|
70
|
+
range: colorsRange
|
|
71
|
+
}),
|
|
72
|
+
[keys, colorsRange]
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
const legendScale = useMemo(
|
|
76
|
+
() => ({
|
|
77
|
+
domain: data.map(({ value }) => getValueByUnit({ total, unit, value })),
|
|
78
|
+
range: colorsRange
|
|
79
|
+
}),
|
|
80
|
+
[data, colorsRange]
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const formattedLegendDirection = useMemo(() => {
|
|
84
|
+
if (!isNil(legendDirection)) {
|
|
85
|
+
return legendDirection;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (equals(variant, 'horizontal')) {
|
|
89
|
+
return 'row';
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return 'column';
|
|
93
|
+
}, [legendDirection, variant]);
|
|
94
|
+
|
|
95
|
+
return {
|
|
96
|
+
colorScale,
|
|
97
|
+
formattedLegendDirection,
|
|
98
|
+
isSmall,
|
|
99
|
+
isVerticalBar,
|
|
100
|
+
legendScale,
|
|
101
|
+
titleVariant,
|
|
102
|
+
total
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
export default useResponsiveBarStack;
|
|
@@ -0,0 +1,102 @@
|
|
|
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 { Props, Gauge } from './Gauge';
|
|
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
|
+
<Gauge
|
|
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('Gauge', () => {
|
|
32
|
+
it('does not display the gauge when there is no data', () => {
|
|
33
|
+
initialize({ data: undefined, thresholds: successThresholds });
|
|
34
|
+
|
|
35
|
+
cy.contains('0.41 s').should('not.exist');
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it('displays the gauge as success when corresponding thresholds are set', () => {
|
|
39
|
+
initialize({ thresholds: successThresholds });
|
|
40
|
+
|
|
41
|
+
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(136, 185, 34)');
|
|
42
|
+
cy.findByTestId('1.1500000000000001-arc').should('be.visible');
|
|
43
|
+
cy.findByTestId('0.15000000000000013-arc').should('be.visible');
|
|
44
|
+
|
|
45
|
+
cy.makeSnapshot();
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('displays the gauge as warning when corresponding thresholds are set', () => {
|
|
49
|
+
initialize({ thresholds: warningThresholds });
|
|
50
|
+
|
|
51
|
+
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(253, 155, 39)');
|
|
52
|
+
cy.findByTestId('1.25-arc').should('be.visible');
|
|
53
|
+
cy.findByTestId('0.15000000000000013-arc').should('be.visible');
|
|
54
|
+
|
|
55
|
+
cy.makeSnapshot();
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('displays the gauge as critical when corresponding thresholds are set', () => {
|
|
59
|
+
initialize({ thresholds: criticalThresholds });
|
|
60
|
+
|
|
61
|
+
cy.contains('0.41 s').should('have.css', 'fill', 'rgb(255, 74, 74)');
|
|
62
|
+
cy.findByTestId('0.6399999999999999-arc').should('be.visible');
|
|
63
|
+
cy.findByTestId('0.54-arc').should('be.visible');
|
|
64
|
+
|
|
65
|
+
cy.makeSnapshot();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it('displays ranged thresholds', () => {
|
|
69
|
+
initialize({ thresholds: rangedThresholds });
|
|
70
|
+
|
|
71
|
+
cy.findByTestId('0.37-arc').should('be.visible');
|
|
72
|
+
cy.findByTestId('0.09999999999999998-arc').should('be.visible');
|
|
73
|
+
|
|
74
|
+
cy.makeSnapshot();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('displays the threshold tooltip when a threshold is hovered', () => {
|
|
78
|
+
initialize({ thresholds: successThresholds });
|
|
79
|
+
|
|
80
|
+
cy.findByTestId('1.1500000000000001-arc').trigger('mouseover', {
|
|
81
|
+
force: true
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
cy.contains('Warning').should('be.visible');
|
|
85
|
+
|
|
86
|
+
cy.findByTestId('0.15000000000000013-arc').trigger('mouseover', {
|
|
87
|
+
force: true
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
cy.contains('Critical').should('be.visible');
|
|
91
|
+
|
|
92
|
+
cy.makeSnapshot();
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it('displays the value as raw when the prop is set', () => {
|
|
96
|
+
initialize({ displayAsRaw: true, thresholds: successThresholds });
|
|
97
|
+
|
|
98
|
+
cy.contains('0.40663333333 s').should('be.visible');
|
|
99
|
+
|
|
100
|
+
cy.makeSnapshot();
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -0,0 +1,145 @@
|
|
|
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
|
+
});
|