@delmaredigital/payload-experiments 0.3.0-rc.1 → 0.4.0-rc.1
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 +172 -21
- package/dist/admin/MetricSourceSelect.js +3 -3
- package/dist/admin/PlacementStatus.d.ts +3 -0
- package/dist/admin/PlacementStatus.js +54 -0
- package/dist/admin/PreviewLinks.d.ts +2 -1
- package/dist/admin/PreviewLinks.js +47 -26
- package/dist/admin/TestsNavLink.d.ts +3 -1
- package/dist/admin/TestsNavLink.js +2 -2
- package/dist/admin/actions/ConfirmDialog.d.ts +2 -1
- package/dist/admin/actions/ConfirmDialog.js +2 -2
- package/dist/admin/actions/DecideDialog.d.ts +2 -1
- package/dist/admin/actions/DecideDialog.js +2 -2
- package/dist/admin/api.d.ts +11 -2
- package/dist/admin/api.js +20 -2
- package/dist/admin/armSelect/ArmSelectField.js +14 -22
- package/dist/admin/arms/arms.model.d.ts +1 -21
- package/dist/admin/arms/arms.model.js +1 -153
- package/dist/admin/blocks/BlockPanel.d.ts +4 -0
- package/dist/admin/blocks/BlockPanel.js +153 -0
- package/dist/admin/blocks/TestBlockField.d.ts +5 -0
- package/dist/admin/blocks/TestBlockField.js +163 -0
- package/dist/admin/blocks/formApi.d.ts +43 -0
- package/dist/admin/blocks/formApi.js +153 -0
- package/dist/admin/blocks/inject.d.ts +7 -0
- package/dist/admin/blocks/inject.js +41 -0
- package/dist/admin/blocks/model.d.ts +17 -0
- package/dist/admin/blocks/model.js +45 -0
- package/dist/admin/blocks/statusCache.d.ts +7 -0
- package/dist/admin/blocks/statusCache.js +83 -0
- package/dist/admin/blocks/useBlockForm.d.ts +17 -0
- package/dist/admin/blocks/useBlockForm.js +46 -0
- package/dist/admin/copy/actions.d.ts +2 -0
- package/dist/admin/copy/actions.js +9 -0
- package/dist/admin/copy/arms.d.ts +1 -6
- package/dist/admin/copy/arms.js +1 -16
- package/dist/admin/copy/blocks.d.ts +27 -0
- package/dist/admin/copy/blocks.js +38 -0
- package/dist/admin/copy/goals.d.ts +2 -0
- package/dist/admin/copy/goals.js +4 -1
- package/dist/admin/copy/newTest.d.ts +10 -0
- package/dist/admin/copy/newTest.js +10 -0
- package/dist/admin/copy/pages.d.ts +26 -0
- package/dist/admin/copy/pages.js +26 -0
- package/dist/admin/copy/readiness.d.ts +25 -3
- package/dist/admin/copy/readiness.js +25 -3
- package/dist/admin/copy/results.d.ts +3 -0
- package/dist/admin/copy/results.js +4 -1
- package/dist/admin/copy/review.d.ts +1 -1
- package/dist/admin/copy/review.js +1 -1
- package/dist/admin/copy/surface.d.ts +0 -1
- package/dist/admin/copy/surface.js +0 -1
- package/dist/admin/copy/testPage.d.ts +4 -0
- package/dist/admin/copy/testPage.js +4 -0
- package/dist/admin/goals/XpGoalField.d.ts +2 -0
- package/dist/admin/goals/XpGoalField.js +152 -0
- package/dist/admin/metricSource.model.d.ts +2 -0
- package/dist/admin/metricSource.model.js +4 -0
- package/dist/admin/pageCollections.d.ts +10 -0
- package/dist/admin/pageCollections.js +20 -0
- package/dist/admin/paths.d.ts +8 -1
- package/dist/admin/paths.js +8 -1
- package/dist/admin/placementStatus.model.d.ts +2 -0
- package/dist/admin/placementStatus.model.js +19 -0
- package/dist/admin/placements/placementLabels.d.ts +11 -0
- package/dist/admin/placements/placementLabels.js +21 -0
- package/dist/admin/placements/placementLabels.model.d.ts +13 -0
- package/dist/admin/placements/placementLabels.model.js +12 -0
- package/dist/admin/placements/usePlacementLabels.d.ts +12 -0
- package/dist/admin/placements/usePlacementLabels.js +102 -0
- package/dist/admin/previewLinks.model.d.ts +2 -0
- package/dist/admin/previewLinks.model.js +3 -0
- package/dist/admin/results/DataQualityPanel.js +4 -1
- package/dist/admin/results/legacy.d.ts +16 -0
- package/dist/admin/results/legacy.js +27 -0
- package/dist/admin/results/results.model.d.ts +9 -6
- package/dist/admin/results/results.model.js +22 -9
- package/dist/admin/results/snapshot.d.ts +14 -0
- package/dist/admin/results/snapshot.js +3 -0
- package/dist/admin/surface/TestsHome.js +43 -15
- package/dist/admin/surface/TestsSurface.js +5 -1
- package/dist/admin/surface/contracts.d.ts +6 -5
- package/dist/admin/surface/goals/GoalForm.js +67 -34
- package/dist/admin/surface/goals/GoalsList.js +3 -3
- package/dist/admin/surface/goals/data.js +19 -16
- package/dist/admin/surface/goals/goals.model.d.ts +1 -2
- package/dist/admin/surface/goals/goals.model.js +1 -3
- package/dist/admin/surface/home.model.d.ts +2 -1
- package/dist/admin/surface/home.model.js +8 -4
- package/dist/admin/surface/newTest/NewTest.js +58 -17
- package/dist/admin/surface/newTest/PageWizard.d.ts +7 -0
- package/dist/admin/surface/newTest/PageWizard.js +209 -0
- package/dist/admin/surface/pagePicker/CopyRoute.d.ts +6 -0
- package/dist/admin/surface/pagePicker/CopyRoute.js +53 -0
- package/dist/admin/surface/pagePicker/PagePicker.d.ts +10 -0
- package/dist/admin/surface/pagePicker/PagePicker.js +172 -0
- package/dist/admin/surface/pagePicker/pagePicker.model.d.ts +25 -0
- package/dist/admin/surface/pagePicker/pagePicker.model.js +25 -0
- package/dist/admin/surface/readiness/ActionDialogs.js +103 -69
- package/dist/admin/surface/readiness/Banner.js +30 -6
- package/dist/admin/surface/readiness/readiness.model.d.ts +8 -1
- package/dist/admin/surface/readiness/readiness.model.js +95 -6
- package/dist/admin/surface/results/ReleasePages.d.ts +3 -1
- package/dist/admin/surface/results/ReleasePages.js +3 -7
- package/dist/admin/surface/results/ResultsBody.js +23 -3
- package/dist/admin/surface/results/ResultsHeader.js +2 -5
- package/dist/admin/surface/results/recommendation.model.d.ts +3 -2
- package/dist/admin/surface/results/recommendation.model.js +10 -3
- package/dist/admin/surface/results/useResults.d.ts +10 -1
- package/dist/admin/surface/surface.css +0 -1
- package/dist/admin/surface/test/AdvancedSection.js +111 -104
- package/dist/admin/surface/test/GoalSection.js +97 -22
- package/dist/admin/surface/test/LengthSection.js +1 -1
- package/dist/admin/surface/test/PageHoldout.d.ts +3 -0
- package/dist/admin/surface/test/PageHoldout.js +67 -0
- package/dist/admin/surface/test/TestPage.js +2 -1
- package/dist/admin/surface/test/VersionsSection.js +12 -5
- package/dist/admin/surface/test/fields.d.ts +13 -4
- package/dist/admin/surface/test/fields.js +46 -14
- package/dist/admin/surface/test/jumpToSection.d.ts +1 -1
- package/dist/admin/surface/test/jumpToSection.js +4 -3
- package/dist/admin/surface/test/pageParts.d.ts +4 -1
- package/dist/admin/surface/test/pageParts.js +79 -2
- package/dist/admin/surface/test/testPage.css +8 -1
- package/dist/admin/surface/test/testPage.model.d.ts +2 -3
- package/dist/admin/surface/test/testPage.model.js +1 -21
- package/dist/admin/surface/testDocument.model.d.ts +1 -0
- package/dist/admin/surface/testDocument.model.js +2 -1
- package/dist/admin/surface/useTestDocument.d.ts +11 -2
- package/dist/admin/surface/useTestDocument.js +55 -16
- package/dist/admin/useApi.d.ts +11 -2
- package/dist/admin/useApi.js +3 -5
- package/dist/admin/useLayerUsage.js +14 -23
- package/dist/admin/views/ExperimentsRootView.js +58 -16
- package/dist/admin/views/TestsNavLinkServer.d.ts +2 -0
- package/dist/admin/views/TestsNavLinkServer.js +43 -0
- package/dist/arms/copy.d.ts +6 -0
- package/dist/arms/copy.js +16 -0
- package/dist/arms/model.d.ts +23 -0
- package/dist/arms/model.js +173 -0
- package/dist/blocks/bindings.d.ts +3 -0
- package/dist/blocks/bindings.js +34 -0
- package/dist/blocks/createExperimentBlock.d.ts +6 -0
- package/dist/blocks/createExperimentBlock.js +77 -0
- package/dist/blocks/formState.d.ts +31 -0
- package/dist/blocks/formState.js +146 -0
- package/dist/blocks/model.d.ts +41 -0
- package/dist/blocks/model.js +34 -0
- package/dist/client/ExperimentGroup.d.ts +6 -0
- package/dist/client/ExperimentGroup.js +9 -0
- package/dist/client/ExperimentsProvider.js +20 -4
- package/dist/client/clickGoals.d.ts +4 -0
- package/dist/client/clickGoals.js +43 -0
- package/dist/collections/experiments/config.js +12 -2
- package/dist/collections/experiments/deleteGuard.d.ts +2 -1
- package/dist/collections/experiments/deleteGuard.js +12 -1
- package/dist/collections/experiments/editability.js +4 -2
- package/dist/collections/experiments/pickSlug.d.ts +2 -0
- package/dist/collections/experiments/pickSlug.js +8 -0
- package/dist/collections/labels.d.ts +3 -0
- package/dist/collections/labels.js +20 -0
- package/dist/collections/metrics.js +12 -2
- package/dist/collections/phases.js +1 -0
- package/dist/collections/serialize.js +7 -0
- package/dist/db/appends.d.ts +6 -2
- package/dist/db/appends.js +10 -4
- package/dist/db/clickGoals.d.ts +9 -0
- package/dist/db/clickGoals.js +22 -0
- package/dist/db/delete.d.ts +1 -0
- package/dist/db/delete.js +1 -0
- package/dist/db/locks.d.ts +14 -0
- package/dist/db/locks.js +36 -1
- package/dist/db/names.d.ts +4 -0
- package/dist/db/names.js +4 -0
- package/dist/db/pageBindings.d.ts +4 -0
- package/dist/db/pageBindings.js +17 -0
- package/dist/db/pageBusy.d.ts +2 -0
- package/dist/db/pageBusy.js +10 -0
- package/dist/db/pageContent.d.ts +10 -0
- package/dist/db/pageContent.js +79 -0
- package/dist/db/pageOccupancy.d.ts +12 -0
- package/dist/db/pageOccupancy.js +45 -0
- package/dist/db/placements.d.ts +33 -0
- package/dist/db/placements.js +54 -0
- package/dist/db/slugs.d.ts +8 -0
- package/dist/db/slugs.js +40 -0
- package/dist/db/snapshots.d.ts +6 -0
- package/dist/db/snapshots.js +9 -5
- package/dist/endpoints/clickKeys.d.ts +5 -0
- package/dist/endpoints/clickKeys.js +17 -0
- package/dist/endpoints/events.js +4 -1
- package/dist/endpoints/index.js +28 -0
- package/dist/endpoints/pages.d.ts +5 -0
- package/dist/endpoints/pages.js +120 -0
- package/dist/endpoints/placementStatus.d.ts +6 -0
- package/dist/endpoints/placementStatus.js +238 -0
- package/dist/endpoints/readBody.d.ts +2 -0
- package/dist/endpoints/readBody.js +24 -0
- package/dist/endpoints/results.js +5 -1
- package/dist/endpoints/summary.js +11 -4
- package/dist/endpoints/wrapBlock.d.ts +6 -0
- package/dist/endpoints/wrapBlock.js +76 -0
- package/dist/errors.d.ts +3 -3
- package/dist/errors.js +4 -4
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +5 -3
- package/dist/exports/adminClient.d.ts +5 -0
- package/dist/exports/adminClient.js +5 -0
- package/dist/exports/adminRsc.d.ts +1 -0
- package/dist/exports/adminRsc.js +1 -0
- package/dist/exports/blocks.d.ts +2 -0
- package/dist/exports/blocks.js +1 -0
- package/dist/exports/client.d.ts +1 -0
- package/dist/exports/client.js +1 -0
- package/dist/exports/index.d.ts +6 -1
- package/dist/exports/index.js +3 -0
- package/dist/exports/puck.d.ts +5 -2
- package/dist/exports/puck.js +3 -1
- package/dist/exports/puckEditor.d.ts +6 -1
- package/dist/exports/puckEditor.js +4 -1
- package/dist/exports/rsc.d.ts +4 -0
- package/dist/exports/rsc.js +2 -0
- package/dist/fields/xpGoal.d.ts +3 -0
- package/dist/fields/xpGoal.js +28 -0
- package/dist/globals/state.js +10 -0
- package/dist/goals/cache.d.ts +3 -0
- package/dist/goals/cache.js +35 -0
- package/dist/goals/fairness.d.ts +40 -0
- package/dist/goals/fairness.js +200 -0
- package/dist/goals/key.d.ts +4 -0
- package/dist/goals/key.js +3 -0
- package/dist/goals/picker/clickGoalPicker.model.d.ts +29 -0
- package/dist/goals/picker/clickGoalPicker.model.js +45 -0
- package/dist/goals/picker/copy.d.ts +16 -0
- package/dist/goals/picker/copy.js +15 -0
- package/dist/goals/picker/useClickGoalPicker.d.ts +30 -0
- package/dist/goals/picker/useClickGoalPicker.js +220 -0
- package/dist/hooks/pageGuard.d.ts +5 -1
- package/dist/hooks/pageGuard.js +160 -80
- package/dist/lib/fetchAllDocs.d.ts +16 -0
- package/dist/lib/fetchAllDocs.js +56 -0
- package/dist/onInit.js +29 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +43 -10
- package/dist/plugin.js +45 -28
- package/dist/puck/ExperimentPicker.js +47 -16
- package/dist/puck/ExperimentSlot.d.ts +51 -1
- package/dist/puck/ExperimentSlot.js +23 -12
- package/dist/puck/copy.d.ts +6 -4
- package/dist/puck/copy.js +6 -4
- package/dist/puck/editor/CreateExperimentDrawer.js +46 -56
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +52 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +292 -137
- package/dist/puck/editor/ResultsReadout.d.ts +6 -0
- package/dist/puck/editor/ResultsReadout.js +99 -0
- package/dist/puck/editor/VersionBuilder.d.ts +34 -0
- package/dist/puck/editor/VersionBuilder.js +317 -0
- package/dist/puck/editor/armWrites.d.ts +7 -0
- package/dist/puck/editor/armWrites.js +71 -0
- package/dist/puck/editor/armsCache.d.ts +14 -0
- package/dist/puck/editor/armsCache.js +78 -0
- package/dist/puck/editor/copy.d.ts +33 -1
- package/dist/puck/editor/copy.js +45 -8
- package/dist/puck/editor/createTest.d.ts +1 -1
- package/dist/puck/editor/createTest.js +25 -14
- package/dist/puck/editor/editor.chrome.css +48 -161
- package/dist/puck/editor/editor.css +48 -161
- package/dist/puck/editor/editor.model.d.ts +8 -3
- package/dist/puck/editor/editor.model.js +16 -10
- package/dist/puck/editor/experimentOutlinePlugin.d.ts +3 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +89 -0
- package/dist/puck/editor/integration.d.ts +10 -0
- package/dist/puck/editor/integration.js +30 -0
- package/dist/puck/editor/xpGoalPuckEditorField.d.ts +7 -0
- package/dist/puck/editor/xpGoalPuckEditorField.js +134 -0
- package/dist/puck/experimentSlotField.d.ts +2 -0
- package/dist/puck/experimentSlotField.js +11 -3
- package/dist/puck/hostContext.d.ts +10 -0
- package/dist/puck/hostContext.js +12 -0
- package/dist/puck/integration.d.ts +6 -0
- package/dist/puck/integration.js +21 -0
- package/dist/puck/routes.d.ts +12 -0
- package/dist/puck/routes.js +11 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +2 -2
- package/dist/puck/xpGoalField.d.ts +3 -0
- package/dist/puck/xpGoalField.js +6 -0
- package/dist/results/health.d.ts +4 -0
- package/dist/results/health.js +27 -0
- package/dist/results/snapshot.js +15 -2
- package/dist/sanitizeReadinessDetail.js +51 -1
- package/dist/server/metadata.js +9 -2
- package/dist/server/normaliseContentRelationships.d.ts +7 -0
- package/dist/server/normaliseContentRelationships.js +62 -0
- package/dist/server/pageKindSeoContract.d.ts +27 -0
- package/dist/server/pageKindSeoContract.js +80 -0
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +72 -13
- package/dist/server/resolveExperimentBlocks.d.ts +5 -0
- package/dist/server/resolveExperimentBlocks.js +54 -0
- package/dist/server/runResults.js +92 -19
- package/dist/server/toClientAssignments.js +2 -1
- package/dist/transitions/addMetric.d.ts +2 -1
- package/dist/transitions/addMetric.js +28 -1
- package/dist/transitions/checkStart.d.ts +17 -1
- package/dist/transitions/checkStart.js +99 -7
- package/dist/transitions/decide.js +40 -1
- package/dist/transitions/deleteExperiment.d.ts +3 -1
- package/dist/transitions/deleteExperiment.js +27 -1
- package/dist/transitions/kernel.js +4 -0
- package/dist/transitions/makeContent.d.ts +5 -0
- package/dist/transitions/makeContent.js +39 -11
- package/dist/transitions/pageCollection.d.ts +10 -0
- package/dist/transitions/pageCollection.js +20 -0
- package/dist/transitions/pageVersions.d.ts +10 -0
- package/dist/transitions/pageVersions.js +44 -0
- package/dist/transitions/phaseRecord.d.ts +1 -0
- package/dist/transitions/placementInteractions.d.ts +40 -0
- package/dist/transitions/placementInteractions.js +94 -0
- package/dist/transitions/placements.d.ts +10 -6
- package/dist/transitions/placements.js +156 -2
- package/dist/transitions/preflightData.d.ts +8 -0
- package/dist/transitions/preflightData.js +248 -36
- package/dist/transitions/resolveCaps.d.ts +1 -0
- package/dist/transitions/resolveCaps.js +6 -2
- package/dist/transitions/start.js +77 -3
- package/dist/types/admin.d.ts +1 -1
- package/dist/types/assignments.d.ts +1 -0
- package/dist/types/contracts.d.ts +31 -10
- package/dist/types/endpoints.d.ts +92 -5
- package/dist/types/index.d.ts +3 -0
- package/dist/types/puck.d.ts +7 -1
- package/dist/types/snapshot.d.ts +17 -4
- package/dist/types/surface.d.ts +13 -0
- package/dist/ui/Tabs.d.ts +4 -2
- package/dist/ui/Tabs.js +33 -26
- package/dist/ui/accent.d.ts +22 -3
- package/dist/ui/accent.js +74 -16
- package/package.json +12 -2
|
@@ -10,6 +10,8 @@ import { addHoldoutArm, addVariant, issuesByRow, removeArm, splitEvenly, totalWe
|
|
|
10
10
|
import { allocationSentence } from '../../allocation.model.js';
|
|
11
11
|
import { balanceWeight, orderedVersions, trafficShares } from './testPage.model.js';
|
|
12
12
|
import { FieldErrors, ReadOnly, reasonFor, save, TextEdit } from './fields.js';
|
|
13
|
+
import { PAGE_COPY } from '../../copy/pages.js';
|
|
14
|
+
import { testPageCollection } from '../pagePicker/pagePicker.model.js';
|
|
13
15
|
import { Section } from './Section.js';
|
|
14
16
|
const COLOURS = {
|
|
15
17
|
control: 'var(--xp-series-muted)',
|
|
@@ -49,6 +51,9 @@ export function VersionsSection({ test, surface, parts }) {
|
|
|
49
51
|
test: test,
|
|
50
52
|
sectionId: "versions",
|
|
51
53
|
children: [
|
|
54
|
+
doc.kind === 'page' && testPageCollection(surface.pageCollections, doc, test.preflight?.pagePlacements)?.contentChecks === false ? /*#__PURE__*/ _jsx("p", {
|
|
55
|
+
children: PAGE_COPY.contentChecksOff
|
|
56
|
+
}) : null,
|
|
52
57
|
reason ? /*#__PURE__*/ _jsx("p", {
|
|
53
58
|
className: "xp-ui-help",
|
|
54
59
|
children: reason
|
|
@@ -70,8 +75,10 @@ export function VersionsSection({ test, surface, parts }) {
|
|
|
70
75
|
/*#__PURE__*/ _jsx("span", {})
|
|
71
76
|
]
|
|
72
77
|
}),
|
|
73
|
-
ordered.map(({ arm, index })=>/*#__PURE__*/ _jsxs("article", {
|
|
78
|
+
ordered.filter(({ arm })=>doc.kind !== 'page' || arm.kind !== 'holdout').map(({ arm, index })=>/*#__PURE__*/ _jsxs("article", {
|
|
74
79
|
className: "xp-version-row",
|
|
80
|
+
id: `xp-version-${arm.key}`,
|
|
81
|
+
tabIndex: -1,
|
|
75
82
|
children: [
|
|
76
83
|
/*#__PURE__*/ _jsx(TextEdit, {
|
|
77
84
|
label: `${GROUP_LABELS[arm.key]}: ${C.label}`,
|
|
@@ -93,7 +100,7 @@ export function VersionsSection({ test, surface, parts }) {
|
|
|
93
100
|
reason: reason,
|
|
94
101
|
hideLabel: true,
|
|
95
102
|
disabled: Boolean(reason),
|
|
96
|
-
|
|
103
|
+
isValid: (raw)=>raw.trim() !== '' && Number.isInteger(Number(raw)) && Number(raw) >= 0 && Number(raw) <= 100,
|
|
97
104
|
invalidMessage: C.invalidShare,
|
|
98
105
|
onDraft: (value)=>setWeightEdit({
|
|
99
106
|
key: arm.key,
|
|
@@ -177,11 +184,11 @@ export function VersionsSection({ test, surface, parts }) {
|
|
|
177
184
|
onClick: ()=>update((arms)=>addVariant(arms, doc.kind)),
|
|
178
185
|
children: C.addVersion
|
|
179
186
|
}),
|
|
180
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
187
|
+
doc.kind !== 'page' ? /*#__PURE__*/ _jsx(Button, {
|
|
181
188
|
disabled: Boolean(reason) || doc.arms.some((arm)=>arm.kind === 'holdout'),
|
|
182
189
|
onClick: ()=>update(addHoldoutArm),
|
|
183
190
|
children: C.addHoldout
|
|
184
|
-
}),
|
|
191
|
+
}) : null,
|
|
185
192
|
/*#__PURE__*/ _jsx(Button, {
|
|
186
193
|
disabled: Boolean(reason),
|
|
187
194
|
onClick: ()=>update(splitEvenly),
|
|
@@ -189,7 +196,7 @@ export function VersionsSection({ test, surface, parts }) {
|
|
|
189
196
|
})
|
|
190
197
|
]
|
|
191
198
|
}),
|
|
192
|
-
doc.arms.some((arm)=>arm.kind === 'holdout') ? /*#__PURE__*/ _jsx("p", {
|
|
199
|
+
doc.kind !== 'page' && doc.arms.some((arm)=>arm.kind === 'holdout') ? /*#__PURE__*/ _jsx("p", {
|
|
193
200
|
className: "xp-ui-help",
|
|
194
201
|
children: ARMS_COPY.holdout
|
|
195
202
|
}) : null,
|
|
@@ -15,7 +15,7 @@ export declare function ReadOnly({ label, value, reason, labelAction }: {
|
|
|
15
15
|
labelAction?: ReactNode;
|
|
16
16
|
}): import("react").JSX.Element;
|
|
17
17
|
/** Local typing is intentionally separate from staging: build the current group on commit. */
|
|
18
|
-
export declare function TextEdit({ label, value, onCommit, reason, multiline, placeholder, type, min, max, required, onDraft,
|
|
18
|
+
export declare function TextEdit({ label, value, onCommit, reason, multiline, placeholder, type, min, max, required, onDraft, isValid, invalidMessage, hideLabel, disabled, help }: {
|
|
19
19
|
label: string;
|
|
20
20
|
value: string | number;
|
|
21
21
|
onCommit: (value: string) => void;
|
|
@@ -27,14 +27,21 @@ export declare function TextEdit({ label, value, onCommit, reason, multiline, pl
|
|
|
27
27
|
min?: number;
|
|
28
28
|
max?: number;
|
|
29
29
|
required?: boolean;
|
|
30
|
-
|
|
30
|
+
isValid?: (value: string) => boolean;
|
|
31
31
|
invalidMessage?: string;
|
|
32
32
|
hideLabel?: boolean;
|
|
33
33
|
disabled?: boolean;
|
|
34
34
|
help?: string;
|
|
35
35
|
}): import("react").JSX.Element;
|
|
36
36
|
export declare const positiveInteger: (raw: string) => boolean;
|
|
37
|
-
export
|
|
37
|
+
export type OptionGroup = {
|
|
38
|
+
label?: string;
|
|
39
|
+
options: readonly {
|
|
40
|
+
label: string;
|
|
41
|
+
value: string;
|
|
42
|
+
}[];
|
|
43
|
+
};
|
|
44
|
+
export declare function SelectEdit({ label, value, options, groups, reason, onCommit, readOnlyValue, labelAction }: {
|
|
38
45
|
label: string;
|
|
39
46
|
value: string;
|
|
40
47
|
options: readonly {
|
|
@@ -45,8 +52,9 @@ export declare function SelectEdit({ label, value, options, reason, onCommit, re
|
|
|
45
52
|
onCommit: (value: string) => void;
|
|
46
53
|
readOnlyValue?: string;
|
|
47
54
|
labelAction?: ReactNode;
|
|
55
|
+
groups?: readonly OptionGroup[];
|
|
48
56
|
}): import("react").JSX.Element;
|
|
49
|
-
export declare function CheckboxList({ label, value, options, reason, onToggle, readOnlyValue, searchable }: {
|
|
57
|
+
export declare function CheckboxList({ label, value, options, groups, reason, onToggle, readOnlyValue, searchable }: {
|
|
50
58
|
label: string;
|
|
51
59
|
value: string[];
|
|
52
60
|
options: readonly {
|
|
@@ -57,6 +65,7 @@ export declare function CheckboxList({ label, value, options, reason, onToggle,
|
|
|
57
65
|
onToggle: (value: string, checked: boolean) => void;
|
|
58
66
|
readOnlyValue?: string;
|
|
59
67
|
searchable?: boolean;
|
|
68
|
+
groups?: readonly OptionGroup[];
|
|
60
69
|
}): import("react").JSX.Element;
|
|
61
70
|
export declare function TestName({ test }: SectionProps): import("react").JSX.Element;
|
|
62
71
|
export declare function Hypothesis({ test }: SectionProps): import("react").JSX.Element;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useId, useState } from 'react';
|
|
4
|
-
import { TextInput, NumberInput, Textarea, Select, SearchInput, CheckboxList as UICheckboxList } from '../../../ui/Inputs.js';
|
|
4
|
+
import { TextInput, NumberInput, Textarea, Select, SearchInput, Checkbox, CheckboxList as UICheckboxList } from '../../../ui/Inputs.js';
|
|
5
5
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
6
6
|
import { EDITABLE_BY_STATUS } from '../../../collections/experiments/editability.js';
|
|
7
7
|
import { lockedReason } from '../../lockedNotice.model.js';
|
|
@@ -45,7 +45,7 @@ export function ReadOnly({ label, value, reason, labelAction }) {
|
|
|
45
45
|
]
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
/** Local typing is intentionally separate from staging: build the current group on commit. */ export function TextEdit({ label, value, onCommit, reason, multiline, placeholder, type = 'text', min, max, required, onDraft,
|
|
48
|
+
/** Local typing is intentionally separate from staging: build the current group on commit. */ export function TextEdit({ label, value, onCommit, reason, multiline, placeholder, type = 'text', min, max, required, onDraft, isValid, invalidMessage, hideLabel = false, disabled = false, help }) {
|
|
49
49
|
const id = useId();
|
|
50
50
|
const [draft, setDraft] = useState(String(value));
|
|
51
51
|
const [error, setError] = useState(null);
|
|
@@ -54,7 +54,8 @@ export function ReadOnly({ label, value, reason, labelAction }) {
|
|
|
54
54
|
]);
|
|
55
55
|
const commit = ()=>{
|
|
56
56
|
if (draft === String(value)) return;
|
|
57
|
-
|
|
57
|
+
// Named isValid, not validate: Payload 4's Local API has a validate method, which the access gate flags.
|
|
58
|
+
if (isValid && !isValid(draft)) {
|
|
58
59
|
setError(draft.trim() ? invalidMessage ?? null : null);
|
|
59
60
|
setDraft(String(value));
|
|
60
61
|
onDraft?.(String(value));
|
|
@@ -96,7 +97,7 @@ export function ReadOnly({ label, value, reason, labelAction }) {
|
|
|
96
97
|
});
|
|
97
98
|
}
|
|
98
99
|
export const positiveInteger = (raw)=>raw.trim() !== '' && Number.isInteger(Number(raw)) && Number(raw) > 0;
|
|
99
|
-
export function SelectEdit({ label, value, options, reason, onCommit, readOnlyValue, labelAction }) {
|
|
100
|
+
export function SelectEdit({ label, value, options, groups, reason, onCommit, readOnlyValue, labelAction }) {
|
|
100
101
|
const id = useId();
|
|
101
102
|
if (reason) {
|
|
102
103
|
return /*#__PURE__*/ _jsx(ReadOnly, {
|
|
@@ -112,13 +113,22 @@ export function SelectEdit({ label, value, options, reason, onCommit, readOnlyVa
|
|
|
112
113
|
labelAction: labelAction,
|
|
113
114
|
value: value,
|
|
114
115
|
onChange: (e)=>onCommit(e.target.value),
|
|
115
|
-
children:
|
|
116
|
+
children: groups ? groups.map((group, index)=>group.label ? /*#__PURE__*/ _jsx("optgroup", {
|
|
117
|
+
label: group.label,
|
|
118
|
+
children: group.options.map((option)=>/*#__PURE__*/ _jsx("option", {
|
|
119
|
+
value: option.value,
|
|
120
|
+
children: option.label
|
|
121
|
+
}, option.value))
|
|
122
|
+
}, index) : group.options.map((option)=>/*#__PURE__*/ _jsx("option", {
|
|
123
|
+
value: option.value,
|
|
124
|
+
children: option.label
|
|
125
|
+
}, option.value))) : options.map((option)=>/*#__PURE__*/ _jsx("option", {
|
|
116
126
|
value: option.value,
|
|
117
127
|
children: option.label
|
|
118
128
|
}, option.value))
|
|
119
129
|
});
|
|
120
130
|
}
|
|
121
|
-
export function CheckboxList({ label, value, options, reason, onToggle, readOnlyValue, searchable = false }) {
|
|
131
|
+
export function CheckboxList({ label, value, options, groups, reason, onToggle, readOnlyValue, searchable = false }) {
|
|
122
132
|
const id = useId();
|
|
123
133
|
const [query, setQuery] = useState('');
|
|
124
134
|
const visible = searchable ? options.filter((option)=>value.includes(option.value) || option.label.toLowerCase().includes(query.toLowerCase())) : options;
|
|
@@ -127,21 +137,43 @@ export function CheckboxList({ label, value, options, reason, onToggle, readOnly
|
|
|
127
137
|
reason: reason,
|
|
128
138
|
value: readOnlyValue ?? value.map((v)=>options.find((o)=>o.value === v)?.label ?? v).join(', ')
|
|
129
139
|
});
|
|
130
|
-
return /*#__PURE__*/
|
|
140
|
+
return /*#__PURE__*/ _jsxs(UICheckboxList, {
|
|
131
141
|
id: id,
|
|
132
142
|
label: label,
|
|
133
143
|
value: value,
|
|
134
|
-
options: visible,
|
|
144
|
+
options: groups ? [] : visible,
|
|
135
145
|
onChange: (next)=>{
|
|
136
146
|
const changed = options.find((option)=>next.includes(option.value) !== value.includes(option.value));
|
|
137
147
|
if (changed) onToggle(changed.value, next.includes(changed.value));
|
|
138
148
|
},
|
|
139
|
-
children:
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
149
|
+
children: [
|
|
150
|
+
searchable ? /*#__PURE__*/ _jsx(SearchInput, {
|
|
151
|
+
id: `${id}-search`,
|
|
152
|
+
label: C.searchGoals,
|
|
153
|
+
value: query,
|
|
154
|
+
onChange: (event)=>setQuery(event.target.value)
|
|
155
|
+
}) : null,
|
|
156
|
+
groups ? groups.map((group, index)=>{
|
|
157
|
+
const items = group.options.filter((option)=>visible.some((item)=>item.value === option.value));
|
|
158
|
+
return items.length ? /*#__PURE__*/ _jsxs("div", {
|
|
159
|
+
children: [
|
|
160
|
+
group.label ? /*#__PURE__*/ _jsx("h3", {
|
|
161
|
+
children: group.label
|
|
162
|
+
}) : null,
|
|
163
|
+
/*#__PURE__*/ _jsx("ul", {
|
|
164
|
+
children: items.map((option)=>/*#__PURE__*/ _jsx("li", {
|
|
165
|
+
children: /*#__PURE__*/ _jsx(Checkbox, {
|
|
166
|
+
id: `${id}-${index}-${option.value}`,
|
|
167
|
+
label: option.label,
|
|
168
|
+
checked: value.includes(option.value),
|
|
169
|
+
onChange: (event)=>onToggle(option.value, event.target.checked)
|
|
170
|
+
})
|
|
171
|
+
}, option.value))
|
|
172
|
+
})
|
|
173
|
+
]
|
|
174
|
+
}, index) : null;
|
|
175
|
+
}) : null
|
|
176
|
+
]
|
|
145
177
|
});
|
|
146
178
|
}
|
|
147
179
|
export function TestName({ test }) {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { SectionId } from '../contracts.js';
|
|
2
2
|
/** Open disclosures before scrolling, then give keyboard users a meaningful landing. */
|
|
3
|
-
export declare function jumpToSection(section: SectionId): void;
|
|
3
|
+
export declare function jumpToSection(section: SectionId, arm?: string): void;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
/** Open disclosures before scrolling, then give keyboard users a meaningful landing. */ export function jumpToSection(section) {
|
|
1
|
+
/** Open disclosures before scrolling, then give keyboard users a meaningful landing. */ export function jumpToSection(section, arm) {
|
|
2
2
|
const target = document.getElementById(`section-${section}`);
|
|
3
3
|
if (target instanceof HTMLDetailsElement) target.open = true;
|
|
4
|
-
|
|
4
|
+
const row = arm ? document.getElementById(`xp-version-${arm}`) : null;
|
|
5
|
+
(row ?? target)?.scrollIntoView?.({
|
|
5
6
|
block: 'start'
|
|
6
7
|
});
|
|
7
|
-
document.getElementById(`title-${section}`)?.focus({
|
|
8
|
+
(row ?? document.getElementById(`title-${section}`))?.focus({
|
|
8
9
|
preventScroll: true
|
|
9
10
|
});
|
|
10
11
|
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
import type { KindParts } from '../contracts.js';
|
|
1
|
+
import type { KindParts, SectionProps } from '../contracts.js';
|
|
2
|
+
export declare function VersionContent({ test, surface, armIndex }: SectionProps & {
|
|
3
|
+
armIndex: number;
|
|
4
|
+
}): import("react").JSX.Element | null;
|
|
2
5
|
export declare const pageParts: KindParts;
|
|
@@ -1,15 +1,92 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
4
4
|
import { pageTargetIssue, setPageTarget, showsPageTarget } from '../../arms/pageTarget.model.js';
|
|
5
|
+
import { useState } from 'react';
|
|
6
|
+
import { CopyRoute } from '../pagePicker/CopyRoute.js';
|
|
7
|
+
import { PagePicker } from '../pagePicker/PagePicker.js';
|
|
8
|
+
import { testPageCollection } from '../pagePicker/pagePicker.model.js';
|
|
9
|
+
import { PAGE_COPY as P } from '../../copy/pages.js';
|
|
5
10
|
import { FieldErrors, reasonFor, save, TextEdit } from './fields.js';
|
|
6
|
-
function VersionContent({ test, armIndex }) {
|
|
11
|
+
export function VersionContent({ test, surface, armIndex }) {
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
7
13
|
const arm = test.doc?.arms[armIndex];
|
|
8
14
|
if (!arm || !test.doc) return null;
|
|
9
15
|
if (!showsPageTarget(test.doc.kind, arm.kind)) return /*#__PURE__*/ _jsx("span", {
|
|
10
16
|
className: "xp-content-chip",
|
|
11
17
|
children: C.holdoutContent
|
|
12
18
|
});
|
|
19
|
+
const collection = testPageCollection(surface.pageCollections, test.doc, test.preflight?.pagePlacements);
|
|
20
|
+
const placement = test.preflight?.pagePlacements?.find((entry)=>entry.arm === arm.key);
|
|
21
|
+
if (collection) {
|
|
22
|
+
const picker = /*#__PURE__*/ _jsx(PagePicker, {
|
|
23
|
+
collection: collection,
|
|
24
|
+
test: test,
|
|
25
|
+
armKey: arm.key,
|
|
26
|
+
apiRoute: surface.apiRoute,
|
|
27
|
+
onChoose: ()=>setOpen(false)
|
|
28
|
+
});
|
|
29
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
30
|
+
className: "xp-version-content xp-version-content--page",
|
|
31
|
+
children: [
|
|
32
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
33
|
+
children: P.where
|
|
34
|
+
}),
|
|
35
|
+
/*#__PURE__*/ _jsx("p", {
|
|
36
|
+
children: placement?.id != null ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
37
|
+
children: [
|
|
38
|
+
placement.title,
|
|
39
|
+
" · ",
|
|
40
|
+
placement.path,
|
|
41
|
+
!placement.published ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
42
|
+
children: [
|
|
43
|
+
" · ",
|
|
44
|
+
P.draft
|
|
45
|
+
]
|
|
46
|
+
}) : null
|
|
47
|
+
]
|
|
48
|
+
}) : arm.pageTarget ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
49
|
+
children: [
|
|
50
|
+
arm.pageTarget,
|
|
51
|
+
" · ",
|
|
52
|
+
P.draft
|
|
53
|
+
]
|
|
54
|
+
}) : P.noPage
|
|
55
|
+
}),
|
|
56
|
+
placement?.id != null ? /*#__PURE__*/ _jsxs("div", {
|
|
57
|
+
children: [
|
|
58
|
+
placement.editorUrl ? /*#__PURE__*/ _jsx("a", {
|
|
59
|
+
href: placement.editorUrl,
|
|
60
|
+
target: "_blank",
|
|
61
|
+
rel: "noopener",
|
|
62
|
+
children: P.open
|
|
63
|
+
}) : null,
|
|
64
|
+
' ',
|
|
65
|
+
placement.url ? /*#__PURE__*/ _jsx("a", {
|
|
66
|
+
href: placement.url,
|
|
67
|
+
target: "_blank",
|
|
68
|
+
rel: "noopener",
|
|
69
|
+
children: P.preview
|
|
70
|
+
}) : null
|
|
71
|
+
]
|
|
72
|
+
}) : null,
|
|
73
|
+
/*#__PURE__*/ _jsx("button", {
|
|
74
|
+
type: "button",
|
|
75
|
+
disabled: !!reasonFor(test, 'arms'),
|
|
76
|
+
onClick: ()=>setOpen((value)=>!value),
|
|
77
|
+
children: open ? P.close : arm.pageTarget ? P.change : P.choose
|
|
78
|
+
}),
|
|
79
|
+
open ? arm.kind === 'variant' ? /*#__PURE__*/ _jsx(CopyRoute, {
|
|
80
|
+
collection: collection,
|
|
81
|
+
children: picker
|
|
82
|
+
}) : picker : null,
|
|
83
|
+
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
84
|
+
test: test,
|
|
85
|
+
path: `arms.${armIndex}.pageTarget`
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
});
|
|
89
|
+
}
|
|
13
90
|
const issue = pageTargetIssue(arm.pageTarget, arm.kind);
|
|
14
91
|
return /*#__PURE__*/ _jsxs("div", {
|
|
15
92
|
className: "xp-version-content",
|
|
@@ -15,6 +15,13 @@
|
|
|
15
15
|
.xp-grid-field .xp-ui-field > label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
|
|
16
16
|
.xp-version-content { display: flex; flex-wrap: nowrap; gap: var(--xp-space-2); align-items: center; min-width: 0; }
|
|
17
17
|
.xp-version-content .xp-ui-button { white-space: nowrap; }
|
|
18
|
+
.xp-version-content--page { flex-direction: column; align-items: stretch; gap: var(--xp-space-3); }
|
|
19
|
+
.xp-version-content--page > button { align-self: flex-start; }
|
|
20
|
+
.xp-page-picker input[type="search"] { width: 100%; }
|
|
21
|
+
.xp-page-picker ul { list-style: none; padding: 0; margin-block: var(--xp-space-3); }
|
|
22
|
+
.xp-page-picker li > button { display: block; width: 100%; text-align: left; }
|
|
23
|
+
.xp-page-picker li > p { color: var(--xp-text-2); font: var(--xp-text-small); }
|
|
24
|
+
.xp-copy-route ol { list-style: decimal; padding-inline-start: var(--xp-space-6); }
|
|
18
25
|
.xp-content-chip { flex-shrink: 0; display: inline-flex; width: fit-content; border-radius: var(--xp-radius-chip); padding: var(--xp-space-half) var(--xp-space-2); font: var(--xp-text-small); background: var(--xp-surface-2); color: var(--xp-text-2); }
|
|
19
26
|
.xp-content-chip.xp-content-ready { background: var(--xp-success-bg); color: var(--xp-success); }
|
|
20
27
|
.xp-content-chip.xp-content-empty { background: var(--xp-warning-bg); color: var(--xp-warning); }
|
|
@@ -66,7 +73,7 @@
|
|
|
66
73
|
.xp-readiness--bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: var(--xp-space-2) var(--xp-space-4); padding-block: var(--xp-space-3); min-height: 64px; border: 0; border-radius: 0; }
|
|
67
74
|
.xp-readiness__state { display: flex; align-items: center; flex-wrap: wrap; gap: var(--xp-space-2); min-width: 0; }
|
|
68
75
|
.xp-readiness__state p, .xp-readiness--bar > p { margin: 0; }
|
|
69
|
-
.xp-readiness__state > p { font-weight: 500; }
|
|
76
|
+
.xp-readiness__state > p { font-weight: 500; white-space: pre-line; }
|
|
70
77
|
.xp-readiness--bar .xp-save-status, .xp-readiness__separator { color: var(--xp-text-3); font: var(--xp-text-small); }
|
|
71
78
|
.xp-readiness__actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--xp-space-2); }
|
|
72
79
|
.xp-readiness--bar > .xp-readiness__actions { grid-column: 2; grid-row: 1 / span 3; justify-content: flex-end; }
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Arm,
|
|
1
|
+
import type { Arm, ExperimentKind, ExposurePolicy } from '../../../types/contracts.js';
|
|
2
2
|
import type { PreflightResult } from '../../../types/endpoints.js';
|
|
3
3
|
export declare function orderedVersions(arms: readonly Arm[]): Array<{
|
|
4
4
|
arm: Arm;
|
|
@@ -13,5 +13,4 @@ export declare function durationSuggestion(preflight: PreflightResult | null, sa
|
|
|
13
13
|
feasible: boolean;
|
|
14
14
|
} | null;
|
|
15
15
|
export declare function exposureOptions(kind: ExperimentKind): readonly ExposurePolicy[];
|
|
16
|
-
|
|
17
|
-
export declare function balanceWeight(arms: Arm[], key: ArmKey, weight: number): Arm[];
|
|
16
|
+
export { balanceWeight } from '../../../arms/model.js';
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { setWeight } from '../../arms/arms.model.js';
|
|
2
1
|
const ORDER = [
|
|
3
2
|
'control',
|
|
4
3
|
'variantA',
|
|
@@ -31,23 +30,4 @@ export function exposureOptions(kind) {
|
|
|
31
30
|
'manual'
|
|
32
31
|
];
|
|
33
32
|
}
|
|
34
|
-
|
|
35
|
-
if (!arms.some((arm)=>arm.key === key) || !Number.isInteger(weight) || weight < 0 || weight > 100) return arms;
|
|
36
|
-
const others = arms.filter((arm)=>arm.key !== key);
|
|
37
|
-
if (!others.length) return arms;
|
|
38
|
-
const total = others.reduce((sum, arm)=>sum + Math.max(0, Number.isFinite(arm.weight) ? arm.weight : 0), 0);
|
|
39
|
-
const denominator = total || others.length;
|
|
40
|
-
const raw = others.map((arm)=>(total ? Math.max(0, Number.isFinite(arm.weight) ? arm.weight : 0) : 1) * (100 - weight) / denominator);
|
|
41
|
-
const whole = raw.map(Math.floor);
|
|
42
|
-
const order = raw.map((_, i)=>i).sort((a, b)=>raw[b] - whole[b] - (raw[a] - whole[a]) || a - b);
|
|
43
|
-
const remainder = 100 - weight - whole.reduce((sum, value)=>sum + value, 0);
|
|
44
|
-
for(let i = 0; i < remainder; i++)whole[order[i]]++;
|
|
45
|
-
const shares = new Map(others.map((arm, i)=>[
|
|
46
|
-
arm.key,
|
|
47
|
-
whole[i]
|
|
48
|
-
]));
|
|
49
|
-
return setWeight(arms, key, weight).map((arm)=>shares.has(arm.key) ? {
|
|
50
|
-
...arm,
|
|
51
|
-
weight: shares.get(arm.key)
|
|
52
|
-
} : arm);
|
|
53
|
-
}
|
|
33
|
+
export { balanceWeight } from '../../../arms/model.js';
|
|
@@ -9,7 +9,8 @@ const EDITABLE_FIELDS = [
|
|
|
9
9
|
'flagPoint',
|
|
10
10
|
'metrics',
|
|
11
11
|
'analysis',
|
|
12
|
-
'exposurePolicy'
|
|
12
|
+
'exposurePolicy',
|
|
13
|
+
'pageCollection'
|
|
13
14
|
];
|
|
14
15
|
/** Drop unknown and locked keys even when the caller is untyped. Groups replace whole groups. */ export function editablePatch(status, partial) {
|
|
15
16
|
return Object.fromEntries(EDITABLE_FIELDS.flatMap((field)=>Object.hasOwn(partial, field) && partial[field] !== undefined && isEditable(status, field) ? [
|
|
@@ -1,14 +1,23 @@
|
|
|
1
|
-
import type { DocId } from '../../types/contracts.js';
|
|
1
|
+
import type { Arm, DocId } from '../../types/contracts.js';
|
|
2
2
|
import type { PreflightResult } from '../../types/endpoints.js';
|
|
3
3
|
import type { TestDocument, TestDocumentPatch } from './testDocument.model.js';
|
|
4
4
|
/** Section data only: staging never saves. Call commit on blur or a section action. */
|
|
5
|
-
export declare function useTestDocument(id: DocId, { apiRoute }: {
|
|
5
|
+
export declare function useTestDocument(id: DocId, { apiRoute, refetchPreflightOnFocus }: {
|
|
6
6
|
apiRoute: string;
|
|
7
|
+
refetchPreflightOnFocus?: boolean;
|
|
7
8
|
}): {
|
|
8
9
|
stage: (partial: TestDocumentPatch) => void;
|
|
9
10
|
commit: () => Promise<void>;
|
|
10
11
|
reload: () => Promise<void>;
|
|
11
12
|
refreshPreflight: () => Promise<void>;
|
|
13
|
+
choosePage: (arm: Arm["key"], page: {
|
|
14
|
+
id: DocId;
|
|
15
|
+
path: string;
|
|
16
|
+
}) => Promise<void>;
|
|
17
|
+
chosenPages: Partial<Record<Arm["key"], {
|
|
18
|
+
id: DocId;
|
|
19
|
+
path: string;
|
|
20
|
+
}>>;
|
|
12
21
|
doc: TestDocument | null;
|
|
13
22
|
preflight: PreflightResult | null;
|
|
14
23
|
preflightError: string | null;
|
|
@@ -7,6 +7,7 @@ import { changedPatch, editablePatch, payloadFieldErrors } from './testDocument.
|
|
|
7
7
|
// Saves outlive their mounted reader. Reopening the same document must wait for its queue.
|
|
8
8
|
const drainingSaves = new Map();
|
|
9
9
|
const initialView = ()=>({
|
|
10
|
+
chosenPages: {},
|
|
10
11
|
doc: null,
|
|
11
12
|
preflight: null,
|
|
12
13
|
preflightError: null,
|
|
@@ -55,6 +56,7 @@ function stage(session, partial) {
|
|
|
55
56
|
if (!session.saved || session.view.stale || session.reloading || session.view.loadState !== 'ready' || session.controller.signal.aborted) return;
|
|
56
57
|
const patch = editablePatch(session.saved.status, partial);
|
|
57
58
|
if (!Object.keys(patch).length) return;
|
|
59
|
+
if (patch.pageCollection !== undefined && patch.pageCollection !== optimistic(session)?.pageCollection) session.view.chosenPages = {};
|
|
58
60
|
session.pending = {
|
|
59
61
|
...session.pending,
|
|
60
62
|
...patch
|
|
@@ -63,7 +65,7 @@ function stage(session, partial) {
|
|
|
63
65
|
if (!session.queue.length) session.view.saving = 'idle';
|
|
64
66
|
session.publish();
|
|
65
67
|
}
|
|
66
|
-
/** Section data only: staging never saves. Call commit on blur or a section action. */ export function useTestDocument(id, { apiRoute }) {
|
|
68
|
+
/** Section data only: staging never saves. Call commit on blur or a section action. */ export function useTestDocument(id, { apiRoute, refetchPreflightOnFocus = false }) {
|
|
67
69
|
const base = apiRoute.replace(/\/$/, '');
|
|
68
70
|
const documentId = String(id);
|
|
69
71
|
const key = JSON.stringify([
|
|
@@ -90,11 +92,12 @@ function stage(session, partial) {
|
|
|
90
92
|
controller,
|
|
91
93
|
reloading: false,
|
|
92
94
|
preflightReads: 0,
|
|
95
|
+
preflightLoading: false,
|
|
93
96
|
publish () {
|
|
94
97
|
if (controller.signal.aborted) return;
|
|
95
98
|
session.view.doc = session.view.loadState === 'ready' ? optimistic(session) : null;
|
|
96
99
|
session.view.hasUnsaved = session.queue.length > 0 || Object.keys(session.pending).length > 0;
|
|
97
|
-
session.view.preflightPending = session.preflightReads > 0;
|
|
100
|
+
session.view.preflightPending = session.preflightReads > 0 || session.preflightLoading;
|
|
98
101
|
setState({
|
|
99
102
|
key,
|
|
100
103
|
view: {
|
|
@@ -109,7 +112,7 @@ function stage(session, partial) {
|
|
|
109
112
|
async function refreshPreflight(initial = false) {
|
|
110
113
|
if (controller.signal.aborted) return;
|
|
111
114
|
const revision = ++preflightRevision;
|
|
112
|
-
session.
|
|
115
|
+
session.preflightLoading = true;
|
|
113
116
|
session.publish();
|
|
114
117
|
// createApi has no signal option; this read must abort without cancelling submitted PATCHes.
|
|
115
118
|
let data;
|
|
@@ -134,12 +137,9 @@ function stage(session, partial) {
|
|
|
134
137
|
} catch {
|
|
135
138
|
message = API_MESSAGES.network;
|
|
136
139
|
}
|
|
137
|
-
session.preflightReads--;
|
|
138
140
|
if (controller.signal.aborted) return;
|
|
139
|
-
if (revision !== preflightRevision)
|
|
140
|
-
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
141
|
+
if (revision !== preflightRevision) return;
|
|
142
|
+
session.preflightLoading = false;
|
|
143
143
|
if (data) {
|
|
144
144
|
session.view.preflight = data;
|
|
145
145
|
session.view.preflightError = null;
|
|
@@ -215,8 +215,9 @@ function stage(session, partial) {
|
|
|
215
215
|
...edit
|
|
216
216
|
}), {});
|
|
217
217
|
session.queue = [];
|
|
218
|
+
// Server text is never shown; the stale-edit sentence is the admin's own.
|
|
218
219
|
session.view.errors = {
|
|
219
|
-
_section:
|
|
220
|
+
_section: TEST_PAGE.staleEdit
|
|
220
221
|
};
|
|
221
222
|
} else if (!response.ok) session.view.errors = {
|
|
222
223
|
...session.view.errors,
|
|
@@ -256,12 +257,9 @@ function stage(session, partial) {
|
|
|
256
257
|
session.publish();
|
|
257
258
|
}
|
|
258
259
|
if (saved) {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
session.preflightReads--;
|
|
263
|
-
session.publish();
|
|
264
|
-
}
|
|
260
|
+
// Recovery is complete; readiness now belongs to the latest preflight read.
|
|
261
|
+
session.preflightReads--;
|
|
262
|
+
await refreshPreflight();
|
|
265
263
|
}
|
|
266
264
|
};
|
|
267
265
|
// Recover both the preceding tail and this step: unexpected throws must not strand later saves.
|
|
@@ -366,11 +364,52 @@ function stage(session, partial) {
|
|
|
366
364
|
}, [
|
|
367
365
|
key
|
|
368
366
|
]);
|
|
367
|
+
useEffect(()=>{
|
|
368
|
+
if (!refetchPreflightOnFocus) return;
|
|
369
|
+
let lastReturn = -Infinity;
|
|
370
|
+
const focus = ()=>{
|
|
371
|
+
if (document.visibilityState !== 'visible' || Date.now() - lastReturn < 100) return;
|
|
372
|
+
lastReturn = Date.now();
|
|
373
|
+
void refreshPreflight();
|
|
374
|
+
};
|
|
375
|
+
const visible = ()=>{
|
|
376
|
+
if (document.visibilityState === 'visible') focus();
|
|
377
|
+
};
|
|
378
|
+
window.addEventListener('focus', focus);
|
|
379
|
+
document.addEventListener('visibilitychange', visible);
|
|
380
|
+
return ()=>{
|
|
381
|
+
window.removeEventListener('focus', focus);
|
|
382
|
+
document.removeEventListener('visibilitychange', visible);
|
|
383
|
+
};
|
|
384
|
+
}, [
|
|
385
|
+
refetchPreflightOnFocus,
|
|
386
|
+
refreshPreflight
|
|
387
|
+
]);
|
|
388
|
+
const choosePage = useCallback((arm, page)=>{
|
|
389
|
+
const session = current.current;
|
|
390
|
+
const doc = session?.key === key ? optimistic(session) : null;
|
|
391
|
+
if (!session || !doc) return Promise.resolve();
|
|
392
|
+
session.view.chosenPages = {
|
|
393
|
+
...session.view.chosenPages,
|
|
394
|
+
[arm]: page
|
|
395
|
+
};
|
|
396
|
+
stage(session, {
|
|
397
|
+
arms: doc.arms.map((item)=>item.key === arm ? {
|
|
398
|
+
...item,
|
|
399
|
+
pageTarget: page.path
|
|
400
|
+
} : item)
|
|
401
|
+
});
|
|
402
|
+
return commit();
|
|
403
|
+
}, [
|
|
404
|
+
key,
|
|
405
|
+
commit
|
|
406
|
+
]);
|
|
369
407
|
return {
|
|
370
408
|
...state.key === key ? state.view : initialView(),
|
|
371
409
|
stage: stagePartial,
|
|
372
410
|
commit,
|
|
373
411
|
reload,
|
|
374
|
-
refreshPreflight
|
|
412
|
+
refreshPreflight,
|
|
413
|
+
choosePage
|
|
375
414
|
};
|
|
376
415
|
}
|
package/dist/admin/useApi.d.ts
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
export declare function useApi(): {
|
|
1
|
+
export declare function useApi(apiRoute: string): {
|
|
2
|
+
wrapBlock: (body: import("../types/endpoints.js").WrapBlockBody) => Promise<import("./api.js").ApiResult<Record<string, unknown>>>;
|
|
3
|
+
pages: (query: {
|
|
4
|
+
collection: string;
|
|
5
|
+
q?: string;
|
|
6
|
+
path?: string;
|
|
7
|
+
page?: number;
|
|
8
|
+
}, signal?: AbortSignal) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PagesResult>>;
|
|
9
|
+
placementStatus: (body: import("../types/endpoints.js").PlacementStatusBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PlacementStatusResult>>;
|
|
2
10
|
start: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
3
11
|
allocate: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").AllocateBody, options?: {
|
|
4
12
|
notFound?: string;
|
|
@@ -9,7 +17,7 @@ export declare function useApi(): {
|
|
|
9
17
|
notFound?: string;
|
|
10
18
|
codes?: Readonly<Record<string, string>>;
|
|
11
19
|
fallback?: string;
|
|
12
|
-
}) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").
|
|
20
|
+
}) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").AddMetricResult>>;
|
|
13
21
|
stop: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
14
22
|
decide: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").DecideBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
15
23
|
releaseHoldout: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
@@ -18,6 +26,7 @@ export declare function useApi(): {
|
|
|
18
26
|
dismissContentEntry: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").DismissContentEntryBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").DismissContentEntryResult>>;
|
|
19
27
|
restoreContentEntry: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").RestoreContentEntryBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").RestoreContentEntryResult>>;
|
|
20
28
|
archive: (id: import("../types/contracts.js").DocId, body: import("../types/endpoints.js").ArchiveBody) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").TransitionSuccess>>;
|
|
29
|
+
clickKeys: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").ClickKeysResult>>;
|
|
21
30
|
preflight: (id: import("../types/contracts.js").DocId) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PreflightResult>>;
|
|
22
31
|
previewToken: (id: import("../types/contracts.js").DocId, arm: string) => Promise<import("./api.js").ApiResult<import("../types/endpoints.js").PreviewTokenResult>>;
|
|
23
32
|
results: (id: import("../types/contracts.js").DocId, options?: {
|