@delmaredigital/payload-experiments 0.4.0-rc.3 → 0.4.0-rc.5
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/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +2 -2
- package/dist/admin/PlacementStatus.js +1 -1
- package/dist/admin/TestsDashboardCards.js +2 -2
- package/dist/admin/TestsNavLink.js +2 -2
- package/dist/admin/blocks/BlockPanel.js +3 -3
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.js +1 -1
- package/dist/admin/blocks/model.js +1 -1
- package/dist/admin/blocks/statusCache.js +1 -1
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +2 -2
- package/dist/admin/copy/blocks.js +3 -2
- package/dist/admin/copy/goals.d.ts +5 -1
- package/dist/admin/copy/goals.js +9 -3
- package/dist/admin/goals/XpGoalField.js +155 -129
- package/dist/admin/goals/xpGoalField.css +2 -3
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +6 -13
- package/dist/admin/surface/SurfaceShell.js +2 -2
- package/dist/admin/surface/TestsHome.d.ts +1 -1
- package/dist/admin/surface/TestsHome.js +3 -3
- package/dist/admin/surface/TestsSurface.js +2 -2
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -1
- package/dist/admin/surface/goals/GoalForm.js +55 -7
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +4 -4
- package/dist/admin/surface/goals/data.js +2 -2
- package/dist/admin/surface/goals/goals.css +7 -0
- package/dist/admin/surface/goals/goals.model.d.ts +11 -1
- package/dist/admin/surface/goals/goals.model.js +43 -0
- package/dist/admin/surface/home.model.d.ts +1 -1
- package/dist/admin/surface/home.model.js +5 -5
- package/dist/admin/surface/newTest/NewTest.d.ts +1 -1
- package/dist/admin/surface/newTest/NewTest.js +1 -1
- package/dist/admin/surface/newTest/PageWizard.d.ts +1 -1
- package/dist/admin/surface/newTest/PageWizard.js +23 -25
- package/dist/admin/surface/results/ResultsHeader.d.ts +2 -2
- package/dist/admin/surface/results/ResultsHeader.js +22 -15
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +45 -156
- package/dist/admin/views/ExperimentsRootView.js +1 -1
- package/dist/admin/views/TestsNavLinkServer.js +1 -1
- package/dist/admin/views/renderCollectionList.js +1 -1
- package/dist/admin/views/renderTestsSurface.js +1 -1
- package/dist/blocks/placementLocale.d.ts +21 -0
- package/dist/blocks/placementLocale.js +115 -0
- package/dist/collections/experiments/config.js +1 -1
- package/dist/collections/metrics.js +1 -1
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +107 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/index.js +28 -1
- package/dist/errors.d.ts +1 -0
- package/dist/errors.js +2 -0
- package/dist/fields/xpGoal.js +1 -1
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +1 -1
- package/dist/goals/picker/clickGoalPicker.model.d.ts +8 -1
- package/dist/goals/picker/clickGoalPicker.model.js +20 -2
- package/dist/goals/picker/copy.d.ts +4 -2
- package/dist/goals/picker/copy.js +4 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/hooks/blockRemovalRule.d.ts +29 -0
- package/dist/hooks/blockRemovalRule.js +141 -0
- package/dist/hooks/pageGuard.d.ts +24 -2
- package/dist/hooks/pageGuard.js +178 -24
- package/dist/lib/placementPages.d.ts +9 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +1 -4
- package/dist/onInit.js +22 -0
- package/dist/plugin.js +2 -1
- package/dist/puck/ExperimentPicker.js +25 -10
- package/dist/puck/copy.d.ts +4 -1
- package/dist/puck/copy.js +4 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +21 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +147 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +11 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +73 -9
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.js +690 -79
- package/dist/puck/editor/LeftoverVersions.d.ts +13 -0
- package/dist/puck/editor/LeftoverVersions.js +115 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +3 -0
- package/dist/puck/editor/QuickTestActions.js +50 -0
- package/dist/puck/editor/ResultsReadout.js +8 -5
- package/dist/puck/editor/VersionBuilder.d.ts +20 -6
- package/dist/puck/editor/VersionBuilder.js +80 -50
- package/dist/puck/editor/armWrites.d.ts +3 -1
- package/dist/puck/editor/armWrites.js +2 -1
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -3
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +42 -5
- package/dist/puck/editor/copy.js +43 -6
- package/dist/puck/editor/editor.chrome.css +44 -0
- package/dist/puck/editor/editor.css +68 -0
- package/dist/puck/editor/editor.model.d.ts +14 -0
- package/dist/puck/editor/editor.model.js +58 -1
- package/dist/puck/editor/editorSurface.d.ts +10 -0
- package/dist/puck/editor/editorSurface.js +65 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/localPlacements.d.ts +2 -0
- package/dist/puck/editor/localPlacements.js +29 -0
- package/dist/puck/editor/outlineVersion.d.ts +5 -0
- package/dist/puck/editor/outlineVersion.js +36 -0
- package/dist/puck/editor/placementsCache.d.ts +50 -0
- package/dist/puck/editor/placementsCache.js +258 -0
- package/dist/puck/editor/sidebar.d.ts +12 -0
- package/dist/puck/editor/sidebar.js +77 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +14 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +109 -98
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/{admin → testSurface}/actions/DecideDialog.d.ts +2 -1
- package/dist/{admin → testSurface}/actions/DecideDialog.js +6 -4
- package/dist/{admin → testSurface}/api.js +5 -6
- package/dist/{admin → testSurface}/copy/common.d.ts +3 -1
- package/dist/{admin → testSurface}/copy/common.js +5 -1
- package/dist/{admin → testSurface}/copy/readiness.d.ts +20 -1
- package/dist/{admin → testSurface}/copy/readiness.js +25 -1
- package/dist/{admin → testSurface}/copy/testPage.d.ts +4 -0
- package/dist/{admin → testSurface}/copy/testPage.js +8 -2
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +1 -1
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +9 -0
- package/dist/testSurface/readPreflight.js +38 -0
- package/dist/testSurface/readinessRead.d.ts +50 -0
- package/dist/testSurface/readinessRead.js +46 -0
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/surface/contracts.d.ts +7 -2
- package/dist/testSurface/surface/editorPlacement.d.ts +21 -0
- package/dist/testSurface/surface/editorPlacement.js +60 -0
- package/dist/{admin → testSurface}/surface/pageBlock/parts.js +19 -9
- package/dist/testSurface/surface/pagePicker/pagePicker.css +10 -0
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.js +37 -7
- package/dist/testSurface/surface/readiness/Banner.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.js +106 -68
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +9 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +66 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +13 -0
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.js +51 -36
- package/dist/{admin → testSurface}/surface/readiness/useTransition.d.ts +5 -2
- package/dist/testSurface/surface/readiness/useTransition.js +98 -0
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +2 -2
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +18 -11
- package/dist/testSurface/surface/setting/setting.css +17 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +4 -2
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +2 -1
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +1 -2
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +80 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +5 -0
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +213 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/{admin → testSurface}/surface/test/VersionsSection.js +13 -6
- package/dist/testSurface/surface/test/testPage.css +104 -0
- package/dist/{admin → testSurface}/surface/useTestDocument.d.ts +9 -2
- package/dist/{admin → testSurface}/surface/useTestDocument.js +92 -46
- package/dist/{admin → testSurface}/surfaceUrls.js +1 -1
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +24 -0
- package/dist/transitions/placementInteractions.js +1 -1
- package/dist/transitions/placements.d.ts +27 -8
- package/dist/transitions/placements.js +77 -6
- package/dist/transitions/preflightData.js +1 -1
- package/dist/transitions/start.js +2 -2
- package/dist/types/endpoints.d.ts +1 -1
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/Dialog.d.ts +4 -1
- package/dist/ui/Dialog.js +41 -3
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Tabs.d.ts +4 -3
- package/dist/ui/Tabs.js +47 -32
- package/dist/ui/ui.css +24 -0
- package/package.json +1 -1
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/results/results.css +0 -64
- package/dist/admin/styles.css +0 -10
- package/dist/admin/styles.d.ts +0 -2
- package/dist/admin/styles.js +0 -3
- package/dist/admin/surface/pagePicker/pagePicker.css +0 -10
- package/dist/admin/surface/readiness/Banner.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- package/dist/admin/surface/readiness/useTransition.js +0 -35
- package/dist/admin/surface/setting/setting.css +0 -17
- package/dist/admin/surface/test/GoalSection.d.ts +0 -2
- package/dist/admin/surface/test/LengthSection.d.ts +0 -2
- package/dist/admin/surface/test/Section.js +0 -48
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/testPage.css +0 -92
- /package/dist/{admin → testSurface}/PreviewLinks.d.ts +0 -0
- /package/dist/{admin → testSurface}/PreviewLinks.js +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/MakeContentResult.js +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/actions.model.js +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/actions/decide.model.js +0 -0
- /package/dist/{admin → testSurface}/allocation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/allocation.model.js +0 -0
- /package/dist/{admin → testSurface}/api.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/arms.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/pageTarget.model.js +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/arms/params.model.js +0 -0
- /package/dist/{admin → testSurface}/copy/actions.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/actions.js +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/advanced.js +0 -0
- /package/dist/{admin → testSurface}/copy/arms.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/arms.js +0 -0
- /package/dist/{admin → testSurface}/copy/audience.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/audience.js +0 -0
- /package/dist/{admin → testSurface}/copy/metrics.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/metrics.js +0 -0
- /package/dist/{admin → testSurface}/copy/pages.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/pages.js +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/recommendation.js +0 -0
- /package/dist/{admin → testSurface}/copy/results.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/results.js +0 -0
- /package/dist/{admin → testSurface}/copy/review.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/review.js +0 -0
- /package/dist/{admin → testSurface}/copy/setting.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/setting.js +0 -0
- /package/dist/{admin → testSurface}/copy/surface.d.ts +0 -0
- /package/dist/{admin → testSurface}/copy/surface.js +0 -0
- /package/dist/{admin → testSurface}/format/date.d.ts +0 -0
- /package/dist/{admin → testSurface}/format/date.js +0 -0
- /package/dist/{admin → testSurface}/labels.d.ts +0 -0
- /package/dist/{admin → testSurface}/labels.js +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/lockedNotice.model.js +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/placementLabels.model.js +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.d.ts +0 -0
- /package/dist/{admin → testSurface}/placements/usePlacementLabels.js +0 -0
- /package/dist/{admin → testSurface}/reload.d.ts +0 -0
- /package/dist/{admin → testSurface}/reload.js +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CappedCell.js +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/CiChart.js +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataQualityPanel.js +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/DataTable.js +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/StatTile.js +0 -0
- /package/dist/{admin → testSurface}/results/VerdictHero.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/VerdictHero.js +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/chart.model.js +0 -0
- /package/dist/{admin → testSurface}/results/format.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/format.js +0 -0
- /package/dist/{admin → testSurface}/results/legacy.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/legacy.js +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/releasePages.model.js +0 -0
- /package/dist/{admin → testSurface}/results/results.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/results.model.js +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.d.ts +0 -0
- /package/dist/{admin → testSurface}/results/snapshot.js +0 -0
- /package/dist/{admin → testSurface}/review/review.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/review/review.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/contracts.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/pageBlock.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/pageBlock/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/CopyRoute.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/PageCombobox.js +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/ReleasePages.js +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/results/useResults.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/useResults.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.js +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/setting.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/AdvancedSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/PageHoldout.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/fields.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/jumpToSection.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/pageParts.js +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/testPage.model.js +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/testDocument.model.js +0 -0
- /package/dist/{admin → testSurface}/surfaceUrls.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/targeting/targeting.model.js +0 -0
- /package/dist/{admin → testSurface}/theme.d.ts +0 -0
- /package/dist/{admin → testSurface}/theme.js +0 -0
- /package/dist/{admin → testSurface}/useApi.d.ts +0 -0
- /package/dist/{admin → testSurface}/useApi.js +0 -0
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { canStartTest, readyToStart } from '../../readinessRead.js';
|
|
3
4
|
import { useEffect, useState } from 'react';
|
|
4
5
|
import { Button } from '../../../ui/Button.js';
|
|
5
6
|
import { SaveStatus, saveStatusMessage } from './SaveStatus.js';
|
|
6
7
|
import { jumpToSection } from '../test/jumpToSection.js';
|
|
7
8
|
import { actionGroupLabel, availableActions } from '../../actions/actions.model.js';
|
|
8
9
|
import { createApi } from '../../api.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
10
|
+
import { TEST_PAGE } from '../../copy/testPage.js';
|
|
11
|
+
import { READINESS_COPY as C, decidedCopy, fixFieldsNext, runningCopy, stoppedCopy } from '../../copy/readiness.js';
|
|
12
|
+
import { READINESS, daysRemaining, displayDate, blockingSteps, pageReadinessContext, errorSection } from './readiness.model.js';
|
|
11
13
|
import { AddMetricAction, AllocateAction, ConfirmAction } from './ActionDialogs.js';
|
|
12
14
|
import { preflightPlacementLabel } from '../../placements/placementLabels.js';
|
|
13
15
|
import { placementUncheckedCopy } from '../../copy/readiness.js';
|
|
14
16
|
import { useTransition } from './useTransition.js';
|
|
17
|
+
import { BlockerList } from './BlockerList.js';
|
|
15
18
|
const RUNNING_ACTIONS = [
|
|
16
19
|
'stop',
|
|
17
20
|
'add-metric',
|
|
18
21
|
'allocate'
|
|
19
22
|
];
|
|
20
|
-
export function
|
|
21
|
-
return props.test.doc ? /*#__PURE__*/ _jsx(ReadinessContent, {
|
|
22
|
-
...props
|
|
23
|
-
}, `${props.test.doc.id}/${props.test.doc.status}`) : null;
|
|
24
|
-
}
|
|
25
|
-
export function ReadinessContent({ test, surface, resultsVersion, bar = false }) {
|
|
23
|
+
export function ReadinessContent({ test, surface, resultsVersion }) {
|
|
26
24
|
const [selected, setSelected] = useState(null);
|
|
27
25
|
const [people, setPeople] = useState(null);
|
|
28
|
-
const transition = useTransition(test);
|
|
26
|
+
const transition = useTransition(test, undefined, surface);
|
|
29
27
|
const doc = test.doc;
|
|
30
28
|
useEffect(()=>{
|
|
31
29
|
let active = true;
|
|
@@ -61,11 +59,38 @@ export function ReadinessContent({ test, surface, resultsVersion, bar = false })
|
|
|
61
59
|
}
|
|
62
60
|
} : check)
|
|
63
61
|
} : null;
|
|
64
|
-
const
|
|
62
|
+
const readinessBlockers = blockingSteps(labelledPreflight, pageReadinessContext(doc, test.preflight, surface));
|
|
65
63
|
const setup = doc.status === 'draft' || doc.status === 'stopped';
|
|
66
|
-
const ready =
|
|
64
|
+
const ready = readyToStart(test, surface.editorPlacementMessage);
|
|
65
|
+
const startEnabled = !transition.checking && canStartTest(test, surface.editorPlacementMessage);
|
|
67
66
|
const unsaved = test.hasUnsaved || test.saving === 'saving';
|
|
68
|
-
const
|
|
67
|
+
const blockers = [
|
|
68
|
+
...readinessBlockers
|
|
69
|
+
];
|
|
70
|
+
if (unsaved && !test.stale) blockers.unshift({
|
|
71
|
+
section: 'header',
|
|
72
|
+
sentence: C.saveFirst,
|
|
73
|
+
code: 'unsaved'
|
|
74
|
+
});
|
|
75
|
+
else if (!test.preflight && !test.preflightError) blockers.unshift({
|
|
76
|
+
section: 'header',
|
|
77
|
+
sentence: C.checking,
|
|
78
|
+
code: 'checking'
|
|
79
|
+
});
|
|
80
|
+
const errorSections = [
|
|
81
|
+
...new Set(Object.keys(test.errors).filter((path)=>path !== '_section').map((path)=>errorSection(path) ?? 'what'))
|
|
82
|
+
];
|
|
83
|
+
for (const section of errorSections.reverse())blockers.unshift({
|
|
84
|
+
section,
|
|
85
|
+
sentence: test.stale ? C.reloadFirst : fixFieldsNext(TEST_PAGE.sections[section]),
|
|
86
|
+
code: `validation:${section}`
|
|
87
|
+
});
|
|
88
|
+
if (test.errors._section || test.stale) blockers.unshift({
|
|
89
|
+
section: 'what',
|
|
90
|
+
sentence: test.stale ? C.reloadFirst : C.reloadAfterError,
|
|
91
|
+
code: 'save-error'
|
|
92
|
+
});
|
|
93
|
+
const startReason = blockers[0]?.sentence ?? test.preflightError ?? (!ready ? C.checking : undefined);
|
|
69
94
|
const actions = availableActions({
|
|
70
95
|
status: doc.status,
|
|
71
96
|
kind: doc.kind,
|
|
@@ -80,48 +105,10 @@ export function ReadinessContent({ test, surface, resultsVersion, bar = false })
|
|
|
80
105
|
label: C.allocate
|
|
81
106
|
} : action);
|
|
82
107
|
const action = actions.find((item)=>item.id === selected);
|
|
83
|
-
const sentence =
|
|
108
|
+
const sentence = transition.busy ? C.changing : setup ? ready && !blockers.length ? C.ready : null : doc.status === 'running' ? runningCopy(displayDate(doc.startedAt), people, daysRemaining(doc, Date.now())) : doc.status === 'decided' ? decidedCopy(displayDate(doc.decidedAt), winner) : C.archived;
|
|
84
109
|
return /*#__PURE__*/ _jsxs("div", {
|
|
85
|
-
className: `xp-readiness xp-readiness--${setup && ready ? 'ready' : 'neutral'}
|
|
110
|
+
className: `xp-readiness xp-readiness--${setup && ready && !blockers.length && !transition.busy ? 'ready' : 'neutral'} xp-readiness--bar xp-tests-container`,
|
|
86
111
|
children: [
|
|
87
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
88
|
-
className: "xp-readiness__state",
|
|
89
|
-
children: [
|
|
90
|
-
bar ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
91
|
-
children: [
|
|
92
|
-
/*#__PURE__*/ _jsx(SaveStatus, {
|
|
93
|
-
test: test
|
|
94
|
-
}),
|
|
95
|
-
sentence && (saveStatusMessage(test) || test.preflightError) ? /*#__PURE__*/ _jsx("span", {
|
|
96
|
-
className: "xp-readiness__separator",
|
|
97
|
-
"aria-hidden": "true",
|
|
98
|
-
children: "·"
|
|
99
|
-
}) : null
|
|
100
|
-
]
|
|
101
|
-
}) : null,
|
|
102
|
-
sentence ? /*#__PURE__*/ _jsx("p", {
|
|
103
|
-
role: "status",
|
|
104
|
-
children: setup && next && !ready && next.section !== 'header' ? /*#__PURE__*/ _jsxs("a", {
|
|
105
|
-
href: `#section-${next.section}`,
|
|
106
|
-
onClick: (event)=>{
|
|
107
|
-
event.preventDefault();
|
|
108
|
-
if (next.section !== 'header') jumpToSection(next.section, next.arm);
|
|
109
|
-
},
|
|
110
|
-
children: [
|
|
111
|
-
sentence,
|
|
112
|
-
next.nextStep ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
113
|
-
children: [
|
|
114
|
-
/*#__PURE__*/ _jsx("br", {}),
|
|
115
|
-
/*#__PURE__*/ _jsx("span", {
|
|
116
|
-
children: next.nextStep
|
|
117
|
-
})
|
|
118
|
-
]
|
|
119
|
-
}) : null
|
|
120
|
-
]
|
|
121
|
-
}) : sentence
|
|
122
|
-
}) : null
|
|
123
|
-
]
|
|
124
|
-
}),
|
|
125
112
|
setup && test.preflight?.checks.some((check)=>check.code === 'page-targets-unchecked' && check.warning) ? /*#__PURE__*/ _jsx("p", {
|
|
126
113
|
children: C.uncheckedPages
|
|
127
114
|
}) : null,
|
|
@@ -140,29 +127,80 @@ export function ReadinessContent({ test, surface, resultsVersion, bar = false })
|
|
|
140
127
|
}) : placementUncheckedCopy(placement.title) : READINESS[check.code].next(check.detail, doc)
|
|
141
128
|
}, `${check.code}:${index}`);
|
|
142
129
|
}),
|
|
143
|
-
|
|
144
|
-
|
|
130
|
+
[
|
|
131
|
+
...new Map(test.preflight?.goalNotes?.map((note)=>[
|
|
132
|
+
String(note.metricId),
|
|
133
|
+
note
|
|
134
|
+
])).values()
|
|
135
|
+
].map((note)=>/*#__PURE__*/ _jsxs("p", {
|
|
136
|
+
className: "xp-readiness__warning",
|
|
137
|
+
children: [
|
|
138
|
+
/*#__PURE__*/ _jsx("span", {
|
|
139
|
+
"aria-hidden": "true",
|
|
140
|
+
children: "⚠ "
|
|
141
|
+
}),
|
|
142
|
+
note.message
|
|
143
|
+
]
|
|
145
144
|
}, note.metricId)),
|
|
146
145
|
doc.status === 'stopped' ? /*#__PURE__*/ _jsx("p", {
|
|
147
146
|
children: stoppedCopy(displayDate(doc.stoppedAt))
|
|
148
147
|
}) : null,
|
|
148
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
149
|
+
className: "xp-readiness__state",
|
|
150
|
+
children: [
|
|
151
|
+
/*#__PURE__*/ _jsx(SaveStatus, {
|
|
152
|
+
test: test,
|
|
153
|
+
messageInBlockerList: setup && !!test.preflight && !test.preflightError
|
|
154
|
+
}),
|
|
155
|
+
sentence && (saveStatusMessage(test) || test.preflightError) ? /*#__PURE__*/ _jsx("span", {
|
|
156
|
+
className: "xp-readiness__separator",
|
|
157
|
+
"aria-hidden": "true",
|
|
158
|
+
children: "·"
|
|
159
|
+
}) : null,
|
|
160
|
+
sentence ? /*#__PURE__*/ _jsx("p", {
|
|
161
|
+
role: "status",
|
|
162
|
+
children: sentence
|
|
163
|
+
}) : null,
|
|
164
|
+
setup ? /*#__PURE__*/ _jsx(BlockerList, {
|
|
165
|
+
steps: blockers,
|
|
166
|
+
renderSentence: (_, index)=>{
|
|
167
|
+
const step = blockers[index];
|
|
168
|
+
return step.section === 'header' ? step.sentence : /*#__PURE__*/ _jsx("a", {
|
|
169
|
+
href: `#section-${step.section}`,
|
|
170
|
+
onClick: (event)=>{
|
|
171
|
+
event.preventDefault();
|
|
172
|
+
if (step.section !== 'header') jumpToSection(step.section, step.arm);
|
|
173
|
+
},
|
|
174
|
+
children: step.sentence
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}) : null
|
|
178
|
+
]
|
|
179
|
+
}),
|
|
149
180
|
/*#__PURE__*/ _jsx("div", {
|
|
150
181
|
className: "xp-readiness__actions",
|
|
151
182
|
children: actions.map((item)=>{
|
|
152
|
-
const reason = item.id === 'start' ? startReason : unsaved ? C.saveFirst : item.id === 'allocate' && doc.allocation >= 100 ? C.everyone : undefined;
|
|
153
|
-
const disabled = transition.busy || !!selected || !!reason;
|
|
154
|
-
return /*#__PURE__*/
|
|
183
|
+
const reason = item.id === 'start' ? startReason : test.stale ? C.reloadFirst : unsaved ? C.saveFirst : item.id === 'allocate' && doc.allocation >= 100 ? C.everyone : undefined;
|
|
184
|
+
const disabled = transition.busy || !!selected || !!reason || item.id === 'start' && !startEnabled;
|
|
185
|
+
return /*#__PURE__*/ _jsxs("span", {
|
|
155
186
|
title: reason,
|
|
156
|
-
children:
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
187
|
+
children: [
|
|
188
|
+
reason && item.id !== 'start' ? /*#__PURE__*/ _jsx("span", {
|
|
189
|
+
className: "xp-readiness-action-reason",
|
|
190
|
+
children: reason
|
|
191
|
+
}) : null,
|
|
192
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
193
|
+
busy: transition.busy,
|
|
194
|
+
variant: item.tone === 'primary' || item.id === 'stop' ? 'primary' : 'secondary',
|
|
195
|
+
disabled: disabled,
|
|
196
|
+
onClick: ()=>{
|
|
197
|
+
if (disabled) return;
|
|
198
|
+
if (item.id === 'start' && doc.status === 'draft') void transition.run('start', ()=>createApi(surface.apiRoute).start(doc.id));
|
|
199
|
+
else setSelected(item.id);
|
|
200
|
+
},
|
|
201
|
+
children: item.label
|
|
202
|
+
})
|
|
203
|
+
]
|
|
166
204
|
}, item.id);
|
|
167
205
|
})
|
|
168
206
|
}),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import '../../../ui/ui.css';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
/** The footer and sidebar show the same bounded list, including other pages. */
|
|
4
|
+
export declare function BlockerList({ steps, renderSentence }: {
|
|
5
|
+
steps: readonly {
|
|
6
|
+
sentence: string;
|
|
7
|
+
}[];
|
|
8
|
+
renderSentence?: (step: {
|
|
9
|
+
sentence: string;
|
|
10
|
+
}, index: number) => ReactNode;
|
|
11
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import '../../../ui/ui.css';
|
|
4
|
+
import { READINESS_COPY, moreBlockers } from '../../copy/readiness.js';
|
|
5
|
+
/** The footer and sidebar show the same bounded list, including other pages. */ export function BlockerList({ steps, renderSentence = (step)=>step.sentence }) {
|
|
6
|
+
return steps.length ? /*#__PURE__*/ _jsxs("div", {
|
|
7
|
+
className: "xp-readiness__blockers",
|
|
8
|
+
role: "status",
|
|
9
|
+
children: [
|
|
10
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
11
|
+
children: READINESS_COPY.beforeStart
|
|
12
|
+
}),
|
|
13
|
+
/*#__PURE__*/ _jsxs("ul", {
|
|
14
|
+
children: [
|
|
15
|
+
steps.slice(0, 3).map((step, index)=>/*#__PURE__*/ _jsxs("li", {
|
|
16
|
+
children: [
|
|
17
|
+
/*#__PURE__*/ _jsx("span", {
|
|
18
|
+
"aria-hidden": "true",
|
|
19
|
+
children: "⊗ "
|
|
20
|
+
}),
|
|
21
|
+
renderSentence(step, index)
|
|
22
|
+
]
|
|
23
|
+
}, index)),
|
|
24
|
+
steps.length > 3 ? /*#__PURE__*/ _jsx("li", {
|
|
25
|
+
children: moreBlockers(steps.length - 3)
|
|
26
|
+
}) : null
|
|
27
|
+
]
|
|
28
|
+
})
|
|
29
|
+
]
|
|
30
|
+
}) : null;
|
|
31
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TestDocApi } from '../contracts.js';
|
|
2
|
+
export declare function saveStatusMessage(test: TestDocApi): string | null;
|
|
3
|
+
type Props = {
|
|
4
|
+
test: TestDocApi;
|
|
5
|
+
messageInBlockerList?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare function ReadinessReadStatus({ test, messageInBlockerList }: Props): import("react").JSX.Element;
|
|
8
|
+
export declare function SaveStatus({ test, messageInBlockerList }: Props): import("react").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { readinessRead } from '../../readinessRead.js';
|
|
4
|
+
import { useRef, useState } from 'react';
|
|
5
|
+
import { Button } from '../../../ui/Button.js';
|
|
6
|
+
import { READINESS_COPY as C } from '../../copy/readiness.js';
|
|
7
|
+
export function saveStatusMessage(test) {
|
|
8
|
+
return test.saving === 'saving' ? C.saving : test.saving === 'saved' || test.saving === 'idle' ? C.saved : test.saving === 'error' && !test.stale ? test.errors._section ? C.saveGeneralError : C.saveError : null;
|
|
9
|
+
}
|
|
10
|
+
export function ReadinessReadStatus({ test, messageInBlockerList = false }) {
|
|
11
|
+
const inFlight = useRef(false);
|
|
12
|
+
const [retrying, setRetrying] = useState(false);
|
|
13
|
+
async function retry() {
|
|
14
|
+
if (inFlight.current || test.preflightPending || test.hasUnsaved || test.saving === 'saving') return;
|
|
15
|
+
inFlight.current = true;
|
|
16
|
+
setRetrying(true);
|
|
17
|
+
try {
|
|
18
|
+
await test.refreshPreflight();
|
|
19
|
+
} finally{
|
|
20
|
+
inFlight.current = false;
|
|
21
|
+
setRetrying(false);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const read = test.preflightRead ?? (test.preflightError ? readinessRead(test) : undefined);
|
|
25
|
+
return /*#__PURE__*/ _jsx(_Fragment, {
|
|
26
|
+
children: read?.message ? /*#__PURE__*/ _jsxs("div", {
|
|
27
|
+
children: [
|
|
28
|
+
!messageInBlockerList ? /*#__PURE__*/ _jsx("span", {
|
|
29
|
+
role: "alert",
|
|
30
|
+
children: read.message
|
|
31
|
+
}) : null,
|
|
32
|
+
' ',
|
|
33
|
+
test.hasUnsaved || test.saving === 'saving' ? /*#__PURE__*/ _jsx("p", {
|
|
34
|
+
children: test.stale ? C.reloadFirst : C.saveFirst
|
|
35
|
+
}) : null,
|
|
36
|
+
read.retry ? /*#__PURE__*/ _jsx("span", {
|
|
37
|
+
title: test.stale ? C.reloadFirst : test.hasUnsaved || test.saving === 'saving' ? C.saveFirst : undefined,
|
|
38
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
39
|
+
disabled: retrying || test.preflightPending || test.hasUnsaved || test.saving === 'saving',
|
|
40
|
+
onClick: ()=>{
|
|
41
|
+
void retry();
|
|
42
|
+
},
|
|
43
|
+
children: C.retry
|
|
44
|
+
})
|
|
45
|
+
}) : null
|
|
46
|
+
]
|
|
47
|
+
}) : null
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
export function SaveStatus({ test, messageInBlockerList }) {
|
|
51
|
+
const message = saveStatusMessage(test);
|
|
52
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
53
|
+
className: "xp-save-status",
|
|
54
|
+
"aria-live": "polite",
|
|
55
|
+
children: [
|
|
56
|
+
message ? /*#__PURE__*/ _jsx("span", {
|
|
57
|
+
role: test.saving === 'error' ? 'alert' : 'status',
|
|
58
|
+
children: message
|
|
59
|
+
}) : null,
|
|
60
|
+
/*#__PURE__*/ _jsx(ReadinessReadStatus, {
|
|
61
|
+
test: test,
|
|
62
|
+
messageInBlockerList: messageInBlockerList
|
|
63
|
+
})
|
|
64
|
+
]
|
|
65
|
+
});
|
|
66
|
+
}
|
|
@@ -4,6 +4,7 @@ import type { TestDocument } from '../testDocument.model.js';
|
|
|
4
4
|
import type { SurfaceProps } from '../contracts.js';
|
|
5
5
|
import { type SectionId } from '../contracts.js';
|
|
6
6
|
export type ReadinessContext = Pick<TestDocument, 'arms' | 'unitType' | 'flagPoint'> & {
|
|
7
|
+
editorPlacementMessage?: string;
|
|
7
8
|
collectionLabel?: string;
|
|
8
9
|
pagePlacements?: PreflightResult['pagePlacements'];
|
|
9
10
|
flagPoints?: readonly Pick<SerializedFlagPoint, 'id' | 'params'>[];
|
|
@@ -14,6 +15,12 @@ export declare const READINESS: Record<ReadinessCode, {
|
|
|
14
15
|
next(detail: unknown, ctx: ReadinessContext): string | null;
|
|
15
16
|
nextStep?: string | ((detail: unknown, ctx: ReadinessContext) => string);
|
|
16
17
|
}>;
|
|
18
|
+
export declare function blockingSteps(preflight: PreflightResult | null, ctx: ReadinessContext): {
|
|
19
|
+
arm?: import("../../../types/contracts.js").ArmKey | undefined;
|
|
20
|
+
section: "header" | SectionId;
|
|
21
|
+
sentence: string;
|
|
22
|
+
code: ReadinessCode;
|
|
23
|
+
}[];
|
|
17
24
|
export declare function nextStep(preflight: PreflightResult | null, ctx: ReadinessContext): {
|
|
18
25
|
nextStep?: string | undefined;
|
|
19
26
|
arm?: import("../../../types/contracts.js").ArmKey | undefined;
|
|
@@ -21,8 +28,14 @@ export declare function nextStep(preflight: PreflightResult | null, ctx: Readine
|
|
|
21
28
|
sentence: string;
|
|
22
29
|
code: ReadinessCode;
|
|
23
30
|
} | null;
|
|
31
|
+
export declare function errorSection(path: string): SectionId | undefined;
|
|
32
|
+
export declare function sectionBlocked(test: {
|
|
33
|
+
preflight: PreflightResult | null;
|
|
34
|
+
errors?: Record<string, string>;
|
|
35
|
+
}, section: SectionId): boolean;
|
|
24
36
|
export declare function sectionDone(test: {
|
|
25
37
|
preflight: PreflightResult | null;
|
|
38
|
+
doc?: Pick<TestDocument, 'targeting'> | null;
|
|
26
39
|
}): Record<SectionId, boolean>;
|
|
27
40
|
export declare function displayDate(value: unknown): string | null;
|
|
28
41
|
export declare function daysRemaining(doc: TestDocument, now: number): number | null;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SURFACE_COPY } from '../../copy/surface.js';
|
|
2
2
|
import { formatDate } from '../../format/date.js';
|
|
3
3
|
import { actionGroupLabel } from '../../actions/actions.model.js';
|
|
4
|
-
import { asymmetricGoalsCopy, placementUncheckedCopy, interactingTestsCopy, sameAddressCopy, identicalVersionCopy, unsupportedContentCopy, versionPageUnavailableCopy, versionPageUncheckedCopy, placementFailureCopy, pageInUseCopy, unpublishedPageCopy, READINESS_COPY as C, attributeNext, contentNext, goalPeopleNext, parameterNext, placementNext, ruleNext, versionsNext } from '../../copy/readiness.js';
|
|
4
|
+
import { unpublishedPlacementsCopy, asymmetricGoalsCopy, placementUncheckedCopy, interactingTestsCopy, sameAddressCopy, identicalVersionCopy, unsupportedContentCopy, versionPageUnavailableCopy, versionPageUncheckedCopy, placementFailureCopy, pageInUseCopy, unpublishedPageCopy, READINESS_COPY as C, attributeNext, contentNext, goalPeopleNext, parameterNext, placementNext, ruleNext, versionsNext } from '../../copy/readiness.js';
|
|
5
5
|
import { normalisePath } from '../../../runtime/normalisePath.js';
|
|
6
6
|
import { testPageCollection } from '../pagePicker/pagePicker.model.js';
|
|
7
7
|
import { SECTION_ORDER } from '../contracts.js';
|
|
@@ -29,12 +29,10 @@ const versions = row('versions', (detail)=>versionsNext(detailText(detail, C.ver
|
|
|
29
29
|
nextStep: (detail)=>`Open ${text(object(detail).title ?? object(detail).path, 'the page')}`
|
|
30
30
|
},
|
|
31
31
|
'invalid-status': row('header', ()=>null),
|
|
32
|
-
'no-placements': row('what', (detail)=>detail === undefined ? C.noPlacements : placementFailureCopy(detail)),
|
|
32
|
+
'no-placements': row('what', (detail, ctx)=>ctx.editorPlacementMessage ?? (detail === undefined ? C.noPlacements : placementFailureCopy(detail))),
|
|
33
33
|
'placement-removed': row('what', ()=>C.placementRemoved),
|
|
34
34
|
'placement-unpublished': {
|
|
35
|
-
...row('versions',
|
|
36
|
-
detail
|
|
37
|
-
]).map((placement)=>`The block you're testing is only on a draft of ${text(object(placement).title, 'this page')}. Publish the page before you start.`).join('\n')),
|
|
35
|
+
...row('versions', unpublishedPlacementsCopy),
|
|
38
36
|
nextStep: 'Publish the page'
|
|
39
37
|
},
|
|
40
38
|
'duplicate-version-row': {
|
|
@@ -136,44 +134,60 @@ const versions = row('versions', (detail)=>versionsNext(detailText(detail, C.ver
|
|
|
136
134
|
'slot-required': versions,
|
|
137
135
|
'duplicate-slot': versions
|
|
138
136
|
};
|
|
139
|
-
export function
|
|
140
|
-
|
|
137
|
+
export function blockingSteps(preflight, ctx) {
|
|
138
|
+
return [
|
|
141
139
|
'header',
|
|
142
140
|
...SECTION_ORDER
|
|
143
|
-
]){
|
|
144
|
-
|
|
145
|
-
if (
|
|
146
|
-
|
|
147
|
-
section,
|
|
148
|
-
sentence: SURFACE_COPY.next,
|
|
149
|
-
code: check.code
|
|
150
|
-
};
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
const mapping = READINESS[check.code];
|
|
154
|
-
if (check.ok || mapping.section !== section) continue;
|
|
155
|
-
const sentence = mapping.next(check.detail, ctx);
|
|
156
|
-
const nextStep = typeof mapping.nextStep === 'function' ? mapping.nextStep(check.detail, ctx) : mapping.nextStep;
|
|
141
|
+
].flatMap((section)=>(preflight?.checks ?? []).flatMap((check)=>{
|
|
142
|
+
const mapping = Object.hasOwn(READINESS, check.code) ? READINESS[check.code] : undefined;
|
|
143
|
+
if (check.ok || (mapping?.section ?? 'what') !== section) return [];
|
|
144
|
+
const sentence = mapping ? mapping.next(check.detail, ctx) : SURFACE_COPY.next;
|
|
157
145
|
const arm = readinessArm(check.code, check.detail, ctx);
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
arm
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
146
|
+
return sentence ? [
|
|
147
|
+
{
|
|
148
|
+
section,
|
|
149
|
+
sentence,
|
|
150
|
+
code: check.code,
|
|
151
|
+
...arm ? {
|
|
152
|
+
arm
|
|
153
|
+
} : {}
|
|
154
|
+
}
|
|
155
|
+
] : [];
|
|
156
|
+
}));
|
|
157
|
+
}
|
|
158
|
+
export function nextStep(preflight, ctx) {
|
|
159
|
+
const next = blockingSteps(preflight, ctx)[0];
|
|
160
|
+
if (!next) return null;
|
|
161
|
+
const mapping = READINESS[next.code];
|
|
162
|
+
const detail = preflight?.checks.find((check)=>!check.ok && check.code === next.code)?.detail;
|
|
163
|
+
const action = mapping && (typeof mapping.nextStep === 'function' ? mapping.nextStep(detail, ctx) : mapping.nextStep);
|
|
164
|
+
return {
|
|
165
|
+
...next,
|
|
166
|
+
...action ? {
|
|
167
|
+
nextStep: action
|
|
168
|
+
} : {}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
export function errorSection(path) {
|
|
172
|
+
if ([
|
|
173
|
+
'name',
|
|
174
|
+
'hypothesis',
|
|
175
|
+
'flagPoint'
|
|
176
|
+
].some((field)=>path === field || path.startsWith(`${field}.`))) return 'what';
|
|
177
|
+
if (/^(arms|pageCollection|allocation)(\.|$)/.test(path)) return 'versions';
|
|
178
|
+
if (/^metrics(\.|$)/.test(path)) return 'win';
|
|
179
|
+
if (/^(targeting)(\.|$)/.test(path)) return 'who';
|
|
180
|
+
if (/^analysis\.(plannedDurationDays|reachPerDay)(\.|$)/.test(path)) return 'length';
|
|
181
|
+
if (/^(analysis|exposurePolicy|layer)(\.|$)/.test(path)) return 'advanced';
|
|
182
|
+
}
|
|
183
|
+
export function sectionBlocked(test, section) {
|
|
184
|
+
if (Object.keys(test.errors ?? {}).some((path)=>errorSection(path) === section)) return true;
|
|
185
|
+
return !!test.preflight?.checks.some((check)=>!check.ok && (Object.hasOwn(READINESS, check.code) ? READINESS[check.code].section : 'what') === section);
|
|
172
186
|
}
|
|
173
187
|
export function sectionDone(test) {
|
|
174
188
|
return Object.fromEntries(SECTION_ORDER.map((section)=>[
|
|
175
189
|
section,
|
|
176
|
-
test.preflight ? !test.preflight.checks.some((check)=>!check.ok && (Object.hasOwn(READINESS, check.code) ? READINESS[check.code].section : SECTION_ORDER[0]) === section) : section === '
|
|
190
|
+
section === 'who' && test.doc && !test.doc.targeting?.length ? false : test.preflight ? !test.preflight.checks.some((check)=>!check.ok && (Object.hasOwn(READINESS, check.code) ? READINESS[check.code].section : SECTION_ORDER[0]) === section) : section === 'advanced'
|
|
177
191
|
]));
|
|
178
192
|
}
|
|
179
193
|
export function displayDate(value) {
|
|
@@ -191,6 +205,7 @@ function pageArm(path, ctx) {
|
|
|
191
205
|
export function pageReadinessContext(doc, preflight, surface) {
|
|
192
206
|
return {
|
|
193
207
|
...doc,
|
|
208
|
+
editorPlacementMessage: surface.editorPlacementMessage,
|
|
194
209
|
flagPoints: surface.flagPoints,
|
|
195
210
|
pagePlacements: preflight?.pagePlacements,
|
|
196
211
|
collectionLabel: testPageCollection(surface.pageCollections, doc, preflight?.pagePlacements)?.label
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { ApiResult } from '../../api.js';
|
|
2
2
|
import type { TestDocApi } from '../contracts.js';
|
|
3
|
+
import type { SurfaceProps } from '../contracts.js';
|
|
4
|
+
import type { ActionId } from '../../actions/actions.model.js';
|
|
3
5
|
/** The ref closes the gap before React renders the disabled button. */
|
|
4
|
-
export declare function useTransition(test: TestDocApi, onSuccess?: () => void): {
|
|
6
|
+
export declare function useTransition(test: TestDocApi, onSuccess?: () => void, surface?: SurfaceProps): {
|
|
5
7
|
busy: boolean;
|
|
8
|
+
checking: boolean;
|
|
6
9
|
error: string | null;
|
|
7
|
-
run: (request: () => Promise<ApiResult<unknown>>, { reloadOnSuccess }?: {
|
|
10
|
+
run: (kind: ActionId | "restart", request: () => Promise<ApiResult<unknown>>, { reloadOnSuccess }?: {
|
|
8
11
|
reloadOnSuccess?: boolean | undefined;
|
|
9
12
|
}) => Promise<void>;
|
|
10
13
|
clearError: () => void;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { blockingSteps, pageReadinessContext } from './readiness.model.js';
|
|
4
|
+
import { API_MESSAGES } from '../../copy/common.js';
|
|
5
|
+
/** The ref closes the gap before React renders the disabled button. */ export function useTransition(test, onSuccess, surface) {
|
|
6
|
+
const inFlight = useRef(false);
|
|
7
|
+
const [busy, setBusy] = useState(false);
|
|
8
|
+
const [checking, setChecking] = useState(false);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const refusal = useRef(null);
|
|
11
|
+
const answer = test.preflightRead?.answer ?? test.preflight;
|
|
12
|
+
const latestAnswer = useRef(answer);
|
|
13
|
+
latestAnswer.current = answer;
|
|
14
|
+
// Dismissal mutates the lifetime once; a later ready answer cannot revive it.
|
|
15
|
+
useEffect(()=>{
|
|
16
|
+
if (!refusal.current) return;
|
|
17
|
+
if (refusal.current.status !== test.doc?.status) {
|
|
18
|
+
clearError();
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (refusal.current.kind !== 'start' && refusal.current.kind !== 'restart') return;
|
|
22
|
+
const successful = !!answer && !test.preflightError;
|
|
23
|
+
const explained = successful && !test.preflightRead?.failed && test.doc && [
|
|
24
|
+
'draft',
|
|
25
|
+
'stopped'
|
|
26
|
+
].includes(test.doc.status) && blockingSteps(answer, surface ? pageReadinessContext(test.doc, answer, surface) : test.doc).length > 0;
|
|
27
|
+
if (refusal.current.phase === 'rereading') {
|
|
28
|
+
// Observe the answer even if another shared read has already begun.
|
|
29
|
+
if (!checking || successful && answer !== refusal.current.answer) {
|
|
30
|
+
refusal.current = {
|
|
31
|
+
...refusal.current,
|
|
32
|
+
phase: 'waiting',
|
|
33
|
+
answer
|
|
34
|
+
};
|
|
35
|
+
if (explained) clearError();
|
|
36
|
+
}
|
|
37
|
+
} else if (explained && answer !== refusal.current.answer) clearError();
|
|
38
|
+
}, [
|
|
39
|
+
answer,
|
|
40
|
+
checking,
|
|
41
|
+
error,
|
|
42
|
+
test.preflightPending,
|
|
43
|
+
test.preflightError,
|
|
44
|
+
test.doc?.status
|
|
45
|
+
]);
|
|
46
|
+
function clearError() {
|
|
47
|
+
refusal.current = null;
|
|
48
|
+
setError(null);
|
|
49
|
+
}
|
|
50
|
+
async function run(kind, request, { reloadOnSuccess = true } = {}) {
|
|
51
|
+
if (inFlight.current || test.hasUnsaved || test.saving === 'saving') return;
|
|
52
|
+
clearError();
|
|
53
|
+
inFlight.current = true;
|
|
54
|
+
setBusy(true);
|
|
55
|
+
let refused = false;
|
|
56
|
+
try {
|
|
57
|
+
const result = await request();
|
|
58
|
+
if (result.ok) {
|
|
59
|
+
test.acceptTransition?.(result.data);
|
|
60
|
+
if (reloadOnSuccess) {
|
|
61
|
+
await test.reload();
|
|
62
|
+
onSuccess?.();
|
|
63
|
+
// Keep the successful action locked until the reloaded document replaces this view.
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
} else {
|
|
67
|
+
refused = true;
|
|
68
|
+
setError(result.message);
|
|
69
|
+
}
|
|
70
|
+
} catch {
|
|
71
|
+
refused = true;
|
|
72
|
+
setError(API_MESSAGES.network);
|
|
73
|
+
}
|
|
74
|
+
setBusy(false);
|
|
75
|
+
try {
|
|
76
|
+
if (refused) {
|
|
77
|
+
refusal.current = {
|
|
78
|
+
kind,
|
|
79
|
+
status: test.doc?.status,
|
|
80
|
+
phase: 'rereading',
|
|
81
|
+
answer: latestAnswer.current
|
|
82
|
+
};
|
|
83
|
+
setChecking(true);
|
|
84
|
+
await test.refreshPreflight(true);
|
|
85
|
+
}
|
|
86
|
+
} finally{
|
|
87
|
+
inFlight.current = false;
|
|
88
|
+
setChecking(false);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
busy,
|
|
93
|
+
checking,
|
|
94
|
+
error,
|
|
95
|
+
run,
|
|
96
|
+
clearError
|
|
97
|
+
};
|
|
98
|
+
}
|