@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
@@ -3,22 +3,33 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { surfaceUrls } from '../../../testSurface/surfaceUrls.js';
4
4
  import { sourceFor } from '../../../testSurface/metricSource.model.js';
5
5
  import { useEffect, useState } from 'react';
6
+ import { useRouter } from 'next/navigation.js';
6
7
  import { formatAdminURL } from 'payload/shared';
7
8
  import { Banner, EmptyState } from '../../../ui/Feedback.js';
8
9
  import { Button } from '../../../ui/Button.js';
9
- import { SearchInput } from '../../../ui/Inputs.js';
10
+ import { SearchInput } from '../../../ui/SearchInput.js';
10
11
  import { SurfaceShell } from '../SurfaceShell.js';
12
+ import { useXpStepNav } from '../useXpStepNav.js';
13
+ import { RowMenu } from '../TestRowMenu.js';
11
14
  import { SURFACE_COPY } from '../../../testSurface/copy/surface.js';
12
15
  import { GOALS_COPY as C, goalsNoMatches, goalUsedBy } from '../../copy/goals.js';
13
16
  import { METRIC_KIND_LABELS } from '../../../testSurface/copy/metrics.js';
14
17
  import { goalUsage } from './goals.model.js';
15
18
  import { goalPages } from './data.js';
19
+ import { DeleteGoalDialog } from './DeleteGoalDialog.js';
16
20
  import './goals.css';
17
21
  export function GoalsList({ surface, returnToTest }) {
22
+ useXpStepNav([
23
+ {
24
+ label: C.title
25
+ }
26
+ ]);
27
+ const router = useRouter();
18
28
  const [data, setData] = useState();
19
29
  const [error, setError] = useState('');
20
30
  const [attempt, setAttempt] = useState(0);
21
31
  const [search, setSearch] = useState('');
32
+ const [deleting, setDeleting] = useState();
22
33
  const returnQuery = returnToTest ? `?${new URLSearchParams({
23
34
  return: returnToTest
24
35
  })}` : '';
@@ -48,14 +59,14 @@ export function GoalsList({ surface, returnToTest }) {
48
59
  attempt
49
60
  ]);
50
61
  const usage = goalUsage(data?.tests ?? []);
51
- const showSearch = (data?.goals.length ?? 0) > 8;
52
- const goals = data?.goals.filter((goal)=>!showSearch || goal.name.toLocaleLowerCase().includes(search.trim().toLocaleLowerCase())) ?? [];
62
+ const query = search.trim().toLocaleLowerCase('en-US');
63
+ const goals = data?.goals.filter((goal)=>goal.name.toLocaleLowerCase('en-US').includes(query)) ?? [];
53
64
  const newGoal = surface.canManage ? /*#__PURE__*/ _jsx(Button, {
54
65
  variant: "primary",
55
66
  href: url(`/experiments/goals/new${returnQuery}`),
56
67
  children: C.newGoal
57
68
  }) : null;
