@delmaredigital/payload-experiments 0.4.0-rc.3 → 0.4.0-rc.5

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