@delmaredigital/payload-experiments 0.4.0-rc.9 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (254) hide show
  1. package/README.md +3 -7
  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 +5 -4
  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 +4 -8
  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 +186 -47
  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 +93 -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 +90 -63
  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 +1 -1
  57. package/dist/collections/experiments/armInvariants.js +8 -5
  58. package/dist/collections/metrics.js +12 -5
  59. package/dist/collections/serialize.js +3 -2
  60. package/dist/db/pageCopies.d.ts +5 -0
  61. package/dist/db/pageCopies.js +31 -0
  62. package/dist/db/snapshots.d.ts +1 -0
  63. package/dist/endpoints/duplicateOriginal.d.ts +38 -0
  64. package/dist/endpoints/duplicateOriginal.js +414 -0
  65. package/dist/endpoints/editorSurface.js +1 -1
  66. package/dist/endpoints/index.js +20 -0
  67. package/dist/endpoints/pages.js +245 -66
  68. package/dist/endpoints/placementStatus.js +1 -0
  69. package/dist/endpoints/results.js +3 -0
  70. package/dist/endpoints/testVersion.d.ts +2 -0
  71. package/dist/endpoints/testVersion.js +38 -0
  72. package/dist/endpoints/transitions.js +4 -5
  73. package/dist/exports/index.d.ts +1 -1
  74. package/dist/goals/picker/copy.js +1 -1
  75. package/dist/goals/sourceLabel.d.ts +2 -0
  76. package/dist/goals/sourceLabel.js +4 -0
  77. package/dist/hooks/trackPageCopies.d.ts +11 -0
  78. package/dist/hooks/trackPageCopies.js +7 -0
  79. package/dist/labels/arms.d.ts +3 -0
  80. package/dist/labels/arms.js +8 -0
  81. package/dist/options.d.ts +2 -0
  82. package/dist/options.js +18 -2
  83. package/dist/plugin.js +56 -2
  84. package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
  85. package/dist/puck/editor/ConfigureTestDrawer.js +36 -26
  86. package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
  87. package/dist/puck/editor/ExperimentSlotEditor.js +219 -106
  88. package/dist/puck/editor/LeftoverVersions.js +17 -32
  89. package/dist/puck/editor/QuickTestActions.d.ts +2 -2
  90. package/dist/puck/editor/QuickTestActions.js +44 -34
  91. package/dist/puck/editor/ResultsReadout.d.ts +3 -1
  92. package/dist/puck/editor/ResultsReadout.js +28 -16
  93. package/dist/puck/editor/VersionBuilder.d.ts +4 -2
  94. package/dist/puck/editor/VersionBuilder.js +42 -63
  95. package/dist/puck/editor/armWrites.js +1 -1
  96. package/dist/puck/editor/copy.d.ts +10 -6
  97. package/dist/puck/editor/copy.js +22 -12
  98. package/dist/puck/editor/editor.chrome.css +9 -8
  99. package/dist/puck/editor/editor.css +14 -9
  100. package/dist/puck/editor/placementsCache.d.ts +1 -1
  101. package/dist/puck/editor/placementsCache.js +9 -17
  102. package/dist/puck/editor/usePageSaveReadiness.d.ts +1 -4
  103. package/dist/puck/editor/usePageSaveReadiness.js +18 -21
  104. package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
  105. package/dist/puck/editor/usePlacementNotice.js +4 -5
  106. package/dist/puck/nestedTestCopy.js +2 -2
  107. package/dist/puck/slotConfig.d.ts +1 -1
  108. package/dist/puck/slotConfig.js +1 -1
  109. package/dist/results/analyse.d.ts +2 -0
  110. package/dist/results/analyse.js +2 -2
  111. package/dist/results/verdict.d.ts +4 -4
  112. package/dist/results/verdict.js +13 -10
  113. package/dist/server/runResults.js +2 -1
  114. package/dist/testSurface/PreviewLinks.d.ts +2 -1
  115. package/dist/testSurface/PreviewLinks.js +3 -3
  116. package/dist/testSurface/actions/DecideDialog.d.ts +7 -4
  117. package/dist/testSurface/actions/DecideDialog.js +71 -59
  118. package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
  119. package/dist/testSurface/actions/LifecycleAction.js +107 -0
  120. package/dist/testSurface/actions/MakeContentResult.js +1 -1
  121. package/dist/testSurface/actions/actions.model.d.ts +13 -5
  122. package/dist/testSurface/actions/actions.model.js +75 -22
  123. package/dist/testSurface/actions/decide.model.d.ts +1 -0
  124. package/dist/testSurface/actions/decide.model.js +1 -0
  125. package/dist/testSurface/allocation.model.js +6 -3
  126. package/dist/testSurface/api.d.ts +4 -1
  127. package/dist/testSurface/api.js +22 -14
  128. package/dist/testSurface/copy/actions.d.ts +36 -14
  129. package/dist/testSurface/copy/actions.js +39 -17
  130. package/dist/testSurface/copy/advanced.d.ts +10 -0
  131. package/dist/testSurface/copy/advanced.js +10 -0
  132. package/dist/testSurface/copy/arms.d.ts +1 -1
  133. package/dist/testSurface/copy/arms.js +1 -1
  134. package/dist/testSurface/copy/audience.d.ts +4 -3
  135. package/dist/testSurface/copy/audience.js +5 -4
  136. package/dist/testSurface/copy/common.d.ts +6 -6
  137. package/dist/testSurface/copy/common.js +6 -6
  138. package/dist/testSurface/copy/metrics.d.ts +6 -0
  139. package/dist/testSurface/copy/metrics.js +8 -0
  140. package/dist/testSurface/copy/pages.d.ts +67 -7
  141. package/dist/testSurface/copy/pages.js +74 -7
  142. package/dist/testSurface/copy/readiness.d.ts +8 -6
  143. package/dist/testSurface/copy/readiness.js +19 -10
  144. package/dist/testSurface/copy/recommendation.d.ts +1 -22
  145. package/dist/testSurface/copy/recommendation.js +2 -22
  146. package/dist/testSurface/copy/results.d.ts +16 -10
  147. package/dist/testSurface/copy/results.js +19 -11
  148. package/dist/testSurface/copy/review.d.ts +13 -10
  149. package/dist/testSurface/copy/review.js +14 -10
  150. package/dist/testSurface/copy/setting.d.ts +1 -2
  151. package/dist/testSurface/copy/setting.js +1 -2
  152. package/dist/testSurface/copy/surface.d.ts +11 -2
  153. package/dist/testSurface/copy/surface.js +14 -11
  154. package/dist/testSurface/copy/testPage.d.ts +16 -10
  155. package/dist/testSurface/copy/testPage.js +24 -18
  156. package/dist/testSurface/format/date.d.ts +5 -2
  157. package/dist/testSurface/format/date.js +24 -8
  158. package/dist/testSurface/format/roundProgress.d.ts +6 -0
  159. package/dist/testSurface/format/roundProgress.js +15 -0
  160. package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
  161. package/dist/testSurface/format/useDateFormatter.js +8 -0
  162. package/dist/testSurface/labels.d.ts +1 -2
  163. package/dist/testSurface/labels.js +2 -3
  164. package/dist/testSurface/lockedNotice.model.d.ts +2 -0
  165. package/dist/testSurface/lockedNotice.model.js +31 -0
  166. package/dist/testSurface/readPreflight.d.ts +0 -1
  167. package/dist/testSurface/readPreflight.js +0 -1
  168. package/dist/testSurface/results/CiChart.js +2 -1
  169. package/dist/testSurface/results/DataTable.d.ts +1 -1
  170. package/dist/testSurface/results/DataTable.js +4 -3
  171. package/dist/testSurface/results/VerdictHero.d.ts +1 -1
  172. package/dist/testSurface/results/legacy.d.ts +0 -5
  173. package/dist/testSurface/results/legacy.js +0 -14
  174. package/dist/testSurface/results/results.css +2 -2
  175. package/dist/testSurface/results/results.model.d.ts +8 -3
  176. package/dist/testSurface/results/results.model.js +25 -21
  177. package/dist/testSurface/results/snapshot.d.ts +2 -0
  178. package/dist/testSurface/results/snapshot.js +3 -0
  179. package/dist/testSurface/surface/contracts.d.ts +6 -1
  180. package/dist/testSurface/surface/editorPlacement.d.ts +1 -1
  181. package/dist/testSurface/surface/editorPlacement.js +1 -1
  182. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +1 -1
  183. package/dist/testSurface/surface/pageBlock/parts.js +25 -12
  184. package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
  185. package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
  186. package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
  187. package/dist/testSurface/surface/pagePicker/PageCombobox.js +298 -209
  188. package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
  189. package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
  190. package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
  191. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +5 -3
  192. package/dist/testSurface/surface/readiness/ActionDialogs.js +213 -207
  193. package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
  194. package/dist/testSurface/surface/readiness/Banner.js +109 -148
  195. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +5 -2
  196. package/dist/testSurface/surface/readiness/SaveStatus.js +8 -7
  197. package/dist/testSurface/surface/readiness/readiness.model.d.ts +14 -5
  198. package/dist/testSurface/surface/readiness/readiness.model.js +62 -12
  199. package/dist/testSurface/surface/readiness/useTransition.d.ts +3 -1
  200. package/dist/testSurface/surface/readiness/useTransition.js +49 -8
  201. package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -3
  202. package/dist/testSurface/surface/results/ReleasePages.js +41 -41
  203. package/dist/testSurface/surface/results/ResultsBody.d.ts +7 -2
  204. package/dist/testSurface/surface/results/ResultsBody.js +170 -110
  205. package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
  206. package/dist/testSurface/surface/results/recommendation.model.js +15 -59
  207. package/dist/testSurface/surface/results/useResults.d.ts +6 -2
  208. package/dist/testSurface/surface/setting/parts.js +31 -28
  209. package/dist/testSurface/surface/setting/setting.css +2 -1
  210. package/dist/testSurface/surface/test/AdvancedSection.js +10 -4
  211. package/dist/testSurface/surface/test/DeleteTest.d.ts +5 -1
  212. package/dist/testSurface/surface/test/DeleteTest.js +63 -55
  213. package/dist/testSurface/surface/test/GoalSection.js +11 -11
  214. package/dist/testSurface/surface/test/LengthSection.js +21 -13
  215. package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
  216. package/dist/testSurface/surface/test/PageHoldout.js +7 -7
  217. package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
  218. package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
  219. package/dist/testSurface/surface/test/Section.js +8 -0
  220. package/dist/testSurface/surface/test/TargetingSection.js +7 -2
  221. package/dist/testSurface/surface/test/TestSurface.js +17 -43
  222. package/dist/testSurface/surface/test/VersionsSection.js +93 -70
  223. package/dist/testSurface/surface/test/fields.d.ts +4 -3
  224. package/dist/testSurface/surface/test/fields.js +10 -16
  225. package/dist/testSurface/surface/test/pageParts.js +13 -7
  226. package/dist/testSurface/surface/test/testPage.css +9 -2
  227. package/dist/testSurface/surface/useTestDocument.d.ts +1 -3
  228. package/dist/testSurface/surface/useTestDocument.js +110 -52
  229. package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
  230. package/dist/testSurface/surface/watchTestDocument.js +181 -0
  231. package/dist/testSurface/surfaceUrls.d.ts +1 -0
  232. package/dist/testSurface/surfaceUrls.js +4 -0
  233. package/dist/testSurface/useApi.d.ts +3 -0
  234. package/dist/transitions/addMetric.d.ts +1 -1
  235. package/dist/transitions/addMetric.js +5 -1
  236. package/dist/transitions/kernel.d.ts +2 -0
  237. package/dist/transitions/kernel.js +1 -1
  238. package/dist/transitions/pageAddress.d.ts +6 -0
  239. package/dist/transitions/pageAddress.js +71 -0
  240. package/dist/transitions/pageVersions.d.ts +1 -1
  241. package/dist/transitions/preflightData.js +10 -2
  242. package/dist/transitions/start.d.ts +1 -1
  243. package/dist/transitions/start.js +8 -5
  244. package/dist/types/armKey.d.ts +2 -0
  245. package/dist/types/armKey.js +1 -0
  246. package/dist/types/contracts.d.ts +11 -1
  247. package/dist/types/endpoints.d.ts +38 -9
  248. package/dist/types/endpoints.js +1 -1
  249. package/dist/types/surface.d.ts +7 -9
  250. package/dist/ui/Dialog.d.ts +21 -2
  251. package/dist/ui/Dialog.js +101 -4
  252. package/dist/ui/Inputs.js +0 -1
  253. package/dist/ui/ui.css +5 -1
  254. package/package.json +2 -2
