@centreon/ui 24.4.21 → 24.4.23
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/README.md +44 -14
- package/package.json +101 -31
- package/public/README.md +39 -0
- package/public/mockServiceWorker.js +303 -0
- package/src/@assets/README.md +5 -0
- package/src/@assets/brand/centreon-logo-one-line-dark.svg +1 -0
- package/src/@assets/brand/centreon-logo-one-line-light.svg +1 -0
- package/src/@assets/icons/downtime.icon.svg +1 -0
- package/src/@types/aria-attributes.d.ts +10 -0
- package/src/@types/data-attributes.d.ts +3 -0
- package/src/@types/globals.d.ts +9 -0
- package/src/@types/vite-env.d.ts +2 -0
- package/src/ActionsList/ActionsList.styles.ts +116 -0
- package/src/ActionsList/index.stories.tsx +74 -0
- package/src/ActionsList/index.tsx +58 -21
- package/src/ActionsList/models.ts +8 -0
- package/src/Button/Icon/index.tsx +11 -2
- package/src/Button/Save/index.stories.tsx +10 -5
- package/src/Button/Save/index.tsx +1 -1
- package/src/Checkbox/Checkbox.tsx +109 -0
- package/src/Checkbox/CheckboxGroup/index.stories.tsx +41 -0
- package/src/Checkbox/CheckboxGroup/index.tsx +75 -0
- package/src/Checkbox/index.stories.tsx +39 -0
- package/src/Checkbox/index.tsx +2 -0
- package/src/Dashboard/Dashboard.styles.ts +108 -0
- package/src/Dashboard/DashboardLayout.stories.tsx +104 -0
- package/src/Dashboard/Grid.tsx +70 -0
- package/src/Dashboard/Item.tsx +100 -0
- package/src/Dashboard/Layout.tsx +79 -0
- package/src/Dashboard/index.tsx +9 -0
- package/src/Dashboard/utils.ts +28 -0
- package/src/Dialog/Confirm/index.tsx +17 -4
- package/src/Dialog/Duplicate/index.test.tsx +1 -1
- package/src/Dialog/index.tsx +14 -2
- package/src/FallbackPage/FallbackPage.tsx +2 -2
- package/src/FileDropZone/index.tsx +1 -1
- package/src/Form/CollapsibleGroup.tsx +15 -5
- package/src/Form/{index.stories.tsx → Form.stories.tsx} +2 -3
- package/src/Form/Form.styles.ts +11 -0
- package/src/Form/{index.tsx → Form.tsx} +38 -16
- package/src/Form/FormButtons.tsx +2 -4
- package/src/Form/Inputs/Autocomplete.tsx +1 -1
- package/src/Form/Inputs/Checkbox.tsx +57 -0
- package/src/Form/Inputs/CheckboxGroup.tsx +76 -0
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +3 -1
- package/src/Form/Inputs/Grid.tsx +4 -2
- package/src/Form/Inputs/Radio.tsx +16 -5
- package/src/Form/Inputs/Switch.tsx +1 -1
- package/src/Form/Inputs/Text.tsx +18 -7
- package/src/Form/Inputs/index.tsx +31 -15
- package/src/Form/Inputs/models.ts +20 -4
- package/src/Form/index.ts +1 -0
- package/src/Form/storiesData.tsx +50 -3
- package/src/Graph/Gauge/AnimatedPie.tsx +102 -0
- package/src/Graph/Gauge/Gauge.stories.tsx +159 -0
- package/src/Graph/Gauge/Gauge.tsx +41 -0
- package/src/Graph/Gauge/PieData.tsx +63 -0
- package/src/Graph/Gauge/ResponsiveGauge.tsx +148 -0
- package/src/Graph/Gauge/Thresholds.tsx +117 -0
- package/src/Graph/Gauge/index.ts +1 -0
- package/src/Graph/Gauge/models.ts +20 -0
- package/src/Graph/HeatMap/HeatMap.stories.tsx +105 -0
- package/src/Graph/HeatMap/HeatMap.styles.tsx +29 -0
- package/src/Graph/HeatMap/HeatMap.tsx +12 -0
- package/src/Graph/HeatMap/HeatMapData.json +137 -0
- package/src/Graph/HeatMap/ResponsiveHeatMap.tsx +98 -0
- package/src/Graph/HeatMap/index.ts +1 -0
- package/src/Graph/HeatMap/model.ts +33 -0
- package/src/Graph/LineChart/BasicComponents/Axes/UnitLabel.tsx +20 -0
- package/src/Graph/LineChart/BasicComponents/Axes/index.tsx +88 -0
- package/src/Graph/LineChart/BasicComponents/Axes/models.ts +26 -0
- package/src/Graph/LineChart/BasicComponents/Axes/useAxisY.ts +100 -0
- package/src/Graph/LineChart/BasicComponents/Grids/index.tsx +20 -0
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +99 -0
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/useRegularLines.ts +15 -0
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +81 -0
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/useStackedLines.ts +39 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/BasicThreshold.tsx +53 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/Circle.tsx +43 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/ThresholdWithPatternLines.tsx +78 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/ThresholdWithVariation.tsx +63 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/helpers/index.ts +69 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/index.tsx +142 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/models.ts +105 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/useCoordinateCircle.ts +46 -0
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/useScaleThreshold.ts +171 -0
- package/src/Graph/LineChart/BasicComponents/Lines/index.tsx +189 -0
- package/src/Graph/LineChart/BasicComponents/Lines/models.ts +45 -0
- package/src/Graph/LineChart/BasicComponents/LoadingProgress.tsx +46 -0
- package/src/Graph/LineChart/BasicComponents/ThresholdLine.tsx +64 -0
- package/src/Graph/LineChart/BasicComponents/Thresholds.tsx +77 -0
- package/src/Graph/LineChart/BasicComponents/useFilterLines.ts +60 -0
- package/src/Graph/LineChart/Header/index.tsx +65 -0
- package/src/Graph/LineChart/Icons/Downtime.tsx +9 -0
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +45 -0
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +66 -0
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/StackedAnchorPoint.tsx +76 -0
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/TooltipAnchorPoint.tsx +96 -0
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/index.tsx +20 -0
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/models.ts +62 -0
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/useTickGraph.ts +94 -0
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/useTooltipAnchorPoint.ts +107 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/Area.tsx +114 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/Line.tsx +103 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Annotation/index.tsx +81 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Area/Downtime.tsx +27 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/EventAnnotations.tsx +61 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Line/Acknowledgement.tsx +27 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/Line/Comments.tsx +25 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/annotationsAtoms.ts +183 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/index.tsx +49 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/models.ts +25 -0
- package/src/Graph/LineChart/InteractiveComponents/Annotations/useAnnotation.ts +56 -0
- package/src/Graph/LineChart/InteractiveComponents/Bar.tsx +21 -0
- package/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/TimeShiftIcon.tsx +62 -0
- package/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/TimeShiftZone.tsx +74 -0
- package/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/index.tsx +85 -0
- package/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/models.ts +12 -0
- package/src/Graph/LineChart/InteractiveComponents/TimeShiftZones/useTimeShiftZones.ts +72 -0
- package/src/Graph/LineChart/InteractiveComponents/Tooltip/index.tsx +59 -0
- package/src/Graph/LineChart/InteractiveComponents/Tooltip/models.ts +9 -0
- package/src/Graph/LineChart/InteractiveComponents/Tooltip/useGraphTooltip.ts +67 -0
- package/src/Graph/LineChart/InteractiveComponents/ZoomPreview/index.tsx +38 -0
- package/src/Graph/LineChart/InteractiveComponents/ZoomPreview/models.ts +9 -0
- package/src/Graph/LineChart/InteractiveComponents/ZoomPreview/useZoomPreview.ts +107 -0
- package/src/Graph/LineChart/InteractiveComponents/ZoomPreview/zoomPreviewAtoms.ts +3 -0
- package/src/Graph/LineChart/InteractiveComponents/index.tsx +168 -0
- package/src/Graph/LineChart/InteractiveComponents/interactionWithGraphAtoms.ts +52 -0
- package/src/Graph/LineChart/Legend/InteractiveValue.tsx +22 -0
- package/src/Graph/LineChart/Legend/Legend.styles.ts +117 -0
- package/src/Graph/LineChart/Legend/LegendContent.tsx +33 -0
- package/src/Graph/LineChart/Legend/LegendHeader.tsx +93 -0
- package/src/Graph/LineChart/Legend/index.tsx +201 -0
- package/src/Graph/LineChart/Legend/models.ts +16 -0
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +99 -0
- package/src/Graph/LineChart/Legend/useLegend.ts +104 -0
- package/src/Graph/LineChart/LineChart.styles.ts +45 -0
- package/src/Graph/LineChart/LineChart.tsx +317 -0
- package/src/Graph/LineChart/LoadingSkeleton.tsx +44 -0
- package/src/Graph/LineChart/common/index.ts +35 -0
- package/src/Graph/LineChart/graphAtoms.ts +3 -0
- package/src/Graph/LineChart/helpers/doc.ts +560 -0
- package/src/Graph/LineChart/helpers/index.ts +63 -0
- package/src/Graph/LineChart/index.stories.tsx +478 -0
- package/src/Graph/LineChart/index.tsx +115 -0
- package/src/Graph/LineChart/mockedData/annotationData.json +326 -0
- package/src/Graph/LineChart/mockedData/exclusionPeriodFirstPeriod.json +588 -0
- package/src/Graph/LineChart/mockedData/exclusionPeriodSecondPeriod.json +588 -0
- package/src/Graph/LineChart/mockedData/exclusionPeriodThirdPeriod.json +581 -0
- package/src/Graph/LineChart/mockedData/lastDay.json +1326 -0
- package/src/Graph/LineChart/mockedData/lastDayAreaStack.json +3106 -0
- package/src/Graph/LineChart/mockedData/lastDayForward.json +1338 -0
- package/src/Graph/LineChart/mockedData/lastDayThreshold.json +2352 -0
- package/src/Graph/LineChart/mockedData/lastMonth.json +1674 -0
- package/src/Graph/LineChart/mockedData/lastWeek.json +2202 -0
- package/src/Graph/LineChart/mockedData/zoomPreview.json +742 -0
- package/src/Graph/LineChart/models.ts +146 -0
- package/src/Graph/LineChart/translatedLabels.ts +9 -0
- package/src/Graph/LineChart/useLineChartData.ts +49 -0
- package/src/Graph/LineChart/useLineChartIntersection.ts +36 -0
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +197 -0
- package/src/Graph/SingleBar/SingleBar.stories.tsx +204 -0
- package/src/Graph/SingleBar/SingleBar.tsx +25 -0
- package/src/Graph/SingleBar/ThresholdLine.tsx +103 -0
- package/src/Graph/SingleBar/Thresholds.tsx +50 -0
- package/src/Graph/SingleBar/index.ts +1 -0
- package/src/Graph/SingleBar/models.ts +10 -0
- package/src/Graph/Text/Text.stories.tsx +67 -0
- package/src/Graph/Text/Text.styles.ts +17 -0
- package/src/Graph/Text/Text.tsx +91 -0
- package/src/Graph/Text/index.ts +1 -0
- package/src/Graph/common/margins.ts +1 -0
- package/src/Graph/common/models.ts +19 -0
- package/src/Graph/common/timeSeries/index.test.ts +624 -0
- package/src/Graph/common/timeSeries/index.ts +626 -0
- package/src/Graph/common/timeSeries/models.ts +129 -0
- package/src/Graph/common/utils.ts +75 -0
- package/src/Graph/index.ts +5 -0
- package/src/Home.stories.mdx +1 -84
- package/src/Image/Image.tsx +11 -1
- package/src/Image/index.stories.tsx +2 -2
- package/src/Image/index.test.tsx +3 -3
- package/src/InputField/Search/PersistentTooltip.tsx +10 -6
- package/src/InputField/Select/Autocomplete/Connected/Multi/MultiConnectedAutocompleteField.cypress.spec.tsx +127 -0
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +4 -22
- package/src/InputField/Select/Autocomplete/Connected/Multi/utils/index.ts +22 -0
- package/src/InputField/Select/Autocomplete/Connected/index.stories.tsx +0 -3
- package/src/InputField/Select/Autocomplete/Connected/index.test.tsx +4 -7
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +47 -9
- package/src/InputField/Select/Autocomplete/Draggable/index.stories.tsx +0 -2
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +32 -15
- package/src/InputField/Select/Autocomplete/index.stories.tsx +1 -10
- package/src/InputField/Select/Autocomplete/index.tsx +5 -2
- package/src/InputField/Select/index.tsx +2 -1
- package/src/InputField/Text/index.tsx +19 -9
- package/src/Listing/ActionBar/index.tsx +15 -8
- package/src/Listing/Cell/DataCell.styles.ts +24 -0
- package/src/Listing/Cell/DataCell.tsx +43 -68
- package/src/Listing/Cell/index.tsx +88 -8
- package/src/Listing/EmptyResult/EmptyResult.tsx +13 -0
- package/src/Listing/Header/Cell/ListingHeaderCell.styles.ts +71 -0
- package/src/Listing/Header/{SortableCell/Content.tsx → Cell/ListingHeaderCell.tsx} +18 -83
- package/src/Listing/Header/Cell/SelectActionListingHeaderCell.styles.ts +26 -0
- package/src/Listing/Header/Cell/SelectActionListingHeaderCell.tsx +70 -0
- package/src/Listing/Header/ListingHeader.styles.ts +16 -0
- package/src/Listing/Header/{index.tsx → ListingHeader.tsx} +28 -105
- package/src/Listing/Header/_internals/DraggableIconButton.tsx +35 -0
- package/src/Listing/Header/{PredefinedSelectionList.tsx → _internals/PredefinedSelectionList.tsx} +1 -1
- package/src/Listing/Header/index.ts +1 -0
- package/src/Listing/Listing.cypress.spec.tsx +122 -0
- package/src/Listing/Listing.styles.ts +81 -0
- package/src/Listing/ListingDocs.mdx +61 -0
- package/src/Listing/Row/EmptyRow.styles.ts +14 -0
- package/src/Listing/Row/EmptyRow.tsx +30 -0
- package/src/Listing/{Row.tsx → Row/Row.tsx} +12 -11
- package/src/Listing/Row/SkeletonLoaderRows.tsx +23 -0
- package/src/Listing/index.stories.tsx +144 -40
- package/src/Listing/index.test.tsx +1 -1
- package/src/Listing/index.tsx +217 -262
- package/src/Listing/models.ts +1 -0
- package/src/Listing/tableAtoms.ts +15 -10
- package/src/Listing/useStyleTable.ts +9 -9
- package/src/ListingPage/index.stories.tsx +21 -8
- package/src/ListingPage/index.tsx +20 -38
- package/src/Logo/CentreonLogo.tsx +2 -2
- package/src/Module/LicensedModule/LicenseCheck/index.stories.tsx +0 -2
- package/src/Module/LicensedModule/LicenseCheck/index.tsx +24 -9
- package/src/Module/LicensedModule/index.tsx +7 -1
- package/src/Panel/Memoized.tsx +1 -1
- package/src/Panel/Section/index.test.tsx +1 -1
- package/src/Panel/Section/index.tsx +1 -1
- package/src/Panel/index.tsx +10 -6
- package/src/ParentSize/ParentSize.tsx +24 -0
- package/src/ParentSize/index.ts +1 -0
- package/src/PopoverMenu/index.tsx +18 -4
- package/src/RichTextEditor/ContentEditable.tsx +70 -24
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +408 -0
- package/src/RichTextEditor/RichTextEditor.tsx +161 -47
- package/src/RichTextEditor/index.stories.tsx +14 -0
- package/src/RichTextEditor/plugins/AutoLinkPlugin/index.tsx +53 -5
- package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +54 -16
- package/src/RichTextEditor/plugins/ToolbarPlugin/AlignPicker.tsx +116 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/BlockButtons.tsx +155 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/FormatButtons.tsx +31 -92
- 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 +75 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/ToolbarPlugin.styles.ts +32 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/UndoRedoButtons.tsx +13 -3
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +35 -10
- package/src/RichTextEditor/translatedLabels.ts +3 -0
- package/src/Snackbar/index.tsx +14 -4
- package/src/Snackbar/useSnackbar.tsx +5 -1
- package/src/SortableItems/SortableItem.tsx +3 -2
- package/src/ThemeProvider/index.tsx +41 -33
- package/src/ThemeProvider/palettes.ts +422 -201
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +51 -0
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx +95 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/ErrorText.tsx +14 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +166 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/index.tsx +76 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +61 -0
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/usePickersStartEndDate.ts +82 -0
- package/src/TimePeriods/CustomTimePeriod/SimpleCustomTimePeriod.tsx +28 -0
- package/src/TimePeriods/CustomTimePeriod/index.tsx +66 -0
- package/src/TimePeriods/DateTimePickerInput.tsx +49 -0
- package/src/TimePeriods/ResolutionTimePeriod.cypress.spec.tsx +65 -0
- package/src/TimePeriods/SelectedTimePeriod.tsx +102 -0
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +510 -0
- package/src/TimePeriods/TimePeriods.styles.ts +22 -0
- package/src/TimePeriods/helpers/index.ts +26 -0
- package/src/TimePeriods/index.stories.tsx +113 -0
- package/src/TimePeriods/index.tsx +79 -0
- package/src/TimePeriods/mockedData.ts +12 -0
- package/src/TimePeriods/models.ts +97 -0
- package/src/TimePeriods/timePeriodsAtoms.ts +102 -0
- package/src/TimePeriods/translatedLabels.ts +9 -0
- package/src/TimePeriods/useSortTimePeriods.ts +31 -0
- package/src/TimePeriods/useTimePeriod.ts +49 -0
- package/src/Typography/EllipsisTypography.tsx +18 -0
- package/src/Typography/FluidTypography/index.stories.tsx +63 -0
- package/src/Typography/FluidTypography/index.tsx +51 -0
- package/src/Typography/FluidTypography/useFluidResizeObserver.ts +56 -0
- package/src/Typography/Subtitle.tsx +55 -0
- package/src/Typography/{index.stories.tsx → Typography.stories.tsx} +5 -5
- package/src/WallpaperPage/index.stories.tsx +1 -1
- package/src/Wizard/ActionsBar.test.tsx +1 -1
- package/src/Wizard/WizardContent.tsx +2 -3
- package/src/Wizard/index.stories.tsx +5 -18
- package/src/Wizard/index.test.tsx +1 -1
- package/src/Wizard/index.tsx +20 -5
- package/src/Wizard/models.ts +7 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-dashboard-normal-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-dashboard-with-item-header-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-dashboard-with-many-panels-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-basic-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-with-20-px-height-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-with-200-px-width-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-with-heading-5-variant-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-fluid-typography-with-long-text-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-listing-as-empty-state-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-listing-loading-with-no-data-1-snap.png +0 -0
- package/src/__image_snapshots__/storyshots-test-js-image-story-shots-listing-with-editable-and-sortable-columns-1-snap.png +0 -0
- package/src/api/TestQueryProvider.tsx +2 -1
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +35 -26
- package/src/api/buildListingEndpoint/index.test.ts +2 -2
- package/src/api/buildListingEndpoint/index.ts +1 -1
- package/src/api/buildListingEndpoint/models.ts +2 -2
- package/src/api/customFetch.ts +22 -3
- package/src/api/useFetchQuery/index.ts +34 -19
- package/src/api/useGraphQuery/index.ts +166 -0
- package/src/api/useGraphQuery/models.ts +15 -0
- package/src/api/useMutationQuery/index.ts +51 -20
- package/src/api/useRequest/index.ts +9 -6
- package/src/base/tokens/README.md +3 -0
- package/src/base/tokens/source/$metadata.json +5 -0
- package/src/base/tokens/source/base.json +142 -0
- package/src/base/tokens/themes/base.tokens.d.ts +38 -0
- package/src/base/tokens/themes/base.tokens.json +695 -0
- package/src/base/tokens/themes/base.tokens.ts +38 -0
- package/src/base/tokens/themes/ui-dark.tokens.d.ts +38 -0
- package/src/base/tokens/themes/ui-dark.tokens.json +695 -0
- package/src/base/tokens/themes/ui-dark.tokens.ts +38 -0
- package/src/base/tokens/themes/ui-light.tokens.d.ts +38 -0
- package/src/base/tokens/themes/ui-light.tokens.json +695 -0
- package/src/base/tokens/themes/ui-light.tokens.ts +38 -0
- package/src/components/Avatar/Avatar.stories.tsx +23 -0
- package/src/components/Avatar/Avatar.styles.ts +11 -0
- package/src/components/Avatar/Avatar.tsx +32 -0
- package/src/components/Avatar/index.ts +1 -0
- package/src/components/Button/Button.stories.tsx +34 -0
- package/src/components/Button/Button.styles.ts +44 -0
- package/src/components/Button/Button.tsx +78 -0
- package/src/components/Button/Icon/IconButton.stories.tsx +18 -0
- package/src/components/Button/Icon/IconButton.styles.ts +14 -0
- package/src/components/Button/Icon/IconButton.tsx +58 -0
- package/src/components/Button/Icon/index.tsx +1 -0
- package/src/components/Button/index.ts +2 -0
- package/src/components/CollapsibleItem/CollapsibleItem.stories.tsx +25 -0
- package/src/components/CollapsibleItem/CollapsibleItem.tsx +47 -0
- package/src/components/CollapsibleItem/index.ts +1 -0
- package/src/components/CollapsibleItem/useCollapsibleItemStyles.ts +15 -0
- package/src/components/DataTable/DataTable.stories.tsx +51 -0
- package/src/components/DataTable/DataTable.styles.ts +27 -0
- package/src/components/DataTable/DataTable.tsx +35 -0
- package/src/components/DataTable/EmptyState/DataTableEmptyState.stories.tsx +21 -0
- package/src/components/DataTable/EmptyState/DataTableEmptyState.styles.ts +26 -0
- package/src/components/DataTable/EmptyState/DataTableEmptyState.tsx +53 -0
- package/src/components/DataTable/Item/DataTableItem.stories.tsx +25 -0
- package/src/components/DataTable/Item/DataTableItem.styles.ts +33 -0
- package/src/components/DataTable/Item/DataTableItem.tsx +123 -0
- package/src/components/DataTable/Item/DataTableItemSkeleton.tsx +13 -0
- package/src/components/DataTable/index.ts +10 -0
- package/src/components/Form/AccessRights/AccessRights.resource.ts +45 -0
- package/src/components/Form/AccessRights/AccessRightsForm.stories.tsx +59 -0
- package/src/components/Form/AccessRights/AccessRightsForm.styles.ts +21 -0
- package/src/components/Form/AccessRights/AccessRightsForm.tsx +67 -0
- package/src/components/Form/AccessRights/AccessRightsFormActions.tsx +80 -0
- package/src/components/Form/AccessRights/Input/AddAction.tsx +31 -0
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.stories.tsx +54 -0
- package/src/components/Form/AccessRights/Input/ContactAccessRightInput.tsx +72 -0
- package/src/components/Form/AccessRights/Input/ContactAccessRightsInput.styles.ts +22 -0
- package/src/components/Form/AccessRights/Input/ContactInputField.tsx +105 -0
- package/src/components/Form/AccessRights/Input/RoleInputField.tsx +29 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.stories.tsx +97 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.styles.ts +71 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsList.tsx +51 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.stories.tsx +116 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItem.tsx +118 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsListItemSkeleton.tsx +26 -0
- package/src/components/Form/AccessRights/List/ContactAccessRightsListSkeleton.tsx +28 -0
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.styles.ts +18 -0
- package/src/components/Form/AccessRights/Stats/AccessRightsStats.tsx +41 -0
- package/src/components/Form/AccessRights/__fixtures__/contactAccessRight.mock.ts +52 -0
- package/src/components/Form/AccessRights/common/GroupLabel.styles.ts +18 -0
- package/src/components/Form/AccessRights/common/GroupLabel.tsx +15 -0
- package/src/components/Form/AccessRights/common/Input.styles.ts +48 -0
- package/src/components/Form/AccessRights/common/RoleInputSelect.styles.ts +11 -0
- package/src/components/Form/AccessRights/common/RoleInputSelect.tsx +57 -0
- package/src/components/Form/AccessRights/index.ts +3 -0
- package/src/components/Form/AccessRights/useAccessRightsForm.test.tsx +531 -0
- package/src/components/Form/AccessRights/useAccessRightsForm.tsx +282 -0
- package/src/components/Form/AccessRights/useAccessRightsForm.utils.ts +41 -0
- package/src/components/Form/AccessRightsV2/AccessRights.cypress.spec.tsx +350 -0
- package/src/components/Form/AccessRightsV2/AccessRights.stories.tsx +119 -0
- package/src/components/Form/AccessRightsV2/AccessRights.styles.ts +10 -0
- package/src/components/Form/AccessRightsV2/AccessRights.tsx +60 -0
- package/src/components/Form/AccessRightsV2/Actions/Actions.styles.ts +14 -0
- package/src/components/Form/AccessRightsV2/Actions/Actions.tsx +81 -0
- package/src/components/Form/AccessRightsV2/Actions/useActions.ts +79 -0
- package/src/components/Form/AccessRightsV2/List/Item.tsx +90 -0
- package/src/components/Form/AccessRightsV2/List/List.styles.tsx +45 -0
- package/src/components/Form/AccessRightsV2/List/List.tsx +52 -0
- package/src/components/Form/AccessRightsV2/List/ListItemSkeleton.tsx +18 -0
- package/src/components/Form/AccessRightsV2/List/ListSkeleton.tsx +22 -0
- package/src/components/Form/AccessRightsV2/List/RemoveAccessRight.tsx +38 -0
- package/src/components/Form/AccessRightsV2/List/StateChip.tsx +28 -0
- package/src/components/Form/AccessRightsV2/List/useItem.ts +64 -0
- package/src/components/Form/AccessRightsV2/Provider.tsx +15 -0
- package/src/components/Form/AccessRightsV2/ShareInput/ContactSwitch.tsx +42 -0
- package/src/components/Form/AccessRightsV2/ShareInput/ShareInput.styles.ts +9 -0
- package/src/components/Form/AccessRightsV2/ShareInput/ShareInput.tsx +77 -0
- package/src/components/Form/AccessRightsV2/ShareInput/useShareInput.tsx +109 -0
- package/src/components/Form/AccessRightsV2/Stats/Stats.tsx +36 -0
- package/src/components/Form/AccessRightsV2/atoms.ts +97 -0
- package/src/components/Form/AccessRightsV2/common/RoleSelectField.styles.tsx +7 -0
- package/src/components/Form/AccessRightsV2/common/RoleSelectField.tsx +45 -0
- package/src/components/Form/AccessRightsV2/models.ts +54 -0
- package/src/components/Form/AccessRightsV2/storiesData.ts +221 -0
- package/src/components/Form/AccessRightsV2/useAccessRightsInitValues.ts +51 -0
- package/src/components/Form/Dashboard/Dashboard.resource.ts +9 -0
- package/src/components/Form/Dashboard/DashboardForm.stories.ts +39 -0
- package/src/components/Form/Dashboard/DashboardForm.styles.ts +21 -0
- package/src/components/Form/Dashboard/DashboardForm.tsx +134 -0
- package/src/components/Form/Dashboard/GlobalRefreshFieldOption.tsx +59 -0
- package/src/components/Form/Dashboard/index.ts +2 -0
- package/src/components/Form/Dashboard/translatedLabels.ts +9 -0
- package/src/components/Form/Form.models.ts +1 -0
- package/src/components/Form/Form.resource.ts +1 -0
- package/src/components/Form/Form.styles.ts +17 -0
- package/src/components/Form/FormActions.tsx +57 -0
- package/src/components/Form/index.ts +4 -0
- package/src/components/Header/PageHeader/PageHeader.stories.tsx +97 -0
- package/src/components/Header/PageHeader/PageHeader.styles.ts +126 -0
- package/src/components/Header/PageHeader/PageHeader.tsx +15 -0
- package/src/components/Header/PageHeader/PageHeaderActions.tsx +17 -0
- package/src/components/Header/PageHeader/PageHeaderMain.tsx +15 -0
- package/src/components/Header/PageHeader/PageHeaderMenu.tsx +15 -0
- package/src/components/Header/PageHeader/PageHeaderMessage.tsx +32 -0
- package/src/components/Header/PageHeader/PageHeaderTitle.tsx +47 -0
- package/src/components/Header/PageHeader/index.ts +14 -0
- package/src/components/Header/index.ts +1 -0
- package/src/components/Icon/Icon.styles.ts +0 -0
- package/src/components/Icon/Icon.tsx +2 -0
- package/src/components/Icon/index.ts +0 -0
- package/src/components/Inputs/Switch/Switch.stories.tsx +22 -0
- package/src/components/Inputs/Switch/Switch.styles.ts +13 -0
- package/src/components/Inputs/Switch/Switch.tsx +18 -0
- package/src/components/Inputs/index.ts +1 -0
- package/src/components/ItemComposition/Item.tsx +41 -0
- package/src/components/ItemComposition/ItemComposition.stories.tsx +78 -0
- package/src/components/ItemComposition/ItemComposition.styles.ts +29 -0
- package/src/components/ItemComposition/ItemComposition.tsx +47 -0
- package/src/components/ItemComposition/index.ts +6 -0
- package/src/components/Layout/AreaIndicator.styles.ts +33 -0
- package/src/components/Layout/AreaIndicator.tsx +35 -0
- package/src/components/Layout/PageLayout/PageLayout.stories.tsx +81 -0
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +41 -0
- package/src/components/Layout/PageLayout/PageLayout.tsx +21 -0
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +24 -0
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +24 -0
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +15 -0
- package/src/components/Layout/PageLayout/index.ts +10 -0
- package/src/components/Layout/index.ts +1 -0
- package/src/components/List/Item/Avatar.tsx +21 -0
- package/src/components/List/Item/AvatarSkeleton.tsx +17 -0
- package/src/components/List/Item/ListItem.stories.tsx +41 -0
- package/src/components/List/Item/ListItem.styles.ts +63 -0
- package/src/components/List/Item/ListItem.tsx +34 -0
- package/src/components/List/Item/Text.tsx +27 -0
- package/src/components/List/Item/TextSkeleton.tsx +22 -0
- package/src/components/List/Item/index.ts +14 -0
- package/src/components/List/List.stories.tsx +70 -0
- package/src/components/List/List.styles.ts +8 -0
- package/src/components/List/List.tsx +19 -0
- package/src/components/List/index.ts +6 -0
- package/src/components/Menu/Button/MenuButton.stories.tsx +16 -0
- package/src/components/Menu/Button/MenuButton.styles.ts +27 -0
- package/src/components/Menu/Button/MenuButton.tsx +67 -0
- package/src/components/Menu/Button/index.ts +1 -0
- package/src/components/Menu/Menu.stories.tsx +71 -0
- package/src/components/Menu/Menu.styles.ts +68 -0
- package/src/components/Menu/Menu.tsx +25 -0
- package/src/components/Menu/MenuDivider.tsx +13 -0
- package/src/components/Menu/MenuItem.tsx +38 -0
- package/src/components/Menu/MenuItems.tsx +36 -0
- package/src/components/Menu/index.ts +12 -0
- package/src/components/Menu/useMenu.tsx +79 -0
- package/src/components/Modal/Modal.stories.tsx +142 -0
- package/src/components/Modal/Modal.styles.ts +90 -0
- package/src/components/Modal/Modal.tsx +79 -0
- package/src/components/Modal/ModalActions.tsx +62 -0
- package/src/components/Modal/ModalBody.tsx +15 -0
- package/src/components/Modal/ModalHeader.tsx +21 -0
- package/src/components/Modal/index.ts +12 -0
- package/src/components/README.md +3 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.stories.tsx +62 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.styles.tsx +22 -0
- package/src/components/Tooltip/ConfirmationTooltip/ConfirmationTooltip.tsx +68 -0
- package/src/components/Tooltip/ConfirmationTooltip/TooltipContent.tsx +31 -0
- package/src/components/Tooltip/ConfirmationTooltip/index.ts +1 -0
- package/src/components/Tooltip/ConfirmationTooltip/models.ts +18 -0
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.stories.tsx +70 -0
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.styles.ts +5 -0
- package/src/components/Tooltip/TextOverflowTooltip/TextOverflowTooltip.tsx +115 -0
- package/src/components/Tooltip/TextOverflowTooltip/index.tsx +1 -0
- package/src/components/Tooltip/Tooltip.stories.tsx +41 -0
- package/src/components/Tooltip/Tooltip.tsx +57 -0
- package/src/components/Tooltip/index.ts +2 -0
- package/src/components/index.ts +13 -0
- package/src/index.ts +31 -21
- package/src/screens/dashboard/DashboardsDetail.stories.tsx +108 -0
- package/src/screens/dashboard/DashboardsOverview.stories.tsx +281 -0
- package/src/styles/tokens/themes/_ui-dark.tokens.json +695 -0
- package/src/styles/tokens/themes/_ui-light.tokens.json +695 -0
- package/src/utils/centreonBaseURL.ts +4 -0
- package/src/utils/docsURL.ts +31 -0
- package/src/utils/getNormalizedId.ts +1 -3
- package/src/utils/index.ts +22 -0
- package/src/utils/panelSize.ts +15 -0
- package/src/utils/sanitizedHTML.ts +18 -0
- package/src/utils/translatedLabel.ts +2 -0
- package/src/utils/useCopyToClipboard.ts +2 -3
- package/src/utils/useDateTimePickerAdapter.ts +309 -0
- package/src/utils/useDebounce.ts +8 -5
- package/src/utils/useDeepCallback.ts +1 -3
- package/src/utils/useDeepMemo.ts +1 -3
- package/src/utils/useInfiniteScrollListing.ts +121 -0
- package/src/utils/useIntersectionObserver.ts +5 -5
- package/src/utils/useKeyObserver.tsx +1 -3
- package/src/utils/useLicenseExpirationWarning.cypress.spec.tsx +137 -0
- package/src/utils/useLicenseExpirationWarning.ts +52 -0
- package/src/utils/useLocaleDateTimeFormat/index.test.tsx +1 -1
- package/src/utils/useLocaleDateTimeFormat/index.ts +4 -2
- package/src/utils/useLocaleDateTimeFormat/localeFallback.test.tsx +1 -1
- package/src/utils/useMemoComponent.ts +1 -1
- package/src/utils/useRefreshInterval.ts +39 -0
- package/src/utils/useResizeObserver.ts +6 -0
- package/src/utils/useThresholds.ts +0 -0
- package/{setupTests.js → test/setupTests.js} +1 -1
- package/{src → test}/testRenderer.tsx +1 -1
- package/.storybook/main.js +0 -82
- package/.storybook/preview.tsx +0 -21
- package/jest.config.js +0 -20
- package/src/Listing/Header/SortableCell/DraggableIcon.tsx +0 -41
- package/src/Listing/Skeleton.tsx +0 -11
- package/src/storyshots.test.js +0 -52
- package/testRunner.js +0 -36
- package/tsconfig.json +0 -29
- package/types/declarations.d.ts +0 -9
- /package/{assets → public/brand}/centreon-logo-one-line-dark.svg +0 -0
- /package/{assets → public/brand}/centreon-logo-one-line-light.svg +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-bold-webfont.ttf +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-bold-webfont.woff +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-bold-webfont.woff2 +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-light-webfont.ttf +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-light-webfont.woff +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-light-webfont.woff2 +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-medium-webfont.ttf +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-medium-webfont.woff +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-medium-webfont.woff2 +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-regular-webfont.ttf +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-regular-webfont.woff +0 -0
- /package/{fonts/fonts-generated → public/fonts}/roboto-regular-webfont.woff2 +0 -0
- /package/{assets → src/@assets/images}/not-authorized-template-background-dark.svg +0 -0
- /package/{assets → src/@assets/images}/not-authorized-template-background-light.svg +0 -0
- /package/src/Listing/Header/{Label.tsx → _internals/Label.tsx} +0 -0
- /package/src/Typography/{index.tsx → story.utils.tsx} +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import { ReactElement, ReactNode, useEffect, useRef } from 'react';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
atom,
|
|
5
|
+
createStore,
|
|
6
|
+
Provider,
|
|
7
|
+
useAtom,
|
|
8
|
+
useAtomValue,
|
|
9
|
+
useSetAtom,
|
|
10
|
+
useStore
|
|
11
|
+
} from 'jotai';
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
ContactAccessRightResource,
|
|
15
|
+
ContactAccessRightStateResource,
|
|
16
|
+
ContactGroupResource,
|
|
17
|
+
ContactResource,
|
|
18
|
+
RoleResource
|
|
19
|
+
} from './AccessRights.resource';
|
|
20
|
+
import {
|
|
21
|
+
createInitialState,
|
|
22
|
+
sortOnAddedStateFirstAndContactName
|
|
23
|
+
} from './useAccessRightsForm.utils';
|
|
24
|
+
|
|
25
|
+
/** state */
|
|
26
|
+
|
|
27
|
+
type loadingState = 'idle' | 'loading';
|
|
28
|
+
|
|
29
|
+
const loadingStatusAtom = atom<loadingState>('idle');
|
|
30
|
+
|
|
31
|
+
type formOptions = {
|
|
32
|
+
contacts: Array<ContactResource | ContactGroupResource>;
|
|
33
|
+
roles: Array<RoleResource>;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const formOptionsAtom = atom<formOptions>({
|
|
37
|
+
contacts: [],
|
|
38
|
+
roles: []
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const contactAccessRightsAtom = atom<Array<ContactAccessRightStateResource>>(
|
|
42
|
+
[]
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
type StateStats = {
|
|
46
|
+
added: number;
|
|
47
|
+
removed: number;
|
|
48
|
+
updated: number;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const contactAccessRightsStateAtom = atom<{
|
|
52
|
+
isDirty: boolean;
|
|
53
|
+
isLoading: boolean;
|
|
54
|
+
stats: StateStats;
|
|
55
|
+
}>((get) => ({
|
|
56
|
+
isDirty: get(contactAccessRightsAtom).some(
|
|
57
|
+
({ state }) => state !== 'unchanged'
|
|
58
|
+
),
|
|
59
|
+
isLoading: get(loadingStatusAtom) === 'loading',
|
|
60
|
+
stats: {
|
|
61
|
+
added: get(contactAccessRightsAtom).filter(({ state }) => state === 'added')
|
|
62
|
+
.length,
|
|
63
|
+
removed: get(contactAccessRightsAtom).filter(
|
|
64
|
+
({ state }) => state === 'removed'
|
|
65
|
+
).length,
|
|
66
|
+
updated: get(contactAccessRightsAtom).filter(
|
|
67
|
+
({ state }) => state === 'updated'
|
|
68
|
+
).length
|
|
69
|
+
}
|
|
70
|
+
}));
|
|
71
|
+
|
|
72
|
+
type callbacks = {
|
|
73
|
+
onSubmit?: (values: Array<ContactAccessRightStateResource>) => void;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const callbacksAtom = atom<callbacks>({});
|
|
77
|
+
|
|
78
|
+
/** provider */
|
|
79
|
+
|
|
80
|
+
export type AccessRightsFormProviderProps = {
|
|
81
|
+
children: ReactNode;
|
|
82
|
+
initialValues?: Array<ContactAccessRightResource>;
|
|
83
|
+
loadingStatus?: loadingState;
|
|
84
|
+
onSubmit?: callbacks['onSubmit'];
|
|
85
|
+
options?: formOptions;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const AccessRightsFormProvider = ({
|
|
89
|
+
children,
|
|
90
|
+
initialValues,
|
|
91
|
+
options,
|
|
92
|
+
loadingStatus = 'idle',
|
|
93
|
+
onSubmit
|
|
94
|
+
}: AccessRightsFormProviderProps): ReactElement => {
|
|
95
|
+
const store = useRef(createStore()).current;
|
|
96
|
+
|
|
97
|
+
const setLoadingStatus = useSetAtom(loadingStatusAtom, { store });
|
|
98
|
+
const setFormOptions = useSetAtom(formOptionsAtom, { store });
|
|
99
|
+
const setContactAccessRights = useSetAtom(contactAccessRightsAtom, { store });
|
|
100
|
+
const setCallbacks = useSetAtom(callbacksAtom, { store });
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
setLoadingStatus(loadingStatus);
|
|
104
|
+
}, [loadingStatus]);
|
|
105
|
+
|
|
106
|
+
useEffect(() => {
|
|
107
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
108
|
+
options && setFormOptions(options);
|
|
109
|
+
}, [options]);
|
|
110
|
+
|
|
111
|
+
useEffect(() => {
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
113
|
+
onSubmit && setCallbacks({ onSubmit });
|
|
114
|
+
}, [onSubmit]);
|
|
115
|
+
|
|
116
|
+
useEffect(() => {
|
|
117
|
+
setContactAccessRights(
|
|
118
|
+
initialValues ? createInitialState(initialValues) : []
|
|
119
|
+
);
|
|
120
|
+
}, [initialValues]);
|
|
121
|
+
|
|
122
|
+
return <Provider store={store}>{children}</Provider>;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
/** hook */
|
|
126
|
+
|
|
127
|
+
type UseAccessRightsForm = {
|
|
128
|
+
addContactAccessRight: (
|
|
129
|
+
contactAccessRight: ContactAccessRightResource
|
|
130
|
+
) => void;
|
|
131
|
+
contactAccessRights: Array<ContactAccessRightStateResource>;
|
|
132
|
+
isDirty: boolean;
|
|
133
|
+
isLoading: boolean;
|
|
134
|
+
options: formOptions;
|
|
135
|
+
removeContactAccessRight: (
|
|
136
|
+
contactAccessRight: ContactAccessRightResource,
|
|
137
|
+
restore?: boolean
|
|
138
|
+
) => void;
|
|
139
|
+
stats: StateStats;
|
|
140
|
+
submit: () => void;
|
|
141
|
+
updateContactAccessRight: (
|
|
142
|
+
contactAccessRight: ContactAccessRightResource
|
|
143
|
+
) => void;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
const useAccessRightsForm = (): UseAccessRightsForm => {
|
|
147
|
+
const store = useStore();
|
|
148
|
+
|
|
149
|
+
const [contactAccessRights, setContactAccessRights] = useAtom(
|
|
150
|
+
contactAccessRightsAtom,
|
|
151
|
+
{ store }
|
|
152
|
+
);
|
|
153
|
+
const { isLoading, isDirty, stats } = useAtomValue(
|
|
154
|
+
contactAccessRightsStateAtom,
|
|
155
|
+
{ store }
|
|
156
|
+
);
|
|
157
|
+
const options = useAtomValue(formOptionsAtom, { store });
|
|
158
|
+
const callbacks = useAtomValue(callbacksAtom, { store });
|
|
159
|
+
|
|
160
|
+
const addContactAccessRight = (
|
|
161
|
+
contactAccessRight: ContactAccessRightResource
|
|
162
|
+
): void =>
|
|
163
|
+
setContactAccessRights((prev) => {
|
|
164
|
+
const isContactAlreadyAdded = prev.some(
|
|
165
|
+
({ contactAccessRight: c }) =>
|
|
166
|
+
c.contact?.id === contactAccessRight.contact?.id
|
|
167
|
+
);
|
|
168
|
+
|
|
169
|
+
return isContactAlreadyAdded
|
|
170
|
+
? prev
|
|
171
|
+
: [
|
|
172
|
+
...prev,
|
|
173
|
+
{
|
|
174
|
+
contactAccessRight,
|
|
175
|
+
state: 'added',
|
|
176
|
+
stateHistory: []
|
|
177
|
+
} as ContactAccessRightStateResource
|
|
178
|
+
].sort(sortOnAddedStateFirstAndContactName);
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
const removeContactAccessRight = (
|
|
182
|
+
contactAccessRight: ContactAccessRightResource,
|
|
183
|
+
restore = false
|
|
184
|
+
): void =>
|
|
185
|
+
setContactAccessRights((prev) => {
|
|
186
|
+
const contactAccessRightIndex = prev.findIndex(
|
|
187
|
+
({ contactAccessRight: prevContactAccessRight }) =>
|
|
188
|
+
prevContactAccessRight.contact?.id === contactAccessRight.contact?.id
|
|
189
|
+
);
|
|
190
|
+
|
|
191
|
+
if (contactAccessRightIndex === -1) {
|
|
192
|
+
return prev;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
const { stateHistory } = prev[contactAccessRightIndex];
|
|
196
|
+
|
|
197
|
+
if (restore) {
|
|
198
|
+
return [
|
|
199
|
+
...prev.slice(0, contactAccessRightIndex),
|
|
200
|
+
{
|
|
201
|
+
...prev[contactAccessRightIndex],
|
|
202
|
+
state: stateHistory[stateHistory.length - 1],
|
|
203
|
+
stateHistory: [...stateHistory, prev[contactAccessRightIndex].state]
|
|
204
|
+
} as ContactAccessRightStateResource,
|
|
205
|
+
...prev.slice(contactAccessRightIndex + 1)
|
|
206
|
+
];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (
|
|
210
|
+
prev[contactAccessRightIndex].state === 'added' ||
|
|
211
|
+
stateHistory[0] === 'added'
|
|
212
|
+
) {
|
|
213
|
+
return [
|
|
214
|
+
...prev.slice(0, contactAccessRightIndex),
|
|
215
|
+
...prev.slice(contactAccessRightIndex + 1)
|
|
216
|
+
];
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
return [
|
|
220
|
+
...prev.slice(0, contactAccessRightIndex),
|
|
221
|
+
{
|
|
222
|
+
...prev[contactAccessRightIndex],
|
|
223
|
+
state: 'removed',
|
|
224
|
+
stateHistory: [...stateHistory, prev[contactAccessRightIndex].state]
|
|
225
|
+
} as ContactAccessRightStateResource,
|
|
226
|
+
...prev.slice(contactAccessRightIndex + 1)
|
|
227
|
+
];
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
const updateContactAccessRight = (
|
|
231
|
+
contactAccessRight: ContactAccessRightResource
|
|
232
|
+
): void =>
|
|
233
|
+
setContactAccessRights((prev) => {
|
|
234
|
+
const contactAccessRightIndex = prev.findIndex(
|
|
235
|
+
({ contactAccessRight: prevContactAccessRight }) =>
|
|
236
|
+
prevContactAccessRight.contact?.id === contactAccessRight.contact?.id
|
|
237
|
+
);
|
|
238
|
+
|
|
239
|
+
if (contactAccessRightIndex === -1) {
|
|
240
|
+
return prev;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
const { stateHistory } = prev[contactAccessRightIndex];
|
|
244
|
+
|
|
245
|
+
const isAdded =
|
|
246
|
+
prev[contactAccessRightIndex].state === 'added' ||
|
|
247
|
+
stateHistory[0] === 'added';
|
|
248
|
+
const isUpdated =
|
|
249
|
+
prev[contactAccessRightIndex].state === 'updated' ||
|
|
250
|
+
stateHistory.findIndex((state) => state === 'updated') <
|
|
251
|
+
stateHistory.findIndex((state) => state === 'unchanged');
|
|
252
|
+
|
|
253
|
+
// eslint-disable-next-line no-nested-ternary
|
|
254
|
+
const state = isAdded ? 'added' : isUpdated ? 'unchanged' : 'updated';
|
|
255
|
+
|
|
256
|
+
return [
|
|
257
|
+
...prev.slice(0, contactAccessRightIndex),
|
|
258
|
+
{
|
|
259
|
+
contactAccessRight,
|
|
260
|
+
state,
|
|
261
|
+
stateHistory: [...stateHistory, prev[contactAccessRightIndex].state]
|
|
262
|
+
} as ContactAccessRightStateResource,
|
|
263
|
+
...prev.slice(contactAccessRightIndex + 1)
|
|
264
|
+
];
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
const submit = (): void => callbacks.onSubmit?.(contactAccessRights);
|
|
268
|
+
|
|
269
|
+
return {
|
|
270
|
+
addContactAccessRight,
|
|
271
|
+
contactAccessRights,
|
|
272
|
+
isDirty,
|
|
273
|
+
isLoading,
|
|
274
|
+
options,
|
|
275
|
+
removeContactAccessRight,
|
|
276
|
+
stats,
|
|
277
|
+
submit,
|
|
278
|
+
updateContactAccessRight
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
export { AccessRightsFormProvider, useAccessRightsForm };
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { ContactAccessRightStateResource } from './AccessRights.resource';
|
|
2
|
+
|
|
3
|
+
export const sortOnContactName = (
|
|
4
|
+
a: ContactAccessRightStateResource,
|
|
5
|
+
b: ContactAccessRightStateResource
|
|
6
|
+
): number =>
|
|
7
|
+
a.contactAccessRight.contact?.name.localeCompare(
|
|
8
|
+
b.contactAccessRight.contact?.name ?? ''
|
|
9
|
+
) || 0;
|
|
10
|
+
|
|
11
|
+
export const sortOnAddedStateFirstAndContactName = (
|
|
12
|
+
a: ContactAccessRightStateResource,
|
|
13
|
+
b: ContactAccessRightStateResource
|
|
14
|
+
): number => {
|
|
15
|
+
if (a.state === 'added' && b.state !== 'added') {
|
|
16
|
+
return -1;
|
|
17
|
+
}
|
|
18
|
+
if (a.state !== 'added' && b.state === 'added') {
|
|
19
|
+
return 1;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
a.contactAccessRight.contact?.name.localeCompare(
|
|
24
|
+
b.contactAccessRight.contact?.name ?? ''
|
|
25
|
+
) || 0
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export const createInitialState = (
|
|
30
|
+
values
|
|
31
|
+
): Array<ContactAccessRightStateResource> =>
|
|
32
|
+
values
|
|
33
|
+
?.map(
|
|
34
|
+
(contactAccessRight) =>
|
|
35
|
+
({
|
|
36
|
+
contactAccessRight,
|
|
37
|
+
state: 'unchanged',
|
|
38
|
+
stateHistory: []
|
|
39
|
+
} as ContactAccessRightStateResource)
|
|
40
|
+
)
|
|
41
|
+
.sort(sortOnAddedStateFirstAndContactName);
|
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
import { Provider, createStore } from 'jotai';
|
|
2
|
+
|
|
3
|
+
import { Method, SnackbarProvider, TestQueryProvider } from '../../..';
|
|
4
|
+
|
|
5
|
+
import { AccessRights } from './AccessRights';
|
|
6
|
+
import {
|
|
7
|
+
buildResult,
|
|
8
|
+
emptyAccessRights,
|
|
9
|
+
labels,
|
|
10
|
+
removedAccessRights,
|
|
11
|
+
roles,
|
|
12
|
+
simpleAccessRights,
|
|
13
|
+
updatedAccessRights
|
|
14
|
+
} from './storiesData';
|
|
15
|
+
|
|
16
|
+
const initialize = ({
|
|
17
|
+
initialValues = simpleAccessRights,
|
|
18
|
+
loading = false,
|
|
19
|
+
link = 'link'
|
|
20
|
+
}): unknown => {
|
|
21
|
+
const cancel = cy.stub();
|
|
22
|
+
const save = cy.stub();
|
|
23
|
+
|
|
24
|
+
cy.interceptAPIRequest({
|
|
25
|
+
alias: 'getContacts',
|
|
26
|
+
method: Method.GET,
|
|
27
|
+
path: '**/contacts?**',
|
|
28
|
+
response: buildResult(false)
|
|
29
|
+
});
|
|
30
|
+
cy.interceptAPIRequest({
|
|
31
|
+
alias: 'getContactGroups',
|
|
32
|
+
method: Method.GET,
|
|
33
|
+
path: '**/contact-groups?**',
|
|
34
|
+
response: buildResult(true)
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
cy.mount({
|
|
38
|
+
Component: (
|
|
39
|
+
<SnackbarProvider>
|
|
40
|
+
<TestQueryProvider>
|
|
41
|
+
<Provider store={createStore()}>
|
|
42
|
+
<AccessRights
|
|
43
|
+
cancel={cancel}
|
|
44
|
+
endpoints={{
|
|
45
|
+
contact: '/contacts',
|
|
46
|
+
contactGroup: '/contact-groups'
|
|
47
|
+
}}
|
|
48
|
+
initialValues={initialValues}
|
|
49
|
+
labels={labels}
|
|
50
|
+
link={link}
|
|
51
|
+
loading={loading}
|
|
52
|
+
roles={roles}
|
|
53
|
+
submit={save}
|
|
54
|
+
/>
|
|
55
|
+
</Provider>
|
|
56
|
+
</TestQueryProvider>
|
|
57
|
+
</SnackbarProvider>
|
|
58
|
+
)
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
cancel,
|
|
63
|
+
save
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
describe('Access rights', () => {
|
|
68
|
+
it('displays the access rights in loading state', () => {
|
|
69
|
+
initialize({ loading: true });
|
|
70
|
+
|
|
71
|
+
cy.contains('Share dashboard with').should('be.visible');
|
|
72
|
+
cy.contains('Contact').should('be.visible');
|
|
73
|
+
cy.contains('Contact group').should('be.visible');
|
|
74
|
+
cy.findByLabelText('Add a contact').should('be.visible');
|
|
75
|
+
cy.findByTestId('add_role').should('be.disabled');
|
|
76
|
+
cy.findByTestId('add').should('be.disabled');
|
|
77
|
+
cy.findByLabelText('Copy link').should('be.visible');
|
|
78
|
+
cy.findByLabelText('Cancel').should('be.visible');
|
|
79
|
+
cy.findByLabelText('Save').should('be.visible');
|
|
80
|
+
|
|
81
|
+
cy.makeSnapshot();
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('displays the access rights without link', () => {
|
|
85
|
+
initialize({ link: null });
|
|
86
|
+
|
|
87
|
+
cy.findByLabelText('Copy link').should('not.exist');
|
|
88
|
+
|
|
89
|
+
cy.makeSnapshot();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('displays the access rights with an empty list', () => {
|
|
93
|
+
initialize({ initialValues: emptyAccessRights });
|
|
94
|
+
|
|
95
|
+
cy.contains('The contact list is empty').should('be.visible');
|
|
96
|
+
|
|
97
|
+
cy.makeSnapshot();
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it('displays the access rights with an empty list', () => {
|
|
101
|
+
initialize({});
|
|
102
|
+
|
|
103
|
+
simpleAccessRights.forEach(({ name, email, isContactGroup, role }) => {
|
|
104
|
+
cy.contains(name).should('be.visible');
|
|
105
|
+
cy.contains(email).should('be.visible');
|
|
106
|
+
cy.get(`[data-groupChip="${name}"]`).should(
|
|
107
|
+
isContactGroup ? 'be.visible' : 'not.exist'
|
|
108
|
+
);
|
|
109
|
+
cy.findByTestId(`role-${name}`).should('have.value', role);
|
|
110
|
+
cy.findByTestId(`remove-${name}`).should('be.visible');
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
cy.makeSnapshot();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('displays a removed chip when the corresponding icon is clicked', () => {
|
|
117
|
+
initialize({});
|
|
118
|
+
|
|
119
|
+
cy.findByTestId(`remove-Leah McGlynn`).should(
|
|
120
|
+
'have.attr',
|
|
121
|
+
'data-removed',
|
|
122
|
+
'false'
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
cy.findByTestId(`remove-Leah McGlynn`).click();
|
|
126
|
+
|
|
127
|
+
cy.findByTestId(`remove-Leah McGlynn`).should(
|
|
128
|
+
'have.attr',
|
|
129
|
+
'data-removed',
|
|
130
|
+
'true'
|
|
131
|
+
);
|
|
132
|
+
cy.contains(labels.list.removed).should('be.visible');
|
|
133
|
+
|
|
134
|
+
cy.makeSnapshot();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it('restores the contact when the contact is removed and the corresponding icon is clicked', () => {
|
|
138
|
+
initialize({});
|
|
139
|
+
|
|
140
|
+
cy.findByTestId(`remove-Leah McGlynn`).click();
|
|
141
|
+
|
|
142
|
+
cy.findByTestId(`remove-Leah McGlynn`).should(
|
|
143
|
+
'have.attr',
|
|
144
|
+
'data-removed',
|
|
145
|
+
'true'
|
|
146
|
+
);
|
|
147
|
+
cy.contains(labels.list.removed).should('be.visible');
|
|
148
|
+
|
|
149
|
+
cy.findByTestId(`remove-Leah McGlynn`).click();
|
|
150
|
+
|
|
151
|
+
cy.findByTestId(`remove-Leah McGlynn`).should(
|
|
152
|
+
'have.attr',
|
|
153
|
+
'data-removed',
|
|
154
|
+
'false'
|
|
155
|
+
);
|
|
156
|
+
cy.contains(labels.list.removed).should('not.exist');
|
|
157
|
+
|
|
158
|
+
cy.makeSnapshot();
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
it('submits the new acces rights list without the removed contact', () => {
|
|
162
|
+
const { save } = initialize({});
|
|
163
|
+
|
|
164
|
+
cy.findByTestId(`remove-Leah McGlynn`).click();
|
|
165
|
+
|
|
166
|
+
cy.findByTestId(`remove-Leah McGlynn`).should(
|
|
167
|
+
'have.attr',
|
|
168
|
+
'data-removed',
|
|
169
|
+
'true'
|
|
170
|
+
);
|
|
171
|
+
cy.contains(labels.list.removed).should('be.visible');
|
|
172
|
+
cy.contains('1 removed').should('be.visible');
|
|
173
|
+
|
|
174
|
+
cy.contains(labels.actions.save)
|
|
175
|
+
.click()
|
|
176
|
+
.then(() => {
|
|
177
|
+
expect(save).to.have.been.calledWith(removedAccessRights);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
cy.makeSnapshot();
|
|
181
|
+
});
|
|
182
|
+
|
|
183
|
+
it('submits the new acces rights list with the updated contact', () => {
|
|
184
|
+
const { save } = initialize({});
|
|
185
|
+
|
|
186
|
+
cy.findByTestId(`role-Leah McGlynn`).parent().click();
|
|
187
|
+
|
|
188
|
+
cy.get('li[data-value="editor"]').click();
|
|
189
|
+
cy.contains(labels.list.updated).should('be.visible');
|
|
190
|
+
cy.contains('1 updated').should('be.visible');
|
|
191
|
+
|
|
192
|
+
cy.contains(labels.actions.save)
|
|
193
|
+
.click()
|
|
194
|
+
.then(() => {
|
|
195
|
+
expect(save).to.have.been.calledWith(updatedAccessRights);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
cy.makeSnapshot();
|
|
199
|
+
});
|
|
200
|
+
|
|
201
|
+
it('removes the updated chip when the contact role is updated and its initial role is assigned back', () => {
|
|
202
|
+
initialize({});
|
|
203
|
+
|
|
204
|
+
cy.findByTestId(`role-Leah McGlynn`).parent().click();
|
|
205
|
+
|
|
206
|
+
cy.get('li[data-value="editor"]').click();
|
|
207
|
+
cy.contains(labels.list.updated).should('be.visible');
|
|
208
|
+
|
|
209
|
+
cy.get('li[data-value="viewer"]').click();
|
|
210
|
+
cy.contains(labels.list.updated).should('not.exist');
|
|
211
|
+
|
|
212
|
+
cy.makeSnapshot();
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
it('retrieves contacts when the contact radio is selected', () => {
|
|
216
|
+
initialize({});
|
|
217
|
+
|
|
218
|
+
cy.contains(labels.add.contact).click();
|
|
219
|
+
cy.findByLabelText(labels.add.autocompleteContact).click();
|
|
220
|
+
|
|
221
|
+
cy.waitForRequest('@getContacts');
|
|
222
|
+
|
|
223
|
+
cy.makeSnapshot();
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('retrieves contact groups when the contact group radio is selected', () => {
|
|
227
|
+
initialize({});
|
|
228
|
+
|
|
229
|
+
cy.contains(labels.add.contactGroup).click();
|
|
230
|
+
cy.findByLabelText(labels.add.autocompleteContactGroup).click();
|
|
231
|
+
|
|
232
|
+
cy.waitForRequest('@getContactGroups');
|
|
233
|
+
|
|
234
|
+
cy.makeSnapshot();
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
it('adds the contact as viewer when a contact is selected and the corresponding button is clicked', () => {
|
|
238
|
+
initialize({});
|
|
239
|
+
|
|
240
|
+
cy.contains(labels.add.contact).click();
|
|
241
|
+
cy.findByLabelText(labels.add.autocompleteContact).click();
|
|
242
|
+
|
|
243
|
+
cy.waitForRequest('@getContacts');
|
|
244
|
+
|
|
245
|
+
cy.contains('Entity 10').click();
|
|
246
|
+
|
|
247
|
+
cy.findByTestId('add').click();
|
|
248
|
+
|
|
249
|
+
cy.contains('Entity 10').should('be.visible');
|
|
250
|
+
|
|
251
|
+
cy.findByTestId('role-Entity 10').should('have.value', 'viewer');
|
|
252
|
+
cy.contains(labels.list.added).should('be.visible');
|
|
253
|
+
|
|
254
|
+
cy.makeSnapshot();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('adds the contact group as editor when a contact group is selected and the corresponding button is clicked', () => {
|
|
258
|
+
initialize({});
|
|
259
|
+
|
|
260
|
+
cy.contains(labels.add.contactGroup).click();
|
|
261
|
+
cy.findByLabelText(labels.add.autocompleteContactGroup).click();
|
|
262
|
+
|
|
263
|
+
cy.waitForRequest('@getContactGroups');
|
|
264
|
+
|
|
265
|
+
cy.contains('Entity Group 10').click();
|
|
266
|
+
cy.findByTestId('add_role').parent().click();
|
|
267
|
+
cy.get('li[data-value="editor"]').click();
|
|
268
|
+
cy.findByTestId('add').click();
|
|
269
|
+
|
|
270
|
+
cy.contains('Entity Group 10').should('be.visible');
|
|
271
|
+
|
|
272
|
+
cy.findByTestId('role-Entity Group 10').should('have.value', 'editor');
|
|
273
|
+
cy.contains(labels.list.added).should('be.visible');
|
|
274
|
+
cy.contains('1 added').should('be.visible');
|
|
275
|
+
|
|
276
|
+
cy.makeSnapshot();
|
|
277
|
+
});
|
|
278
|
+
|
|
279
|
+
it('displays statistics when a contact is added, a contact is updated and a contact is removed', () => {
|
|
280
|
+
initialize({});
|
|
281
|
+
|
|
282
|
+
cy.contains(labels.add.contactGroup).click();
|
|
283
|
+
cy.findByLabelText(labels.add.autocompleteContactGroup).click();
|
|
284
|
+
|
|
285
|
+
cy.waitForRequest('@getContactGroups');
|
|
286
|
+
|
|
287
|
+
cy.contains('Entity Group 10').click();
|
|
288
|
+
cy.findByTestId('add_role').parent().click();
|
|
289
|
+
cy.get('li[data-value="editor"]').click();
|
|
290
|
+
cy.findByTestId('add').click();
|
|
291
|
+
|
|
292
|
+
cy.contains('Entity Group 10').should('be.visible');
|
|
293
|
+
|
|
294
|
+
cy.findByTestId(`role-Leah McGlynn`).parent().click();
|
|
295
|
+
cy.get('li[data-value="editor"]').click();
|
|
296
|
+
|
|
297
|
+
cy.findByTestId('remove-Jody Blanda').click();
|
|
298
|
+
|
|
299
|
+
cy.contains('1 added | 1 updated | 1 removed').should('be.visible');
|
|
300
|
+
|
|
301
|
+
cy.makeSnapshot();
|
|
302
|
+
});
|
|
303
|
+
|
|
304
|
+
it('clears the autocomplete when a contact is selected and the contact type is changed', () => {
|
|
305
|
+
initialize({});
|
|
306
|
+
|
|
307
|
+
cy.contains(labels.add.contact).click();
|
|
308
|
+
cy.findByLabelText(labels.add.autocompleteContact).click();
|
|
309
|
+
|
|
310
|
+
cy.waitForRequest('@getContacts');
|
|
311
|
+
|
|
312
|
+
cy.contains('Entity 10').click();
|
|
313
|
+
cy.findByLabelText(labels.add.autocompleteContact).should(
|
|
314
|
+
'have.value',
|
|
315
|
+
'Entity 10'
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
cy.contains(labels.add.contactGroup).click();
|
|
319
|
+
cy.findByLabelText(labels.add.autocompleteContactGroup).should(
|
|
320
|
+
'have.value',
|
|
321
|
+
''
|
|
322
|
+
);
|
|
323
|
+
|
|
324
|
+
cy.makeSnapshot();
|
|
325
|
+
});
|
|
326
|
+
|
|
327
|
+
it('removes the contact from the list when the contact has been to the list and the corresponding button is clicked', () => {
|
|
328
|
+
initialize({});
|
|
329
|
+
|
|
330
|
+
cy.contains(labels.add.contact).click();
|
|
331
|
+
cy.findByLabelText(labels.add.autocompleteContact).click();
|
|
332
|
+
|
|
333
|
+
cy.waitForRequest('@getContacts');
|
|
334
|
+
|
|
335
|
+
cy.contains('Entity 10').click();
|
|
336
|
+
|
|
337
|
+
cy.findByTestId('add').click();
|
|
338
|
+
|
|
339
|
+
cy.contains('Entity 10').should('be.visible');
|
|
340
|
+
|
|
341
|
+
cy.contains(labels.list.added).should('be.visible');
|
|
342
|
+
|
|
343
|
+
cy.findByTestId('remove-Entity 10').click();
|
|
344
|
+
|
|
345
|
+
cy.contains('Entity 10').should('not.exist');
|
|
346
|
+
cy.contains(labels.list.added).should('not.exist');
|
|
347
|
+
|
|
348
|
+
cy.makeSnapshot();
|
|
349
|
+
});
|
|
350
|
+
});
|