@delmaredigital/payload-experiments 0.4.0-rc.7 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (367) hide show
  1. package/README.md +9 -15
  2. package/dist/admin/MetricSourceSelect.js +10 -3
  3. package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
  4. package/dist/admin/blocks/BlockPanel.d.ts +1 -0
  5. package/dist/admin/blocks/BlockPanel.js +75 -29
  6. package/dist/admin/blocks/model.js +7 -6
  7. package/dist/admin/copy/blocks.d.ts +14 -11
  8. package/dist/admin/copy/blocks.js +33 -22
  9. package/dist/admin/copy/goals.d.ts +15 -8
  10. package/dist/admin/copy/goals.js +18 -8
  11. package/dist/admin/copy/newTest.d.ts +10 -7
  12. package/dist/admin/copy/newTest.js +14 -7
  13. package/dist/admin/copy/status.d.ts +1 -1
  14. package/dist/admin/copy/status.js +2 -1
  15. package/dist/admin/pageCollections.d.ts +1 -0
  16. package/dist/admin/pageCollections.js +3 -0
  17. package/dist/admin/placementStatus.model.js +5 -3
  18. package/dist/admin/status.model.d.ts +1 -0
  19. package/dist/admin/status.model.js +2 -1
  20. package/dist/admin/surface/ResultsRoute.js +12 -10
  21. package/dist/admin/surface/SurfaceShell.d.ts +4 -2
  22. package/dist/admin/surface/SurfaceShell.js +28 -3
  23. package/dist/admin/surface/TestRowMenu.d.ts +13 -0
  24. package/dist/admin/surface/TestRowMenu.js +163 -0
  25. package/dist/admin/surface/TestsHome.d.ts +4 -3
  26. package/dist/admin/surface/TestsHome.js +224 -52
  27. package/dist/admin/surface/TestsSurface.js +2 -1
  28. package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
  29. package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
  30. package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
  31. package/dist/admin/surface/goals/GoalForm.js +280 -198
  32. package/dist/admin/surface/goals/GoalsList.js +102 -33
  33. package/dist/admin/surface/goals/data.d.ts +2 -0
  34. package/dist/admin/surface/goals/data.js +9 -0
  35. package/dist/admin/surface/goals/goals.css +3 -2
  36. package/dist/admin/surface/goals/goals.model.d.ts +2 -2
  37. package/dist/admin/surface/goals/goals.model.js +7 -12
  38. package/dist/admin/surface/home.model.d.ts +15 -8
  39. package/dist/admin/surface/home.model.js +22 -18
  40. package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
  41. package/dist/admin/surface/newTest/NewTest.js +156 -96
  42. package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
  43. package/dist/admin/surface/newTest/PageWizard.js +99 -68
  44. package/dist/admin/surface/newTest/newTest.css +28 -11
  45. package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
  46. package/dist/admin/surface/results/ResultsHeader.js +98 -66
  47. package/dist/admin/surface/surface.css +29 -0
  48. package/dist/admin/surface/test/TestPage.js +46 -38
  49. package/dist/admin/surface/useXpStepNav.d.ts +11 -0
  50. package/dist/admin/surface/useXpStepNav.js +14 -0
  51. package/dist/admin/views/TestsSurfaceClient.js +27 -3
  52. package/dist/admin/views/buildSurfaceProps.js +18 -66
  53. package/dist/arms/copy.d.ts +13 -3
  54. package/dist/arms/copy.js +5 -4
  55. package/dist/blocks/createExperimentBlock.js +1 -1
  56. package/dist/blocks/formState.js +2 -2
  57. package/dist/collections/experiments/armInvariants.js +8 -5
  58. package/dist/collections/experiments/config.js +8 -3
  59. package/dist/collections/experiments/deleteGuard.js +2 -2
  60. package/dist/collections/experiments/lockHook.js +21 -2
  61. package/dist/collections/experiments/pickSlug.js +2 -0
  62. package/dist/collections/metrics.js +12 -5
  63. package/dist/collections/metricsGuards.js +2 -0
  64. package/dist/collections/serialize.js +8 -6
  65. package/dist/constants.d.ts +1 -0
  66. package/dist/constants.js +1 -0
  67. package/dist/db/adapter.d.ts +9 -1
  68. package/dist/db/adapter.js +77 -1
  69. package/dist/db/delete.d.ts +1 -1
  70. package/dist/db/delete.js +2 -4
  71. package/dist/db/events.d.ts +9 -0
  72. package/dist/db/events.js +42 -8
  73. package/dist/db/executor.d.ts +7 -1
  74. package/dist/db/executor.js +7 -3
  75. package/dist/db/pageCopies.d.ts +5 -0
  76. package/dist/db/pageCopies.js +31 -0
  77. package/dist/db/results.d.ts +5 -1
  78. package/dist/db/results.js +21 -5
  79. package/dist/db/snapshots.d.ts +2 -0
  80. package/dist/endpoints/deleteImpact.js +2 -1
  81. package/dist/endpoints/duplicateOriginal.d.ts +38 -0
  82. package/dist/endpoints/duplicateOriginal.js +414 -0
  83. package/dist/endpoints/editorSurface.js +1 -1
  84. package/dist/endpoints/events.js +103 -39
  85. package/dist/endpoints/index.js +22 -8
  86. package/dist/endpoints/pages.js +245 -66
  87. package/dist/endpoints/placementStatus.js +8 -4
  88. package/dist/endpoints/results.d.ts +1 -1
  89. package/dist/endpoints/results.js +9 -2
  90. package/dist/endpoints/routeId.d.ts +2 -2
  91. package/dist/endpoints/routeId.js +11 -5
  92. package/dist/endpoints/summary.js +46 -12
  93. package/dist/endpoints/testVersion.d.ts +2 -0
  94. package/dist/endpoints/testVersion.js +38 -0
  95. package/dist/endpoints/transitions.js +41 -29
  96. package/dist/errors.d.ts +4 -0
  97. package/dist/errors.js +6 -0
  98. package/dist/events/request.d.ts +6 -2
  99. package/dist/events/request.js +35 -8
  100. package/dist/events/rows.d.ts +1 -1
  101. package/dist/events/rows.js +24 -8
  102. package/dist/events/writable.d.ts +9 -0
  103. package/dist/events/writable.js +13 -0
  104. package/dist/exports/index.d.ts +1 -1
  105. package/dist/exports/rsc.d.ts +1 -0
  106. package/dist/exports/rsc.js +1 -0
  107. package/dist/goals/fairness.js +2 -2
  108. package/dist/goals/picker/copy.js +1 -1
  109. package/dist/goals/sourceLabel.d.ts +2 -0
  110. package/dist/goals/sourceLabel.js +4 -0
  111. package/dist/hooks/hostHook.js +6 -2
  112. package/dist/hooks/pageGuard.js +4 -0
  113. package/dist/hooks/trackPageCopies.d.ts +11 -0
  114. package/dist/hooks/trackPageCopies.js +7 -0
  115. package/dist/labels/arms.d.ts +3 -0
  116. package/dist/labels/arms.js +8 -0
  117. package/dist/lib/fetchAllDocs.d.ts +1 -1
  118. package/dist/manifest/compile.js +8 -5
  119. package/dist/onInit.js +14 -0
  120. package/dist/options.d.ts +2 -0
  121. package/dist/options.js +23 -2
  122. package/dist/plugin.js +56 -2
  123. package/dist/proxy/pageNavigation.d.ts +4 -0
  124. package/dist/proxy/pageNavigation.js +28 -0
  125. package/dist/proxy/resolve.js +52 -25
  126. package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
  127. package/dist/puck/editor/ConfigureTestDrawer.js +40 -29
  128. package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
  129. package/dist/puck/editor/ExperimentSlotEditor.js +376 -139
  130. package/dist/puck/editor/LeftoverVersions.js +17 -32
  131. package/dist/puck/editor/QuickTestActions.d.ts +6 -3
  132. package/dist/puck/editor/QuickTestActions.js +55 -33
  133. package/dist/puck/editor/ResultsReadout.d.ts +4 -1
  134. package/dist/puck/editor/ResultsReadout.js +28 -15
  135. package/dist/puck/editor/VersionBuilder.d.ts +17 -4
  136. package/dist/puck/editor/VersionBuilder.js +175 -112
  137. package/dist/puck/editor/armWrites.js +2 -2
  138. package/dist/puck/editor/armsCache.js +1 -3
  139. package/dist/puck/editor/copy.d.ts +14 -7
  140. package/dist/puck/editor/copy.js +26 -13
  141. package/dist/puck/editor/editor.chrome.css +10 -8
  142. package/dist/puck/editor/editor.css +15 -9
  143. package/dist/puck/editor/editor.model.d.ts +1 -0
  144. package/dist/puck/editor/placementsCache.d.ts +4 -0
  145. package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
  146. package/dist/puck/editor/usePageSaveReadiness.js +31 -0
  147. package/dist/puck/nestedTestCopy.js +2 -2
  148. package/dist/puck/slotConfig.d.ts +1 -1
  149. package/dist/puck/slotConfig.js +1 -1
  150. package/dist/results/aggregate.d.ts +6 -3
  151. package/dist/results/aggregate.js +9 -9
  152. package/dist/results/analyse.d.ts +2 -0
  153. package/dist/results/analyse.js +2 -2
  154. package/dist/results/health.d.ts +8 -0
  155. package/dist/results/health.js +28 -0
  156. package/dist/results/identityCredit.d.ts +1 -0
  157. package/dist/results/identityCredit.js +4 -1
  158. package/dist/results/verdict.d.ts +4 -4
  159. package/dist/results/verdict.js +15 -11
  160. package/dist/runtime/cookie.d.ts +10 -2
  161. package/dist/runtime/cookie.js +38 -6
  162. package/dist/runtime/cookieOptions.d.ts +6 -0
  163. package/dist/runtime/cookieOptions.js +14 -0
  164. package/dist/runtime/proxyRuntime.d.ts +1 -0
  165. package/dist/runtime/proxyRuntime.js +18 -8
  166. package/dist/runtime/signing.d.ts +1 -0
  167. package/dist/runtime/signing.js +5 -0
  168. package/dist/sanitizeReadinessDetail.d.ts +2 -2
  169. package/dist/sanitizeReadinessDetail.js +20 -2
  170. package/dist/server/getAssignments.js +11 -10
  171. package/dist/server/recordContentChange.d.ts +1 -1
  172. package/dist/server/recordContentChange.js +11 -2
  173. package/dist/server/resolveExperimentBlocks.js +2 -4
  174. package/dist/server/resolveExperimentData.js +2 -5
  175. package/dist/server/runResults.js +54 -15
  176. package/dist/server/startExperiment.d.ts +20 -0
  177. package/dist/server/startExperiment.js +70 -0
  178. package/dist/server/trackConversion.js +10 -13
  179. package/dist/testSurface/PreviewLinks.d.ts +2 -1
  180. package/dist/testSurface/PreviewLinks.js +3 -3
  181. package/dist/testSurface/actions/DecideDialog.d.ts +10 -4
  182. package/dist/testSurface/actions/DecideDialog.js +93 -63
  183. package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
  184. package/dist/testSurface/actions/LifecycleAction.js +107 -0
  185. package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
  186. package/dist/testSurface/actions/MakeContentResult.js +10 -2
  187. package/dist/testSurface/actions/actions.model.d.ts +13 -5
  188. package/dist/testSurface/actions/actions.model.js +75 -22
  189. package/dist/testSurface/actions/decide.model.d.ts +1 -0
  190. package/dist/testSurface/actions/decide.model.js +1 -0
  191. package/dist/testSurface/allocation.model.js +6 -3
  192. package/dist/testSurface/api.d.ts +9 -6
  193. package/dist/testSurface/api.js +43 -23
  194. package/dist/testSurface/copy/actions.d.ts +37 -14
  195. package/dist/testSurface/copy/actions.js +40 -17
  196. package/dist/testSurface/copy/advanced.d.ts +10 -0
  197. package/dist/testSurface/copy/advanced.js +10 -0
  198. package/dist/testSurface/copy/arms.d.ts +1 -1
  199. package/dist/testSurface/copy/arms.js +1 -1
  200. package/dist/testSurface/copy/audience.d.ts +4 -3
  201. package/dist/testSurface/copy/audience.js +5 -4
  202. package/dist/testSurface/copy/common.d.ts +8 -6
  203. package/dist/testSurface/copy/common.js +8 -6
  204. package/dist/testSurface/copy/languages.d.ts +1 -0
  205. package/dist/testSurface/copy/languages.js +1 -0
  206. package/dist/testSurface/copy/metrics.d.ts +7 -0
  207. package/dist/testSurface/copy/metrics.js +9 -0
  208. package/dist/testSurface/copy/pages.d.ts +67 -7
  209. package/dist/testSurface/copy/pages.js +74 -7
  210. package/dist/testSurface/copy/readiness.d.ts +20 -7
  211. package/dist/testSurface/copy/readiness.js +36 -10
  212. package/dist/testSurface/copy/recommendation.d.ts +1 -22
  213. package/dist/testSurface/copy/recommendation.js +2 -22
  214. package/dist/testSurface/copy/results.d.ts +21 -12
  215. package/dist/testSurface/copy/results.js +24 -13
  216. package/dist/testSurface/copy/review.d.ts +13 -10
  217. package/dist/testSurface/copy/review.js +14 -10
  218. package/dist/testSurface/copy/setting.d.ts +1 -2
  219. package/dist/testSurface/copy/setting.js +1 -2
  220. package/dist/testSurface/copy/surface.d.ts +11 -2
  221. package/dist/testSurface/copy/surface.js +14 -11
  222. package/dist/testSurface/copy/testPage.d.ts +36 -12
  223. package/dist/testSurface/copy/testPage.js +53 -16
  224. package/dist/testSurface/format/date.d.ts +5 -2
  225. package/dist/testSurface/format/date.js +24 -8
  226. package/dist/testSurface/format/roundProgress.d.ts +6 -0
  227. package/dist/testSurface/format/roundProgress.js +15 -0
  228. package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
  229. package/dist/testSurface/format/useDateFormatter.js +8 -0
  230. package/dist/testSurface/labels.d.ts +1 -2
  231. package/dist/testSurface/labels.js +2 -3
  232. package/dist/testSurface/lockedNotice.model.d.ts +2 -0
  233. package/dist/testSurface/lockedNotice.model.js +31 -0
  234. package/dist/testSurface/readPreflight.d.ts +4 -0
  235. package/dist/testSurface/readPreflight.js +6 -0
  236. package/dist/testSurface/readinessRead.d.ts +3 -0
  237. package/dist/testSurface/readinessRead.js +4 -0
  238. package/dist/testSurface/results/CiChart.js +2 -1
  239. package/dist/testSurface/results/DataTable.d.ts +1 -1
  240. package/dist/testSurface/results/DataTable.js +4 -3
  241. package/dist/testSurface/results/VerdictHero.d.ts +3 -2
  242. package/dist/testSurface/results/VerdictHero.js +5 -1
  243. package/dist/testSurface/results/legacy.d.ts +0 -5
  244. package/dist/testSurface/results/legacy.js +0 -14
  245. package/dist/testSurface/results/results.css +2 -2
  246. package/dist/testSurface/results/results.model.d.ts +9 -4
  247. package/dist/testSurface/results/results.model.js +31 -23
  248. package/dist/testSurface/results/snapshot.d.ts +2 -0
  249. package/dist/testSurface/results/snapshot.js +3 -0
  250. package/dist/testSurface/surface/contracts.d.ts +13 -1
  251. package/dist/testSurface/surface/editorPlacement.d.ts +3 -3
  252. package/dist/testSurface/surface/editorPlacement.js +2 -2
  253. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +3 -3
  254. package/dist/testSurface/surface/pageBlock/parts.js +25 -12
  255. package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
  256. package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
  257. package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
  258. package/dist/testSurface/surface/pagePicker/PageCombobox.js +300 -197
  259. package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
  260. package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
  261. package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
  262. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +9 -5
  263. package/dist/testSurface/surface/readiness/ActionDialogs.js +241 -230
  264. package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
  265. package/dist/testSurface/surface/readiness/Banner.js +113 -141
  266. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +8 -4
  267. package/dist/testSurface/surface/readiness/SaveStatus.js +23 -22
  268. package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -6
  269. package/dist/testSurface/surface/readiness/readiness.model.js +168 -21
  270. package/dist/testSurface/surface/readiness/useTransition.d.ts +6 -4
  271. package/dist/testSurface/surface/readiness/useTransition.js +57 -14
  272. package/dist/testSurface/surface/results/ReleasePages.d.ts +6 -3
  273. package/dist/testSurface/surface/results/ReleasePages.js +42 -41
  274. package/dist/testSurface/surface/results/ResultsBody.d.ts +11 -4
  275. package/dist/testSurface/surface/results/ResultsBody.js +221 -118
  276. package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
  277. package/dist/testSurface/surface/results/recommendation.model.js +15 -59
  278. package/dist/testSurface/surface/results/useResults.d.ts +13 -8
  279. package/dist/testSurface/surface/results/useResults.js +3 -2
  280. package/dist/testSurface/surface/setting/parts.js +89 -46
  281. package/dist/testSurface/surface/setting/setting.css +2 -1
  282. package/dist/testSurface/surface/test/AdvancedSection.js +11 -4
  283. package/dist/testSurface/surface/test/DeleteTest.d.ts +10 -2
  284. package/dist/testSurface/surface/test/DeleteTest.js +173 -74
  285. package/dist/testSurface/surface/test/GoalSection.js +18 -14
  286. package/dist/testSurface/surface/test/LengthSection.js +24 -13
  287. package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
  288. package/dist/testSurface/surface/test/PageHoldout.js +11 -8
  289. package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
  290. package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
  291. package/dist/testSurface/surface/test/Section.js +8 -0
  292. package/dist/testSurface/surface/test/TargetingSection.js +82 -12
  293. package/dist/testSurface/surface/test/TestSurface.js +73 -37
  294. package/dist/testSurface/surface/test/VersionsSection.js +141 -91
  295. package/dist/testSurface/surface/test/fields.d.ts +32 -6
  296. package/dist/testSurface/surface/test/fields.js +166 -52
  297. package/dist/testSurface/surface/test/pageParts.js +27 -12
  298. package/dist/testSurface/surface/test/testPage.css +9 -2
  299. package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
  300. package/dist/testSurface/surface/test/testPage.model.js +6 -0
  301. package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
  302. package/dist/testSurface/surface/testDocument.model.js +4 -1
  303. package/dist/testSurface/surface/useTestDocument.d.ts +21 -5
  304. package/dist/testSurface/surface/useTestDocument.js +472 -167
  305. package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
  306. package/dist/testSurface/surface/watchTestDocument.js +181 -0
  307. package/dist/testSurface/surfaceUrls.d.ts +1 -0
  308. package/dist/testSurface/surfaceUrls.js +4 -0
  309. package/dist/testSurface/useApi.d.ts +8 -5
  310. package/dist/testSurface/useOnTestReturn.d.ts +2 -0
  311. package/dist/testSurface/useOnTestReturn.js +27 -0
  312. package/dist/testSurface/useReadinessPolling.js +3 -1
  313. package/dist/transitions/addMetric.d.ts +2 -5
  314. package/dist/transitions/addMetric.js +5 -1
  315. package/dist/transitions/allocate.d.ts +2 -2
  316. package/dist/transitions/allocate.js +3 -1
  317. package/dist/transitions/archive.d.ts +1 -1
  318. package/dist/transitions/archive.js +3 -2
  319. package/dist/transitions/checkStart.d.ts +1 -0
  320. package/dist/transitions/checkStart.js +17 -6
  321. package/dist/transitions/decide.d.ts +1 -1
  322. package/dist/transitions/decide.js +5 -3
  323. package/dist/transitions/deleteExperiment.d.ts +2 -2
  324. package/dist/transitions/deleteExperiment.js +17 -7
  325. package/dist/transitions/kernel.d.ts +4 -0
  326. package/dist/transitions/kernel.js +9 -4
  327. package/dist/transitions/makeContent.d.ts +2 -1
  328. package/dist/transitions/makeContent.js +12 -8
  329. package/dist/transitions/nestedPlacementNames.d.ts +2 -2
  330. package/dist/transitions/nestedPlacementNames.js +4 -5
  331. package/dist/transitions/pageAddress.d.ts +6 -0
  332. package/dist/transitions/pageAddress.js +71 -0
  333. package/dist/transitions/pageVersions.d.ts +1 -1
  334. package/dist/transitions/phaseRecord.d.ts +2 -0
  335. package/dist/transitions/phaseRecord.js +5 -0
  336. package/dist/transitions/placementInteractions.d.ts +3 -3
  337. package/dist/transitions/placementInteractions.js +8 -7
  338. package/dist/transitions/placements.d.ts +2 -0
  339. package/dist/transitions/placements.js +5 -5
  340. package/dist/transitions/preflightData.d.ts +3 -2
  341. package/dist/transitions/preflightData.js +77 -43
  342. package/dist/transitions/releaseHoldout.d.ts +2 -1
  343. package/dist/transitions/releaseHoldout.js +3 -1
  344. package/dist/transitions/releasePages.d.ts +2 -1
  345. package/dist/transitions/releasePages.js +3 -1
  346. package/dist/transitions/resolveCaps.d.ts +2 -4
  347. package/dist/transitions/start.d.ts +7 -9
  348. package/dist/transitions/start.js +75 -39
  349. package/dist/transitions/startReads.d.ts +7 -0
  350. package/dist/transitions/startReads.js +28 -0
  351. package/dist/transitions/stop.d.ts +2 -1
  352. package/dist/transitions/stop.js +3 -2
  353. package/dist/types/armKey.d.ts +2 -0
  354. package/dist/types/armKey.js +1 -0
  355. package/dist/types/contracts.d.ts +17 -4
  356. package/dist/types/endpoints.d.ts +89 -17
  357. package/dist/types/endpoints.js +1 -1
  358. package/dist/types/runtime.d.ts +15 -9
  359. package/dist/types/snapshot.d.ts +2 -0
  360. package/dist/types/surface.d.ts +7 -9
  361. package/dist/ui/ChipsInput.d.ts +8 -1
  362. package/dist/ui/ChipsInput.js +17 -4
  363. package/dist/ui/Dialog.d.ts +21 -2
  364. package/dist/ui/Dialog.js +101 -4
  365. package/dist/ui/Inputs.js +0 -1
  366. package/dist/ui/ui.css +5 -1
  367. package/package.json +2 -2