@@ -1,24 +1,30 @@
1
+ import { BLOCK_COPY } from './blocks.js';
1
2
  export const NEW_TEST_COPY = {
2
3
  question: 'What do you want to test?',
3
4
  block: 'A block on a page',
4
5
  setting: 'A setting',
5
6
  page: 'A whole page',
6
7
  pageMeaning: 'Show different versions of a whole page at the same address, and see which one works better.',
7
- collection: 'Collection',
8
+ collection: 'Which type of page?',
8
9
  original: 'Original',
9
10
  originalHelp: 'Choose the page visitors see today.',
10
11
  review: 'Review',
11
12
  backToTest: 'Back to the test',
12
13
  finishSetup: 'Finish setup',
13
- start: 'Start',
14
- blocksHandoff: "Pick the block to test with 'Test a block on this page'.",
14
+ blocksHandoff: `Choose '${BLOCK_COPY.testBlock}' to pick the block to test.`,
15
+ blocksOnlyHandoff: `Open the page you want to test, then choose '${BLOCK_COPY.testBlock}' to pick the block to test.`,
16
+ pageType: 'Page type',
17
+ choosePageType: 'Choose a page type',
15
18
  blockMeaning: 'Compare different versions of content on a page.',
16
19
  settingMeaning: 'Compare different choices for a setting on your site.',
17
20
  unavailable: 'A developer needs to set up pages or settings before you can create a test.',
18
- handoff: 'Open the page, add an Experiment block where you want it, and choose Set up test.',
19
- noPages: 'There are no pages yet.',
20
- recentPages: 'Showing the 50 most recently edited.',
21
- open: 'Open',
21
+ handoff: 'Open the page you want to test, then follow these steps in the editor.',
22
+ mixedEditorHandoff: 'Open the page you want to test, then follow the steps for its editor.',
23
+ pagesMarked: (editor)=>`Pages marked ${editor}:`,
24
+ handoffSteps: [
25
+ 'Add a Test block to the page.',
26
+ 'Choose Set up test in the sidebar.'
27
+ ],
22
28
  chooseSetting: 'Which setting do you want to test?',
23
29
  people: 'Count people as:',
24
30
  visitors: 'Visitors',
@@ -35,6 +41,7 @@ export const NEW_TEST_COPY = {
35
41
  name: 'Name',
36
42
  hypothesis: 'Why are you testing this? (optional)',
37
43
  back: 'Back',
44
+ change: 'Change',
38
45
  next: 'Next',
39
46
  createTest: 'Create',
40
47
  creating: 'Creating…',
@@ -1,7 +1,7 @@
1
1
  export declare const STATUS_TOOLTIPS: {
2
2
  readonly draft: "Draft";
3
3
  readonly running: "Running";
4
- readonly stopped: "Stopped — everyone sees the Original";
4
+ readonly stopped: (label?: string) => string;
5
5
  readonly decided: "Decided — everyone sees the winner";
6
6
  readonly decidedWithHoldout: "Decided — everyone sees the winner, except the holdout";
7
7
  readonly archived: "Archived";
@@ -1,7 +1,8 @@
1
+ import { controlVersionName } from '../../labels/arms.js';
1
2
  export const STATUS_TOOLTIPS = {
2
3
  draft: 'Draft',
3
4
  running: 'Running',
4
- stopped: 'Stopped — everyone sees the Original',
5
+ stopped: (label)=>`Stopped — everyone sees ${controlVersionName(label)}`,
5
6
  decided: 'Decided — everyone sees the winner',
6
7
  decidedWithHoldout: 'Decided — everyone sees the winner, except the holdout',
7
8
  archived: 'Archived'
@@ -3,6 +3,7 @@ import type { ExperimentsPageCollection } from '../types/contracts.js';
3
3
  export declare function serializePageCollections(collections: ExperimentsPageCollection[], req: PayloadRequest): {
4
4
  copyUrl: string;
5
5
  copyLabel: string;
6
+ copyEnabled?: true | undefined;
6
7
  copyHint?: string | undefined;
7
8
  slug: string;
8
9
  label: string;
@@ -10,6 +10,9 @@ export function serializePageCollections(collections, req) {
10
10
  ...entry.copyHint ? {
11
11
  copyHint: entry.copyHint
12
12
  } : {},
13
+ ...entry.copy ? {
14
+ copyEnabled: true
15
+ } : {},
13
16
  copyUrl: entry.copyUrl ?? formatAdminURL({
14
17
  adminRoute: req.payload.config.routes.admin,
15
18
  path: `/collections/${entry.slug}`
@@ -1,3 +1,4 @@
1
+ import { controlVersionName } from '../labels/arms.js';
1
2
  export function pageStatusCopy(test) {
2
3
  if (test.pagesReleased) return null;
3
4
  const winner = `${test.winnerLabel ?? 'the winner'}${test.winnerTitle ? ` (${test.winnerTitle})` : ''}`;
@@ -6,14 +7,15 @@ export function pageStatusCopy(test) {
6
7
  return `This page is ${test.armLabel} in the draft test ${test.name}.`;
7
8
  case 'stopped':
8
9
  {
9
- const visitors = test.role === 'original' ? 'Visitors see this page.' : !test.originalPath ? 'Visitors see the Original.' : `Visitors to ${test.originalPath === '/' ? 'the homepage (/)' : test.originalPath} see the Original.`;
10
+ const control = controlVersionName(test.controlLabel);
11
+ const visitors = test.role === 'original' ? 'Visitors see this page.' : !test.originalPath ? `Visitors see ${control}.` : `Visitors to ${test.originalPath === '/' ? 'the homepage (/)' : test.originalPath} see ${control}.`;
10
12
  return `This page is ${test.armLabel} in the stopped test ${test.name}. ${visitors}`;
11
13
  }
12
14
  case 'running':
13
15
  return `This page is the ${test.armLabel} of a running test: ${test.name}.`;
14
16
  case 'decided':
15
- return `This page is ${test.armLabel} of a decided test; ${test.rollout ? `most visitors see ${winner}; a holdout still sees the Original` : `visitors see ${winner}`}.`;
17
+ return `This page is ${test.armLabel} of a decided test; ${test.rollout ? `most visitors see ${winner}; a holdout still sees ${controlVersionName(test.controlLabel ?? (test.role === 'original' ? test.armLabel : undefined))}` : `visitors see ${winner}`}.`;
16
18
  case 'archived':
17
- return test.winner ? `This page is also shown at the other versions' addresses because test ${test.name} made it the winner. To free it, open the test and choose "Release pages".` : test.role === 'original' ? `This page's address now shows the winner of test ${test.name}. To free it, open the test and choose "Release pages".` : `This page's address now shows ${winner}. To show this page again, open the test and choose "Release pages".`;
19
+ return test.winner ? `This page is also shown at the other versions' addresses because test ${test.name} made it the winner. Use "Release pages" on the test to free it.` : test.role === 'original' ? `This page's address now shows the winner of test ${test.name}. Use "Release pages" on the test to free it.` : `This page's address now shows ${winner}. Use "Release pages" on the test to show this page again.`;
18
20
  }
19
21
  }
@@ -4,6 +4,7 @@ export declare function statusPill({ status, arms, decision }: {
4
4
  status: Status;
5
5
  arms?: readonly {
6
6
  key: string;
7
+ label?: string;
7
8
  }[] | null;
8
9
  decision?: {
9
10
  winnerArm?: string | null;
@@ -9,9 +9,10 @@ const TONES = {
9
9
  };
10
10
  export function statusPill({ status, arms = [], decision }) {
11
11
  const holdout = status === 'decided' && arms?.some((group)=>group.key === 'holdout') && Boolean(decision?.winnerArm) && decision?.winnerArm !== 'control' && !decision?.holdoutReleasedAt;
12
+ const tooltip = status === 'stopped' ? STATUS_TOOLTIPS.stopped(arms?.find((group)=>group.key === 'control')?.label) : holdout ? STATUS_TOOLTIPS.decidedWithHoldout : STATUS_TOOLTIPS[status];
12
13
  return {
13
14
  label: statusLabel(status),
14
15
  tone: TONES[status],
15
- tooltip: holdout ? STATUS_TOOLTIPS.decidedWithHoldout : STATUS_TOOLTIPS[status]
16
+ tooltip
16
17
  };
17
18
  }
@@ -23,9 +23,7 @@ export function ResultsRoute(props) {
23
23
  function ManagedResults({ id, surface, onTitleChange }) {
24
24
  const test = useTestDocument(id, {
25
25
  apiRoute: surface.apiRoute,
26
- contentLocale: surface.contentLocale,
27
- refetchDocumentOnFocus: true,
28
- refetchPreflightOnFocus: true
26
+ contentLocale: surface.contentLocale
29
27
  });
30
28
  useEffect(()=>{
31
29
  if (test.doc?.name) onTitleChange?.(test.doc.name);
@@ -48,10 +46,8 @@ function ManagedResults({ id, surface, onTitleChange }) {
48
46
  id: id,
49
47
  surface: surface,
50
48
  onRecomputed: ()=>setResultsVersion((value)=>value + 1),
51
- onChanged: (doc)=>{
52
- test.acceptTransition?.({
53
- doc
54
- });
49
+ onChanged: (transition)=>{
50
+ if (transition) test.acceptTransition?.(transition);
55
51
  void test.reload();
56
52
  },
57
53
  renderPage: (parts)=>/*#__PURE__*/ _jsx(ResultsHeader, {
@@ -59,7 +55,7 @@ function ManagedResults({ id, surface, onTitleChange }) {
59
55
  surface: surface,
60
56
  resultsVersion: resultsVersion,
61
57
  ...parts
62
- }, `${test.doc.id}/${test.doc.status}/${test.doc.phase}`)
58
+ }, test.doc.id)
63
59
  });
64
60
  return /*#__PURE__*/ _jsx(ReaderResultsShell, {
65
61
  surface: surface,
@@ -1,5 +1,5 @@
1
1
  import '../theme.css';
2
- import type { ReactNode } from 'react';
2
+ import { type ReactNode } from 'react';
3
3
  import './surface.css';
4
4
  export interface SurfaceShellProps {
5
5
  adminRoute: string;
@@ -12,5 +12,7 @@ export interface SurfaceShellProps {
12
12
  status?: ReactNode;
13
13
  actions?: ReactNode;
14
14
  subtitle?: ReactNode;
15
+ className?: string;
16
+ dynamicTitle?: boolean;
15
17
  }
16
- export declare function SurfaceShell({ adminRoute, children, crumbs, title, status, actions, subtitle }: SurfaceShellProps): import("react").JSX.Element;
18
+ export declare function SurfaceShell({ adminRoute, children, crumbs, title, status, actions, subtitle, className, dynamicTitle }: SurfaceShellProps): import("react").JSX.Element;
@@ -1,18 +1,41 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import '../theme.css';
4
+ import { useContext, useEffect } from 'react';
4
5
  import { formatAdminURL } from 'payload/shared';
5
6
  import { Breadcrumb } from '../../ui/Breadcrumb.js';
6
7
  import { Button } from '../../ui/Button.js';
7
8
  import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
9
+ import { XpStepNavContext } from './useXpStepNav.js';
8
10
  import './surface.css';
9
11
  export function SurfaceShell({ adminRoute, children, crumbs = [
10
12
  {
11
13
  label: SURFACE_COPY.title
12
14
  }
13
- ], title = SURFACE_COPY.title, status, actions, subtitle }) {
15
+ ], title = SURFACE_COPY.title, status, actions, subtitle, className, dynamicTitle = false }) {
16
+ const stepNav = useContext(XpStepNavContext);
17
+ const route = stepNav?.route;
18
+ const items = stepNav?.items.length && route !== 'home' && route !== 'goals' ? stepNav.items.map(({ label, url })=>({
19
+ label,
20
+ href: url
21
+ })) : crumbs;
22
+ // Custom view metadata is static in Payload 3. Use the name already loaded by the screen.
23
+ useEffect(()=>{
24
+ if (!dynamicTitle && route !== 'goal') return;
25
+ const previous = document.title;
26
+ const next = `${title} · ${SURFACE_COPY.title}`;
27
+ document.title = next;
28
+ return ()=>{
29
+ if (document.title === next) document.title = previous;
30
+ };
31
+ }, [
32
+ title,
33
+ dynamicTitle,
34
+ route
35
+ ]);
14
36
  return /*#__PURE__*/ _jsxs("div", {
15
- className: "xp-tests-surface xp-test-surface",
37
+ className: `xp-tests-surface xp-test-surface${className ? ` ${className}` : ''}`,
38
+ "data-dialog-focus-scope": true,
16
39
  children: [
17
40
  /*#__PURE__*/ _jsxs("header", {
18
41
  className: "xp-tests-shell-header",
@@ -21,7 +44,7 @@ export function SurfaceShell({ adminRoute, children, crumbs = [
21
44
  className: "xp-tests-container xp-tests-shell-top",
22
45
  children: [
23
46
  /*#__PURE__*/ _jsx(Breadcrumb, {
24
- items: crumbs
47
+ items: items
25
48
  }),
26
49
  /*#__PURE__*/ _jsx(Button, {
27
50
  variant: "quiet",
@@ -43,6 +66,8 @@ export function SurfaceShell({ adminRoute, children, crumbs = [
43
66
  className: "xp-tests-shell-title",
44
67
  children: [
45
68
  /*#__PURE__*/ _jsx("h1", {
69
+ tabIndex: -1,
70
+ "data-dialog-focus-fallback": true,
46
71
  children: title
47
72
  }),
48
73
  status
@@ -0,0 +1,13 @@
1
+ import type { ExperimentAction } from '../../testSurface/actions/actions.model.js';
2
+ export declare function TestRowMenu({ name, actions, onSelect }: {
3
+ name: string;
4
+ actions: ExperimentAction[];
5
+ onSelect: (action: ExperimentAction) => void;
6
+ }): import("react").JSX.Element;
7
+ export declare function RowMenu<T extends Pick<ExperimentAction, 'label' | 'tone' | 'unavailable' | 'hint'> & {
8
+ id: string;
9
+ }>({ label, actions, onSelect, }: {
10
+ label: string;
11
+ actions: T[];
12
+ onSelect: (action: T) => void;
13
+ }): import("react").JSX.Element;
@@ -0,0 +1,163 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
4
+ import { Button } from '../../ui/Button.js';
5
+ import { actionsForTest } from '../../testSurface/copy/actions.js';
6
+ export function TestRowMenu({ name, actions, onSelect }) {
7
+ return /*#__PURE__*/ _jsx(RowMenu, {
8
+ label: actionsForTest(name),
9
+ actions: actions,
10
+ onSelect: onSelect
11
+ });
12
+ }
13
+ export function RowMenu({ label, actions, onSelect }) {
14
+ const root = useRef(null);
15
+ const menu = useRef(null);
16
+ const triggerId = useId();
17
+ const menuId = useId();
18
+ const [open, setOpen] = useState(false);
19
+ const startAtEnd = useRef(false);
20
+ const menuItems = ()=>[
21
+ ...menu.current?.querySelectorAll('[role="menuitem"]') ?? []
22
+ ];
23
+ function close(restoreFocus) {
24
+ if (restoreFocus) root.current?.querySelector('button')?.focus();
25
+ setOpen(false);
26
+ }
27
+ useLayoutEffect(()=>{
28
+ if (!open) return;
29
+ const items = menuItems();
30
+ (startAtEnd.current ? items.at(-1) : items[0])?.focus();
31
+ }, [
32
+ open
33
+ ]);
34
+ useEffect(()=>{
35
+ if (!open) return;
36
+ const element = root.current;
37
+ if (!element) return;
38
+ const doc = element.ownerDocument;
39
+ const dismiss = (event)=>{
40
+ if (!element.contains(event.target)) setOpen(false);
41
+ };
42
+ doc.addEventListener('pointerdown', dismiss, true);
43
+ return ()=>doc.removeEventListener('pointerdown', dismiss, true);
44
+ }, [
45
+ open
46
+ ]);
47
+ return /*#__PURE__*/ _jsxs("div", {
48
+ className: "xp-tests-row-menu",
49
+ ref: root,
50
+ onBlur: (event)=>{
51
+ if (open && !event.currentTarget.contains(event.relatedTarget)) close(false);
52
+ },
53
+ children: [
54
+ /*#__PURE__*/ _jsx(Button, {
55
+ id: triggerId,
56
+ className: "xp-tests-row-menu-trigger",
57
+ variant: "quiet",
58
+ size: "sm",
59
+ "aria-label": label,
60
+ "aria-haspopup": "menu",
61
+ "aria-expanded": open,
62
+ "aria-controls": open ? menuId : undefined,
63
+ onClick: ()=>{
64
+ if (open) close(true);
65
+ else {
66
+ startAtEnd.current = false;
67
+ setOpen(true);
68
+ }
69
+ },
70
+ onKeyDown: (event)=>{
71
+ if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;
72
+ event.preventDefault();
73
+ startAtEnd.current = event.key === 'ArrowUp';
74
+ if (open) {
75
+ const items = menuItems();
76
+ (startAtEnd.current ? items.at(-1) : items[0])?.focus();
77
+ } else setOpen(true);
78
+ },
79
+ children: /*#__PURE__*/ _jsxs("svg", {
80
+ width: "18",
81
+ height: "18",
82
+ viewBox: "0 0 18 18",
83
+ fill: "currentColor",
84
+ "aria-hidden": "true",
85
+ children: [
86
+ /*#__PURE__*/ _jsx("circle", {
87
+ cx: "4",
88
+ cy: "9",
89
+ r: "1.3"
90
+ }),
91
+ /*#__PURE__*/ _jsx("circle", {
92
+ cx: "9",
93
+ cy: "9",
94
+ r: "1.3"
95
+ }),
96
+ /*#__PURE__*/ _jsx("circle", {
97
+ cx: "14",
98
+ cy: "9",
99
+ r: "1.3"
100
+ })
101
+ ]
102
+ })
103
+ }),
104
+ open ? /*#__PURE__*/ _jsx("div", {
105
+ id: menuId,
106
+ ref: menu,
107
+ role: "menu",
108
+ "aria-labelledby": triggerId,
109
+ className: "xp-tests-row-menu-items",
110
+ onKeyDown: (event)=>{
111
+ const items = menuItems();
112
+ const index = items.findIndex((item)=>item === event.target);
113
+ const key = event.key;
114
+ if (key === 'Tab') {
115
+ close(true);
116
+ return;
117
+ }
118
+ if (key === 'Escape') {
119
+ event.preventDefault();
120
+ close(true);
121
+ return;
122
+ }
123
+ const next = key === 'Home' ? items[0] : key === 'End' ? items.at(-1) : key === 'ArrowDown' ? items[(index + 1) % items.length] : key === 'ArrowUp' ? items[(index - 1 + items.length) % items.length] : key.length === 1 && key !== ' ' && !event.altKey && !event.ctrlKey && !event.metaKey ? [
124
+ ...items.slice(index + 1),
125
+ ...items.slice(0, index + 1)
126
+ ].find((item)=>item.textContent?.trim().toLowerCase().startsWith(key.toLowerCase())) : undefined;
127
+ if (next) {
128
+ event.preventDefault();
129
+ next.focus();
130
+ }
131
+ },
132
+ children: actions.map((action, index)=>{
133
+ const detail = action.unavailable ?? action.hint;
134
+ const detailId = `${menuId}-${index}`;
135
+ return /*#__PURE__*/ _jsxs("button", {
136
+ type: "button",
137
+ role: "menuitem",
138
+ tabIndex: -1,
139
+ "aria-label": action.label,
140
+ "aria-disabled": action.unavailable ? true : undefined,
141
+ className: `xp-tests-menu-item${action.tone === 'secondary' ? '' : ` xp-tests-menu-item--${action.tone}`}`,
142
+ "aria-describedby": detail ? detailId : undefined,
143
+ onClick: ()=>{
144
+ if (action.unavailable) return;
145
+ close(true);
146
+ onSelect(action);
147
+ },
148
+ children: [
149
+ /*#__PURE__*/ _jsx("span", {
150
+ children: action.label
151
+ }),
152
+ detail ? /*#__PURE__*/ _jsx("span", {
153
+ id: detailId,
154
+ className: "xp-ui-help",
155
+ children: detail
156
+ }) : null
157
+ ]
158
+ }, action.id);
159
+ })
160
+ }) : null
161
+ ]
162
+ });
163
+ }
@@ -1,10 +1,11 @@
1
1
  import type { SurfaceShellProps } from './SurfaceShell.js';
2
- import type { ReadinessContext } from '../../testSurface/surface/readiness/readiness.model.js';
3
- export declare function TestsHome({ adminRoute, apiRoute, contentLocale, canManage, crumbs, flagPoints }: {
2
+ import type { SurfaceProps } from '../../testSurface/surface/contracts.js';
3
+ export declare function TestsHome({ adminRoute, apiRoute, contentLocale, canManage, canReadResults, crumbs, flagPoints }: {
4
4
  adminRoute: string;
5
5
  apiRoute: string;
6
6
  contentLocale?: string;
7
7
  canManage?: boolean;
8
+ canReadResults?: boolean;
8
9
  crumbs?: SurfaceShellProps['crumbs'];
9
- flagPoints?: ReadinessContext['flagPoints'];
10
+ flagPoints?: SurfaceProps['flagPoints'];
10
11
  }): import("react").JSX.Element;