@centreon/ui 23.10.121 → 24.4.0-MON-191815.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 +63 -44
- 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/ConnectedAutocomplete.tsx +2 -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 +34 -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 +36 -18
- 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
|
@@ -31,7 +31,9 @@ import {
|
|
|
31
31
|
last,
|
|
32
32
|
cond,
|
|
33
33
|
always,
|
|
34
|
-
T
|
|
34
|
+
T,
|
|
35
|
+
includes,
|
|
36
|
+
split
|
|
35
37
|
} from 'ramda';
|
|
36
38
|
|
|
37
39
|
import { margin } from '../../LineChart/common';
|
|
@@ -179,7 +181,7 @@ const getMetricValuesForUnit = ({
|
|
|
179
181
|
) as Array<number>;
|
|
180
182
|
|
|
181
183
|
return pipe(
|
|
182
|
-
filter(propEq(
|
|
184
|
+
filter(propEq(unit, 'unit')) as (line) => Array<Line>,
|
|
183
185
|
map(prop('metric_id')),
|
|
184
186
|
map(getTimeSeriesValuesForMetric),
|
|
185
187
|
flatten,
|
|
@@ -203,7 +205,18 @@ const getLineForMetric = ({
|
|
|
203
205
|
lines,
|
|
204
206
|
metric_id
|
|
205
207
|
}: LineForMetricProps): Line | undefined =>
|
|
206
|
-
find(propEq(
|
|
208
|
+
find(propEq(metric_id, 'metric_id'), lines);
|
|
209
|
+
|
|
210
|
+
interface LinesForMetricsProps {
|
|
211
|
+
lines: Array<Line>;
|
|
212
|
+
metricIds: Array<number>;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
export const getLinesForMetrics = ({
|
|
216
|
+
lines,
|
|
217
|
+
metricIds
|
|
218
|
+
}: LinesForMetricsProps): Array<Line> =>
|
|
219
|
+
filter(({ metric_id }) => metricIds.includes(metric_id), lines);
|
|
207
220
|
|
|
208
221
|
interface LinesTimeSeries {
|
|
209
222
|
lines: Array<Line>;
|
|
@@ -275,7 +288,7 @@ interface HasStackedLines {
|
|
|
275
288
|
}
|
|
276
289
|
|
|
277
290
|
const hasUnitStackedLines = ({ lines, unit }: HasStackedLines): boolean =>
|
|
278
|
-
pipe(getSortedStackedLines, any(propEq(
|
|
291
|
+
pipe(getSortedStackedLines, any(propEq(unit, 'unit')))(lines);
|
|
279
292
|
|
|
280
293
|
const getTimeSeriesForLines = ({
|
|
281
294
|
lines,
|
|
@@ -476,15 +489,7 @@ const registerMsUnitToNumeral = (): null => {
|
|
|
476
489
|
|
|
477
490
|
registerMsUnitToNumeral();
|
|
478
491
|
|
|
479
|
-
const
|
|
480
|
-
value,
|
|
481
|
-
unit,
|
|
482
|
-
base = 1000
|
|
483
|
-
}: FormatMetricValueProps): string | null => {
|
|
484
|
-
if (isNil(value)) {
|
|
485
|
-
return null;
|
|
486
|
-
}
|
|
487
|
-
|
|
492
|
+
const getBase1024 = ({ unit, base }): boolean => {
|
|
488
493
|
const base2Units = [
|
|
489
494
|
'B',
|
|
490
495
|
'bytes',
|
|
@@ -497,7 +502,19 @@ const formatMetricValue = ({
|
|
|
497
502
|
'b'
|
|
498
503
|
];
|
|
499
504
|
|
|
500
|
-
|
|
505
|
+
return base2Units.includes(unit) || Number(base) === 1024;
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
const formatMetricValue = ({
|
|
509
|
+
value,
|
|
510
|
+
unit,
|
|
511
|
+
base = 1000
|
|
512
|
+
}: FormatMetricValueProps): string | null => {
|
|
513
|
+
if (isNil(value)) {
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
const base1024 = getBase1024({ base, unit });
|
|
501
518
|
|
|
502
519
|
const formatSuffix = cond([
|
|
503
520
|
[equals('ms'), always(' ms')],
|
|
@@ -525,6 +542,8 @@ const formatMetricValueWithUnit = ({
|
|
|
525
542
|
return null;
|
|
526
543
|
}
|
|
527
544
|
|
|
545
|
+
const base1024 = getBase1024({ base, unit });
|
|
546
|
+
|
|
528
547
|
if (isRaw) {
|
|
529
548
|
const unitText = equals('%', unit) ? unit : ` ${unit}`;
|
|
530
549
|
|
|
@@ -537,7 +556,9 @@ const formatMetricValueWithUnit = ({
|
|
|
537
556
|
|
|
538
557
|
const formattedMetricValue = formatMetricValue({ base, unit, value });
|
|
539
558
|
|
|
540
|
-
return
|
|
559
|
+
return base1024 || !unit || equals(unit, 'ms')
|
|
560
|
+
? formattedMetricValue
|
|
561
|
+
: `${formattedMetricValue} ${unit}`;
|
|
541
562
|
};
|
|
542
563
|
|
|
543
564
|
const getStackedYScale = ({
|
|
@@ -593,6 +614,23 @@ const getMetricWithLatestData = (
|
|
|
593
614
|
};
|
|
594
615
|
};
|
|
595
616
|
|
|
617
|
+
interface FormatMetricNameProps {
|
|
618
|
+
legend: string | null;
|
|
619
|
+
name: string;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export const formatMetricName = ({
|
|
623
|
+
legend,
|
|
624
|
+
name
|
|
625
|
+
}: FormatMetricNameProps): string => {
|
|
626
|
+
const legendName = legend || name;
|
|
627
|
+
const metricName = includes('#', legendName)
|
|
628
|
+
? split('#')(legendName)[1]
|
|
629
|
+
: legendName;
|
|
630
|
+
|
|
631
|
+
return metricName;
|
|
632
|
+
};
|
|
633
|
+
|
|
596
634
|
export {
|
|
597
635
|
getTimeSeries,
|
|
598
636
|
getLineData,
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import numeral from 'numeral';
|
|
1
2
|
import {
|
|
2
3
|
T,
|
|
3
4
|
always,
|
|
@@ -6,13 +7,14 @@ import {
|
|
|
6
7
|
gt,
|
|
7
8
|
gte,
|
|
8
9
|
head,
|
|
10
|
+
last,
|
|
9
11
|
length,
|
|
10
12
|
lt,
|
|
11
13
|
lte,
|
|
12
14
|
pluck
|
|
13
15
|
} from 'ramda';
|
|
14
16
|
|
|
15
|
-
import { Theme } from '@mui/material';
|
|
17
|
+
import { Theme, darken, getLuminance, lighten } from '@mui/material';
|
|
16
18
|
|
|
17
19
|
import { Thresholds } from './models';
|
|
18
20
|
|
|
@@ -73,3 +75,69 @@ export const getColorFromDataAndTresholds = ({
|
|
|
73
75
|
[T, always(theme.palette.error.main)]
|
|
74
76
|
])(data);
|
|
75
77
|
};
|
|
78
|
+
|
|
79
|
+
interface ValueByUnitProps {
|
|
80
|
+
total: number;
|
|
81
|
+
unit: 'percentage' | 'number';
|
|
82
|
+
value: number;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const getValueByUnit = ({
|
|
86
|
+
unit,
|
|
87
|
+
value,
|
|
88
|
+
total
|
|
89
|
+
}: ValueByUnitProps): string => {
|
|
90
|
+
if (equals(unit, 'number')) {
|
|
91
|
+
return numeral(value).format('0a').toUpperCase();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return `${((value * 100) / total).toFixed(1)}%`;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
interface NormalizeLevelProps {
|
|
98
|
+
factor: number;
|
|
99
|
+
level: number;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const normalizeLevel = ({ level, factor }: NormalizeLevelProps): number =>
|
|
103
|
+
(level * factor) / 10;
|
|
104
|
+
|
|
105
|
+
interface EmphasizeCurveColorProps {
|
|
106
|
+
color: string;
|
|
107
|
+
index: number;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export const emphasizeCurveColor = ({
|
|
111
|
+
color,
|
|
112
|
+
index
|
|
113
|
+
}: EmphasizeCurveColorProps): string => {
|
|
114
|
+
const totalLevels = 5;
|
|
115
|
+
const levels = [...Array(totalLevels).keys()];
|
|
116
|
+
const factor = 10 / totalLevels;
|
|
117
|
+
|
|
118
|
+
if (gte(getLuminance(color), 0.5)) {
|
|
119
|
+
if (gte(index, totalLevels * 2)) {
|
|
120
|
+
return darken(color, normalizeLevel({ factor, level: last(levels) }));
|
|
121
|
+
}
|
|
122
|
+
if (gte(index, totalLevels)) {
|
|
123
|
+
return darken(
|
|
124
|
+
color,
|
|
125
|
+
normalizeLevel({ factor, level: levels[totalLevels + 1 - index] })
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return lighten(color, normalizeLevel({ factor, level: levels[index] }));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (gte(index, totalLevels * 2)) {
|
|
133
|
+
return lighten(color, normalizeLevel({ factor, level: last(levels) }));
|
|
134
|
+
}
|
|
135
|
+
if (gte(index, totalLevels)) {
|
|
136
|
+
return lighten(
|
|
137
|
+
color,
|
|
138
|
+
normalizeLevel({ factor, level: levels[totalLevels + 1 - index] })
|
|
139
|
+
);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return darken(color, normalizeLevel({ factor, level: levels[index] }));
|
|
143
|
+
};
|
package/src/Graph/index.ts
CHANGED
|
@@ -2,4 +2,8 @@ export { default as LineChart } from './LineChart';
|
|
|
2
2
|
export { Gauge } from './Gauge';
|
|
3
3
|
export { SingleBar } from './SingleBar';
|
|
4
4
|
export { Text as GraphText } from './Text';
|
|
5
|
+
|
|
5
6
|
export { HeatMap } from './HeatMap';
|
|
7
|
+
export { BarStack } from './BarStack';
|
|
8
|
+
export { PieChart } from './PieChart';
|
|
9
|
+
export * from './Tree';
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { has } from 'ramda';
|
|
2
|
+
|
|
3
|
+
import { SvgIcon, SvgIconProps, SvgIconTypeMap } from '@mui/material';
|
|
4
|
+
import { OverridableComponent } from '@mui/material/OverridableComponent';
|
|
5
|
+
|
|
6
|
+
interface Props extends SvgIconProps {
|
|
7
|
+
Icon: JSX.Element | OverridableComponent<SvgIconTypeMap>;
|
|
8
|
+
dataTestId?: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const BaseIcon = ({ Icon, dataTestId, ...props }: Props): JSX.Element => {
|
|
12
|
+
if (!has('key', Icon)) {
|
|
13
|
+
const Component = Icon as (props: SvgIconProps) => JSX.Element;
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<SvgIcon
|
|
17
|
+
data-testid={dataTestId || (Icon as () => JSX.Element).name}
|
|
18
|
+
{...props}
|
|
19
|
+
>
|
|
20
|
+
<Component />
|
|
21
|
+
</SvgIcon>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<SvgIcon data-testid={dataTestId} {...props}>
|
|
27
|
+
{Icon as JSX.Element}
|
|
28
|
+
</SvgIcon>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default BaseIcon;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { SvgIconProps } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
import BaseIcon from './BaseIcon';
|
|
4
|
+
|
|
5
|
+
const icon = (
|
|
6
|
+
<g>
|
|
7
|
+
<path d="M7.6215 5.243C7.9422 5.243 8.2557 5.1479 8.52236 4.96972C8.78901 4.79155 8.99685 4.53831 9.11958 4.24202C9.2423 3.94573 9.27441 3.6197 9.21185 3.30516C9.14928 2.99062 8.99485 2.70169 8.76808 2.47492C8.54131 2.24815 8.25238 2.09372 7.93784 2.03116C7.6233 1.96859 7.29727 2.0007 7.00098 2.12343C6.70469 2.24616 6.45145 2.45399 6.27327 2.72065C6.0951 2.9873 6 3.30079 6 3.6215C6 4.05155 6.17084 4.46398 6.47493 4.76807C6.77902 5.07216 7.19145 5.243 7.6215 5.243Z" />
|
|
8
|
+
<path d="M17.8192 12.3739C17.743 12.1905 17.6143 12.0338 17.4492 11.9235C17.2841 11.8132 17.0901 11.7541 16.8915 11.7538C16.8915 11.7538 14.9107 11.4903 14.3232 11.8736C14.0659 12.083 13.8556 12.3442 13.706 12.6403L10.396 12.1161C10.142 11.2785 9.05429 8.10738 9.05429 8.10738L8.24354 6.81076C8.09994 6.57117 7.89855 6.37142 7.6578 6.22979C7.41705 6.08815 7.14463 6.00914 6.86545 6C6.64749 6.01064 6.43062 6.03754 6.21666 6.0805L2 7.86971V11.68H2.23096L4.36037 12.0174L2.81746 19.7866H4.52041L5.979 13.3006L7.68196 14.9221V19.7866H9.30345V13.706L8.16304 12.6183L13.3649 13.4415L10.4094 19.9725L20.928 19.8671L17.8192 12.3739ZM8.03845 9.87167C8.03845 9.87167 8.59142 11.1712 8.88179 11.8736L7.67525 11.682L8.03845 9.87167ZM3.62437 11.0408V8.921L5.08295 8.35368L4.52137 11.1827L3.62437 11.0408Z" />
|
|
9
|
+
</g>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
export const DowntimeIcon = (props: SvgIconProps): JSX.Element => (
|
|
13
|
+
<BaseIcon {...props} Icon={icon} height="24" viewBox="0 0 24 24" width="24" />
|
|
14
|
+
);
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import NumberField, { NumberProps } from './Number';
|
|
2
|
+
|
|
3
|
+
const initialize = (props: NumberProps): void => {
|
|
4
|
+
cy.mount({
|
|
5
|
+
Component: <NumberField {...props} />
|
|
6
|
+
});
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
describe('Number field', () => {
|
|
10
|
+
it('displays the placeholder when the field has no default or fallback values', () => {
|
|
11
|
+
initialize({ dataTestId: 'test', onChange: cy.stub() });
|
|
12
|
+
|
|
13
|
+
cy.get('input').should('have.value', '');
|
|
14
|
+
cy.get('input').should('have.attr', 'placeholder', '0');
|
|
15
|
+
|
|
16
|
+
cy.makeSnapshot();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('displays the fallback value as placeholder when the field as no default value', () => {
|
|
20
|
+
initialize({ dataTestId: 'test', fallbackValue: 25, onChange: cy.stub() });
|
|
21
|
+
|
|
22
|
+
cy.get('input').should('have.value', '');
|
|
23
|
+
cy.get('input').should('have.attr', 'placeholder', '25');
|
|
24
|
+
|
|
25
|
+
cy.makeSnapshot();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('displays the default value as placeholder when the field as default value', () => {
|
|
29
|
+
initialize({ dataTestId: 'test', defaultValue: 25, onChange: cy.stub() });
|
|
30
|
+
|
|
31
|
+
cy.get('input').should('have.value', '25');
|
|
32
|
+
|
|
33
|
+
cy.makeSnapshot();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('displays the fallback value when the field is cleared out', () => {
|
|
37
|
+
initialize({
|
|
38
|
+
dataTestId: 'test',
|
|
39
|
+
defaultValue: 25,
|
|
40
|
+
fallbackValue: 10,
|
|
41
|
+
onChange: cy.stub()
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
cy.get('input').should('have.value', '25');
|
|
45
|
+
cy.get('input').clear();
|
|
46
|
+
cy.get('input').should('have.value', '');
|
|
47
|
+
cy.get('input').should('have.attr', 'placeholder', '10');
|
|
48
|
+
|
|
49
|
+
cy.makeSnapshot();
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('displays the field using auto size', () => {
|
|
53
|
+
initialize({
|
|
54
|
+
autoSize: true,
|
|
55
|
+
dataTestId: 'test',
|
|
56
|
+
defaultValue: 25,
|
|
57
|
+
onChange: cy.stub()
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
cy.get('input').should('have.value', '25');
|
|
61
|
+
|
|
62
|
+
cy.get('input').type('0');
|
|
63
|
+
|
|
64
|
+
cy.makeSnapshot();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('sets the value to the minimum value configured when a value less than the minimum value is typed in the field', () => {
|
|
68
|
+
initialize({
|
|
69
|
+
dataTestId: 'test',
|
|
70
|
+
defaultValue: 25,
|
|
71
|
+
inputProps: {
|
|
72
|
+
min: 2
|
|
73
|
+
},
|
|
74
|
+
onChange: cy.stub()
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
cy.get('input').should('have.value', '25');
|
|
78
|
+
|
|
79
|
+
cy.get('input').clear().type('-1');
|
|
80
|
+
|
|
81
|
+
cy.get('input').should('have.value', '2');
|
|
82
|
+
|
|
83
|
+
cy.makeSnapshot();
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
import { Meta, StoryObj } from '@storybook/react';
|
|
3
|
+
|
|
4
|
+
import NumberField from './Number';
|
|
5
|
+
|
|
6
|
+
const meta: Meta<typeof NumberField> = {
|
|
7
|
+
argTypes: {
|
|
8
|
+
defaultValue: {
|
|
9
|
+
defaultValue: 0,
|
|
10
|
+
description:
|
|
11
|
+
'The initial value which will be used by the input for the first render',
|
|
12
|
+
type: 'number'
|
|
13
|
+
},
|
|
14
|
+
fallbackValue: {
|
|
15
|
+
defaultValue: 0,
|
|
16
|
+
description: 'This value will be used when the input is cleared',
|
|
17
|
+
type: 'number'
|
|
18
|
+
},
|
|
19
|
+
onChange: {
|
|
20
|
+
description:
|
|
21
|
+
'The change function with the actual value as parameter. This parameter will be the value when the input is filled but it will be the fallbackValue when the input is cleared out',
|
|
22
|
+
type: 'function'
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
component: NumberField
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default meta;
|
|
29
|
+
type Story = StoryObj<typeof NumberField>;
|
|
30
|
+
|
|
31
|
+
export const Default: Story = {
|
|
32
|
+
args: {
|
|
33
|
+
onChange: console.log
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const WithDefaultValue: Story = {
|
|
38
|
+
args: {
|
|
39
|
+
defaultValue: 25,
|
|
40
|
+
onChange: console.log
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export const WithFallbackValue: Story = {
|
|
45
|
+
args: {
|
|
46
|
+
fallbackValue: 25,
|
|
47
|
+
onChange: console.log
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const WithFallbackValueAndDefaultValue: Story = {
|
|
52
|
+
args: {
|
|
53
|
+
defaultValue: 10,
|
|
54
|
+
fallbackValue: 25,
|
|
55
|
+
onChange: console.log
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
export const WithFallbackValueAndDefaultValueAutoSize: Story = {
|
|
60
|
+
args: {
|
|
61
|
+
autoSize: true,
|
|
62
|
+
defaultValue: 10,
|
|
63
|
+
fallbackValue: 25,
|
|
64
|
+
onChange: console.log
|
|
65
|
+
}
|
|
66
|
+
};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { ChangeEvent, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { T, always, cond, isEmpty, isNil } from 'ramda';
|
|
4
|
+
|
|
5
|
+
import TextField, { TextProps } from '../Text';
|
|
6
|
+
|
|
7
|
+
export interface NumberProps
|
|
8
|
+
extends Omit<TextProps, 'defaultValue' | 'onChange'> {
|
|
9
|
+
/**
|
|
10
|
+
* The initial value which will be used by the input for the first render
|
|
11
|
+
*/
|
|
12
|
+
defaultValue?: number;
|
|
13
|
+
/**
|
|
14
|
+
* This value will be used when the input is cleared
|
|
15
|
+
*/
|
|
16
|
+
fallbackValue?: number;
|
|
17
|
+
/**
|
|
18
|
+
* The change function with the actual value as parameter. This parameter will be the value when the input is filled but it will be the fallbackValue when the input is cleared out
|
|
19
|
+
*/
|
|
20
|
+
onChange: (actualValue: number) => void;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const NumberField = ({
|
|
24
|
+
fallbackValue = 0,
|
|
25
|
+
defaultValue,
|
|
26
|
+
onChange,
|
|
27
|
+
...props
|
|
28
|
+
}: NumberProps): JSX.Element => {
|
|
29
|
+
const [placeholder, setPlaceholder] = useState<string | undefined>();
|
|
30
|
+
const [actualValue, setActualValue] = useState(
|
|
31
|
+
defaultValue ? `${defaultValue}` : ''
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const { inputProps } = props;
|
|
35
|
+
|
|
36
|
+
const changeValue = (event: ChangeEvent<HTMLInputElement>): void => {
|
|
37
|
+
const inputValue = event.target.value;
|
|
38
|
+
|
|
39
|
+
const number = Number(inputValue);
|
|
40
|
+
const campledNumber = cond([
|
|
41
|
+
[() => isEmpty(inputValue), always(fallbackValue)],
|
|
42
|
+
[() => Number.isNaN(number), always(number)],
|
|
43
|
+
[
|
|
44
|
+
T,
|
|
45
|
+
always(
|
|
46
|
+
Math.max(
|
|
47
|
+
!isNil(inputProps?.min) ? inputProps?.min : -Infinity,
|
|
48
|
+
number
|
|
49
|
+
)
|
|
50
|
+
)
|
|
51
|
+
]
|
|
52
|
+
])();
|
|
53
|
+
|
|
54
|
+
onChange(campledNumber);
|
|
55
|
+
setPlaceholder(isEmpty(inputValue) ? `${fallbackValue}` : undefined);
|
|
56
|
+
setActualValue(isEmpty(inputValue) ? inputValue : `${campledNumber}`);
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<TextField
|
|
61
|
+
defaultValue={defaultValue}
|
|
62
|
+
type="number"
|
|
63
|
+
value={actualValue}
|
|
64
|
+
onChange={changeValue}
|
|
65
|
+
{...props}
|
|
66
|
+
inputProps={inputProps}
|
|
67
|
+
placeholder={
|
|
68
|
+
placeholder || (!defaultValue ? `${fallbackValue}` : undefined)
|
|
69
|
+
}
|
|
70
|
+
/>
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export default NumberField;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import IconSearch from '@mui/icons-material/Search';
|
|
2
2
|
|
|
3
|
-
import TextField, {
|
|
3
|
+
import TextField, { TextProps } from '../Text';
|
|
4
4
|
|
|
5
|
-
type Props = Omit<
|
|
5
|
+
type Props = Omit<TextProps, 'StartAdornment'>;
|
|
6
6
|
|
|
7
7
|
const SearchAdornment = (): JSX.Element => <IconSearch />;
|
|
8
8
|
|
|
@@ -13,10 +13,12 @@ import { baseEndpoint, getEndpoint, label, optionsData } from './utils';
|
|
|
13
13
|
|
|
14
14
|
import MultiConnectedAutocompleteField from '.';
|
|
15
15
|
|
|
16
|
-
const renderMultiAutocompleteField = (): RenderResult =>
|
|
16
|
+
const renderMultiAutocompleteField = (customRenderTags?): RenderResult =>
|
|
17
17
|
render(
|
|
18
18
|
<TestQueryProvider>
|
|
19
19
|
<MultiConnectedAutocompleteField
|
|
20
|
+
baseEndpoint=""
|
|
21
|
+
customRenderTags={customRenderTags}
|
|
20
22
|
field="host.name"
|
|
21
23
|
getEndpoint={getEndpoint}
|
|
22
24
|
label={label}
|
|
@@ -41,4 +43,23 @@ describe(MultiConnectedAutocompleteField, () => {
|
|
|
41
43
|
expect(getFetchCall(0)).toEqual(`${baseEndpoint}?page=1`);
|
|
42
44
|
});
|
|
43
45
|
});
|
|
46
|
+
|
|
47
|
+
it('display tags when customTagsRender is defined', async () => {
|
|
48
|
+
const customRender = (tags: React.ReactNode): React.ReactNode => (
|
|
49
|
+
<div data-testid="custom-tags-wrapper">{tags}</div>
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
const { getByLabelText, getByTestId } =
|
|
53
|
+
renderMultiAutocompleteField(customRender);
|
|
54
|
+
|
|
55
|
+
fireEvent.click(getByLabelText('Open'));
|
|
56
|
+
|
|
57
|
+
await waitFor(() => {
|
|
58
|
+
const tagChip = getByTestId(
|
|
59
|
+
`tag-option-chip-${optionsData.result[0].id}`
|
|
60
|
+
);
|
|
61
|
+
expect(tagChip).toBeVisible();
|
|
62
|
+
expect(tagChip).toHaveTextContent(optionsData.result[0].name);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
44
65
|
});
|
|
@@ -45,6 +45,7 @@ const renderSingleConnectedAutocompleteField = (
|
|
|
45
45
|
render(
|
|
46
46
|
<TestQueryProvider>
|
|
47
47
|
<SingleConnectedAutocompleteField
|
|
48
|
+
baseEndpoint=""
|
|
48
49
|
field="host.name"
|
|
49
50
|
getEndpoint={getEndpoint}
|
|
50
51
|
label={label}
|
|
@@ -94,8 +95,8 @@ describe(SingleConnectedAutocompleteField, () => {
|
|
|
94
95
|
});
|
|
95
96
|
|
|
96
97
|
await waitFor(() => {
|
|
97
|
-
expect(getFetchCall(2)).toEqual(
|
|
98
|
-
|
|
98
|
+
expect(decodeURIComponent(getFetchCall(2))).toEqual(
|
|
99
|
+
'endpoint?page=1&search={"$and":[{"$and":[{"host.name":{"$lk":"%My Option 2%"}}]}]}'
|
|
99
100
|
);
|
|
100
101
|
});
|
|
101
102
|
});
|