@delmaredigital/payload-experiments 0.4.0-rc.1 → 0.4.0-rc.11
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 +284 -772
- package/dist/admin/LayerUsage.js +1 -1
- package/dist/admin/MetricSourceSelect.js +12 -5
- package/dist/admin/PlacementStatus.js +1 -1
- package/dist/admin/TestsDashboardCards.d.ts +1 -0
- package/dist/admin/TestsDashboardCards.js +5 -9
- package/dist/admin/TestsNavLink.d.ts +1 -0
- package/dist/admin/TestsNavLink.js +5 -11
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +129 -37
- package/dist/admin/blocks/TestBlockField.js +3 -3
- package/dist/admin/blocks/formApi.d.ts +3 -0
- package/dist/admin/blocks/formApi.js +10 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +10 -6
- package/dist/admin/blocks/statusCache.d.ts +2 -0
- package/dist/admin/blocks/statusCache.js +12 -3
- package/dist/admin/components/RootViewMessage.js +1 -1
- package/dist/admin/copy/blocks.d.ts +21 -1
- package/dist/admin/copy/blocks.js +40 -6
- package/dist/admin/copy/goals.d.ts +21 -9
- package/dist/admin/copy/goals.js +28 -11
- package/dist/admin/copy/newTest.d.ts +7 -7
- package/dist/admin/copy/newTest.js +10 -7
- package/dist/admin/goals/XpGoalField.d.ts +2 -0
- package/dist/admin/goals/XpGoalField.js +156 -114
- package/dist/admin/goals/xpGoalField.css +47 -0
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/paths.d.ts +3 -0
- package/dist/admin/paths.js +3 -0
- package/dist/admin/placementStatus.model.js +1 -1
- package/dist/admin/status.model.js +1 -1
- package/dist/admin/surface/ResultsRoute.d.ts +2 -1
- package/dist/admin/surface/ResultsRoute.js +20 -24
- package/dist/admin/surface/SurfaceShell.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +29 -4
- package/dist/admin/surface/TestRowMenu.d.ts +13 -0
- package/dist/admin/surface/TestRowMenu.js +163 -0
- package/dist/admin/surface/TestsHome.d.ts +5 -3
- package/dist/admin/surface/TestsHome.js +273 -58
- package/dist/admin/surface/TestsSurface.js +8 -7
- package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
- package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
- package/dist/admin/surface/goals/GoalForm.d.ts +2 -1
- package/dist/admin/surface/goals/GoalForm.js +342 -212
- package/dist/admin/surface/goals/GoalsList.d.ts +1 -1
- package/dist/admin/surface/goals/GoalsList.js +107 -37
- package/dist/admin/surface/goals/data.d.ts +2 -0
- package/dist/admin/surface/goals/data.js +11 -2
- package/dist/admin/surface/goals/goals.css +9 -1
- package/dist/admin/surface/goals/goals.model.d.ts +12 -2
- package/dist/admin/surface/goals/goals.model.js +39 -1
- package/dist/admin/surface/home.model.d.ts +10 -8
- package/dist/admin/surface/home.model.js +27 -22
- package/dist/admin/surface/newTest/NewTest.d.ts +4 -4
- package/dist/admin/surface/newTest/NewTest.js +149 -118
- package/dist/admin/surface/newTest/PageWizard.d.ts +5 -2
- package/dist/admin/surface/newTest/PageWizard.js +115 -80
- package/dist/admin/surface/newTest/newTest.css +28 -9
- package/dist/admin/surface/results/ResultsHeader.d.ts +3 -3
- package/dist/admin/surface/results/ResultsHeader.js +115 -83
- package/dist/admin/surface/surface.css +29 -0
- package/dist/admin/surface/test/TestPage.d.ts +1 -2
- package/dist/admin/surface/test/TestPage.js +44 -152
- package/dist/admin/surface/useXpStepNav.d.ts +11 -0
- package/dist/admin/surface/useXpStepNav.js +14 -0
- package/dist/admin/theme.css +2 -0
- package/dist/admin/views/CollectionListRedirect.d.ts +1 -0
- package/dist/admin/views/CollectionListRedirect.js +1 -1
- package/dist/admin/views/ExperimentsRootView.js +18 -165
- package/dist/admin/views/GoalEditRedirect.d.ts +4 -0
- package/dist/admin/views/GoalEditRedirect.js +14 -0
- package/dist/admin/views/GoalsCollectionListView.d.ts +2 -0
- package/dist/admin/views/GoalsCollectionListView.js +4 -0
- package/dist/admin/views/TestsCollectionListView.d.ts +2 -0
- package/dist/admin/views/TestsCollectionListView.js +4 -0
- package/dist/admin/views/TestsNavLinkServer.d.ts +1 -0
- package/dist/admin/views/TestsNavLinkServer.js +2 -2
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +35 -0
- package/dist/admin/views/buildSurfaceProps.d.ts +8 -0
- package/dist/admin/views/buildSurfaceProps.js +102 -0
- package/dist/admin/views/renderCollectionList.d.ts +2 -0
- package/dist/admin/views/renderCollectionList.js +34 -0
- package/dist/admin/views/renderTestsSurface.d.ts +3 -0
- package/dist/admin/views/renderTestsSurface.js +34 -0
- package/dist/blocks/bindings.js +8 -14
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +2 -2
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +37 -0
- package/dist/blocks/placementLocale.js +270 -0
- package/dist/collections/experiments/config.js +17 -8
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metrics.js +28 -9
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +8 -6
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.d.ts +30 -0
- package/dist/db/bulkPlacementRemoval.js +111 -0
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/placements.d.ts +2 -0
- package/dist/db/placements.js +8 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +2 -0
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +207 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +407 -0
- package/dist/endpoints/editorSurface.d.ts +3 -0
- package/dist/endpoints/editorSurface.js +31 -0
- package/dist/endpoints/events.js +103 -39
- package/dist/endpoints/index.js +57 -9
- package/dist/endpoints/pages.js +247 -64
- package/dist/endpoints/placementStatus.js +13 -5
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +6 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/errors.d.ts +5 -0
- package/dist/errors.js +8 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/adminRsc.d.ts +3 -0
- package/dist/exports/adminRsc.js +3 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/fields/xpGoal.js +3 -15
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +44 -35
- 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 +6 -2
- package/dist/goals/picker/copy.js +11 -2
- package/dist/goals/picker/useClickGoalPicker.d.ts +1 -1
- package/dist/goals/picker/useClickGoalPicker.js +4 -2
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -0
- package/dist/goals/validate.d.ts +3 -0
- package/dist/goals/validate.js +15 -0
- package/dist/hooks/blockRemovalRule.d.ts +30 -0
- package/dist/hooks/blockRemovalRule.js +165 -0
- package/dist/hooks/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +27 -2
- package/dist/hooks/pageGuard.js +213 -45
- package/dist/hooks/puckGoals.d.ts +5 -0
- package/dist/hooks/puckGoals.js +62 -0
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- package/dist/lib/placementPages.d.ts +10 -0
- package/dist/{admin/previewLinks.model.js → lib/placementPages.js} +10 -5
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +13 -6
- package/dist/onInit.js +36 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +23 -2
- package/dist/plugin.js +70 -21
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +62 -40
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +5 -1
- package/dist/puck/copy.js +5 -1
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +25 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +150 -0
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +12 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +89 -21
- package/dist/puck/editor/EditorControls.d.ts +14 -0
- package/dist/puck/editor/EditorControls.js +99 -0
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +1007 -182
- package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
- package/dist/puck/editor/LeftoverVersions.js +79 -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 +6 -0
- package/dist/puck/editor/QuickTestActions.js +72 -0
- package/dist/puck/editor/ResultsReadout.d.ts +4 -1
- package/dist/puck/editor/ResultsReadout.js +35 -19
- package/dist/puck/editor/VersionBuilder.d.ts +67 -12
- package/dist/puck/editor/VersionBuilder.js +560 -231
- package/dist/puck/editor/armWrites.d.ts +11 -2
- package/dist/puck/editor/armWrites.js +43 -4
- package/dist/puck/editor/armsCache.d.ts +3 -1
- package/dist/puck/editor/armsCache.js +20 -4
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +65 -20
- package/dist/puck/editor/copy.js +73 -21
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +200 -20
- package/dist/puck/editor/editor.css +338 -25
- package/dist/puck/editor/editor.model.d.ts +17 -1
- package/dist/puck/editor/editor.model.js +61 -4
- 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 +5 -0
- package/dist/puck/editor/localPlacements.js +43 -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 +60 -0
- package/dist/puck/editor/placementsCache.js +263 -0
- package/dist/puck/editor/sidebar.d.ts +8 -0
- package/dist/puck/editor/sidebar.js +74 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +15 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +105 -86
- package/dist/puck/experimentSlotField.d.ts +3 -0
- package/dist/puck/experimentSlotField.js +15 -4
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +2 -2
- package/dist/puck/slotConfig.js +18 -5
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.d.ts +1 -1
- package/dist/results/verdict.js +9 -7
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +22 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +48 -22
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +8 -8
- package/dist/server/runResults.js +54 -15
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/{admin → testSurface}/PreviewLinks.d.ts +2 -1
- package/dist/{admin → testSurface}/PreviewLinks.js +9 -5
- package/dist/testSurface/actions/DecideDialog.d.ts +17 -0
- package/dist/testSurface/actions/DecideDialog.js +222 -0
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/{admin → testSurface}/actions/MakeContentResult.d.ts +4 -3
- package/dist/{admin → testSurface}/actions/MakeContentResult.js +10 -2
- package/dist/{admin → testSurface}/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +123 -0
- package/dist/{admin → testSurface}/actions/decide.model.d.ts +1 -0
- package/dist/{admin → testSurface}/actions/decide.model.js +1 -0
- package/dist/{admin → testSurface}/allocation.model.js +6 -3
- package/dist/{admin → testSurface}/api.d.ts +20 -7
- package/dist/{admin → testSurface}/api.js +72 -22
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/{admin → testSurface}/copy/actions.d.ts +37 -14
- package/dist/{admin → testSurface}/copy/actions.js +40 -17
- package/dist/{admin → testSurface}/copy/advanced.d.ts +10 -0
- package/dist/{admin → testSurface}/copy/advanced.js +10 -0
- package/dist/{admin → testSurface}/copy/arms.d.ts +1 -1
- package/dist/{admin → testSurface}/copy/arms.js +1 -1
- package/dist/{admin → testSurface}/copy/audience.d.ts +4 -3
- package/dist/{admin → testSurface}/copy/audience.js +5 -4
- package/dist/{admin → testSurface}/copy/common.d.ts +15 -6
- package/dist/{admin → testSurface}/copy/common.js +20 -10
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/{admin → testSurface}/copy/metrics.d.ts +7 -0
- package/dist/testSurface/copy/metrics.js +18 -0
- package/dist/testSurface/copy/pages.d.ts +84 -0
- package/dist/testSurface/copy/pages.js +90 -0
- package/dist/{admin → testSurface}/copy/readiness.d.ts +40 -6
- package/dist/{admin → testSurface}/copy/readiness.js +54 -9
- package/dist/{admin → testSurface}/copy/recommendation.d.ts +4 -4
- package/dist/{admin → testSurface}/copy/recommendation.js +4 -4
- package/dist/{admin → testSurface}/copy/results.d.ts +19 -12
- package/dist/{admin → testSurface}/copy/results.js +21 -12
- package/dist/testSurface/copy/review.d.ts +20 -0
- package/dist/testSurface/copy/review.js +21 -0
- package/dist/{admin → testSurface}/copy/setting.d.ts +1 -2
- package/dist/{admin → testSurface}/copy/setting.js +1 -2
- package/dist/{admin → testSurface}/copy/surface.d.ts +11 -2
- package/dist/{admin → testSurface}/copy/surface.js +14 -11
- package/dist/{admin → testSurface}/copy/testPage.d.ts +61 -12
- package/dist/testSurface/copy/testPage.js +168 -0
- package/dist/testSurface/format/adminURL.d.ts +7 -0
- package/dist/testSurface/format/adminURL.js +9 -0
- package/dist/{admin → testSurface}/format/date.d.ts +1 -0
- package/dist/testSurface/format/date.js +21 -0
- package/dist/{admin → testSurface}/labels.d.ts +1 -2
- package/dist/{admin → testSurface}/labels.js +2 -3
- package/dist/{admin → testSurface}/lockedNotice.model.d.ts +2 -0
- package/dist/{admin → testSurface}/lockedNotice.model.js +31 -0
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/{admin → testSurface}/placements/placementLabels.d.ts +2 -0
- package/dist/{admin → testSurface}/placements/placementLabels.js +3 -2
- package/dist/{admin → testSurface}/previewLinks.model.d.ts +1 -6
- package/dist/testSurface/previewLinks.model.js +4 -0
- package/dist/testSurface/readPreflight.d.ts +13 -0
- package/dist/testSurface/readPreflight.js +44 -0
- package/dist/testSurface/readinessRead.d.ts +53 -0
- package/dist/testSurface/readinessRead.js +50 -0
- package/dist/{admin → testSurface}/results/VerdictHero.d.ts +2 -1
- package/dist/{admin → testSurface}/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +64 -0
- package/dist/{admin → testSurface}/results/results.model.d.ts +3 -2
- package/dist/{admin → testSurface}/results/results.model.js +16 -11
- package/dist/{admin → testSurface}/surface/contracts.d.ts +17 -3
- package/dist/testSurface/surface/editorPlacement.d.ts +26 -0
- package/dist/testSurface/surface/editorPlacement.js +78 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +9 -0
- package/dist/testSurface/surface/pageBlock/parts.js +107 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +13 -0
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +273 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +21 -0
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +498 -0
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -0
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.d.ts +7 -3
- package/dist/{admin → testSurface}/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/{admin → testSurface}/surface/readiness/ActionDialogs.d.ts +9 -5
- package/dist/testSurface/surface/readiness/ActionDialogs.js +372 -0
- package/dist/{admin → testSurface}/surface/readiness/Banner.d.ts +4 -3
- package/dist/testSurface/surface/readiness/Banner.js +198 -0
- 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 +13 -0
- package/dist/testSurface/surface/readiness/SaveStatus.js +67 -0
- package/dist/{admin → testSurface}/surface/readiness/parts.js +0 -2
- package/dist/{admin → testSurface}/surface/readiness/readiness.model.d.ts +28 -2
- package/dist/testSurface/surface/readiness/readiness.model.js +377 -0
- package/dist/testSurface/surface/readiness/useTransition.d.ts +16 -0
- package/dist/testSurface/surface/readiness/useTransition.js +141 -0
- package/dist/{admin → testSurface}/surface/results/ReleasePages.d.ts +6 -3
- package/dist/{admin → testSurface}/surface/results/ReleasePages.js +40 -40
- package/dist/{admin → testSurface}/surface/results/ResultsBody.d.ts +11 -4
- package/dist/{admin → testSurface}/surface/results/ResultsBody.js +207 -104
- package/dist/{admin → testSurface}/surface/results/recommendation.model.js +3 -3
- package/dist/{admin → testSurface}/surface/results/useResults.d.ts +26 -8
- package/dist/{admin → testSurface}/surface/results/useResults.js +3 -2
- package/dist/{admin → testSurface}/surface/setting/parts.js +89 -46
- package/dist/testSurface/surface/setting/setting.css +18 -0
- package/dist/{admin → testSurface}/surface/test/AdvancedSection.js +12 -4
- package/dist/testSurface/surface/test/DeleteTest.d.ts +23 -0
- package/dist/testSurface/surface/test/DeleteTest.js +270 -0
- package/dist/testSurface/surface/test/GoalSection.d.ts +4 -0
- package/dist/{admin → testSurface}/surface/test/GoalSection.js +119 -89
- package/dist/testSurface/surface/test/LengthSection.d.ts +2 -0
- package/dist/{admin → testSurface}/surface/test/LengthSection.js +25 -14
- package/dist/{admin → testSurface}/surface/test/PageHoldout.d.ts +1 -1
- package/dist/{admin → testSurface}/surface/test/PageHoldout.js +11 -8
- package/dist/{admin → testSurface}/surface/test/Rail.js +7 -4
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.d.ts +2 -1
- package/dist/{admin → testSurface}/surface/test/ReadinessBar.js +4 -11
- package/dist/{admin → testSurface}/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +88 -0
- package/dist/{admin → testSurface}/surface/test/TargetingSection.js +87 -12
- package/dist/testSurface/surface/test/TestSurface.d.ts +19 -0
- package/dist/testSurface/surface/test/TestSurface.js +265 -0
- package/dist/testSurface/surface/test/VersionsSection.d.ts +5 -0
- package/dist/testSurface/surface/test/VersionsSection.js +301 -0
- package/dist/{admin → testSurface}/surface/test/fields.d.ts +33 -9
- package/dist/testSurface/surface/test/fields.js +300 -0
- package/dist/{admin → testSurface}/surface/test/pageParts.js +30 -44
- package/dist/testSurface/surface/test/testPage.css +111 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.d.ts +1 -0
- package/dist/{admin → testSurface}/surface/test/testPage.model.js +6 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.d.ts +3 -0
- package/dist/{admin → testSurface}/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +60 -0
- package/dist/testSurface/surface/useTestDocument.js +782 -0
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +8 -0
- package/dist/testSurface/surfaceUrls.js +23 -0
- package/dist/{admin → testSurface}/useApi.d.ts +21 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +26 -0
- package/dist/transitions/addMetric.d.ts +2 -5
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +6 -1
- package/dist/transitions/checkStart.js +133 -17
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +6 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +41 -17
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +32 -0
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +16 -12
- package/dist/transitions/placements.d.ts +54 -8
- package/dist/transitions/placements.js +304 -81
- package/dist/transitions/preflightData.d.ts +5 -3
- package/dist/transitions/preflightData.js +137 -40
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +72 -35
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/contracts.d.ts +15 -3
- package/dist/types/endpoints.d.ts +121 -17
- package/dist/types/puck.d.ts +1 -0
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +9 -9
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- package/dist/ui/Dialog.d.ts +24 -2
- package/dist/ui/Dialog.js +141 -6
- package/dist/ui/Drawer.d.ts +10 -0
- package/dist/ui/Drawer.js +29 -0
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +6 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +4 -4
- package/dist/ui/Tabs.js +35 -32
- package/dist/ui/ui.css +50 -5
- package/package.json +3 -2
- package/dist/admin/actions/ConfirmDialog.d.ts +0 -19
- package/dist/admin/actions/ConfirmDialog.js +0 -149
- package/dist/admin/actions/DecideDialog.d.ts +0 -10
- package/dist/admin/actions/DecideDialog.js +0 -190
- package/dist/admin/actions/actions.model.js +0 -70
- package/dist/admin/copy/metrics.js +0 -9
- package/dist/admin/copy/pages.d.ts +0 -26
- package/dist/admin/copy/pages.js +0 -26
- package/dist/admin/copy/review.d.ts +0 -17
- package/dist/admin/copy/review.js +0 -17
- package/dist/admin/copy/testPage.js +0 -104
- package/dist/admin/format/date.js +0 -10
- 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/pageBlock/pageBlock.model.js +0 -8
- package/dist/admin/surface/pageBlock/parts.js +0 -69
- package/dist/admin/surface/pagePicker/CopyRoute.d.ts +0 -6
- package/dist/admin/surface/pagePicker/CopyRoute.js +0 -53
- package/dist/admin/surface/pagePicker/PagePicker.d.ts +0 -10
- package/dist/admin/surface/pagePicker/PagePicker.js +0 -172
- package/dist/admin/surface/readiness/ActionDialogs.js +0 -337
- package/dist/admin/surface/readiness/Banner.js +0 -190
- package/dist/admin/surface/readiness/SaveStatus.d.ts +0 -5
- package/dist/admin/surface/readiness/SaveStatus.js +0 -53
- package/dist/admin/surface/readiness/readiness.model.js +0 -205
- package/dist/admin/surface/readiness/useTransition.d.ts +0 -11
- 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 -47
- package/dist/admin/surface/test/VersionsSection.d.ts +0 -4
- package/dist/admin/surface/test/VersionsSection.js +0 -247
- package/dist/admin/surface/test/fields.js +0 -216
- package/dist/admin/surface/test/testPage.css +0 -97
- package/dist/admin/surface/useTestDocument.d.ts +0 -32
- package/dist/admin/surface/useTestDocument.js +0 -415
- /package/dist/{admin → testSurface}/allocation.model.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}/metricSource.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/metricSource.model.js +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/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/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/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/readiness/parts.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/results/recommendation.model.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/setting/parts.d.ts +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/Rail.d.ts +0 -0
- /package/dist/{admin → testSurface}/surface/test/TargetingSection.d.ts +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}/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.js +0 -0
package/dist/admin/LayerUsage.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { FieldDescription, FieldLabel, useDocumentInfo } from '@payloadcms/ui';
|
|
4
4
|
import { useLayerExperiments } from './useLayerUsage.js';
|
|
5
|
-
import { statusLabel } from '
|
|
5
|
+
import { statusLabel } from '../testSurface/labels.js';
|
|
6
6
|
import { HISTORY_COPY, layerRow, layerSummary } from './copy/history.js';
|
|
7
7
|
export function LayerUsage({ field, path }) {
|
|
8
8
|
const { id } = useDocumentInfo();
|
|
@@ -1,14 +1,21 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { SelectInput, useField } from '@payloadcms/ui';
|
|
4
|
-
import { metricSourceHint, metricSourceOptions, sourceFor } from '
|
|
5
|
-
import { METRICS_COPY } from '
|
|
4
|
+
import { metricSourceHint, metricSourceOptions, sourceFor } from '../testSurface/metricSource.model.js';
|
|
5
|
+
import { METRICS_COPY } from '../testSurface/copy/metrics.js';
|
|
6
|
+
import { goalSourceLabel } from '../goals/sourceLabel.js';
|
|
6
7
|
export function MetricSourceSelect({ path, field, readOnly }) {
|
|
7
8
|
const { value, setValue } = useField({
|
|
8
9
|
path
|
|
9
10
|
});
|
|
10
11
|
const sources = field.admin?.custom?.sources ?? [];
|
|
11
|
-
const
|
|
12
|
+
const source = sourceFor(value, sources);
|
|
13
|
+
const hint = metricSourceHint(source);
|
|
14
|
+
const options = metricSourceOptions(sources);
|
|
15
|
+
if (value && !source) options.push({
|
|
16
|
+
value,
|
|
17
|
+
label: goalSourceLabel(value)
|
|
18
|
+
});
|
|
12
19
|
const locked = Boolean(readOnly || field.admin?.readOnly);
|
|
13
20
|
return /*#__PURE__*/ _jsxs("div", {
|
|
14
21
|
children: [
|
|
@@ -18,8 +25,8 @@ export function MetricSourceSelect({ path, field, readOnly }) {
|
|
|
18
25
|
label: field.label ?? METRICS_COPY.source,
|
|
19
26
|
description: field.admin?.description,
|
|
20
27
|
required: field.required,
|
|
21
|
-
options:
|
|
22
|
-
value:
|
|
28
|
+
options: options,
|
|
29
|
+
value: source?.id ?? value ?? '',
|
|
23
30
|
readOnly: locked,
|
|
24
31
|
onChange: (option)=>{
|
|
25
32
|
if (!locked) setValue(option && !Array.isArray(option) ? option.value : null);
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { useConfig, useDocumentInfo } from '@payloadcms/ui';
|
|
4
4
|
import { useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { formatAdminURL } from 'payload/shared';
|
|
6
|
-
import { createApi } from '
|
|
6
|
+
import { createApi } from '../testSurface/api.js';
|
|
7
7
|
import { pageStatusCopy } from './placementStatus.model.js';
|
|
8
8
|
/** Manage-only endpoint: access-filtered editors see no status or error text. */ export function PlacementStatus(_props) {
|
|
9
9
|
const { id, collectionSlug } = useDocumentInfo();
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { surfaceUrls } from '../testSurface/surfaceUrls.js';
|
|
3
4
|
import './theme.css';
|
|
4
5
|
import './dashboard.css';
|
|
5
6
|
import { Card, useAuth, useConfig } from '@payloadcms/ui';
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
export function TestsDashboardCards() {
|
|
7
|
+
import { SURFACE_COPY } from '../testSurface/copy/surface.js';
|
|
8
|
+
/** @deprecated Retained for existing import maps until 0.5.0. */ export function TestsDashboardCards() {
|
|
9
9
|
const { config } = useConfig();
|
|
10
10
|
const { permissions } = useAuth();
|
|
11
11
|
const testPermissions = permissions?.collections?.['xp-experiments'];
|
|
12
12
|
const canManage = testPermissions?.update === true;
|
|
13
13
|
if (!canManage) return null;
|
|
14
|
-
const href = (path)=>formatAdminURL({
|
|
15
|
-
adminRoute: config.routes.admin,
|
|
16
|
-
path
|
|
17
|
-
});
|
|
18
14
|
return /*#__PURE__*/ _jsxs("section", {
|
|
19
15
|
className: "xp-dash-group",
|
|
20
16
|
"aria-labelledby": "xp-dash-title",
|
|
@@ -32,7 +28,7 @@ export function TestsDashboardCards() {
|
|
|
32
28
|
title: SURFACE_COPY.navAllTests,
|
|
33
29
|
titleAs: "h3",
|
|
34
30
|
buttonAriaLabel: SURFACE_COPY.dashShowTests,
|
|
35
|
-
href:
|
|
31
|
+
href: surfaceUrls.home(config.routes.admin),
|
|
36
32
|
id: "card-xp-tests"
|
|
37
33
|
})
|
|
38
34
|
}),
|
|
@@ -41,7 +37,7 @@ export function TestsDashboardCards() {
|
|
|
41
37
|
title: SURFACE_COPY.navGoals,
|
|
42
38
|
titleAs: "h3",
|
|
43
39
|
buttonAriaLabel: SURFACE_COPY.dashShowGoals,
|
|
44
|
-
href:
|
|
40
|
+
href: surfaceUrls.goals(config.routes.admin),
|
|
45
41
|
id: "card-xp-goals"
|
|
46
42
|
})
|
|
47
43
|
})
|
|
@@ -1,22 +1,16 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { surfaceUrls } from '../testSurface/surfaceUrls.js';
|
|
3
4
|
import './theme.css';
|
|
4
5
|
import { Link, NavGroup, useAuth, useConfig } from '@payloadcms/ui';
|
|
5
|
-
import { formatAdminURL } from 'payload/shared';
|
|
6
6
|
import { usePathname } from 'next/navigation.js';
|
|
7
|
-
import { SURFACE_COPY } from '
|
|
8
|
-
function TestsNav({ isOpen = true }) {
|
|
7
|
+
import { SURFACE_COPY } from '../testSurface/copy/surface.js';
|
|
8
|
+
/** @deprecated Retained for existing import maps until 0.5.0. */ function TestsNav({ isOpen = true }) {
|
|
9
9
|
const { config } = useConfig();
|
|
10
10
|
const { permissions } = useAuth();
|
|
11
11
|
const pathname = usePathname();
|
|
12
|
-
const href =
|
|
13
|
-
|
|
14
|
-
path: '/experiments'
|
|
15
|
-
});
|
|
16
|
-
const goalsHref = formatAdminURL({
|
|
17
|
-
adminRoute: config.routes.admin,
|
|
18
|
-
path: '/experiments/goals'
|
|
19
|
-
});
|
|
12
|
+
const href = surfaceUrls.home(config.routes.admin);
|
|
13
|
+
const goalsHref = surfaceUrls.goals(config.routes.admin);
|
|
20
14
|
const base = href.replace(/\/$/, '');
|
|
21
15
|
const goalsBase = goalsHref.replace(/\/$/, '');
|
|
22
16
|
const goalsActive = pathname === goalsBase || Boolean(pathname?.startsWith(`${goalsBase}/`));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { UIFieldClientProps } from 'payload';
|
|
2
|
+
import '../theme.css';
|
|
2
3
|
export declare function BlockStatusField({ path }: UIFieldClientProps): import("react").JSX.Element | null;
|
|
3
4
|
export declare function BlockSlotRowLabel(): import("react").JSX.Element;
|
|
4
5
|
export declare function CopyOriginalField({ path }: UIFieldClientProps): import("react").JSX.Element | null;
|
|
@@ -1,20 +1,32 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { Banner, Button,
|
|
4
|
-
import {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { Banner, Button, toast, useFormInitializing, useRowLabel } from '@payloadcms/ui';
|
|
4
|
+
import { formatAdminURL } from 'payload/shared';
|
|
5
|
+
import { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { ConfirmDialog } from '../../ui/Dialog.js';
|
|
7
|
+
import { actionTitle } from '../../testSurface/copy/actions.js';
|
|
8
|
+
import { READINESS_COPY } from '../../testSurface/copy/readiness.js';
|
|
9
|
+
import '../theme.css';
|
|
5
10
|
import { copyOriginalIntoVersion, syncExperimentSlots, unwrapExperimentBlock } from '../../blocks/formState.js';
|
|
6
|
-
import { BLOCK_COPY, blockSyncNotice } from '
|
|
7
|
-
import { API_MESSAGES } from '
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
11
|
+
import { BLOCK_COPY, blockSyncNotice, blockUnwrapNotice, blockDeleteConfirmation, blockUnwrapConfirmation, blockRunningUnwrap, blockDecidedUnwrap, blockFinishedCopy } from '../../admin/copy/blocks.js';
|
|
12
|
+
import { API_MESSAGES } from '../../testSurface/copy/common.js';
|
|
13
|
+
import { canUnwrapOriginal, liveStatus, slotLabel, statusSentence } from './model.js';
|
|
14
|
+
import { createApi } from '../../testSurface/api.js';
|
|
15
|
+
import { useBlockStatus, setBlockStatus } from './statusCache.js';
|
|
10
16
|
import { useBlockForm } from './useBlockForm.js';
|
|
17
|
+
import { BlockChangedError, RefusalError } from './formApi.js';
|
|
18
|
+
import { notifyTestDocument } from '../../testSurface/surface/watchTestDocument.js';
|
|
19
|
+
function errorMessage(error) {
|
|
20
|
+
return error instanceof BlockChangedError || error instanceof RefusalError ? error.message : API_MESSAGES.failed;
|
|
21
|
+
}
|
|
11
22
|
export function BlockStatusField({ path }) {
|
|
12
23
|
const context = useBlockForm(path), { block, field, manager, config, collection, replace } = context;
|
|
13
24
|
const initializing = useFormInitializing();
|
|
14
25
|
const status = useBlockStatus(config.routes.api, block?.experiment, true);
|
|
15
26
|
const synced = useRef(false), syncing = useRef(false);
|
|
16
27
|
const [notice, setNotice] = useState(false), [error, setError] = useState(), [busy, setBusy] = useState(false);
|
|
17
|
-
const [
|
|
28
|
+
const [syncError, setSyncError] = useState();
|
|
29
|
+
const [confirmation, setConfirmation] = useState();
|
|
18
30
|
const canSync = !initializing && manager && block && field && liveStatus(status) && [
|
|
19
31
|
'draft',
|
|
20
32
|
'stopped'
|
|
@@ -23,7 +35,7 @@ export function BlockStatusField({ path }) {
|
|
|
23
35
|
if (!canSync || syncing.current) return;
|
|
24
36
|
syncing.current = true;
|
|
25
37
|
setBusy(true);
|
|
26
|
-
|
|
38
|
+
setSyncError(undefined);
|
|
27
39
|
try {
|
|
28
40
|
const next = syncExperimentSlots(block, status.arms, field);
|
|
29
41
|
if (JSON.stringify(next.slots) !== JSON.stringify(block.slots)) {
|
|
@@ -32,8 +44,8 @@ export function BlockStatusField({ path }) {
|
|
|
32
44
|
]);
|
|
33
45
|
setNotice(true);
|
|
34
46
|
}
|
|
35
|
-
} catch
|
|
36
|
-
|
|
47
|
+
} catch (error) {
|
|
48
|
+
setSyncError(errorMessage(error));
|
|
37
49
|
} finally{
|
|
38
50
|
syncing.current = false;
|
|
39
51
|
setBusy(false);
|
|
@@ -44,45 +56,115 @@ export function BlockStatusField({ path }) {
|
|
|
44
56
|
synced.current = true;
|
|
45
57
|
void sync();
|
|
46
58
|
});
|
|
47
|
-
if (!status) return null;
|
|
48
|
-
|
|
59
|
+
if (!status || !manager) return null;
|
|
60
|
+
const draft = liveStatus(status) && status.status === 'draft';
|
|
61
|
+
const stopped = liveStatus(status) && status.status === 'stopped';
|
|
62
|
+
async function unwrap(deleteDraft = false) {
|
|
49
63
|
if (!block || !field || busy) return;
|
|
50
64
|
setBusy(true);
|
|
51
65
|
setError(undefined);
|
|
66
|
+
let deleted = false;
|
|
52
67
|
try {
|
|
68
|
+
if (deleteDraft) {
|
|
69
|
+
const api = createApi(config.routes.api);
|
|
70
|
+
const found = await api.findTestIdBySlug(block.experiment);
|
|
71
|
+
if (!found.ok) throw new RefusalError(found.message);
|
|
72
|
+
const removed = await api.deleteTest(found.data, {
|
|
73
|
+
draft: true
|
|
74
|
+
});
|
|
75
|
+
if (!removed.ok) throw new RefusalError(removed.message);
|
|
76
|
+
deleted = true;
|
|
77
|
+
notifyTestDocument(config.routes.api, found.data);
|
|
78
|
+
setBlockStatus(config.routes.api, block.experiment, {
|
|
79
|
+
deleted: true
|
|
80
|
+
});
|
|
81
|
+
}
|
|
53
82
|
await replace(unwrapExperimentBlock(block, field));
|
|
54
|
-
|
|
55
|
-
|
|
83
|
+
setConfirmation(undefined);
|
|
84
|
+
toast.success(blockUnwrapNotice(Boolean(collection?.versions?.drafts), deleted));
|
|
85
|
+
} catch (error) {
|
|
86
|
+
setError(deleted ? BLOCK_COPY.finishUnwrap : errorMessage(error));
|
|
56
87
|
} finally{
|
|
57
88
|
setBusy(false);
|
|
58
89
|
}
|
|
59
90
|
}
|
|
60
91
|
const sentence = statusSentence(status);
|
|
92
|
+
const linkedCopy = liveStatus(status) ? status.status === 'running' ? blockRunningUnwrap : status.status === 'decided' ? blockDecidedUnwrap : status.status === 'archived' && status.winnerArm && !status.discarded ? blockFinishedCopy(slotLabel(status.winnerArm, status), status.winnerArm === 'control', status.winnerArm !== 'control' && canUnwrapOriginal(status, block)) : undefined : undefined;
|
|
93
|
+
const href = formatAdminURL({
|
|
94
|
+
adminRoute: config.routes.admin,
|
|
95
|
+
path: `/experiments/by-slug/${encodeURIComponent(block?.experiment ?? '')}`
|
|
96
|
+
});
|
|
61
97
|
return /*#__PURE__*/ _jsxs("div", {
|
|
62
98
|
children: [
|
|
63
99
|
liveStatus(status) && status.status === 'running' ? /*#__PURE__*/ _jsx(Banner, {
|
|
64
100
|
children: sentence
|
|
65
|
-
}) : /*#__PURE__*/ _jsx("p", {
|
|
101
|
+
}) : linkedCopy && liveStatus(status) && status.status === 'archived' ? null : /*#__PURE__*/ _jsx("p", {
|
|
66
102
|
children: sentence
|
|
67
103
|
}),
|
|
104
|
+
linkedCopy ? /*#__PURE__*/ _jsxs("p", {
|
|
105
|
+
children: [
|
|
106
|
+
linkedCopy.before,
|
|
107
|
+
/*#__PURE__*/ _jsx("a", {
|
|
108
|
+
href: href,
|
|
109
|
+
children: linkedCopy.link
|
|
110
|
+
}),
|
|
111
|
+
linkedCopy.after
|
|
112
|
+
]
|
|
113
|
+
}) : null,
|
|
114
|
+
linkedCopy && liveStatus(status) && status.status === 'archived' && !canUnwrapOriginal(status, block) ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
115
|
+
children: [
|
|
116
|
+
/*#__PURE__*/ _jsx("p", {
|
|
117
|
+
children: BLOCK_COPY.archivedReplaceWhy
|
|
118
|
+
}),
|
|
119
|
+
/*#__PURE__*/ _jsx("ol", {
|
|
120
|
+
children: BLOCK_COPY.archivedReplaceSteps.map((step)=>/*#__PURE__*/ _jsx("li", {
|
|
121
|
+
children: step
|
|
122
|
+
}, step))
|
|
123
|
+
})
|
|
124
|
+
]
|
|
125
|
+
}) : null,
|
|
68
126
|
notice ? /*#__PURE__*/ _jsx("p", {
|
|
69
127
|
role: "status",
|
|
70
128
|
children: blockSyncNotice(Boolean(collection?.versions?.drafts))
|
|
71
129
|
}) : null,
|
|
72
|
-
|
|
130
|
+
canUnwrapOriginal(status, block) || draft || stopped ? /*#__PURE__*/ _jsx(Button, {
|
|
73
131
|
disabled: busy,
|
|
74
|
-
onClick: ()=>
|
|
75
|
-
|
|
132
|
+
onClick: (event)=>{
|
|
133
|
+
if (draft || stopped) {
|
|
134
|
+
event?.currentTarget?.focus();
|
|
135
|
+
setError(undefined);
|
|
136
|
+
setConfirmation({
|
|
137
|
+
name: status.name,
|
|
138
|
+
draft
|
|
139
|
+
});
|
|
140
|
+
} else void unwrap();
|
|
141
|
+
},
|
|
142
|
+
children: draft ? BLOCK_COPY.removeAndUnwrap : BLOCK_COPY.unwrap
|
|
143
|
+
}) : null,
|
|
144
|
+
confirmation ? /*#__PURE__*/ _jsx(ConfirmDialog, {
|
|
145
|
+
title: actionTitle(confirmation.draft ? BLOCK_COPY.deleteAndUnwrap : BLOCK_COPY.unwrap, confirmation.name),
|
|
146
|
+
description: confirmation.draft ? blockDeleteConfirmation(confirmation.name) : blockUnwrapConfirmation(confirmation.name),
|
|
147
|
+
cancelLabel: BLOCK_COPY.cancel,
|
|
148
|
+
onClose: ()=>setConfirmation(undefined),
|
|
149
|
+
busy: busy,
|
|
150
|
+
busyLabel: READINESS_COPY.changing,
|
|
151
|
+
error: error,
|
|
152
|
+
confirm: {
|
|
153
|
+
label: confirmation.draft ? BLOCK_COPY.deleteAndUnwrap : BLOCK_COPY.unwrap,
|
|
154
|
+
destructive: true,
|
|
155
|
+
disabled: confirmation.draft ? !draft : !stopped,
|
|
156
|
+
onClick: ()=>unwrap(confirmation.draft)
|
|
157
|
+
}
|
|
76
158
|
}) : null,
|
|
77
|
-
error ? /*#__PURE__*/ _jsx("p", {
|
|
159
|
+
error && !confirmation ? /*#__PURE__*/ _jsx("p", {
|
|
78
160
|
role: "alert",
|
|
79
161
|
children: error
|
|
80
162
|
}) : null,
|
|
81
|
-
|
|
163
|
+
syncError ? /*#__PURE__*/ _jsx("p", {
|
|
82
164
|
role: "alert",
|
|
83
|
-
children:
|
|
165
|
+
children: syncError
|
|
84
166
|
}) : null,
|
|
85
|
-
|
|
167
|
+
syncError && canSync ? /*#__PURE__*/ _jsx(Button, {
|
|
86
168
|
disabled: busy,
|
|
87
169
|
onClick: ()=>void sync(),
|
|
88
170
|
children: BLOCK_COPY.retry
|
|
@@ -104,8 +186,7 @@ export function CopyOriginalField({ path }) {
|
|
|
104
186
|
const rowPath = path.slice(0, path.lastIndexOf('.'));
|
|
105
187
|
const slot = form.getDataByPath(`${rowPath}.slot`);
|
|
106
188
|
const [busy, setBusy] = useState(false), [error, setError] = useState();
|
|
107
|
-
const
|
|
108
|
-
const modalSlug = `xp-copy-original-${useId()}`;
|
|
189
|
+
const [confirming, setConfirming] = useState(false);
|
|
109
190
|
if (!manager || !field || !block || !slot || slot === 'control' || !liveStatus(status) || ![
|
|
110
191
|
'draft',
|
|
111
192
|
'stopped',
|
|
@@ -119,15 +200,19 @@ export function CopyOriginalField({ path }) {
|
|
|
119
200
|
await replace([
|
|
120
201
|
copyOriginalIntoVersion(block, slot, field)
|
|
121
202
|
]);
|
|
122
|
-
|
|
123
|
-
|
|
203
|
+
setConfirming(false);
|
|
204
|
+
} catch (error) {
|
|
205
|
+
setError(errorMessage(error));
|
|
124
206
|
} finally{
|
|
125
207
|
setBusy(false);
|
|
126
208
|
}
|
|
127
209
|
}
|
|
128
|
-
function requestCopy() {
|
|
129
|
-
if (block?.slots.find((row)=>row.slot === slot)?.blocks?.length)
|
|
130
|
-
|
|
210
|
+
function requestCopy(event) {
|
|
211
|
+
if (block?.slots.find((row)=>row.slot === slot)?.blocks?.length) {
|
|
212
|
+
event?.currentTarget?.focus();
|
|
213
|
+
setError(undefined);
|
|
214
|
+
setConfirming(true);
|
|
215
|
+
} else void copy();
|
|
131
216
|
}
|
|
132
217
|
return /*#__PURE__*/ _jsxs("div", {
|
|
133
218
|
children: [
|
|
@@ -136,15 +221,22 @@ export function CopyOriginalField({ path }) {
|
|
|
136
221
|
onClick: requestCopy,
|
|
137
222
|
children: BLOCK_COPY.copy
|
|
138
223
|
}),
|
|
139
|
-
/*#__PURE__*/ _jsx(
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
confirmLabel: BLOCK_COPY.replace,
|
|
224
|
+
/*#__PURE__*/ _jsx(ConfirmDialog, {
|
|
225
|
+
open: confirming,
|
|
226
|
+
title: actionTitle(BLOCK_COPY.replaceVersion, status.name),
|
|
227
|
+
description: BLOCK_COPY.confirmCopy,
|
|
144
228
|
cancelLabel: BLOCK_COPY.cancel,
|
|
145
|
-
|
|
229
|
+
onClose: ()=>setConfirming(false),
|
|
230
|
+
busy: busy,
|
|
231
|
+
busyLabel: READINESS_COPY.changing,
|
|
232
|
+
error: error,
|
|
233
|
+
confirm: {
|
|
234
|
+
label: BLOCK_COPY.replace,
|
|
235
|
+
destructive: true,
|
|
236
|
+
onClick: copy
|
|
237
|
+
}
|
|
146
238
|
}),
|
|
147
|
-
error ? /*#__PURE__*/ _jsx("p", {
|
|
239
|
+
error && !confirming ? /*#__PURE__*/ _jsx("p", {
|
|
148
240
|
role: "alert",
|
|
149
241
|
children: error
|
|
150
242
|
}) : null
|
|
@@ -6,9 +6,9 @@ import { useMemo, useRef, useState } from 'react';
|
|
|
6
6
|
import { hostBlocks } from '../../blocks/model.js';
|
|
7
7
|
import { wrapExperimentBlock } from '../../blocks/formState.js';
|
|
8
8
|
import { CreateRefused, createTest } from '../../puck/editor/createTest.js';
|
|
9
|
-
import { createApi } from '
|
|
10
|
-
import { BLOCK_COPY, blockSaveNotice, blockTestName } from '
|
|
11
|
-
import { API_MESSAGES } from '
|
|
9
|
+
import { createApi } from '../../testSurface/api.js';
|
|
10
|
+
import { BLOCK_COPY, blockSaveNotice, blockTestName } from '../../admin/copy/blocks.js';
|
|
11
|
+
import { API_MESSAGES } from '../../testSurface/copy/common.js';
|
|
12
12
|
import { adaptClientBlocksField, BlockChangedError, dataAt, experimentBlockSlug, findClientBlocksField, replaceBlockRow, wrapMode } from './formApi.js';
|
|
13
13
|
import { blockChoices, labelText } from './model.js';
|
|
14
14
|
export function TestBlockField(props) {
|
|
@@ -5,6 +5,9 @@ import { type HostBlock } from '../../blocks/model.js';
|
|
|
5
5
|
export declare class BlockChangedError extends Error {
|
|
6
6
|
constructor();
|
|
7
7
|
}
|
|
8
|
+
/** An API refusal already translated into editor-facing copy. */
|
|
9
|
+
export declare class RefusalError extends Error {
|
|
10
|
+
}
|
|
8
11
|
export type RowsField = Extract<Field, {
|
|
9
12
|
type: 'blocks';
|
|
10
13
|
}>;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { EXPERIMENT_BLOCK_SLUG, hostBlocks } from '../../blocks/model.js';
|
|
2
|
-
import { BLOCK_COPY } from '
|
|
2
|
+
import { BLOCK_COPY } from '../../admin/copy/blocks.js';
|
|
3
3
|
/** The only form-state failure with block-specific editor copy. */ export class BlockChangedError extends Error {
|
|
4
4
|
constructor(){
|
|
5
5
|
super(BLOCK_COPY.blockChanged);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
/** An API refusal already translated into editor-facing copy. */ export class RefusalError extends Error {
|
|
9
|
+
}
|
|
8
10
|
export const wrapMode = 'form-api';
|
|
9
11
|
/** Client twin: unnamed layout containers do not contribute to a data path. */ export function findClientBlocksField(fields, name) {
|
|
10
12
|
for (const field of fields){
|
|
@@ -71,14 +73,18 @@ export function rowLocation(path) {
|
|
|
71
73
|
export function dataAt(data, path) {
|
|
72
74
|
return path.split('.').reduce((value, key)=>value && typeof value === 'object' ? value[key] : undefined, data);
|
|
73
75
|
}
|
|
76
|
+
/** Stable object keys; array order and scalar values remain significant. */ function stringify(value) {
|
|
77
|
+
return JSON.stringify(value, (_, item)=>item && typeof item === 'object' && !Array.isArray(item) ? Object.fromEntries(Object.entries(item).sort(([a], [b])=>a < b ? -1 : a > b ? 1 : 0)) : item);
|
|
78
|
+
}
|
|
74
79
|
/** Payload 3.90.2 and 4 beta.6 use the same row APIs. Sync replaces the whole
|
|
75
80
|
* wrapper so add/drop/reorder and the server-rendered component slots stay together.
|
|
76
81
|
* N=0 needs UPDATE: removeFieldRow alone serializes the empty field as number 0.
|
|
77
82
|
*/ export async function replaceBlockRow(args) {
|
|
78
83
|
const { form, getFormState, collectionSlug, id, field, index, rows } = args;
|
|
79
84
|
const data = form.getData(), before = hostBlocks(data[field]);
|
|
80
|
-
if (args.expectedBlock &&
|
|
81
|
-
|
|
85
|
+
if (args.expectedBlock && stringify(form.getDataByPath(`${field}.${index}`)) !== stringify(args.expectedBlock)) throw new BlockChangedError();
|
|
86
|
+
// Compare the same reader on both sides: getData() keeps empty row counts as 0.
|
|
87
|
+
const original = stringify(form.getDataByPath(field));
|
|
82
88
|
const next = [
|
|
83
89
|
...before.slice(0, index),
|
|
84
90
|
...rows,
|
|
@@ -100,7 +106,7 @@ export function dataAt(data, path) {
|
|
|
100
106
|
renderAllFields: true,
|
|
101
107
|
skipValidation: true
|
|
102
108
|
});
|
|
103
|
-
if (
|
|
109
|
+
if (stringify(form.getDataByPath(field)) !== original) throw new BlockChangedError();
|
|
104
110
|
if (!result.state) throw new Error('Missing server form state');
|
|
105
111
|
const state = result.state;
|
|
106
112
|
function subFieldState(rowIndex) {
|
|
@@ -7,6 +7,7 @@ import { XP_TEST_BLOCK } from '../paths.js';
|
|
|
7
7
|
name: 'xpTestBlock',
|
|
8
8
|
type: 'ui',
|
|
9
9
|
admin: {
|
|
10
|
+
// Payload supplies the active locale's form data here; there is no raw adapter row.
|
|
10
11
|
condition: (data)=>{
|
|
11
12
|
try {
|
|
12
13
|
return registration.appliesTo ? registration.appliesTo(data) === true : true;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { PlacementStatusResult } from '../../types/endpoints.js';
|
|
2
|
+
import { type HostBlock } from '../../blocks/model.js';
|
|
2
3
|
import type { RowsField } from './formApi.js';
|
|
3
4
|
export type BlockStatus = PlacementStatusResult['slugs'][string];
|
|
4
5
|
export type LiveBlockStatus = Extract<BlockStatus, {
|
|
@@ -7,10 +8,10 @@ export type LiveBlockStatus = Extract<BlockStatus, {
|
|
|
7
8
|
export declare function liveStatus(status: BlockStatus | null): status is LiveBlockStatus;
|
|
8
9
|
export declare function slotLabel(slot: string, status: BlockStatus | null): string;
|
|
9
10
|
export declare function statusSentence(status: BlockStatus): string;
|
|
10
|
-
export declare function
|
|
11
|
+
export declare function canUnwrapOriginal(status: BlockStatus, block?: HostBlock): boolean;
|
|
11
12
|
export declare function labelText(value: unknown): string | undefined;
|
|
12
13
|
export declare function blockChoices(value: unknown, field: RowsField, blockSlug: string): {
|
|
13
|
-
block:
|
|
14
|
+
block: HostBlock;
|
|
14
15
|
index: number;
|
|
15
16
|
label: string;
|
|
16
17
|
option: string;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { hostBlocks } from '../../blocks/model.js';
|
|
2
|
-
import { BLOCK_COPY, blockDecidedStatus, blockDraftStatus, blockFinishedStatus, blockPosition } from '
|
|
1
|
+
import { hostBlocks, slotBlocks } from '../../blocks/model.js';
|
|
2
|
+
import { BLOCK_COPY, blockDecidedStatus, blockDraftStatus, blockFinishedStatus, blockPosition } from '../../admin/copy/blocks.js';
|
|
3
3
|
export function liveStatus(status) {
|
|
4
4
|
return !!status && 'status' in status;
|
|
5
5
|
}
|
|
6
6
|
export function slotLabel(slot, status) {
|
|
7
|
-
return (liveStatus(status) ? status.arms.find((arm)=>arm.key !== 'holdout' &&
|
|
7
|
+
return (liveStatus(status) ? status.arms.find((arm)=>arm.key !== 'holdout' && arm.key === slot)?.label : undefined) || BLOCK_COPY.slotLabels[slot] || slot;
|
|
8
8
|
}
|
|
9
9
|
export function statusSentence(status) {
|
|
10
10
|
if (!liveStatus(status)) return BLOCK_COPY.deleted;
|
|
@@ -20,11 +20,15 @@ export function statusSentence(status) {
|
|
|
20
20
|
case 'decided':
|
|
21
21
|
return blockDecidedStatus(winnerLabel, status.rollout);
|
|
22
22
|
case 'archived':
|
|
23
|
-
return status.winnerArm ? blockFinishedStatus(winnerLabel) : BLOCK_COPY.
|
|
23
|
+
return status.discarded ? BLOCK_COPY.discarded : status.winnerArm ? blockFinishedStatus(winnerLabel, status.winnerArm === 'control') : BLOCK_COPY.neverDecided;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
export function
|
|
27
|
-
|
|
26
|
+
export function canUnwrapOriginal(status, block) {
|
|
27
|
+
if (!liveStatus(status)) return true;
|
|
28
|
+
if (status.status !== 'archived') return false;
|
|
29
|
+
if (status.discarded || !status.winnerArm || status.winnerArm === 'control') return true;
|
|
30
|
+
const slot = status.winnerArm;
|
|
31
|
+
return !!block && slotBlocks(block, slot).length === 0;
|
|
28
32
|
}
|
|
29
33
|
export function labelText(value) {
|
|
30
34
|
return typeof value === 'string' ? value : value && typeof value === 'object' ? Object.values(value).find((item)=>typeof item === 'string') : undefined;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { BlockStatus } from './model.js';
|
|
2
2
|
export declare const validBlockSlug: (slug: unknown) => slug is string;
|
|
3
|
+
/** Update a mounted owner's snapshot and invalidate an older pending read. */
|
|
4
|
+
export declare function setBlockStatus(api: string, slug: string, value: BlockStatus): void;
|
|
3
5
|
/** Only status fields own reads. StrictMode replays the same mount token; a
|
|
4
6
|
* different owner after the last cleanup starts fresh, even in the same commit.
|
|
5
7
|
* Deferred eviction removes every entry with no live owner after that commit.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useCallback, useEffect, useRef, useSyncExternalStore } from 'react';
|
|
2
|
-
import { createApi } from '
|
|
2
|
+
import { createApi } from '../../testSurface/api.js';
|
|
3
3
|
const cache = new Map();
|
|
4
4
|
// Subscribers do not create status entries: a label alone owns no cached data.
|
|
5
5
|
const listeners = new Map();
|
|
@@ -9,6 +9,13 @@ const keyOf = (api, slug)=>JSON.stringify([
|
|
|
9
9
|
]);
|
|
10
10
|
const publish = (key)=>listeners.get(key)?.callbacks.forEach((listener)=>listener());
|
|
11
11
|
export const validBlockSlug = (slug)=>typeof slug === 'string' && slug.length > 0 && slug.length <= 64;
|
|
12
|
+
/** Update a mounted owner's snapshot and invalidate an older pending read. */ export function setBlockStatus(api, slug, value) {
|
|
13
|
+
const key = keyOf(api, slug), current = cache.get(key);
|
|
14
|
+
if (!current) return;
|
|
15
|
+
current.revision++;
|
|
16
|
+
current.value = value;
|
|
17
|
+
publish(key);
|
|
18
|
+
}
|
|
12
19
|
/** Only status fields own reads. StrictMode replays the same mount token; a
|
|
13
20
|
* different owner after the last cleanup starts fresh, even in the same commit.
|
|
14
21
|
* Deferred eviction removes every entry with no live owner after that commit.
|
|
@@ -47,7 +54,8 @@ export const validBlockSlug = (slug)=>typeof slug === 'string' && slug.length >
|
|
|
47
54
|
current = {
|
|
48
55
|
value: null,
|
|
49
56
|
owners: 0,
|
|
50
|
-
mounts: new WeakSet()
|
|
57
|
+
mounts: new WeakSet(),
|
|
58
|
+
revision: 0
|
|
51
59
|
};
|
|
52
60
|
cache.set(key, current);
|
|
53
61
|
}
|
|
@@ -55,12 +63,13 @@ export const validBlockSlug = (slug)=>typeof slug === 'string' && slug.length >
|
|
|
55
63
|
owned.owners++;
|
|
56
64
|
owned.mounts.add(token.current);
|
|
57
65
|
publish(key);
|
|
66
|
+
const revision = owned.revision;
|
|
58
67
|
if (!owned.pending) owned.pending = createApi(api).placementStatus({
|
|
59
68
|
slugs: [
|
|
60
69
|
slug
|
|
61
70
|
]
|
|
62
71
|
}).then((result)=>{
|
|
63
|
-
if (cache.get(key) !== owned) return;
|
|
72
|
+
if (cache.get(key) !== owned || owned.revision !== revision) return;
|
|
64
73
|
owned.value = result.ok ? result.data?.slugs[slug] ?? null : null;
|
|
65
74
|
publish(key);
|
|
66
75
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import '../theme.css';
|
|
4
|
-
import { theme } from '
|
|
4
|
+
import { theme } from '../../testSurface/theme.js';
|
|
5
5
|
export function RootViewMessage({ children, alert = false }) {
|
|
6
6
|
return /*#__PURE__*/ _jsx("div", {
|
|
7
7
|
role: alert ? 'alert' : undefined,
|
|
@@ -4,6 +4,7 @@ export declare const BLOCK_COPY: {
|
|
|
4
4
|
empty: string;
|
|
5
5
|
blockChanged: string;
|
|
6
6
|
replace: string;
|
|
7
|
+
replaceVersion: string;
|
|
7
8
|
cancel: string;
|
|
8
9
|
retry: string;
|
|
9
10
|
saveFirst: string;
|
|
@@ -11,10 +12,18 @@ export declare const BLOCK_COPY: {
|
|
|
11
12
|
copy: string;
|
|
12
13
|
confirmCopy: string;
|
|
13
14
|
unwrap: string;
|
|
15
|
+
removeAndUnwrap: string;
|
|
16
|
+
deleteAndUnwrap: string;
|
|
17
|
+
alreadyDeleted: "This test was already deleted. Reload the page.";
|
|
18
|
+
noLongerDraft: "This test is no longer a draft. Reload the page.";
|
|
19
|
+
finishUnwrap: string;
|
|
14
20
|
deleted: string;
|
|
15
21
|
discarded: string;
|
|
22
|
+
neverDecided: string;
|
|
16
23
|
running: string;
|
|
17
24
|
stopped: string;
|
|
25
|
+
archivedReplaceWhy: string;
|
|
26
|
+
archivedReplaceSteps: string[];
|
|
18
27
|
slotLabels: Record<string, string>;
|
|
19
28
|
wrapRefusals: Record<string, string>;
|
|
20
29
|
};
|
|
@@ -22,6 +31,17 @@ export declare const blockPosition: (label: string, position: number) => string;
|
|
|
22
31
|
export declare const blockTestName: (title: string, label: string) => string;
|
|
23
32
|
export declare const blockDraftStatus: (name: string) => string;
|
|
24
33
|
export declare const blockDecidedStatus: (winner: string, rollout: boolean) => string;
|
|
25
|
-
export
|
|
34
|
+
export type BlockLinkedCopy = {
|
|
35
|
+
before: string;
|
|
36
|
+
link: string;
|
|
37
|
+
after: string;
|
|
38
|
+
};
|
|
39
|
+
export declare const blockRunningUnwrap: BlockLinkedCopy;
|
|
40
|
+
export declare const blockDecidedUnwrap: BlockLinkedCopy;
|
|
41
|
+
export declare const blockFinishedCopy: (winner: string, originalWon?: boolean, emptyWinner?: boolean) => BlockLinkedCopy;
|
|
42
|
+
export declare const blockFinishedStatus: (winner: string, originalWon?: boolean) => string;
|
|
43
|
+
export declare const blockDeleteConfirmation: (name: string) => string;
|
|
44
|
+
export declare const blockUnwrapConfirmation: (name: string) => string;
|
|
45
|
+
export declare const blockUnwrapNotice: (drafts: boolean, deleted: boolean) => string;
|
|
26
46
|
export declare const blockSaveNotice: (drafts: boolean) => "Save a draft of this page to add the test." | "Save this page to add the test.";
|
|
27
47
|
export declare const blockSyncNotice: (drafts: boolean) => "Versions were updated to match the test. Save draft to keep them." | "Versions were updated to match the test. Save to keep them.";
|