@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
package/README.md CHANGED
@@ -2,11 +2,7 @@
2
2
 
3
3
  A/B testing for Payload CMS and Next.js, from the content you already manage. Test a block on a page, a whole page against another page, or a setting your developer makes testable. Pick a goal, including click goals you name and attach to buttons and links, then compare the Original with your new versions. Results appear in the admin: they count only people who actually saw the content, warn when traffic looks wrong, and check guardrail goals (goals you don't want to hurt). You pick a winner and can make it permanent. Your data stays in your own Postgres database. There is no vendor.
4
4
 
5
- > ⚠️ Upgrading from 0.4.0-rc.8 to rc.9? Set `events.rateLimit` and `rateLimitUnit`, or explicitly use `false` for requests you limit upstream. Use signing keys of at least 32 characters, including previous rotation keys. Serve events on the page's origin, preserve `Sec-Fetch-Site`, `Origin`, and `Referer`, and configure the public origin in `events.origin` or Payload's `serverURL`. If you use a reverse proxy, forward the browser-facing host and protocol. Set `skipProxyUrlNormalize: true` and keep full prefetch off experiment routes. Use matching cookie settings in the proxy and event handler and cap `cookie.maxAgeDays` at 400. Deploy proxies and event handlers together because an older proxy can reissue IDs. Pre-rc.9 IDs expire on January 7, 2028 at 00:00 UTC by default. Drain older `trackConversion` writers before upgraded writers use the same event table. Update exhaustive TypeScript switches and records over `SnapshotHealth` and `RefusalCode`. See the [rc.9 upgrade steps](https://plugins.delmaredigital.com/docs/experiments/upgrading#from-040-rc7-or-rc8-to-rc9).
6
-
7
- > ⚠️ Upgrading from 0.4.0-rc.7? Apply the rc.9 runtime steps above and set the Postgres adapter's `transactionOptions.isolationLevel` to `'read committed'` or remove the override if the database has a supported default. PostgreSQL treats `READ UNCOMMITTED` as `READ COMMITTED`, so both are supported. The app refuses to start with other levels. If your client expects HTTP `403` when a manager deletes a running, stopped, or decided test by ID, handle HTTP `409` with code `invalid-status` and ask the manager to archive the test first. See the [rc.8 release notes](https://github.com/delmaredigital/payload-experiments/blob/main/CHANGELOG.md#040-rc8---2026-12-01).
8
-
9
- > ⚠️ Upgrading to 0.4 from 0.3? Run `payload migrate:create` for four nullable plugin columns (`xp_experiments.page_collection`, `_xp_experiments_v.version_page_collection`, `xp_phases.placement_docs`, and `xp_state.retired_slugs`), plus the Experiment block and `xpGoal` changes if you adopt them. Apply the migration and run `payload generate:importmap`. Use PostgreSQL `READ COMMITTED` for default and guarded host transactions. PostgreSQL's `READ UNCOMMITTED` is equivalent. Update clients that expect HTTP `403` when a manager deletes a running, stopped, or decided test by ID. Handle HTTP `409` with code `invalid-status` and ask the manager to archive first. Registered page and block saves can be refused with `page-busy` or `interacting-tests`. Publish draft-only placements before starting a test, and publish the Original and winning pages before deciding a stopped whole-page test. Reserve `click:` for click goals and update `admin.editorUrl` for its required `editor` argument. Apply the runtime requirements in the rc.9 callout above. See the [full 0.4 upgrade steps](https://plugins.delmaredigital.com/docs/experiments/upgrading#to-04).
5
+ ![A Test block in the Puck editor with Original and Variant A tabs, and the test's status, actions and traffic split in the sidebar](https://plugins.delmaredigital.com/images/experiments/editor-test-block.png)
10
6
 
11
7
  ## Install
12
8
 
@@ -161,13 +157,13 @@ full prefetch of pages that count content on server render is unsupported.
161
157
 
162
158
  ## Running a test
163
159
 
164
- 1. Start from the content: add an **Experiment block** (in Puck's **A/B tests** category),
160
+ 1. Start from the content: add a **Test block** (in Puck's **A/B tests** category),
165
161
  or open **Tests** in the admin to test whole pages or a registered setting.
166
162
  2. Keep the **Original**, use **Copy Original here** in Puck to make a version,
167
163
  and make your changes. For whole pages, use Payload's **Duplicate** action, give the
168
164
  copy its own address, publish it, then choose it as a version in the test.
169
165
  3. Pick a **goal**: a signup, purchase, or a named click goal on a button or
170
- link. Add guardrail goals for outcomes you don't want to hurt.
166
+ link. Mark goals you don't want to hurt as **Must not get worse**.
171
167
  4. Save, follow the setup checks, preview each version ([wire preview links](#preview-and-editor-links)), and **Start**. The
172
168
  results explain whether to keep running or choose a winner.
173
169
  5. Use **Decide** to pick the winner, then **Make it the content** to make it permanent.
@@ -3,12 +3,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { SelectInput, useField } from '@payloadcms/ui';
4
4
  import { metricSourceHint, metricSourceOptions, sourceFor } from '../testSurface/metricSource.model.js';
5
5
  import { METRICS_COPY } from '../testSurface/copy/metrics.js';
6
+ import { goalSourceLabel } from '../goals/sourceLabel.js';
6
7
  export function MetricSourceSelect({ path, field, readOnly }) {
7
8
  const { value, setValue } = useField({
8
9
  path
9
10
  });
10
11
  const sources = field.admin?.custom?.sources ?? [];
11
- const hint = metricSourceHint(sourceFor(value, sources));
12
+ const source = sourceFor(value, sources);
13
+ const hint = metricSourceHint(source);
14
+ const options = metricSourceOptions(sources);
15
+ if (value && !source) options.push({
16
+ value,
17
+ label: goalSourceLabel(value)
18
+ });
12
19
  const locked = Boolean(readOnly || field.admin?.readOnly);
13
20
  return /*#__PURE__*/ _jsxs("div", {
14
21
  children: [
@@ -18,8 +25,8 @@ export function MetricSourceSelect({ path, field, readOnly }) {
18
25
  label: field.label ?? METRICS_COPY.source,
19
26
  description: field.admin?.description,
20
27
  required: field.required,
21
- options: metricSourceOptions(sources),
22
- value: sourceFor(value, sources)?.id ?? value ?? '',
28
+ options: options,
29
+ value: source?.id ?? value ?? '',
23
30
  readOnly: locked,
24
31
  onChange: (option)=>{
25
32
  if (!locked) setValue(option && !Array.isArray(option) ? option.value : null);
@@ -23,7 +23,7 @@ export declare function bindArmSelect({ live, candidates, stored }: {
23
23
  pickable: boolean;
24
24
  options: {
25
25
  label: string;
26
- value: import("../../types/contracts.js").ArmKey;
26
+ value: import("../../types/armKey.js").ArmKey;
27
27
  }[];
28
28
  stale: string | null;
29
29
  banner: string | null;
@@ -1,4 +1,5 @@
1
1
  import type { UIFieldClientProps } from 'payload';
2
+ import '../theme.css';
2
3
  export declare function BlockStatusField({ path }: UIFieldClientProps): import("react").JSX.Element | null;
3
4
  export declare function BlockSlotRowLabel(): import("react").JSX.Element;
4
5
  export declare function CopyOriginalField({ path }: UIFieldClientProps): import("react").JSX.Element | null;
@@ -1,8 +1,12 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
- import { Banner, Button, ConfirmationModal, toast, useModal, useFormInitializing, useRowLabel } from '@payloadcms/ui';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { Banner, Button, toast, useFormInitializing, useRowLabel } from '@payloadcms/ui';
4
4
  import { formatAdminURL } from 'payload/shared';
5
- import { useEffect, useId, useRef, useState } from 'react';
5
+ import { useEffect, useRef, useState } from 'react';
6
+ import { ConfirmDialog } from '../../ui/Dialog.js';
7
+ import { actionTitle } from '../../testSurface/copy/actions.js';
8
+ import { READINESS_COPY } from '../../testSurface/copy/readiness.js';
9
+ import '../theme.css';
6
10
  import { copyOriginalIntoVersion, syncExperimentSlots, unwrapExperimentBlock } from '../../blocks/formState.js';
7
11
  import { BLOCK_COPY, blockSyncNotice, blockUnwrapNotice, blockDeleteConfirmation, blockUnwrapConfirmation, blockRunningUnwrap, blockDecidedUnwrap, blockFinishedCopy } from '../../admin/copy/blocks.js';
8
12
  import { API_MESSAGES } from '../../testSurface/copy/common.js';
@@ -11,6 +15,7 @@ import { createApi } from '../../testSurface/api.js';
11
15
  import { useBlockStatus, setBlockStatus } from './statusCache.js';
12
16
  import { useBlockForm } from './useBlockForm.js';
13
17
  import { BlockChangedError, RefusalError } from './formApi.js';
18
+ import { notifyTestDocument } from '../../testSurface/surface/watchTestDocument.js';
14
19
  function errorMessage(error) {
15
20
  return error instanceof BlockChangedError || error instanceof RefusalError ? error.message : API_MESSAGES.failed;
16
21
  }
@@ -21,8 +26,7 @@ export function BlockStatusField({ path }) {
21
26
  const synced = useRef(false), syncing = useRef(false);
22
27
  const [notice, setNotice] = useState(false), [error, setError] = useState(), [busy, setBusy] = useState(false);
23
28
  const [syncError, setSyncError] = useState();
24
- const { openModal } = useModal();
25
- const modalSlug = `xp-unwrap-${useId()}`;
29
+ const [confirmation, setConfirmation] = useState();
26
30
  const canSync = !initializing && manager && block && field && liveStatus(status) && [
27
31
  'draft',
28
32
  'stopped'
@@ -55,13 +59,13 @@ export function BlockStatusField({ path }) {
55
59
  if (!status || !manager) return null;
56
60
  const draft = liveStatus(status) && status.status === 'draft';
57
61
  const stopped = liveStatus(status) && status.status === 'stopped';
58
- async function unwrap() {
62
+ async function unwrap(deleteDraft = false) {
59
63
  if (!block || !field || busy) return;
60
64
  setBusy(true);
61
65
  setError(undefined);
62
66
  let deleted = false;
63
67
  try {
64
- if (draft) {
68
+ if (deleteDraft) {
65
69
  const api = createApi(config.routes.api);
66
70
  const found = await api.findTestIdBySlug(block.experiment);
67
71
  if (!found.ok) throw new RefusalError(found.message);
@@ -70,11 +74,13 @@ export function BlockStatusField({ path }) {
70
74
  });
71
75
  if (!removed.ok) throw new RefusalError(removed.message);
72
76
  deleted = true;
77
+ notifyTestDocument(config.routes.api, found.data);
73
78
  setBlockStatus(config.routes.api, block.experiment, {
74
79
  deleted: true
75
80
  });
76
81
  }
77
82
  await replace(unwrapExperimentBlock(block, field));
83
+ setConfirmation(undefined);
78
84
  toast.success(blockUnwrapNotice(Boolean(collection?.versions?.drafts), deleted));
79
85
  } catch (error) {
80
86
  setError(deleted ? BLOCK_COPY.finishUnwrap : errorMessage(error));
@@ -83,7 +89,8 @@ export function BlockStatusField({ path }) {
83
89
  }
84
90
  }
85
91
  const sentence = statusSentence(status);
86
- const linkedCopy = liveStatus(status) ? status.status === 'running' ? blockRunningUnwrap : status.status === 'decided' ? blockDecidedUnwrap : status.status === 'archived' && status.winnerArm && !status.discarded ? blockFinishedCopy(slotLabel(status.winnerArm, status), status.winnerArm === 'control', status.winnerArm !== 'control' && canUnwrapOriginal(status, block)) : undefined : undefined;
92
+ const controlLabel = slotLabel('control', status);
93
+ const linkedCopy = liveStatus(status) ? status.status === 'running' ? blockRunningUnwrap : status.status === 'decided' ? blockDecidedUnwrap : status.status === 'archived' && status.winnerArm && !status.discarded ? blockFinishedCopy(slotLabel(status.winnerArm, status), status.winnerArm === 'control', status.winnerArm !== 'control' && canUnwrapOriginal(status, block), controlLabel) : undefined : undefined;
87
94
  const href = formatAdminURL({
88
95
  adminRoute: config.routes.admin,
89
96
  path: `/experiments/by-slug/${encodeURIComponent(block?.experiment ?? '')}`
@@ -105,24 +112,52 @@ export function BlockStatusField({ path }) {
105
112
  linkedCopy.after
106
113
  ]
107
114
  }) : null,
115
+ linkedCopy && liveStatus(status) && status.status === 'archived' && !canUnwrapOriginal(status, block) ? /*#__PURE__*/ _jsxs(_Fragment, {
116
+ children: [
117
+ /*#__PURE__*/ _jsx("p", {
118
+ children: BLOCK_COPY.archivedReplaceWhy
119
+ }),
120
+ /*#__PURE__*/ _jsx("ol", {
121
+ children: BLOCK_COPY.archivedReplaceSteps.map((step)=>/*#__PURE__*/ _jsx("li", {
122
+ children: step
123
+ }, step))
124
+ })
125
+ ]
126
+ }) : null,
108
127
  notice ? /*#__PURE__*/ _jsx("p", {
109
128
  role: "status",
110
129
  children: blockSyncNotice(Boolean(collection?.versions?.drafts))
111
130
  }) : null,
112
131
  canUnwrapOriginal(status, block) || draft || stopped ? /*#__PURE__*/ _jsx(Button, {
113
132
  disabled: busy,
114
- onClick: ()=>draft || stopped ? openModal(modalSlug) : void unwrap(),
133
+ onClick: (event)=>{
134
+ if (draft || stopped) {
135
+ event?.currentTarget?.focus();
136
+ setError(undefined);
137
+ setConfirmation({
138
+ name: status.name,
139
+ draft
140
+ });
141
+ } else void unwrap();
142
+ },
115
143
  children: draft ? BLOCK_COPY.removeAndUnwrap : BLOCK_COPY.unwrap
116
144
  }) : null,
117
- draft || stopped ? /*#__PURE__*/ _jsx(ConfirmationModal, {
118
- modalSlug: modalSlug,
119
- heading: draft ? BLOCK_COPY.removeAndUnwrap : BLOCK_COPY.unwrap,
120
- body: draft ? blockDeleteConfirmation(status.name) : blockUnwrapConfirmation(status.name),
121
- confirmLabel: draft ? BLOCK_COPY.deleteAndUnwrap : BLOCK_COPY.unwrap,
145
+ confirmation ? /*#__PURE__*/ _jsx(ConfirmDialog, {
146
+ title: actionTitle(confirmation.draft ? BLOCK_COPY.deleteAndUnwrap : BLOCK_COPY.unwrap, confirmation.name),
147
+ description: confirmation.draft ? blockDeleteConfirmation(confirmation.name, controlLabel) : blockUnwrapConfirmation(confirmation.name, controlLabel),
122
148
  cancelLabel: BLOCK_COPY.cancel,
123
- onConfirm: unwrap
149
+ onClose: ()=>setConfirmation(undefined),
150
+ busy: busy,
151
+ busyLabel: READINESS_COPY.changing,
152
+ error: error,
153
+ confirm: {
154
+ label: confirmation.draft ? BLOCK_COPY.deleteAndUnwrap : BLOCK_COPY.unwrap,
155
+ destructive: true,
156
+ disabled: confirmation.draft ? !draft : !stopped,
157
+ onClick: ()=>unwrap(confirmation.draft)
158
+ }
124
159
  }) : null,
125
- error ? /*#__PURE__*/ _jsx("p", {
160
+ error && !confirmation ? /*#__PURE__*/ _jsx("p", {
126
161
  role: "alert",
127
162
  children: error
128
163
  }) : null,
@@ -152,8 +187,7 @@ export function CopyOriginalField({ path }) {
152
187
  const rowPath = path.slice(0, path.lastIndexOf('.'));
153
188
  const slot = form.getDataByPath(`${rowPath}.slot`);
154
189
  const [busy, setBusy] = useState(false), [error, setError] = useState();
155
- const { openModal } = useModal();
156
- const modalSlug = `xp-copy-original-${useId()}`;
190
+ const [confirming, setConfirming] = useState(false);
157
191
  if (!manager || !field || !block || !slot || slot === 'control' || !liveStatus(status) || ![
158
192
  'draft',
159
193
  'stopped',
@@ -167,32 +201,44 @@ export function CopyOriginalField({ path }) {
167
201
  await replace([
168
202
  copyOriginalIntoVersion(block, slot, field)
169
203
  ]);
204
+ setConfirming(false);
170
205
  } catch (error) {
171
206
  setError(errorMessage(error));
172
207
  } finally{
173
208
  setBusy(false);
174
209
  }
175
210
  }
176
- function requestCopy() {
177
- if (block?.slots.find((row)=>row.slot === slot)?.blocks?.length) openModal(modalSlug);
178
- else void copy();
211
+ function requestCopy(event) {
212
+ if (block?.slots.find((row)=>row.slot === slot)?.blocks?.length) {
213
+ event?.currentTarget?.focus();
214
+ setError(undefined);
215
+ setConfirming(true);
216
+ } else void copy();
179
217
  }
218
+ const controlLabel = slotLabel('control', status);
180
219
  return /*#__PURE__*/ _jsxs("div", {
181
220
  children: [
182
221
  /*#__PURE__*/ _jsx(Button, {
183
222
  disabled: busy,
184
223
  onClick: requestCopy,
185
- children: BLOCK_COPY.copy
224
+ children: BLOCK_COPY.copy(controlLabel)
186
225
  }),
187
- /*#__PURE__*/ _jsx(ConfirmationModal, {
188
- modalSlug: modalSlug,
189
- heading: BLOCK_COPY.copy,
190
- body: BLOCK_COPY.confirmCopy,
191
- confirmLabel: BLOCK_COPY.replace,
226
+ /*#__PURE__*/ _jsx(ConfirmDialog, {
227
+ open: confirming,
228
+ title: actionTitle(BLOCK_COPY.replaceVersion, status.name),
229
+ description: BLOCK_COPY.confirmCopy(controlLabel),
192
230
  cancelLabel: BLOCK_COPY.cancel,
193
- onConfirm: copy
231
+ onClose: ()=>setConfirming(false),
232
+ busy: busy,
233
+ busyLabel: READINESS_COPY.changing,
234
+ error: error,
235
+ confirm: {
236
+ label: BLOCK_COPY.replace,
237
+ destructive: true,
238
+ onClick: copy
239
+ }
194
240
  }),
195
- error ? /*#__PURE__*/ _jsx("p", {
241
+ error && !confirming ? /*#__PURE__*/ _jsx("p", {
196
242
  role: "alert",
197
243
  children: error
198
244
  }) : null
@@ -8,19 +8,20 @@ export function slotLabel(slot, status) {
8
8
  }
9
9
  export function statusSentence(status) {
10
10
  if (!liveStatus(status)) return BLOCK_COPY.deleted;
11
+ const controlLabel = slotLabel('control', status);
11
12
  const winner = status.arms.find((arm)=>arm.key === status.winnerArm);
12
13
  const winnerLabel = winner?.label || BLOCK_COPY.slotLabels[status.winnerArm ?? 'control'] || status.winnerArm || BLOCK_COPY.slotLabels.control;
13
14
  switch(status.status){
14
15
  case 'draft':
15
- return blockDraftStatus(status.name);
16
+ return blockDraftStatus(status.name, controlLabel);
16
17
  case 'running':
17
18
  return BLOCK_COPY.running;
18
19
  case 'stopped':
19
- return BLOCK_COPY.stopped;
20
+ return BLOCK_COPY.stopped(controlLabel);
20
21
  case 'decided':
21
- return blockDecidedStatus(winnerLabel, status.rollout);
22
+ return blockDecidedStatus(winnerLabel, status.rollout, controlLabel);
22
23
  case 'archived':
23
- return status.discarded ? BLOCK_COPY.discarded : status.winnerArm ? blockFinishedStatus(winnerLabel, status.winnerArm === 'control') : BLOCK_COPY.neverDecided;
24
+ return status.discarded ? BLOCK_COPY.discarded(controlLabel) : status.winnerArm ? blockFinishedStatus(winnerLabel, status.winnerArm === 'control', controlLabel) : BLOCK_COPY.neverDecided(controlLabel);
24
25
  }
25
26
  }
26
27
  export function canUnwrapOriginal(status, block) {
@@ -4,12 +4,13 @@ export declare const BLOCK_COPY: {
4
4
  empty: string;
5
5
  blockChanged: string;
6
6
  replace: string;
7
+ replaceVersion: string;
7
8
  cancel: string;
8
9
  retry: string;
9
10
  saveFirst: string;
10
11
  setup: string;
11
- copy: string;
12
- confirmCopy: string;
12
+ copy: (label?: string) => string;
13
+ confirmCopy: (label?: string) => string;
13
14
  unwrap: string;
14
15
  removeAndUnwrap: string;
15
16
  deleteAndUnwrap: string;
@@ -17,17 +18,19 @@ export declare const BLOCK_COPY: {
17
18
  noLongerDraft: "This test is no longer a draft. Reload the page.";
18
19
  finishUnwrap: string;
19
20
  deleted: string;
20
- discarded: string;
21
- neverDecided: string;
21
+ discarded: (label?: string) => string;
22
+ neverDecided: (label?: string) => string;
22
23
  running: string;
23
- stopped: string;
24
+ stopped: (label?: string) => string;
25
+ archivedReplaceWhy: string;
26
+ archivedReplaceSteps: string[];
24
27
  slotLabels: Record<string, string>;
25
28
  wrapRefusals: Record<string, string>;
26
29
  };
27
30
  export declare const blockPosition: (label: string, position: number) => string;
28
31
  export declare const blockTestName: (title: string, label: string) => string;
29
- export declare const blockDraftStatus: (name: string) => string;
30
- export declare const blockDecidedStatus: (winner: string, rollout: boolean) => string;
32
+ export declare const blockDraftStatus: (name: string, label?: string) => string;
33
+ export declare const blockDecidedStatus: (winner: string, rollout: boolean, label?: string) => string;
31
34
  export type BlockLinkedCopy = {
32
35
  before: string;
33
36
  link: string;
@@ -35,10 +38,10 @@ export type BlockLinkedCopy = {
35
38
  };
36
39
  export declare const blockRunningUnwrap: BlockLinkedCopy;
37
40
  export declare const blockDecidedUnwrap: BlockLinkedCopy;
38
- export declare const blockFinishedCopy: (winner: string, originalWon?: boolean, emptyWinner?: boolean) => BlockLinkedCopy;
39
- export declare const blockFinishedStatus: (winner: string, originalWon?: boolean) => string;
40
- export declare const blockDeleteConfirmation: (name: string) => string;
41
- export declare const blockUnwrapConfirmation: (name: string) => string;
41
+ export declare function blockFinishedCopy(winner: string, originalWon?: boolean, emptyWinner?: boolean, label?: string): BlockLinkedCopy;
42
+ export declare const blockFinishedStatus: (winner: string, originalWon?: boolean, label?: string) => string;
43
+ export declare const blockDeleteConfirmation: (name: string, label?: string) => string;
44
+ export declare const blockUnwrapConfirmation: (name: string, label?: string) => string;
42
45
  export declare const blockUnwrapNotice: (drafts: boolean, deleted: boolean) => string;
43
46
  export declare const blockSaveNotice: (drafts: boolean) => "Save a draft of this page to add the test." | "Save this page to add the test.";
44
47
  export declare const blockSyncNotice: (drafts: boolean) => "Versions were updated to match the test. Save draft to keep them." | "Versions were updated to match the test. Save to keep them.";
@@ -1,35 +1,42 @@
1
1
  import { API_MESSAGES } from '../../testSurface/copy/common.js';
2
+ import { ARM_LABELS, controlVersionName } from '../../labels/arms.js';
2
3
  export const BLOCK_COPY = {
3
4
  testBlock: 'Test a block on this page',
4
5
  pick: 'Choose a block',
5
- empty: 'There are no blocks on this page to test yet. Add one, save, then come back.',
6
+ empty: 'There are no saved blocks to test yet.',
6
7
  blockChanged: 'This block changed while you were working. Nothing was replaced. Try again.',
7
8
  replace: 'Replace',
9
+ replaceVersion: 'Replace a version in',
8
10
  cancel: 'Cancel',
9
11
  retry: 'Try again',
10
- saveFirst: 'Save your changes, then try again.',
12
+ saveFirst: 'Save your changes to test this block.',
11
13
  setup: 'Set up the test',
12
- copy: 'Copy the Original into this version',
13
- confirmCopy: "Replace this version's content with a copy of the Original? Edits you made to this version will be lost.",
14
+ copy: (label)=>`Copy ${controlVersionName(label)} into this version`,
15
+ confirmCopy: (label)=>`Replace this version's content with a copy of ${controlVersionName(label)}? Edits you made to this version will be lost.`,
14
16
  unwrap: 'Unwrap',
15
17
  removeAndUnwrap: 'Remove the test and unwrap',
16
18
  deleteAndUnwrap: 'Delete and unwrap',
17
19
  alreadyDeleted: API_MESSAGES.testAlreadyDeleted,
18
20
  noLongerDraft: API_MESSAGES.testNoLongerDraft,
19
21
  finishUnwrap: 'The test was removed; use Unwrap to finish.',
20
- deleted: "This block's test was deleted; the page shows the Original.",
21
- discarded: 'Winner discarded: this block shows the Original. Use Unwrap to replace it with the Original content.',
22
- neverDecided: 'Archived without a winner: this block shows the Original. Use Unwrap to replace it with the Original content.',
22
+ deleted: `This block's test was deleted; the page shows ${controlVersionName()}.`,
23
+ discarded: (label)=>`Winner discarded: this block shows ${controlVersionName(label)}. Use Unwrap to replace it with the content of ${controlVersionName(label)}.`,
24
+ neverDecided: (label)=>`Archived without a winner: this block shows ${controlVersionName(label)}. Use Unwrap to replace it with the content of ${controlVersionName(label)}.`,
23
25
  running: "Running: visitors see different versions. Edit a version's tab to change it; the change is noted on the results.",
24
- stopped: 'Stopped: visitors see the Original.',
26
+ stopped: (label)=>`Stopped: visitors see ${controlVersionName(label)}.`,
27
+ archivedReplaceWhy: 'To keep the winner on this page without the test, replace the Test block.',
28
+ archivedReplaceSteps: [
29
+ 'Copy the winning content into ordinary page blocks.',
30
+ 'Remove the Test block.'
31
+ ],
25
32
  slotLabels: {
26
- control: 'Original',
27
- variantA: 'Variant A',
28
- variantB: 'Variant B',
29
- variantC: 'Variant C'
33
+ control: ARM_LABELS.control,
34
+ variantA: ARM_LABELS.variantA,
35
+ variantB: ARM_LABELS.variantB,
36
+ variantC: ARM_LABELS.variantC
30
37
  },
31
38
  wrapRefusals: {
32
- 'wrap-target-missing': 'Reload the page and try again.',
39
+ 'wrap-target-missing': 'Reload to see the current page.',
33
40
  'locked-placement': 'Another editor has this page open. Try again when it is unlocked.',
34
41
  'invalid-status': 'This action is not available in the current status.',
35
42
  'unknown-collection': "That page type isn't set up for tests.",
@@ -38,8 +45,8 @@ export const BLOCK_COPY = {
38
45
  };
39
46
  export const blockPosition = (label, position)=>`${label} (block ${position})`;
40
47
  export const blockTestName = (title, label)=>`${title}: ${label}`;
41
- export const blockDraftStatus = (name)=>`This block is being tested in the draft test ${name}. Visitors see the Original until it starts.`;
42
- export const blockDecidedStatus = (winner, rollout)=>`Decided: visitors see ${winner}${rollout ? '; a holdout still sees the Original' : ''}.`;
48
+ export const blockDraftStatus = (name, label)=>`This block is being tested in the draft test ${name}. Visitors see ${controlVersionName(label)} until it starts.`;
49
+ export const blockDecidedStatus = (winner, rollout, label)=>`Decided: visitors see ${winner}${rollout ? `; a holdout still sees ${controlVersionName(label)}` : ''}.`;
43
50
  export const blockRunningUnwrap = {
44
51
  before: 'Stop ',
45
52
  link: 'the test',
@@ -50,17 +57,21 @@ export const blockDecidedUnwrap = {
50
57
  link: 'the test',
51
58
  after: '.'
52
59
  };
53
- export const blockFinishedCopy = (winner, originalWon = false, emptyWinner = false)=>({
54
- before: emptyWinner ? 'Archived: the winner has no content here, so visitors see the Original. Unwrap leaves the page as visitors see it now. View the results on ' : originalWon ? `Archived: the Original won. This block shows ${winner}. Use Unwrap to keep its content without the Experiment block. View the results on ` : `Archived: this block keeps serving ${winner}, with the Original as a fallback if it is empty. To replace it, copy the content into ordinary page blocks, then remove this Experiment block. View the results on `,
60
+ export function blockFinishedCopy(winner, originalWon = false, emptyWinner = false, label) {
61
+ const control = controlVersionName(label);
62
+ const before = emptyWinner ? `Archived: the winner has no content here, so visitors see ${control}. Unwrap leaves the page as visitors see it now. View the results on ` : originalWon ? `Archived: ${control} won. This block shows ${winner}. Use Unwrap to keep its content without the Test block. View the results on ` : `Archived: this block keeps serving ${winner}, with ${control} as a fallback if it is empty. View the results on `;
63
+ return {
64
+ before,
55
65
  link: 'the test',
56
66
  after: '.'
57
- });
58
- export const blockFinishedStatus = (winner, originalWon = false)=>{
59
- const copy = blockFinishedCopy(winner, originalWon);
67
+ };
68
+ }
69
+ export const blockFinishedStatus = (winner, originalWon = false, label)=>{
70
+ const copy = blockFinishedCopy(winner, originalWon, false, label);
60
71
  return copy.before + copy.link + copy.after;
61
72
  };
62
- export const blockDeleteConfirmation = (name)=>`Delete the draft test ${name} and put the Original back in its place? Deleting the test can't be undone.`;
63
- export const blockUnwrapConfirmation = (name)=>`Put the Original back in this block's place? The test ${name} and its results are kept; it can't be started again.`;
73
+ export const blockDeleteConfirmation = (name, label)=>`Delete the draft test ${name} and put ${controlVersionName(label)} back in its place? Deleting the test can't be undone.`;
74
+ export const blockUnwrapConfirmation = (name, label)=>`${controlVersionName(label, true)} replaces this block when you save the page. The test ${name} and its results are kept.`;
64
75
  export const blockUnwrapNotice = (drafts, deleted)=>`${deleted ? 'The draft test was deleted and the block unwrapped.' : 'The block was unwrapped.'} ${drafts ? 'Save draft' : 'Save'} to keep it.`;
65
76
  export const blockSaveNotice = (drafts)=>drafts ? 'Save a draft of this page to add the test.' : 'Save this page to add the test.';
66
77
  export const blockSyncNotice = (drafts)=>drafts ? 'Versions were updated to match the test. Save draft to keep them.' : 'Versions were updated to match the test. Save to keep them.';
@@ -8,6 +8,7 @@ export declare const GOALS_COPY: {
8
8
  readonly name: "Name";
9
9
  readonly source: "Measured by";
10
10
  readonly directionColumn: "Better when";
11
+ readonly nameRequired: "Enter a name for this goal.";
11
12
  readonly direction: "Better when it goes";
12
13
  readonly increase: "More is better";
13
14
  readonly decrease: "Less is better";
@@ -25,18 +26,19 @@ export declare const GOALS_COPY: {
25
26
  readonly slugLocked: "The short name stays the same once a test uses this goal.";
26
27
  readonly sourceLocked: "What this goal measures stays the same once a test uses it.";
27
28
  readonly chooseSource: "Choose an outcome";
28
- readonly window: "Count results for (hours)";
29
+ readonly window: "Count results for (days)";
30
+ readonly windowError: "Enter a whole number of days, at least 1.";
29
31
  readonly minimum: "Minimum completions before deciding";
32
+ readonly minimumError: "Enter a number of at least 1.";
30
33
  readonly advanced: "Advanced";
31
34
  readonly capping: "Limit very large values";
32
35
  readonly capType: "Limit by";
33
- readonly capValue: "Limit value";
34
- readonly noCap: "No limit";
35
- readonly percentile: "Based on past amounts";
36
- readonly absolute: "Fixed amount";
37
- readonly capHelp: "For past amounts, enter a number such as 0.99 to limit only the largest 1%; or enter a fixed amount.";
36
+ readonly capValue: "Fixed amount";
37
+ readonly noCap: "Don't limit";
38
+ readonly absolute: "Limit to a fixed amount";
39
+ readonly fixedAmountError: "Enter an amount of zero or more.";
38
40
  readonly threshold: "Warn when it gets worse by (%)";
39
- readonly save: "Save";
41
+ readonly createGoal: "Create goal";
40
42
  readonly saving: "Saving…";
41
43
  readonly cancel: "Cancel";
42
44
  readonly remove: "Delete goal";
@@ -49,9 +51,13 @@ export declare const GOALS_COPY: {
49
51
  readonly notFound: "This goal no longer exists.";
50
52
  readonly backToTest: "Back to the test";
51
53
  readonly useGoal: "Use this goal";
52
- readonly open: "Open";
53
54
  readonly search: "Search goals";
54
55
  readonly clearSearch: "Clear search";
56
+ readonly roles: {
57
+ readonly primary: "Main goal";
58
+ readonly secondary: "Also tracked";
59
+ readonly guardrails: "Must not get worse";
60
+ };
55
61
  readonly fields: "Goal details";
56
62
  readonly deleteTitle: "Delete this goal?";
57
63
  readonly deleteBody: "This cannot be undone.";
@@ -64,3 +70,4 @@ export declare function goalInUse(count: number): string;
64
70
  export declare function goalDeleteLockedStart(count: number): string;
65
71
  export declare function goalsNoMatches(search: string): string;
66
72
  export declare function goalShowAll(count: number): string;
73
+ export declare function largestValues(quantile: string): string;
@@ -1,4 +1,5 @@
1
1
  import { CLICK_GOAL_COPY } from '../../goals/picker/copy.js';
2
+ import { percentileTail } from '../../testSurface/copy/metrics.js';
2
3
  export const GOALS_COPY = {
3
4
  slugRule: CLICK_GOAL_COPY.slugRule,
4
5
  duplicateSlug: CLICK_GOAL_COPY.duplicateSlug,
@@ -9,6 +10,7 @@ export const GOALS_COPY = {
9
10
  name: 'Name',
10
11
  source: 'Measured by',
11
12
  directionColumn: 'Better when',
13
+ nameRequired: 'Enter a name for this goal.',
12
14
  direction: 'Better when it goes',
13
15
  increase: 'More is better',
14
16
  decrease: 'Less is better',
@@ -26,18 +28,19 @@ export const GOALS_COPY = {
26
28
  slugLocked: 'The short name stays the same once a test uses this goal.',
27
29
  sourceLocked: 'What this goal measures stays the same once a test uses it.',
28
30
  chooseSource: 'Choose an outcome',
29
- window: 'Count results for (hours)',
31
+ window: 'Count results for (days)',
32
+ windowError: 'Enter a whole number of days, at least 1.',
30
33
  minimum: 'Minimum completions before deciding',
34
+ minimumError: 'Enter a number of at least 1.',
31
35
  advanced: 'Advanced',
32
36
  capping: 'Limit very large values',
33
37
  capType: 'Limit by',
34
- capValue: 'Limit value',
35
- noCap: 'No limit',
36
- percentile: 'Based on past amounts',
37
- absolute: 'Fixed amount',
38
- capHelp: 'For past amounts, enter a number such as 0.99 to limit only the largest 1%; or enter a fixed amount.',
38
+ capValue: 'Fixed amount',
39
+ noCap: "Don't limit",
40
+ absolute: 'Limit to a fixed amount',
41
+ fixedAmountError: 'Enter an amount of zero or more.',
39
42
  threshold: 'Warn when it gets worse by (%)',
40
- save: 'Save',
43
+ createGoal: 'Create goal',
41
44
  saving: 'Saving…',
42
45
  cancel: 'Cancel',
43
46
  remove: 'Delete goal',
@@ -50,9 +53,13 @@ export const GOALS_COPY = {
50
53
  notFound: 'This goal no longer exists.',
51
54
  backToTest: 'Back to the test',
52
55
  useGoal: 'Use this goal',
53
- open: 'Open',
54
56
  search: 'Search goals',
55
57
  clearSearch: 'Clear search',
58
+ roles: {
59
+ primary: 'Main goal',
60
+ secondary: 'Also tracked',
61
+ guardrails: 'Must not get worse'
62
+ },
56
63
  fields: 'Goal details',
57
64
  deleteTitle: 'Delete this goal?',
58
65
  deleteBody: 'This cannot be undone.',
@@ -75,3 +82,6 @@ export function goalsNoMatches(search) {
75
82
  export function goalShowAll(count) {
76
83
  return `Show all ${count}`;
77
84
  }
85
+ export function largestValues(quantile) {
86
+ return `Limit the largest ${percentileTail(Number(quantile))}%`;
87
+ }
@@ -4,21 +4,23 @@ export declare const NEW_TEST_COPY: {
4
4
  readonly setting: "A setting";
5
5
  readonly page: "A whole page";
6
6
  readonly pageMeaning: "Show different versions of a whole page at the same address, and see which one works better.";
7
- readonly collection: "Collection";
7
+ readonly collection: "Which type of page?";
8
8
  readonly original: "Original";
9
9
  readonly originalHelp: "Choose the page visitors see today.";
10
10
  readonly review: "Review";
11
11
  readonly backToTest: "Back to the test";
12
12
  readonly finishSetup: "Finish setup";
13
- readonly start: "Start";
14
- readonly blocksHandoff: "Pick the block to test with 'Test a block on this page'.";
13
+ readonly blocksHandoff: `Choose '${string}' to pick the block to test.`;
14
+ readonly blocksOnlyHandoff: `Open the page you want to test, then choose '${string}' to pick the block to test.`;
15
+ readonly pageType: "Page type";
16
+ readonly choosePageType: "Choose a page type";
15
17
  readonly blockMeaning: "Compare different versions of content on a page.";
16
18
  readonly settingMeaning: "Compare different choices for a setting on your site.";
17
19
  readonly unavailable: "A developer needs to set up pages or settings before you can create a test.";
18
- readonly handoff: "Open the page, add an Experiment block where you want it, and choose Set up test.";
19
- readonly noPages: "There are no pages yet.";
20
- readonly recentPages: "Showing the 50 most recently edited.";
21
- readonly open: "Open";
20
+ readonly handoff: "Open the page you want to test, then follow these steps in the editor.";
21
+ readonly mixedEditorHandoff: "Open the page you want to test, then follow the steps for its editor.";
22
+ readonly pagesMarked: (editor: string) => string;
23
+ readonly handoffSteps: readonly ["Add a Test block to the page.", "Choose Set up test in the sidebar."];
22
24
  readonly chooseSetting: "Which setting do you want to test?";
23
25
  readonly people: "Count people as:";
24
26
  readonly visitors: "Visitors";
@@ -35,6 +37,7 @@ export declare const NEW_TEST_COPY: {
35
37
  readonly name: "Name";
36
38
  readonly hypothesis: "Why are you testing this? (optional)";
37
39
  readonly back: "Back";
40
+ readonly change: "Change";
38
41
  readonly next: "Next";
39
42
  readonly createTest: "Create";
40
43
  readonly creating: "Creating…";