@@ -1,49 +1,119 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { placementLanguageSuffix } from '../../copy/languages.js';
4
- import { useEffect, useRef, useState } from 'react';
4
+ import { useCallback, useEffect, useRef, useState } from 'react';
5
5
  import { createApi } from '../../api.js';
6
- import { DELETE_TEST as C } from '../../copy/testPage.js';
6
+ import { API_MESSAGES } from '../../copy/common.js';
7
+ import { DELETE_TEST as C, deleteStatusCopy } from '../../copy/testPage.js';
8
+ import { useOnTestReturn } from '../../useOnTestReturn.js';
7
9
  import { Button } from '../../../ui/Button.js';
8
- import { Dialog } from '../../../ui/Dialog.js';
10
+ import { ConfirmDialog } from '../../../ui/Dialog.js';
11
+ import { canDeleteTest } from '../../actions/actions.model.js';
12
+ import { READINESS_COPY } from '../../copy/readiness.js';
13
+ import { surfaceUrls } from '../../surfaceUrls.js';
14
+ import { notifyTestDocument } from '../watchTestDocument.js';
9
15
  const VISIBLE_PAGES = 5;
10
16
  export const DELETE_IMPACT_TIMEOUT_MS = 15_000;
11
- /** Matches deleteExperiment's status guard; the server rechecks under its lock. */ export function DeleteTest({ test, canManage, apiRoute, contentLocale, onDeleted }) {
12
- const [open, setOpen] = useState(false);
17
+ export function DeleteTestAction({ test, surface }) {
18
+ if (!test.doc) return null;
19
+ return /*#__PURE__*/ _jsx(DeleteTest, {
20
+ test: test.doc,
21
+ canManage: surface.canManage,
22
+ statusReadPending: test.statusReadPending,
23
+ apiRoute: surface.apiRoute,
24
+ contentLocale: surface.contentLocale,
25
+ onStatusChanged: ()=>{
26
+ void test.reload();
27
+ },
28
+ onDeleted: (outcome)=>window.location.assign(surfaceUrls.home(surface.adminRoute, {
29
+ deleted: outcome
30
+ }))
31
+ }, test.doc.id);
32
+ }
33
+ /** Matches deleteExperiment's status guard; the server rechecks under its lock. */ export function DeleteTest({ test, canManage, apiRoute, contentLocale, onDeleted, onStatusChanged, onDialogChange, fromMenu = false, statusReadPending }) {
34
+ const [open, setOpen] = useState(fromMenu);
13
35
  const [busy, setBusy] = useState(false);
14
36
  const pending = useRef(false);
37
+ const actions = useRef(null);
15
38
  const [error, setError] = useState();
16
- const [impact, setImpact] = useState({
39
+ const [checked, setChecked] = useState();
40
+ const [refusal, setRefusal] = useState();
41
+ const [checkAttempt, setCheckAttempt] = useState(0);
42
+ const checkKey = JSON.stringify([
43
+ test.id,
44
+ apiRoute,
45
+ contentLocale,
46
+ test.status,
47
+ typeof test.updatedAt === 'string' ? test.updatedAt : null,
48
+ checkAttempt
49
+ ]);
50
+ const impact = refusal ?? (checked?.key === checkKey ? checked.impact : {
17
51
  state: 'loading'
18
52
  });
53
+ const deletable = canDeleteTest(test.status);
54
+ const statusMessage = deletable ? undefined : deleteStatusCopy(test.status, test.kind);
55
+ const blocked = !canManage ? API_MESSAGES.forbidden : impact.state === 'blocked' ? impact.reason === 'invalid-status' ? statusMessage ?? impact.message : impact.message : statusMessage;
56
+ useOnTestReturn(useCallback(()=>{
57
+ if (!pending.current) setCheckAttempt((value)=>value + 1);
58
+ }, []), open && !blocked);
59
+ useEffect(()=>{
60
+ if (open && blocked && !busy) actions.current?.querySelector('[data-dialog-cancel]')?.focus();
61
+ }, [
62
+ open,
63
+ blocked,
64
+ busy
65
+ ]);
19
66
  useEffect(()=>{
20
- if (!open) return;
67
+ if (!open || !deletable || !canManage || refusal) return;
21
68
  let current = true;
22
69
  const controller = new AbortController();
70
+ const record = (impact)=>setChecked({
71
+ key: checkKey,
72
+ impact
73
+ });
23
74
  const timer = setTimeout(()=>{
24
75
  if (!current) return;
25
76
  current = false;
26
77
  controller.abort();
27
- setImpact({
78
+ record({
28
79
  state: 'failed'
29
80
  });
30
81
  }, DELETE_IMPACT_TIMEOUT_MS);
31
- setImpact({
32
- state: 'loading'
33
- });
34
82
  void createApi(apiRoute, contentLocale).deleteImpact(test.id, controller.signal).then((result)=>{
35
83
  if (!current) return;
36
84
  clearTimeout(timer);
37
- setImpact(result.ok && result.data && [
38
- 'none',
39
- 'block',
40
- 'page'
41
- ].includes(result.data.effect) ? {
42
- state: 'ready',
43
- data: result.data
44
- } : {
85
+ if (result.ok) {
86
+ record(readableImpact(result.data) ? {
87
+ state: 'ready',
88
+ data: result.data
89
+ } : {
90
+ state: 'blocked',
91
+ message: API_MESSAGES.unreadable
92
+ });
93
+ } else if (result.status === 0 || result.status >= 500) record({
45
94
  state: 'failed'
46
95
  });
96
+ else if (result.status === 404) setRefusal({
97
+ state: 'blocked',
98
+ message: C.alreadyDeleted,
99
+ reason: 'already-deleted'
100
+ });
101
+ else if (result.status === 409 && result.code === 'invalid-status') {
102
+ setRefusal({
103
+ state: 'blocked',
104
+ message: result.message,
105
+ reason: 'invalid-status',
106
+ refusedStatus: test.status
107
+ });
108
+ } else setRefusal({
109
+ state: 'blocked',
110
+ message: result.message,
111
+ reason: [
112
+ 401,
113
+ 403
114
+ ].includes(result.status) ? 'access' : undefined
115
+ });
116
+ if (!result.ok && !onDialogChange && result.status === 409) onStatusChanged();
47
117
  });
48
118
  return ()=>{
49
119
  current = false;
@@ -52,91 +122,120 @@ export const DELETE_IMPACT_TIMEOUT_MS = 15_000;
52
122
  };
53
123
  }, [
54
124
  open,
125
+ deletable,
126
+ canManage,
127
+ refusal,
128
+ checkKey,
55
129
  test.id,
56
130
  apiRoute,
57
131
  contentLocale
58
132
  ]);
59
- if (!canManage || ![
60
- 'draft',
61
- 'archived'
62
- ].includes(test.status)) return null;
133
+ if (!open && (!canManage || !deletable)) return null;
63
134
  const checking = impact.state === 'loading';
135
+ function showDialog() {
136
+ setError(undefined);
137
+ setChecked(undefined);
138
+ setRefusal(undefined);
139
+ setOpen(true);
140
+ onDialogChange?.(true);
141
+ }
142
+ function close() {
143
+ setOpen(false);
144
+ onDialogChange?.(false);
145
+ // Keep the refusal visible until dismissed. Reloading can move the row to another group.
146
+ if (impact.state === 'blocked' && impact.reason === 'already-deleted') onDeleted('already');
147
+ if (impact.state === 'blocked' && impact.reason === 'access') onStatusChanged();
148
+ if (onDialogChange && impact.state === 'blocked' && impact.reason === 'invalid-status') onStatusChanged();
149
+ }
64
150
  async function remove() {
65
- if (checking || pending.current) return;
151
+ if (blocked || checking || statusReadPending || pending.current) return;
66
152
  pending.current = true;
67
153
  setBusy(true);
68
154
  setError(undefined);
69
155
  const result = await createApi(apiRoute).deleteTest(test.id);
70
156
  if (result.ok || result.status === 404) {
157
+ if (result.ok) notifyTestDocument(apiRoute, test.id);
71
158
  setOpen(false);
159
+ onDialogChange?.(false);
72
160
  onDeleted(result.ok ? 'done' : 'already');
73
- } else setError(result.message);
161
+ } else if (result.status === 409 && result.code === 'invalid-status') {
162
+ setRefusal({
163
+ state: 'blocked',
164
+ message: result.message,
165
+ reason: 'invalid-status',
166
+ refusedStatus: test.status
167
+ });
168
+ if (!onDialogChange) onStatusChanged();
169
+ } else if (result.status === 401 || result.status === 403) {
170
+ setRefusal({
171
+ state: 'blocked',
172
+ message: result.message,
173
+ reason: 'access'
174
+ });
175
+ } else {
176
+ setError(result.message);
177
+ if (result.status === 409) onStatusChanged();
178
+ }
74
179
  pending.current = false;
75
180
  setBusy(false);
76
181
  }
77
182
  return /*#__PURE__*/ _jsxs(_Fragment, {
78
183
  children: [
79
- /*#__PURE__*/ _jsx(Button, {
184
+ !fromMenu && canManage && deletable && !statusReadPending && (refusal?.reason !== 'invalid-status' || refusal.refusedStatus !== test.status) ? /*#__PURE__*/ _jsx(Button, {
80
185
  variant: "quiet",
81
186
  size: "sm",
82
- onClick: ()=>{
83
- setError(undefined);
84
- setImpact({
85
- state: 'loading'
86
- });
87
- setOpen(true);
187
+ onClick: (event)=>{
188
+ event.currentTarget.focus();
189
+ showDialog();
88
190
  },
89
191
  children: C.action
90
- }),
91
- /*#__PURE__*/ _jsxs(Dialog, {
92
- open: open,
93
- title: C.title(test.name),
94
- initialFocus: "cancel",
95
- dismissible: !busy,
96
- onClose: ()=>setOpen(false),
97
- children: [
98
- /*#__PURE__*/ _jsx("p", {
99
- children: C.consequences
100
- }),
101
- /*#__PURE__*/ _jsx("p", {
102
- children: C.content
103
- }),
104
- /*#__PURE__*/ _jsx("p", {
105
- role: "status",
106
- "aria-atomic": "true",
107
- children: checking ? C.checking : impact.state === 'failed' ? C.checkFailed : impact.state === 'ready' ? impactSummary(impact.data) : ''
108
- }),
109
- impact.state === 'ready' ? /*#__PURE__*/ _jsx(ImpactDetails, {
110
- impact: impact.data
111
- }) : null,
112
- error ? /*#__PURE__*/ _jsx("p", {
113
- role: "alert",
114
- children: error
115
- }) : null,
116
- /*#__PURE__*/ _jsxs("div", {
117
- className: "xp-ui-button-group",
192
+ }) : null,
193
+ /*#__PURE__*/ _jsx("div", {
194
+ ref: actions,
195
+ children: /*#__PURE__*/ _jsx(ConfirmDialog, {
196
+ open: open,
197
+ title: C.title(test.name),
198
+ description: blocked ? undefined : C.consequences,
199
+ busy: busy,
200
+ busyLabel: READINESS_COPY.changing,
201
+ onClose: close,
202
+ cancelLabel: blocked ? C.close : C.cancel,
203
+ error: blocked ?? error,
204
+ confirm: blocked ? undefined : {
205
+ label: C.action,
206
+ destructive: true,
207
+ disabled: checking || statusReadPending,
208
+ onClick: remove
209
+ },
210
+ children: blocked ? (impact.state === 'blocked' && impact.reason === 'invalid-status' ? impact.refusedStatus : test.status) === 'running' && canManage ? /*#__PURE__*/ _jsx("ol", {
211
+ children: C.runningSteps.map((step)=>/*#__PURE__*/ _jsx("li", {
212
+ children: step
213
+ }, step))
214
+ }) : null : /*#__PURE__*/ _jsxs(_Fragment, {
118
215
  children: [
119
- /*#__PURE__*/ _jsx(Button, {
120
- "data-dialog-cancel": true,
121
- disabled: busy,
122
- onClick: ()=>setOpen(false),
123
- children: C.cancel
216
+ /*#__PURE__*/ _jsx("p", {
217
+ children: C.content
124
218
  }),
125
- /*#__PURE__*/ _jsx(Button, {
126
- variant: "danger",
127
- disabled: checking,
128
- "aria-disabled": busy || checking || undefined,
129
- "aria-busy": busy || undefined,
130
- onClick: ()=>void remove(),
131
- children: C.action
132
- })
219
+ /*#__PURE__*/ _jsx("p", {
220
+ role: "status",
221
+ "aria-atomic": "true",
222
+ children: checking ? C.checking : impact.state === 'failed' ? C.checkFailed : impact.state === 'ready' ? impactSummary(impact.data) : ''
223
+ }),
224
+ impact.state === 'ready' ? /*#__PURE__*/ _jsx(ImpactDetails, {
225
+ impact: impact.data
226
+ }) : null
133
227
  ]
134
228
  })
135
- ]
229
+ })
136
230
  })
137
231
  ]
138
232
  });
139
233
  }
234
+ function readableImpact(impact) {
235
+ if (impact?.effect === 'none') return true;
236
+ if (impact?.effect === 'page') return typeof impact.winnerPath === 'string' && Array.isArray(impact.addresses) && impact.addresses.every((path)=>typeof path === 'string') && (impact.afterPaths === undefined || impact.afterPaths !== null && typeof impact.afterPaths === 'object' && Object.values(impact.afterPaths).every((path)=>typeof path === 'string'));
237
+ return impact?.effect === 'block' && typeof impact.controlLabel === 'string' && Number.isInteger(impact.pageCount) && Number.isInteger(impact.unreadablePages) && Array.isArray(impact.placements) && impact.placements.every((place)=>typeof place?.title === 'string' && typeof place.before?.label === 'string' && typeof place.after?.label === 'string' && (place.path === null || typeof place.path === 'string') && (place.locales === undefined || Array.isArray(place.locales) && place.locales.every((locale)=>typeof locale === 'string')));
238
+ }
140
239
  function impactSummary(impact) {
141
240
  return impact.effect === 'none' ? C.noEffect : C.changedPages(impact.effect === 'block' ? impact.pageCount : impact.addresses.length);
142
241
  }
@@ -7,12 +7,12 @@ import { Button } from '../../../ui/Button.js';
7
7
  import { useEffect, useMemo, useState } from 'react';
8
8
  import { surfaceUrls } from '../../surfaceUrls.js';
9
9
  import { TEST_PAGE as C } from '../../copy/testPage.js';
10
- import { METRIC_KIND_LABELS } from '../../copy/metrics.js';
11
- import { isClickSource } from '../../../goals/key.js';
10
+ import { METRICS_COPY, METRIC_KIND_LABELS } from '../../copy/metrics.js';
11
+ import { isClickSource, validClickSource } from '../../../goals/key.js';
12
12
  import { createApi } from '../../api.js';
13
13
  import { sourceFor } from '../../metricSource.model.js';
14
14
  import { reviewView } from '../../review/review.model.js';
15
- import { FieldErrors, reasonFor, save, SelectEdit } from './fields.js';
15
+ import { FieldErrors, ReadOnly, reasonFor, save, SelectEdit } from './fields.js';
16
16
  import { Section } from './Section.js';
17
17
  export function GoalSection({ test, surface, embedded = false }) {
18
18
  const api = useMemo(()=>createApi(surface.apiRoute), [
@@ -139,7 +139,7 @@ export function GoalSection({ test, surface, embedded = false }) {
139
139
  value: id,
140
140
  label: unknownGoal
141
141
  });
142
- const otherGoals = visible.filter((option)=>option.value !== String(doc.metrics?.primary ?? ''));
142
+ const otherGoals = visible.filter((option)=>option.value !== String(doc.metrics?.primary ?? '') && (!reason || chosen.includes(option.value)));
143
143
  const otherCount = new Set([
144
144
  ...doc.metrics?.guardrails ?? [],
145
145
  ...doc.metrics?.secondary ?? []
@@ -209,7 +209,8 @@ export function GoalSection({ test, surface, embedded = false }) {
209
209
  });
210
210
  const display = (ids)=>ids.length ? ids.map((id)=>options.find((option)=>option.value === String(id))?.label ?? unknownGoal).join(', ') : C.noGoal;
211
211
  const primary = metrics.find((metric)=>String(metric.id) === String(doc.metrics?.primary));
212
- const kind = sourceFor(primary?.source, surface.metricSources)?.kind;
212
+ const primarySource = sourceFor(primary?.source, surface.metricSources);
213
+ const kind = primarySource?.kind;
213
214
  const baseline = test.preflight?.baseline && String(test.preflight.baseline.metricId) === String(doc.metrics?.primary) ? reviewView(test.preflight, {
214
215
  primaryMetricKind: kind
215
216
  }).baseline : null;
@@ -232,6 +233,9 @@ export function GoalSection({ test, surface, embedded = false }) {
232
233
  })
233
234
  ]
234
235
  }) : null,
236
+ /*#__PURE__*/ _jsx("p", {
237
+ children: C.goalHelp
238
+ }),
235
239
  /*#__PURE__*/ _jsx(SelectEdit, {
236
240
  labelAction: /*#__PURE__*/ _jsx("span", {
237
241
  className: "xp-ui-button-group",
@@ -260,12 +264,12 @@ export function GoalSection({ test, surface, embedded = false }) {
260
264
  ]),
261
265
  onCommit: changePrimary
262
266
  }),
263
- /*#__PURE__*/ _jsx("p", {
264
- children: C.goalHelp
265
- }),
266
267
  primary && isClickSource(primary.source) ? /*#__PURE__*/ _jsx("p", {
267
268
  children: C.clickGoalHelp
268
269
  }) : null,
270
+ validClickSource(primary?.source) || primarySource?.clientWritable && primarySource.kind !== 'revenue' ? /*#__PURE__*/ _jsx("p", {
271
+ children: METRICS_COPY.browserWritablePrimary
272
+ }) : null,
269
273
  baseline ? /*#__PURE__*/ _jsxs("p", {
270
274
  children: [
271
275
  primary?.name ? `${primary.name}: ` : '',
@@ -288,11 +292,15 @@ export function GoalSection({ test, surface, embedded = false }) {
288
292
  className: "xp-other-goal-list",
289
293
  children: otherGoals.map((option, index)=>{
290
294
  const role = doc.metrics?.guardrails?.some((id)=>String(id) === option.value) ? 'guardrails' : doc.metrics?.secondary?.some((id)=>String(id) === option.value) ? 'secondary' : '';
295
+ const label = onPage.get(option.value) ?? option.label;
296
+ if (reason) return /*#__PURE__*/ _jsx(ReadOnly, {
297
+ label: label,
298
+ value: role === 'guardrails' ? C.mustNotWorsen : C.watch
299
+ }, option.value);
291
300
  return /*#__PURE__*/ _jsxs(Select, {
292
301
  id: `${roleId}-${index}`,
293
- label: onPage.get(option.value) ?? option.label,
302
+ label: label,
294
303
  value: role,
295
- disabled: Boolean(reason),
296
304
  onChange: (event)=>setRole(option.value, event.target.value),
297
305
  children: [
298
306
  /*#__PURE__*/ _jsx("option", {
@@ -314,10 +322,6 @@ export function GoalSection({ test, surface, embedded = false }) {
314
322
  /*#__PURE__*/ _jsx("p", {
315
323
  children: C.otherGoalsHelp
316
324
  }),
317
- reason ? /*#__PURE__*/ _jsx("p", {
318
- className: "xp-ui-help",
319
- children: reason
320
- }) : null,
321
325
  /*#__PURE__*/ _jsx(FieldErrors, {
322
326
  test: test,
323
327
  path: "metrics.guardrails"
@@ -3,12 +3,16 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Button } from '../../../ui/Button.js';
4
4
  import { TEST_PAGE as C, suggestedWeeks, weeksHint } from '../../copy/testPage.js';
5
5
  import { durationSuggestion } from './testPage.model.js';
6
- import { FieldErrors, positiveInteger, reasonFor, save, TextEdit } from './fields.js';
6
+ import { FieldErrors, positiveInteger, ReadOnly, reasonFor, save, TextEdit } from './fields.js';
7
+ import { useDateFormatter } from '../../format/useDateFormatter.js';
7
8
  import { Section } from './Section.js';
8
9
  export function LengthSection({ test, surface }) {
10
+ const formatDate = useDateFormatter();
9
11
  const doc = test.doc;
10
12
  const reason = reasonFor(test, 'analysis');
11
- const suggestion = durationSuggestion(test.preflight, doc.analysis?.plannedDurationDays);
13
+ const days = doc.analysis?.plannedDurationDays ?? 28;
14
+ const suggestion = !reason ? durationSuggestion(test.preflight, days) : null;
15
+ const end = typeof doc.startedAt === 'string' ? Date.parse(doc.startedAt) + days * 86_400_000 : NaN;
12
16
  const required = [
13
17
  'manual',
14
18
  'viewport'
@@ -27,45 +31,52 @@ export function LengthSection({ test, surface }) {
27
31
  /*#__PURE__*/ _jsxs("div", {
28
32
  className: "xp-field-grid",
29
33
  children: [
30
- /*#__PURE__*/ _jsxs("div", {
34
+ !reason || test.fieldDrafts?.['analysis.reachPerDay'] ? /*#__PURE__*/ _jsxs("div", {
31
35
  children: [
32
36
  /*#__PURE__*/ _jsx(TextEdit, {
37
+ test: test,
38
+ draftKey: "analysis.reachPerDay",
33
39
  label: required ? `${C.reach} ${C.required}` : C.reach,
34
40
  value: doc.analysis?.reachPerDay ?? '',
35
41
  type: "number",
36
42
  min: 1,
37
43
  reason: reason,
38
- required: required,
44
+ required: required && !reason,
39
45
  onCommit: (value)=>change('reachPerDay', value)
40
46
  }),
41
- /*#__PURE__*/ _jsx("p", {
47
+ !reason ? /*#__PURE__*/ _jsx("p", {
42
48
  className: "xp-ui-help",
43
49
  children: C.reachHelp
44
- }),
50
+ }) : null,
45
51
  /*#__PURE__*/ _jsx(FieldErrors, {
46
52
  test: test,
47
53
  path: "analysis.reachPerDay"
48
54
  })
49
55
  ]
50
- }),
56
+ }, "reach") : null,
51
57
  /*#__PURE__*/ _jsxs("div", {
52
58
  children: [
53
59
  /*#__PURE__*/ _jsx(TextEdit, {
60
+ test: test,
54
61
  label: C.duration,
55
- value: doc.analysis?.plannedDurationDays ?? 28,
62
+ value: days,
56
63
  type: "number",
57
64
  min: 1,
58
65
  reason: reason,
59
66
  isValid: positiveInteger,
60
67
  onCommit: (value)=>change('plannedDurationDays', value),
61
- help: weeksHint(doc.analysis?.plannedDurationDays ?? 28)
68
+ help: !reason ? weeksHint(days) : undefined
62
69
  }),
63
70
  /*#__PURE__*/ _jsx(FieldErrors, {
64
71
  test: test,
65
72
  path: "analysis.plannedDurationDays"
66
73
  })
67
74
  ]
68
- })
75
+ }, "duration"),
76
+ reason ? /*#__PURE__*/ _jsx(ReadOnly, {
77
+ label: C.endDate,
78
+ value: formatDate(end)
79
+ }) : null
69
80
  ]
70
81
  }),
71
82
  suggestion ? /*#__PURE__*/ _jsxs("div", {
@@ -74,7 +85,7 @@ export function LengthSection({ test, surface }) {
74
85
  /*#__PURE__*/ _jsx("p", {
75
86
  children: suggestedWeeks(suggestion.weeks)
76
87
  }),
77
- !reason ? /*#__PURE__*/ _jsx(Button, {
88
+ /*#__PURE__*/ _jsx(Button, {
78
89
  onClick: ()=>save(test, 'analysis', ()=>({
79
90
  analysis: {
80
91
  ...test.doc.analysis,
@@ -83,12 +94,12 @@ export function LengthSection({ test, surface }) {
83
94
  }
84
95
  })),
85
96
  children: C.apply
86
- }) : null,
97
+ }),
87
98
  !suggestion.feasible ? /*#__PURE__*/ _jsx("p", {
88
99
  children: C.infeasible
89
100
  }) : null
90
101
  ]
91
- }) : !test.preflight?.estimate ? /*#__PURE__*/ _jsx("p", {
102
+ }) : !reason && !test.preflight?.estimate ? /*#__PURE__*/ _jsx("p", {
92
103
  children: doc.analysis?.reachPerDay == null ? C.noSuggestion : C.chooseGoalSuggestion
93
104
  }) : null,
94
105
  test.errors.analysis ? /*#__PURE__*/ _jsx("p", {
@@ -1,3 +1,3 @@
1
1
  import type { SectionProps } from '../contracts.js';
2
2
  /** Whole-page holdouts have no page of their own; their controls live under Advanced. */
3
- export declare function PageHoldout({ test }: SectionProps): import("react").JSX.Element;
3
+ export declare function PageHoldout({ test }: SectionProps): import("react").JSX.Element | null;
@@ -1,9 +1,10 @@
1
1
  'use client';
2
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
+ import { actionGroupLabel } from '../../actions/actions.model.js';
4
5
  import { ARMS_COPY } from '../../copy/arms.js';
5
6
  import { addHoldoutArm, removeArm, splitEvenly } from '../../arms/arms.model.js';
6
- import { balanceWeight } from './testPage.model.js';
7
+ import { balanceWeight, trafficSplit } from './testPage.model.js';
7
8
  import { FieldErrors, reasonFor, save, TextEdit } from './fields.js';
8
9
  import { Button } from '../../../ui/Button.js';
9
10
  /** Whole-page holdouts have no page of their own; their controls live under Advanced. */ export function PageHoldout({ test }) {
@@ -11,11 +12,13 @@ import { Button } from '../../../ui/Button.js';
11
12
  const arm = doc.arms.find((item)=>item.kind === 'holdout');
12
13
  const index = doc.arms.findIndex((item)=>item.kind === 'holdout');
13
14
  const reason = reasonFor(test, 'arms');
15
+ if (reason && !arm) return null;
14
16
  return /*#__PURE__*/ _jsxs("div", {
15
17
  children: [
16
18
  arm ? /*#__PURE__*/ _jsxs(_Fragment, {
17
19
  children: [
18
20
  /*#__PURE__*/ _jsx(TextEdit, {
21
+ test: test,
19
22
  label: `${C.holdoutPrefix}${C.label}`,
20
23
  value: arm.label,
21
24
  reason: reason,
@@ -27,8 +30,10 @@ import { Button } from '../../../ui/Button.js';
27
30
  }))
28
31
  }),
29
32
  /*#__PURE__*/ _jsx(TextEdit, {
33
+ test: test,
30
34
  label: `${C.holdoutPrefix}${C.weight}`,
31
35
  type: "number",
36
+ scope: trafficSplit(doc.arms),
32
37
  min: 0,
33
38
  max: 100,
34
39
  value: arm.weight,
@@ -43,24 +48,22 @@ import { Button } from '../../../ui/Button.js';
43
48
  test: test,
44
49
  path: `arms.${index}`
45
50
  }),
46
- /*#__PURE__*/ _jsx(Button, {
47
- disabled: !!reason,
51
+ !reason ? /*#__PURE__*/ _jsx(Button, {
48
52
  onClick: ()=>save(test, 'arms', ()=>({
49
53
  arms: splitEvenly(removeArm(doc.arms, arm.key))
50
54
  })),
51
55
  children: C.remove
52
- })
56
+ }) : null
53
57
  ]
54
- }) : /*#__PURE__*/ _jsx(Button, {
55
- disabled: !!reason,
58
+ }) : !reason ? /*#__PURE__*/ _jsx(Button, {
56
59
  onClick: ()=>save(test, 'arms', ()=>({
57
60
  arms: addHoldoutArm(doc.arms)
58
61
  })),
59
62
  children: C.addHoldout
60
- }),
63
+ }) : null,
61
64
  /*#__PURE__*/ _jsx("p", {
62
65
  className: "xp-ui-help",
63
- children: ARMS_COPY.holdout
66
+ children: ARMS_COPY.holdout(actionGroupLabel('control', doc.arms.find((arm)=>arm.key === 'control')?.label))
64
67
  })
65
68
  ]
66
69
  });
@@ -2,4 +2,5 @@ import type { SectionProps } from '../contracts.js';
2
2
  /** Measure wrapping actions/copy so the final section always clears the fixed bar. */
3
3
  export declare function ReadinessBar({ onHeightChange, ...props }: SectionProps & {
4
4
  onHeightChange: (height: number) => void;
5
- }): import("react").JSX.Element;
5
+ embedded?: boolean;
6
+ }): import("react").JSX.Element | null;
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useLayoutEffect, useRef } from 'react';
4
- import { READINESS_COPY as C } from '../../copy/readiness.js';
5
4
  import { ReadinessContent } from '../readiness/Banner.js';
6
5
  /** Measure wrapping actions/copy so the final section always clears the fixed bar. */ export function ReadinessBar({ onHeightChange, ...props }) {
7
6
  const ref = useRef(null);
@@ -20,13 +19,8 @@ import { ReadinessContent } from '../readiness/Banner.js';
20
19
  }, [
21
20
  onHeightChange
22
21
  ]);
23
- return /*#__PURE__*/ _jsx("div", {
24
- ref: ref,
25
- className: "xp-test-readiness-bar",
26
- role: "region",
27
- "aria-label": C.label,
28
- children: props.test.doc ? /*#__PURE__*/ _jsx(ReadinessContent, {
29
- ...props
30
- }, `${props.test.doc.id}/${props.test.doc.status}`) : null
31
- });
22
+ return props.test.doc ? /*#__PURE__*/ _jsx(ReadinessContent, {
23
+ ...props,
24
+ barRef: ref
25
+ }, props.test.doc.id) : null;
32
26
  }
@@ -6,6 +6,7 @@ import { readinessParts } from '../readiness/parts.js';
6
6
  import { SectionCard } from '../../../ui/SectionCard.js';
7
7
  import { SECTION_ORDER } from '../contracts.js';
8
8
  import { fixFieldsNext } from '../../copy/readiness.js';
9
+ import { sectionLockNotice } from '../../lockedNotice.model.js';
9
10
  import { TEST_PAGE as C } from '../../copy/testPage.js';
10
11
  export function Section({ test, sectionId, children, surface }) {
11
12
  const hasAdvancedError = Object.keys(test.errors).some((path)=>path.startsWith('analysis.') && ![
@@ -18,6 +19,11 @@ export function Section({ test, sectionId, children, surface }) {
18
19
  setPrevHasAdvancedError(hasAdvancedError);
19
20
  if (hasAdvancedError) setOpen(true);
20
21
  }
22
+ const reason = test.doc && sectionLockNotice(test.doc.status, sectionId);
23
+ const notice = reason ? /*#__PURE__*/ _jsx("p", {
24
+ className: "xp-ui-help xp-section-lock",
25
+ children: reason
26
+ }) : null;
21
27
  const setup = test.doc?.status === 'draft' || test.doc?.status === 'stopped';
22
28
  const blocked = setup && sectionBlocked(test, sectionId);
23
29
  const blockers = setup && test.doc ? blockingSteps(test.preflight, surface ? pageReadinessContext(test.doc, test.preflight, surface) : test.doc).filter((step)=>step.section === sectionId) : [];
@@ -58,6 +64,7 @@ export function Section({ test, sectionId, children, surface }) {
58
64
  /*#__PURE__*/ _jsxs("div", {
59
65
  className: "xp-ui-section-body",
60
66
  children: [
67
+ notice,
61
68
  children,
62
69
  blockerLines
63
70
  ]
@@ -73,6 +80,7 @@ export function Section({ test, sectionId, children, surface }) {
73
80
  headingId: `title-${sectionId}`,
74
81
  className: "xp-test-section",
75
82
  children: [
83
+ notice,
76
84
  children,
77
85
  blockerLines
78
86
  ]