58
- return /*#__PURE__*/ _jsx(SurfaceShell, {
69
+ return /*#__PURE__*/ _jsxs(SurfaceShell, {
59
70
  adminRoute: surface.adminRoute,
60
71
  title: C.title,
61
72
  crumbs: [
@@ -69,6 +80,35 @@ export function GoalsList({ surface, returnToTest }) {
69
80
  ],
70
81
  actions: /*#__PURE__*/ _jsxs(_Fragment, {
71
82
  children: [
83
+ /*#__PURE__*/ _jsxs("div", {
84
+ className: "xp-tests-search",
85
+ children: [
86
+ /*#__PURE__*/ _jsxs("svg", {
87
+ viewBox: "0 0 16 16",
88
+ fill: "none",
89
+ stroke: "currentColor",
90
+ strokeWidth: "1.5",
91
+ "aria-hidden": "true",
92
+ children: [
93
+ /*#__PURE__*/ _jsx("circle", {
94
+ cx: "7",
95
+ cy: "7",
96
+ r: "4.5"
97
+ }),
98
+ /*#__PURE__*/ _jsx("path", {
99
+ d: "m10.5 10.5 3.5 3.5"
100
+ })
101
+ ]
102
+ }),
103
+ /*#__PURE__*/ _jsx(SearchInput, {
104
+ id: "xp-goals-search",
105
+ label: C.search,
106
+ placeholder: C.search,
107
+ value: search,
108
+ onChange: (event)=>setSearch(event.target.value)
109
+ })
110
+ ]
111
+ }),
72
112
  returnToTest ? /*#__PURE__*/ _jsx(Button, {
73
113
  variant: "quiet",
74
114
  href: url(`/experiments/${encodeURIComponent(returnToTest)}`),
@@ -77,17 +117,10 @@ export function GoalsList({ surface, returnToTest }) {
77
117
  newGoal
78
118
  ]
79
119
  }),
80
- children: /*#__PURE__*/ _jsxs("div", {
81
- className: "xp-goals",
82
- children: [
83
- showSearch ? /*#__PURE__*/ _jsx(SearchInput, {
84
- id: "xp-goals-search",
85
- label: C.search,
86
- placeholder: C.search,
87
- value: search,
88
- onChange: (event)=>setSearch(event.target.value)
89
- }) : null,
90
- error ? /*#__PURE__*/ _jsx(Banner, {
120
+ children: [
121
+ /*#__PURE__*/ _jsx("div", {
122
+ className: "xp-goals",
123
+ children: error ? /*#__PURE__*/ _jsx(Banner, {
91
124
  tone: "error",
92
125
  action: /*#__PURE__*/ _jsx(Button, {
93
126
  size: "sm",
@@ -101,13 +134,19 @@ export function GoalsList({ surface, returnToTest }) {
101
134
  }) : !data.goals.length ? /*#__PURE__*/ _jsx(EmptyState, {
102
135
  action: newGoal,
103
136
  children: C.empty
104
- }) : !goals.length ? /*#__PURE__*/ _jsx(EmptyState, {
105
- action: /*#__PURE__*/ _jsx(Button, {
106
- variant: "quiet",
107
- onClick: ()=>setSearch(''),
108
- children: C.clearSearch
109
- }),
110
- children: goalsNoMatches(search)
137
+ }) : !goals.length ? /*#__PURE__*/ _jsxs("div", {
138
+ className: "xp-tests-no-matches",
139
+ children: [
140
+ /*#__PURE__*/ _jsx("p", {
141
+ children: goalsNoMatches(search)
142
+ }),
143
+ /*#__PURE__*/ _jsx(Button, {
144
+ variant: "quiet",
145
+ size: "sm",
146
+ onClick: ()=>setSearch(''),
147
+ children: C.clearSearch
148
+ })
149
+ ]
111
150
  }) : /*#__PURE__*/ _jsx("div", {
112
151
  className: "xp-tests-list",
113
152
  children: goals.map((goal)=>{
@@ -115,6 +154,25 @@ export function GoalsList({ surface, returnToTest }) {
115
154
  const kind = sourceFor(goal.source, surface.metricSources)?.kind;
116
155
  const label = kind && Object.hasOwn(METRIC_KIND_LABELS, kind) ? METRIC_KIND_LABELS[kind] : undefined;
117
156
  const href = url(`/experiments/goals/${encodeURIComponent(String(goal.id))}${returnQuery}`);
157
+ const returnHref = returnToTest ? url(`/experiments/${encodeURIComponent(returnToTest)}?${new URLSearchParams({
158
+ goal: String(goal.id)
159
+ })}`) : undefined;
160
+ const actions = [
161
+ ...returnHref ? [
162
+ {
163
+ id: 'use',
164
+ label: C.useGoal,
165
+ tone: 'primary'
166
+ }
167
+ ] : [],
168
+ ...surface.canManage && !count ? [
169
+ {
170
+ id: 'delete',
171
+ label: C.remove,
172
+ tone: 'danger'
173
+ }
174
+ ] : []
175
+ ];
118
176
  return /*#__PURE__*/ _jsxs("article", {
119
177
  className: "xp-tests-row",
120
178
  children: [
@@ -151,20 +209,31 @@ export function GoalsList({ surface, returnToTest }) {
151
209
  })
152
210
  ]
153
211
  }),
154
- /*#__PURE__*/ _jsx(Button, {
155
- className: "xp-tests-row-action",
156
- variant: returnToTest ? 'primary' : 'secondary',
157
- size: "sm",
158
- href: returnToTest ? url(`/experiments/${encodeURIComponent(returnToTest)}?${new URLSearchParams({
159
- goal: String(goal.id)
160
- })}`) : href,
161
- children: returnToTest ? C.useGoal : C.open
162
- })
212
+ actions.length ? /*#__PURE__*/ _jsx(RowMenu, {
213
+ label: `Actions for ${goal.name}`,
214
+ actions: actions,
215
+ onSelect: (action)=>{
216
+ if (action.id === 'use' && returnHref) router.push(returnHref);
217
+ else if (action.id === 'delete') setDeleting(goal);
218
+ }
219
+ }) : null
163
220
  ]
164
221
  }, `${typeof goal.id}:${goal.id}`);
165
222
  })
166
223
  })
167
- ]
168
- })
224
+ }),
225
+ deleting ? /*#__PURE__*/ _jsx(DeleteGoalDialog, {
226
+ goal: deleting,
227
+ apiRoute: surface.apiRoute,
228
+ onClose: ()=>setDeleting(undefined),
229
+ onDeleted: ()=>{
230
+ setData((current)=>current && {
231
+ ...current,
232
+ goals: current.goals.filter((goal)=>goal.id !== deleting.id)
233
+ });
234
+ setDeleting(undefined);
235
+ }
236
+ }) : null
237
+ ]
169
238
  });
170
239
  }
@@ -1,3 +1,4 @@
1
+ import type { DocId } from '../../../types/contracts.js';
1
2
  export declare class GoalResponseError extends Error {
2
3
  readonly fields: Record<string, string>;
3
4
  constructor(message: string, fields: Record<string, string>);
@@ -7,3 +8,4 @@ export declare function goalResponse(response: Response, fallback: string, optio
7
8
  notFound?: string;
8
9
  }): Promise<unknown>;
9
10
  export declare function goalPages<T>(base: string, collection: 'xp-metrics' | 'xp-experiments', signal: AbortSignal): Promise<T[]>;
11
+ export declare function deleteGoal(apiRoute: string, id: DocId): Promise<void>;
@@ -33,3 +33,12 @@ export async function goalPages(base, collection, signal) {
33
33
  if (!result.ok) goalRefusal(result.body, result.status, C.loadError);
34
34
  return result.docs;
35
35
  }
36
+ export async function deleteGoal(apiRoute, id) {
37
+ const response = await fetch(`${apiRoute.replace(/\/$/, '')}/xp-metrics/${encodeURIComponent(id)}`, {
38
+ method: 'DELETE',
39
+ credentials: 'include'
40
+ });
41
+ await goalResponse(response, C.deleteError, {
42
+ notFound: C.notFound
43
+ });
44
+ }
@@ -1,6 +1,5 @@
1
1
  /* Compact rows reuse surface.css's xp-tests-list / xp-tests-row classes. */
2
2
  .xp-goals { display: grid; gap: var(--xp-space-4); }
3
- .xp-goals > .xp-ui-field { max-width: 20rem; }
4
3
  .xp-goal-form { max-width: 48rem; display: grid; gap: var(--xp-space-4); }
5
4
  .xp-goal-card { display: grid; gap: var(--xp-space-4); }
6
5
  .xp-goal-card > h2 { margin: 0; font: var(--xp-text-title); }
@@ -10,10 +9,12 @@
10
9
  .xp-goal-advanced > summary { padding: var(--xp-space-4); cursor: pointer; font: var(--xp-text-body); }
11
10
  .xp-goal-advanced > summary:focus-visible { outline: 2px solid var(--xp-focus); outline-offset: 2px; }
12
11
  .xp-goal-advanced-fields { display: grid; gap: var(--xp-space-4); padding: 0 var(--xp-space-4) var(--xp-space-4); }
12
+ .xp-goal-advanced-fields h3 { margin: 0; font: var(--xp-text-title); }
13
+ .xp-goal-save { position: sticky; bottom: 0; background: var(--xp-surface); padding: var(--xp-space-3) 0; }
13
14
 
14
15
  .xp-goal-usage { display: grid; gap: var(--xp-space-3); }
15
16
  .xp-goal-usage > h2, .xp-goal-usage > ul { margin: 0; }
16
17
  .xp-goal-usage > h2 { font: var(--xp-text-title); }
17
18
  .xp-goal-usage > ul { display: grid; gap: var(--xp-space-3); padding-inline-start: var(--xp-space-5); }
18
- .xp-goal-usage li > span { display: block; color: var(--xp-text-2); font: var(--xp-text-small); }
19
+ .xp-goal-usage-roles { margin-inline: var(--xp-space-2); color: var(--xp-text-2); font: var(--xp-text-small); }
19
20
  .xp-goal-usage > .xp-ui-button { justify-self: start; }
@@ -28,12 +28,12 @@ export interface GoalUsageTest {
28
28
  }
29
29
  /** Count each experiment once per goal, retaining the API's id types. */
30
30
  export declare function goalUsage(tests: readonly GoalUsageTest[]): Map<DocId, number>;
31
- export { goalSlug } from '../../../goals/picker/clickGoalPicker.model.js';
31
+ export { clickGoalSlug as goalSlug } from '../../../goals/picker/clickGoalPicker.model.js';
32
32
  /** One row per readable test returned by the API, retaining every role. */
33
33
  export declare function goalUsageRows(tests: readonly GoalUsageTest[], goalId: DocId): {
34
34
  id: DocId;
35
35
  name: string;
36
36
  roles: string[];
37
- status?: string;
37
+ status?: Status | null;
38
38
  }[];
39
39
  export declare function visibleGoalUsage<T>(rows: readonly T[], expanded: boolean): readonly T[];
@@ -1,5 +1,4 @@
1
- import { TEST_PAGE } from '../../../testSurface/copy/testPage.js';
2
- import { statusLabel } from '../../../testSurface/labels.js';
1
+ import { GOALS_COPY } from '../../copy/goals.js';
3
2
  /** Count each experiment once per goal, retaining the API's id types. */ export function goalUsage(tests) {
4
3
  const byGoal = new Map();
5
4
  for (const test of tests){
@@ -23,13 +22,9 @@ import { statusLabel } from '../../../testSurface/labels.js';
23
22
  tests.size
24
23
  ]));
25
24
  }
26
- export { goalSlug } from '../../../goals/picker/clickGoalPicker.model.js';
25
+ export { clickGoalSlug as goalSlug } from '../../../goals/picker/clickGoalPicker.model.js';
27
26
  const referenceId = (reference)=>reference && typeof reference === 'object' ? reference.id : reference;
28
- const usageLabels = {
29
- primary: TEST_PAGE.goal,
30
- guardrails: TEST_PAGE.guardrailsShort,
31
- secondary: TEST_PAGE.secondaryShort
32
- };
27
+ const usageLabels = GOALS_COPY.roles;
33
28
  /** One row per readable test returned by the API, retaining every role. */ export function goalUsageRows(tests, goalId) {
34
29
  const rows = new Map();
35
30
  for (const test of tests){
@@ -37,11 +32,11 @@ const usageLabels = {
37
32
  ...referenceId(test.metrics?.primary) === goalId ? [
38
33
  usageLabels.primary
39
34
  ] : [],
40
- ...test.metrics?.guardrails?.some((reference)=>referenceId(reference) === goalId) ? [
41
- usageLabels.guardrails
42
- ] : [],
43
35
  ...test.metrics?.secondary?.some((reference)=>referenceId(reference) === goalId) ? [
44
36
  usageLabels.secondary
37
+ ] : [],
38
+ ...test.metrics?.guardrails?.some((reference)=>referenceId(reference) === goalId) ? [
39
+ usageLabels.guardrails
45
40
  ] : []
46
41
  ];
47
42
  if (!roles.length) continue;
@@ -55,7 +50,7 @@ const usageLabels = {
55
50
  ...roles
56
51
  ])
57
52
  ],
58
- status: test.status ? statusLabel(test.status) : undefined
53
+ status: test.status
59
54
  });
60
55
  }
61
56
  return [
@@ -1,34 +1,41 @@
1
1
  import type { Arm, DocId, ExperimentKind, Status, UnitType } from '../../types/contracts.js';
2
2
  import type { SummaryResponse } from '../../types/endpoints.js';
3
+ import type { DateFormatter } from '../../testSurface/format/date.js';
3
4
  import type { ReadinessContext } from '../../testSurface/surface/readiness/readiness.model.js';
5
+ import { type ActionDecision } from '../../testSurface/actions/actions.model.js';
4
6
  export interface HomeTest {
5
7
  id: DocId;
6
8
  name: string;
7
9
  kind: ExperimentKind;
8
10
  status: Status;
9
11
  unitType: UnitType;
12
+ startedAt?: string | null;
10
13
  updatedAt?: string | null;
11
14
  flagPoint?: string | null;
12
15
  analysis?: {
13
16
  plannedDurationDays?: number | null;
14
17
  } | null;
15
18
  arms?: Arm[] | null;
19
+ phase?: number;
20
+ allocation?: number;
16
21
  decidedAt?: string | null;
17
- decision?: {
18
- winnerArm?: string | null;
19
- holdoutReleasedAt?: string | null;
20
- discardedAt?: string | null;
21
- pagesReleasedAt?: string | null;
22
- } | null;
22
+ decision?: ActionDecision | null;
23
23
  }
24
24
  type Summary = SummaryResponse[DocId] | undefined;
25
25
  export type Health = 'red' | 'amber' | 'green';
26
26
  export declare function healthDot(test: HomeTest, summary: Summary): Health | undefined;
27
27
  export declare function groupTests(tests: readonly HomeTest[], summaries: SummaryResponse, search?: string): {
28
- label: "Needs attention" | "Running" | "Decided" | "Ready to start" | "Draft" | "Archived";
28
+ key: string;
29
+ label: "Needs attention" | "Running" | "Stopped" | "Decided" | "Ready to start" | "Draft" | "Archived";
29
30
  tests: HomeTest[];
30
31
  }[];
31
- export declare function homeCard(test: HomeTest, summary: Summary, adminRoute: string, flagPoints?: ReadinessContext['flagPoints'], goalNames?: Readonly<Record<string, string>>): {
32
+ export declare function homeCard(test: HomeTest, summary: Summary, adminRoute: string, { formatDate, now, flagPoints, goalNames, canReadResults, }: {
33
+ formatDate: DateFormatter;
34
+ now: number;
35
+ flagPoints?: ReadinessContext['flagPoints'];
36
+ goalNames?: Readonly<Record<string, string>>;
37
+ canReadResults?: boolean;
38
+ }): {
32
39
  kind: "Page block" | "Setting" | "Whole page";
33
40
  pill: {
34
41
  label: string;
@@ -1,5 +1,5 @@
1
1
  import { formatAdminURL } from 'payload/shared';
2
- import { formatDate } from '../../testSurface/format/date.js';
2
+ import { roundProgress } from '../../testSurface/format/roundProgress.js';
3
3
  import { armLabel } from '../../testSurface/labels.js';
4
4
  import { statusPill } from '../status.model.js';
5
5
  import { decidedLine, runningLine, SURFACE_COPY } from '../../testSurface/copy/surface.js';
@@ -13,35 +13,36 @@ export function healthDot(test, summary) {
13
13
  return code ? 'green' : undefined;
14
14
  }
15
15
  export function groupTests(tests, summaries, search = '') {
16
- const groups = SURFACE_COPY.groups.map((label)=>({
17
- label,
18
- tests: []
19
- }));
16
+ const groups = new Map(Object.entries(SURFACE_COPY.groups).map(([key, label])=>[
17
+ key,
18
+ {
19
+ key,
20
+ label,
21
+ tests: []
22
+ }
23
+ ]));
20
24
  const query = search.trim().toLocaleLowerCase('en-US');
21
25
  for (const test of tests){
22
26
  if (!test.name.toLocaleLowerCase('en-US').includes(query)) continue;
23
27
  const summary = summaries[test.id];
24
28
  const health = healthDot(test, summary);
25
- const index = test.status === 'running' ? health === 'red' || health === 'amber' ? 0 : 1 : test.status === 'decided' ? 4 : test.status === 'archived' ? 5 : summary?.ready === true ? 2 : 3;
26
- groups[index].tests.push(test);
29
+ const group = test.status === 'running' && (health === 'red' || health === 'amber') ? 'attention' : test.status === 'draft' && summary?.ready === true ? 'ready' : test.status;
30
+ (groups.get(group) ?? groups.get('draft')).tests.push(test);
27
31
  }
28
- return groups;
32
+ return [
33
+ ...groups.values()
34
+ ];
29
35
  }
30
36
  const number = (value)=>value != null && Number.isFinite(value) ? new Intl.NumberFormat('en-US', {
31
37
  maximumFractionDigits: 0
32
38
  }).format(value) : '—';
33
- export function homeCard(test, summary, adminRoute, flagPoints, goalNames = {}) {
34
- const results = [
35
- 'running',
36
- 'stopped',
37
- 'decided',
38
- 'archived'
39
- ].includes(test.status);
39
+ export function homeCard(test, summary, adminRoute, { formatDate, now, flagPoints, goalNames = {}, canReadResults = true }) {
40
+ const results = canReadResults && test.status !== 'draft';
40
41
  const href = formatAdminURL({
41
42
  adminRoute,
42
43
  path: `/experiments/${encodeURIComponent(test.id)}${results ? '/results' : ''}`
43
44
  });
44
- let line = summary?.ready === true ? SURFACE_COPY.ready : nextCopy(SURFACE_COPY.next);
45
+ let line = summary?.ready === true ? test.status === 'stopped' ? SURFACE_COPY.readyAgain : SURFACE_COPY.ready : nextCopy(SURFACE_COPY.next);
45
46
  const next = summary?.next;
46
47
  if ((test.status === 'draft' || test.status === 'stopped') && summary?.ready !== true && next && Object.hasOwn(READINESS, next.code)) {
47
48
  // Keep unexpected text out of authored copy, including responses from older servers.
@@ -56,7 +57,10 @@ export function homeCard(test, summary, adminRoute, flagPoints, goalNames = {})
56
57
  });
57
58
  if (sentence) line = nextCopy(next.code === 'page-no-targets' ? READINESS_COPY.choosePages : sentence);
58
59
  }
59
- if (test.status === 'running') line = runningLine(number(summary?.days), number(test.analysis?.plannedDurationDays), number(summary?.exposures));
60
+ if (test.status === 'running') {
61
+ const progress = roundProgress(test.startedAt, test.analysis?.plannedDurationDays, now, summary?.days ?? 0);
62
+ line = runningLine(number(progress.day), number(progress.plannedDays), number(summary?.exposures));
63
+ }
60
64
  if (test.status === 'decided') {
61
65
  const winner = test.decision?.winnerArm;
62
66
  const winnerLabel = test.arms?.find((arm)=>arm.key === winner)?.label?.trim();
@@ -69,6 +73,6 @@ export function homeCard(test, summary, adminRoute, flagPoints, goalNames = {})
69
73
  line,
70
74
  health: healthDot(test, summary),
71
75
  href,
72
- action: results ? SURFACE_COPY.results : test.status === 'draft' || test.status === 'stopped' ? SURFACE_COPY.continue : SURFACE_COPY.open
76
+ action: results ? SURFACE_COPY.results : test.status !== 'draft' || summary?.ready === true ? SURFACE_COPY.open : SURFACE_COPY.continue
73
77
  };
74
78
  }
@@ -1,7 +1,7 @@
1
- import type { TestsSurfaceProps } from '../../../types/surface.js';
1
+ import type { BlockPageCollection } from '../../../types/surface.js';
2
2
  import type { SurfaceProps } from '../../../testSurface/surface/contracts.js';
3
3
  import './newTest.css';
4
- export declare function NewTest({ surface, pages }: {
4
+ export declare function NewTest({ surface, blockPageCollections }: {
5
5
  surface: SurfaceProps;
6
- pages?: TestsSurfaceProps['pages'];
6
+ blockPageCollections?: BlockPageCollection[];
7
7
  }): import("react").JSX.Element;