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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/dist/admin/surface/ResultsRoute.js +2 -10
  2. package/dist/admin/surface/newTest/PageWizard.js +10 -12
  3. package/dist/admin/surface/results/ResultsHeader.js +15 -8
  4. package/dist/goals/fairness.d.ts +1 -1
  5. package/dist/goals/fairness.js +1 -1
  6. package/dist/puck/editor/ConfigureTestDrawer.js +2 -2
  7. package/dist/puck/editor/CreateExperimentDrawer.js +4 -0
  8. package/dist/puck/editor/EditorControls.d.ts +1 -1
  9. package/dist/puck/editor/EditorControls.js +1 -1
  10. package/dist/puck/editor/ExperimentSlotEditor.js +425 -80
  11. package/dist/puck/editor/LeftoverVersions.d.ts +13 -0
  12. package/dist/puck/editor/LeftoverVersions.js +115 -0
  13. package/dist/puck/editor/PlacementNotice.d.ts +8 -0
  14. package/dist/puck/editor/PlacementNotice.js +22 -0
  15. package/dist/puck/editor/QuickTestActions.d.ts +3 -0
  16. package/dist/puck/editor/QuickTestActions.js +50 -0
  17. package/dist/puck/editor/ResultsReadout.js +5 -0
  18. package/dist/puck/editor/VersionBuilder.d.ts +20 -6
  19. package/dist/puck/editor/VersionBuilder.js +78 -48
  20. package/dist/puck/editor/armWrites.d.ts +3 -1
  21. package/dist/puck/editor/armWrites.js +2 -1
  22. package/dist/puck/editor/cloneSlot.d.ts +2 -0
  23. package/dist/puck/editor/cloneSlot.js +7 -0
  24. package/dist/puck/editor/copy.d.ts +24 -3
  25. package/dist/puck/editor/copy.js +24 -3
  26. package/dist/puck/editor/editor.chrome.css +11 -0
  27. package/dist/puck/editor/editor.css +29 -0
  28. package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
  29. package/dist/puck/editor/outlineVersion.d.ts +5 -0
  30. package/dist/puck/editor/outlineVersion.js +36 -0
  31. package/dist/puck/editor/placementsCache.d.ts +33 -2
  32. package/dist/puck/editor/placementsCache.js +208 -33
  33. package/dist/puck/editor/sidebar.d.ts +12 -0
  34. package/dist/puck/editor/sidebar.js +77 -0
  35. package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
  36. package/dist/puck/editor/usePlacementNotice.js +14 -0
  37. package/dist/testSurface/api.js +1 -1
  38. package/dist/testSurface/copy/common.d.ts +1 -1
  39. package/dist/testSurface/copy/common.js +3 -1
  40. package/dist/testSurface/copy/readiness.d.ts +17 -1
  41. package/dist/testSurface/copy/readiness.js +22 -1
  42. package/dist/testSurface/copy/testPage.d.ts +1 -0
  43. package/dist/testSurface/copy/testPage.js +1 -0
  44. package/dist/testSurface/readPreflight.d.ts +9 -0
  45. package/dist/testSurface/readPreflight.js +38 -0
  46. package/dist/testSurface/readinessRead.d.ts +50 -0
  47. package/dist/testSurface/readinessRead.js +46 -0
  48. package/dist/testSurface/surface/contracts.d.ts +6 -2
  49. package/dist/testSurface/surface/editorPlacement.d.ts +21 -0
  50. package/dist/testSurface/surface/editorPlacement.js +60 -0
  51. package/dist/testSurface/surface/pageBlock/parts.js +13 -3
  52. package/dist/testSurface/surface/readiness/ActionDialogs.js +37 -7
  53. package/dist/testSurface/surface/readiness/Banner.d.ts +1 -4
  54. package/dist/testSurface/surface/readiness/Banner.js +106 -68
  55. package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
  56. package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
  57. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +6 -2
  58. package/dist/testSurface/surface/readiness/SaveStatus.js +35 -22
  59. package/dist/testSurface/surface/readiness/parts.js +0 -2
  60. package/dist/testSurface/surface/readiness/readiness.model.d.ts +13 -0
  61. package/dist/testSurface/surface/readiness/readiness.model.js +51 -36
  62. package/dist/testSurface/surface/readiness/useTransition.d.ts +5 -2
  63. package/dist/testSurface/surface/readiness/useTransition.js +69 -7
  64. package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
  65. package/dist/testSurface/surface/test/GoalSection.js +1 -0
  66. package/dist/testSurface/surface/test/LengthSection.d.ts +1 -1
  67. package/dist/testSurface/surface/test/LengthSection.js +2 -1
  68. package/dist/testSurface/surface/test/Rail.js +7 -4
  69. package/dist/testSurface/surface/test/ReadinessBar.js +1 -2
  70. package/dist/testSurface/surface/test/Section.d.ts +3 -1
  71. package/dist/testSurface/surface/test/Section.js +38 -6
  72. package/dist/testSurface/surface/test/TargetingSection.js +5 -0
  73. package/dist/testSurface/surface/test/TestSurface.d.ts +2 -1
  74. package/dist/testSurface/surface/test/TestSurface.js +68 -7
  75. package/dist/testSurface/surface/test/VersionsSection.js +1 -0
  76. package/dist/testSurface/surface/test/testPage.css +12 -0
  77. package/dist/testSurface/surface/useTestDocument.d.ts +5 -2
  78. package/dist/testSurface/surface/useTestDocument.js +61 -46
  79. package/dist/testSurface/useReadinessPolling.d.ts +3 -0
  80. package/dist/testSurface/useReadinessPolling.js +24 -0
  81. package/dist/transitions/preflightData.js +1 -1
  82. package/dist/ui/Card.d.ts +2 -1
  83. package/dist/ui/Card.js +4 -4
  84. package/dist/ui/Tabs.d.ts +2 -1
  85. package/dist/ui/Tabs.js +19 -6
  86. package/dist/ui/ui.css +18 -0
  87. package/package.json +1 -1
@@ -1,5 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { canStartTest, readyToStart } from '../../readinessRead.js';
3
4
  import { DocsResponseError, fetchAllDocs } from '../../../lib/fetchAllDocs.js';
4
5
  import { usePlacementLabels, placementDetailKey } from '../../placements/usePlacementLabels.js';
5
6
  import { placementUncheckedCopy } from '../../copy/readiness.js';
@@ -14,20 +15,21 @@ import { REVIEW_COPY as R } from '../../copy/review.js';
14
15
  import { READINESS_COPY as C } from '../../copy/readiness.js';
15
16
  import { API_MESSAGES, refusalMessage } from '../../copy/common.js';
16
17
  import { createApi } from '../../api.js';
18
+ import { blockingSteps, pageReadinessContext } from './readiness.model.js';
17
19
  import { useTransition } from './useTransition.js';
18
20
  /** Prop-driven ConfirmDialog adapter: same model/copy, section reload instead of a page reload. */ export function ConfirmAction({ test, surface, action, winnerLabel, onClose }) {
19
21
  const api = createApi(surface.apiRoute);
20
22
  const [typed, setTyped] = useState('');
21
23
  const [content, setContent] = useState(null);
22
24
  const [reportBusy, setReportBusy] = useState(false);
23
- const transition = useTransition(test, onClose);
25
+ const transition = useTransition(test, onClose, surface);
24
26
  const phrase = action.confirm.phrase ? expectedConfirm(action.confirm.phrase.action, winnerLabel) : null;
25
- const ready = action.id !== 'start' || Boolean(test.preflight && !test.preflightPending && !test.preflightError && test.preflight.checks.every((check)=>check.ok));
27
+ const ready = action.id !== 'start' || !transition.checking && canStartTest(test, surface.editorPlacementMessage);
26
28
  const enabled = ready && !transition.busy && !test.hasUnsaved && test.saving !== 'saving' && (!phrase || matchesConfirm(phrase, typed));
27
29
  async function submit(finish = false) {
28
30
  if (!enabled || !test.doc) return;
29
31
  const id = test.doc.id;
30
- await transition.run(async ()=>{
32
+ await transition.run(finish ? 'archive' : action.id === 'start' && test.doc.status === 'stopped' ? 'restart' : action.id, async ()=>{
31
33
  if (finish) return api.archive(id, {
32
34
  mode: 'after-content'
33
35
  });
@@ -105,11 +107,21 @@ import { useTransition } from './useTransition.js';
105
107
  }) : null
106
108
  ]
107
109
  }),
110
+ transition.busy ? /*#__PURE__*/ _jsx("p", {
111
+ role: "status",
112
+ children: C.changing
113
+ }) : null,
108
114
  transition.error ? /*#__PURE__*/ _jsx("p", {
109
115
  role: "alert",
110
116
  children: transition.error
111
117
  }) : null,
118
+ !content && (test.hasUnsaved || test.saving === 'saving') ? /*#__PURE__*/ _jsx("p", {
119
+ children: test.stale ? C.reloadFirst : C.saveFirst
120
+ }) : !content && action.id === 'start' && !readyToStart(test, surface.editorPlacementMessage) ? /*#__PURE__*/ _jsx("p", {
121
+ children: test.preflightError ? test.preflightError : test.doc ? blockingSteps(test.preflight, pageReadinessContext(test.doc, test.preflight, surface))[0]?.sentence ?? C.checking : C.checking
122
+ }) : null,
112
123
  !content ? /*#__PURE__*/ _jsx(Button, {
124
+ busy: transition.busy,
113
125
  disabled: !enabled,
114
126
  onClick: ()=>{
115
127
  void submit();
@@ -128,7 +140,7 @@ import { useTransition } from './useTransition.js';
128
140
  /** AllocateDialog's validation and copy, with data supplied by the test document. */ export function AllocateAction({ test, surface, onClose }) {
129
141
  const current = test.doc?.allocation ?? 100;
130
142
  const [value, setValue] = useState(String(Math.min(100, current + 1)));
131
- const transition = useTransition(test, onClose);
143
+ const transition = useTransition(test, onClose, surface);
132
144
  const allocation = Number(value);
133
145
  const valid = value.trim() !== '' && Number.isInteger(allocation) && allocation > current && allocation <= 100;
134
146
  const disabled = transition.busy || test.hasUnsaved || test.saving === 'saving';
@@ -157,18 +169,26 @@ import { useTransition } from './useTransition.js';
157
169
  })
158
170
  ]
159
171
  }),
172
+ test.hasUnsaved || test.saving === 'saving' ? /*#__PURE__*/ _jsx("p", {
173
+ children: test.stale ? C.reloadFirst : C.saveFirst
174
+ }) : null,
160
175
  !valid ? /*#__PURE__*/ _jsx("p", {
161
176
  children: R.allocationInvalid
162
177
  }) : null,
178
+ transition.busy ? /*#__PURE__*/ _jsx("p", {
179
+ role: "status",
180
+ children: C.changing
181
+ }) : null,
163
182
  transition.error ? /*#__PURE__*/ _jsx("p", {
164
183
  role: "alert",
165
184
  children: transition.error
166
185
  }) : null,
167
186
  /*#__PURE__*/ _jsx(Button, {
187
+ busy: transition.busy,
168
188
  disabled: disabled || !valid,
169
189
  onClick: ()=>{
170
190
  // Not-found can also mean the experiment is missing; use round copy for the missing phase record.
171
- if (valid && test.doc) void transition.run(()=>createApi(surface.apiRoute).allocate(test.doc.id, {
191
+ if (valid && test.doc) void transition.run('allocate', ()=>createApi(surface.apiRoute).allocate(test.doc.id, {
172
192
  allocation
173
193
  }, {
174
194
  notFound: API_MESSAGES.roundChanged
@@ -196,7 +216,7 @@ import { useTransition } from './useTransition.js';
196
216
  ...surface
197
217
  });
198
218
  const [role, setRole] = useState('secondary');
199
- const transition = useTransition(test, onClose);
219
+ const transition = useTransition(test, onClose, surface);
200
220
  useEffect(()=>{
201
221
  const controller = new AbortController();
202
222
  void (async ()=>{
@@ -296,15 +316,25 @@ import { useTransition } from './useTransition.js';
296
316
  !loading && !loadError && !available.length ? /*#__PURE__*/ _jsx("p", {
297
317
  children: R.noMetrics
298
318
  }) : null,
319
+ transition.busy ? /*#__PURE__*/ _jsx("p", {
320
+ role: "status",
321
+ children: C.changing
322
+ }) : null,
299
323
  loadError || transition.error ? /*#__PURE__*/ _jsx("p", {
300
324
  role: "alert",
301
325
  children: loadError ?? transition.error
302
326
  }) : null,
327
+ test.hasUnsaved || test.saving === 'saving' ? /*#__PURE__*/ _jsx("p", {
328
+ children: test.stale ? C.reloadFirst : C.saveFirst
329
+ }) : !loading && !loadError && available.length > 0 && !selected ? /*#__PURE__*/ _jsx("p", {
330
+ children: C.chooseGoalToAdd
331
+ }) : null,
303
332
  /*#__PURE__*/ _jsx(Button, {
333
+ busy: transition.busy,
304
334
  disabled: disabled || loading || !!loadError || !selected,
305
335
  onClick: ()=>{
306
336
  // Goal and phase lookups share not-found; prefer the more likely missing goal without reading server text.
307
- if (selected && test.doc) void transition.run(async ()=>{
337
+ if (selected && test.doc) void transition.run('add-metric', async ()=>{
308
338
  const result = await createApi(surface.apiRoute).addMetric(test.doc.id, {
309
339
  metric: selected.id,
310
340
  role
@@ -1,5 +1,2 @@
1
1
  import type { SectionProps } from '../contracts.js';
2
- export declare function Banner(props: SectionProps): import("react").JSX.Element | null;
3
- export declare function ReadinessContent({ test, surface, resultsVersion, bar }: SectionProps & {
4
- bar?: boolean;
5
- }): import("react").JSX.Element;
2
+ export declare function ReadinessContent({ test, surface, resultsVersion }: SectionProps): import("react").JSX.Element;
@@ -1,31 +1,29 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { canStartTest, readyToStart } from '../../readinessRead.js';
3
4
  import { useEffect, useState } from 'react';
4
5
  import { Button } from '../../../ui/Button.js';
5
6
  import { SaveStatus, saveStatusMessage } from './SaveStatus.js';
6
7
  import { jumpToSection } from '../test/jumpToSection.js';
7
8
  import { actionGroupLabel, availableActions } from '../../actions/actions.model.js';
8
9
  import { createApi } from '../../api.js';
9
- import { READINESS_COPY as C, decidedCopy, nextCopy, runningCopy, stoppedCopy } from '../../copy/readiness.js';
10
- import { READINESS, daysRemaining, displayDate, nextStep, pageReadinessContext } from './readiness.model.js';
10
+ import { TEST_PAGE } from '../../copy/testPage.js';
11
+ import { READINESS_COPY as C, decidedCopy, fixFieldsNext, runningCopy, stoppedCopy } from '../../copy/readiness.js';
12
+ import { READINESS, daysRemaining, displayDate, blockingSteps, pageReadinessContext, errorSection } from './readiness.model.js';
11
13
  import { AddMetricAction, AllocateAction, ConfirmAction } from './ActionDialogs.js';
12
14
  import { preflightPlacementLabel } from '../../placements/placementLabels.js';
13
15
  import { placementUncheckedCopy } from '../../copy/readiness.js';
14
16
  import { useTransition } from './useTransition.js';
17
+ import { BlockerList } from './BlockerList.js';
15
18
  const RUNNING_ACTIONS = [
16
19
  'stop',
17
20
  'add-metric',
18
21
  'allocate'
19
22
  ];
20
- export function Banner(props) {
21
- return props.test.doc ? /*#__PURE__*/ _jsx(ReadinessContent, {
22
- ...props
23
- }, `${props.test.doc.id}/${props.test.doc.status}`) : null;
24
- }
25
- export function ReadinessContent({ test, surface, resultsVersion, bar = false }) {
23
+ export function ReadinessContent({ test, surface, resultsVersion }) {
26
24
  const [selected, setSelected] = useState(null);
27
25
  const [people, setPeople] = useState(null);
28
- const transition = useTransition(test);
26
+ const transition = useTransition(test, undefined, surface);
29
27
  const doc = test.doc;
30
28
  useEffect(()=>{
31
29
  let active = true;
@@ -61,11 +59,38 @@ export function ReadinessContent({ test, surface, resultsVersion, bar = false })
61
59
  }
62
60
  } : check)
63
61
  } : null;
64
- const next = nextStep(labelledPreflight, pageReadinessContext(doc, test.preflight, surface));
62
+ const readinessBlockers = blockingSteps(labelledPreflight, pageReadinessContext(doc, test.preflight, surface));
65
63
  const setup = doc.status === 'draft' || doc.status === 'stopped';
66
- const ready = Boolean(test.preflight && !test.preflightPending && !test.preflightError && test.preflight.checks.every((check)=>check.ok));
64
+ const ready = readyToStart(test, surface.editorPlacementMessage);
65
+ const startEnabled = !transition.checking && canStartTest(test, surface.editorPlacementMessage);
67
66
  const unsaved = test.hasUnsaved || test.saving === 'saving';
68
- const startReason = unsaved ? C.saveFirst : next?.sentence ?? (!ready ? test.preflightError ? C.checkError : C.checking : undefined);
67
+ const blockers = [
68
+ ...readinessBlockers
69
+ ];
70
+ if (unsaved && !test.stale) blockers.unshift({
71
+ section: 'header',
72
+ sentence: C.saveFirst,
73
+ code: 'unsaved'
74
+ });
75
+ else if (!test.preflight && !test.preflightError) blockers.unshift({
76
+ section: 'header',
77
+ sentence: C.checking,
78
+ code: 'checking'
79
+ });
80
+ const errorSections = [
81
+ ...new Set(Object.keys(test.errors).filter((path)=>path !== '_section').map((path)=>errorSection(path) ?? 'what'))
82
+ ];
83
+ for (const section of errorSections.reverse())blockers.unshift({
84
+ section,
85
+ sentence: test.stale ? C.reloadFirst : fixFieldsNext(TEST_PAGE.sections[section]),
86
+ code: `validation:${section}`
87
+ });
88
+ if (test.errors._section || test.stale) blockers.unshift({
89
+ section: 'what',
90
+ sentence: test.stale ? C.reloadFirst : C.reloadAfterError,
91
+ code: 'save-error'
92
+ });
93
+ const startReason = blockers[0]?.sentence ?? test.preflightError ?? (!ready ? C.checking : undefined);
69
94
  const actions = availableActions({
70
95
  status: doc.status,
71
96
  kind: doc.kind,
@@ -80,48 +105,10 @@ export function ReadinessContent({ test, surface, resultsVersion, bar = false })
80
105
  label: C.allocate
81
106
  } : action);
82
107
  const action = actions.find((item)=>item.id === selected);
83
- const sentence = setup ? bar && test.preflightError ? null : ready ? C.ready : next ? nextCopy(next.sentence) : test.preflightError ? C.checkError : C.checking : doc.status === 'running' ? runningCopy(displayDate(doc.startedAt), people, daysRemaining(doc, Date.now())) : doc.status === 'decided' ? decidedCopy(displayDate(doc.decidedAt), winner) : C.archived;
108
+ const sentence = transition.busy ? C.changing : setup ? ready && !blockers.length ? C.ready : null : doc.status === 'running' ? runningCopy(displayDate(doc.startedAt), people, daysRemaining(doc, Date.now())) : doc.status === 'decided' ? decidedCopy(displayDate(doc.decidedAt), winner) : C.archived;
84
109
  return /*#__PURE__*/ _jsxs("div", {
85
- className: `xp-readiness xp-readiness--${setup && ready ? 'ready' : 'neutral'}${bar ? ' xp-readiness--bar xp-tests-container' : ''}`,
110
+ className: `xp-readiness xp-readiness--${setup && ready && !blockers.length && !transition.busy ? 'ready' : 'neutral'} xp-readiness--bar xp-tests-container`,
86
111
  children: [
87
- /*#__PURE__*/ _jsxs("div", {
88
- className: "xp-readiness__state",
89
- children: [
90
- bar ? /*#__PURE__*/ _jsxs(_Fragment, {
91
- children: [
92
- /*#__PURE__*/ _jsx(SaveStatus, {
93
- test: test
94
- }),
95
- sentence && (saveStatusMessage(test) || test.preflightError) ? /*#__PURE__*/ _jsx("span", {
96
- className: "xp-readiness__separator",
97
- "aria-hidden": "true",
98
- children: "·"
99
- }) : null
100
- ]
101
- }) : null,
102
- sentence ? /*#__PURE__*/ _jsx("p", {
103
- role: "status",
104
- children: setup && next && !ready && next.section !== 'header' ? /*#__PURE__*/ _jsxs("a", {
105
- href: `#section-${next.section}`,
106
- onClick: (event)=>{
107
- event.preventDefault();
108
- if (next.section !== 'header') jumpToSection(next.section, next.arm);
109
- },
110
- children: [
111
- sentence,
112
- next.nextStep ? /*#__PURE__*/ _jsxs(_Fragment, {
113
- children: [
114
- /*#__PURE__*/ _jsx("br", {}),
115
- /*#__PURE__*/ _jsx("span", {
116
- children: next.nextStep
117
- })
118
- ]
119
- }) : null
120
- ]
121
- }) : sentence
122
- }) : null
123
- ]
124
- }),
125
112
  setup && test.preflight?.checks.some((check)=>check.code === 'page-targets-unchecked' && check.warning) ? /*#__PURE__*/ _jsx("p", {
126
113
  children: C.uncheckedPages
127
114
  }) : null,
@@ -140,29 +127,80 @@ export function ReadinessContent({ test, surface, resultsVersion, bar = false })
140
127
  }) : placementUncheckedCopy(placement.title) : READINESS[check.code].next(check.detail, doc)
141
128
  }, `${check.code}:${index}`);
142
129
  }),
143
- test.preflight?.goalNotes?.map((note)=>/*#__PURE__*/ _jsx("p", {
144
- children: note.message
130
+ [
131
+ ...new Map(test.preflight?.goalNotes?.map((note)=>[
132
+ String(note.metricId),
133
+ note
134
+ ])).values()
135
+ ].map((note)=>/*#__PURE__*/ _jsxs("p", {
136
+ className: "xp-readiness__warning",
137
+ children: [
138
+ /*#__PURE__*/ _jsx("span", {
139
+ "aria-hidden": "true",
140
+ children: "⚠ "
141
+ }),
142
+ note.message
143
+ ]
145
144
  }, note.metricId)),
146
145
  doc.status === 'stopped' ? /*#__PURE__*/ _jsx("p", {
147
146
  children: stoppedCopy(displayDate(doc.stoppedAt))
148
147
  }) : null,
148
+ /*#__PURE__*/ _jsxs("div", {
149
+ className: "xp-readiness__state",
150
+ children: [
151
+ /*#__PURE__*/ _jsx(SaveStatus, {
152
+ test: test,
153
+ messageInBlockerList: setup && !!test.preflight && !test.preflightError
154
+ }),
155
+ sentence && (saveStatusMessage(test) || test.preflightError) ? /*#__PURE__*/ _jsx("span", {
156
+ className: "xp-readiness__separator",
157
+ "aria-hidden": "true",
158
+ children: "·"
159
+ }) : null,
160
+ sentence ? /*#__PURE__*/ _jsx("p", {
161
+ role: "status",
162
+ children: sentence
163
+ }) : null,
164
+ setup ? /*#__PURE__*/ _jsx(BlockerList, {
165
+ steps: blockers,
166
+ renderSentence: (_, index)=>{
167
+ const step = blockers[index];
168
+ return step.section === 'header' ? step.sentence : /*#__PURE__*/ _jsx("a", {
169
+ href: `#section-${step.section}`,
170
+ onClick: (event)=>{
171
+ event.preventDefault();
172
+ if (step.section !== 'header') jumpToSection(step.section, step.arm);
173
+ },
174
+ children: step.sentence
175
+ });
176
+ }
177
+ }) : null
178
+ ]
179
+ }),
149
180
  /*#__PURE__*/ _jsx("div", {
150
181
  className: "xp-readiness__actions",
151
182
  children: actions.map((item)=>{
152
- const reason = item.id === 'start' ? startReason : unsaved ? C.saveFirst : item.id === 'allocate' && doc.allocation >= 100 ? C.everyone : undefined;
153
- const disabled = transition.busy || !!selected || !!reason;
154
- return /*#__PURE__*/ _jsx("span", {
183
+ const reason = item.id === 'start' ? startReason : test.stale ? C.reloadFirst : unsaved ? C.saveFirst : item.id === 'allocate' && doc.allocation >= 100 ? C.everyone : undefined;
184
+ const disabled = transition.busy || !!selected || !!reason || item.id === 'start' && !startEnabled;
185
+ return /*#__PURE__*/ _jsxs("span", {
155
186
  title: reason,
156
- children: /*#__PURE__*/ _jsx(Button, {
157
- variant: item.tone === 'primary' || bar && item.id === 'stop' ? 'primary' : 'secondary',
158
- disabled: disabled,
159
- onClick: ()=>{
160
- if (disabled) return;
161
- if (item.id === 'start' && doc.status === 'draft') void transition.run(()=>createApi(surface.apiRoute).start(doc.id));
162
- else setSelected(item.id);
163
- },
164
- children: item.label
165
- })
187
+ children: [
188
+ reason && item.id !== 'start' ? /*#__PURE__*/ _jsx("span", {
189
+ className: "xp-readiness-action-reason",
190
+ children: reason
191
+ }) : null,
192
+ /*#__PURE__*/ _jsx(Button, {
193
+ busy: transition.busy,
194
+ variant: item.tone === 'primary' || item.id === 'stop' ? 'primary' : 'secondary',
195
+ disabled: disabled,
196
+ onClick: ()=>{
197
+ if (disabled) return;
198
+ if (item.id === 'start' && doc.status === 'draft') void transition.run('start', ()=>createApi(surface.apiRoute).start(doc.id));
199
+ else setSelected(item.id);
200
+ },
201
+ children: item.label
202
+ })
203
+ ]
166
204
  }, item.id);
167
205
  })
168
206
  }),
@@ -0,0 +1,11 @@
1
+ import '../../../ui/ui.css';
2
+ import type { ReactNode } from 'react';
3
+ /** The footer and sidebar show the same bounded list, including other pages. */
4
+ export declare function BlockerList({ steps, renderSentence }: {
5
+ steps: readonly {
6
+ sentence: string;
7
+ }[];
8
+ renderSentence?: (step: {
9
+ sentence: string;
10
+ }, index: number) => ReactNode;
11
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,31 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import '../../../ui/ui.css';
4
+ import { READINESS_COPY, moreBlockers } from '../../copy/readiness.js';
5
+ /** The footer and sidebar show the same bounded list, including other pages. */ export function BlockerList({ steps, renderSentence = (step)=>step.sentence }) {
6
+ return steps.length ? /*#__PURE__*/ _jsxs("div", {
7
+ className: "xp-readiness__blockers",
8
+ role: "status",
9
+ children: [
10
+ /*#__PURE__*/ _jsx("strong", {
11
+ children: READINESS_COPY.beforeStart
12
+ }),
13
+ /*#__PURE__*/ _jsxs("ul", {
14
+ children: [
15
+ steps.slice(0, 3).map((step, index)=>/*#__PURE__*/ _jsxs("li", {
16
+ children: [
17
+ /*#__PURE__*/ _jsx("span", {
18
+ "aria-hidden": "true",
19
+ children: "⊗ "
20
+ }),
21
+ renderSentence(step, index)
22
+ ]
23
+ }, index)),
24
+ steps.length > 3 ? /*#__PURE__*/ _jsx("li", {
25
+ children: moreBlockers(steps.length - 3)
26
+ }) : null
27
+ ]
28
+ })
29
+ ]
30
+ }) : null;
31
+ }
@@ -1,5 +1,9 @@
1
1
  import type { TestDocApi } from '../contracts.js';
2
2
  export declare function saveStatusMessage(test: TestDocApi): string | null;
3
- export declare function SaveStatus({ test }: {
3
+ type Props = {
4
4
  test: TestDocApi;
5
- }): import("react").JSX.Element;
5
+ messageInBlockerList?: boolean;
6
+ };
7
+ export declare function ReadinessReadStatus({ test, messageInBlockerList }: Props): import("react").JSX.Element;
8
+ export declare function SaveStatus({ test, messageInBlockerList }: Props): import("react").JSX.Element;
9
+ export {};
@@ -1,12 +1,13 @@
1
1
  'use client';
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { readinessRead } from '../../readinessRead.js';
3
4
  import { useRef, useState } from 'react';
4
5
  import { Button } from '../../../ui/Button.js';
5
6
  import { READINESS_COPY as C } from '../../copy/readiness.js';
6
7
  export function saveStatusMessage(test) {
7
- return test.saving === 'saving' ? C.saving : test.saving === 'saved' || test.saving === 'idle' ? C.saved : test.saving === 'error' && !test.stale ? C.saveError : null;
8
+ return test.saving === 'saving' ? C.saving : test.saving === 'saved' || test.saving === 'idle' ? C.saved : test.saving === 'error' && !test.stale ? test.errors._section ? C.saveGeneralError : C.saveError : null;
8
9
  }
9
- export function SaveStatus({ test }) {
10
+ export function ReadinessReadStatus({ test, messageInBlockerList = false }) {
10
11
  const inFlight = useRef(false);
11
12
  const [retrying, setRetrying] = useState(false);
12
13
  async function retry() {
@@ -20,6 +21,33 @@ export function SaveStatus({ test }) {
20
21
  setRetrying(false);
21
22
  }
22
23
  }
24
+ const read = test.preflightRead ?? (test.preflightError ? readinessRead(test) : undefined);
25
+ return /*#__PURE__*/ _jsx(_Fragment, {
26
+ children: read?.message ? /*#__PURE__*/ _jsxs("div", {
27
+ children: [
28
+ !messageInBlockerList ? /*#__PURE__*/ _jsx("span", {
29
+ role: "alert",
30
+ children: read.message
31
+ }) : null,
32
+ ' ',
33
+ test.hasUnsaved || test.saving === 'saving' ? /*#__PURE__*/ _jsx("p", {
34
+ children: test.stale ? C.reloadFirst : C.saveFirst
35
+ }) : null,
36
+ read.retry ? /*#__PURE__*/ _jsx("span", {
37
+ title: test.stale ? C.reloadFirst : test.hasUnsaved || test.saving === 'saving' ? C.saveFirst : undefined,
38
+ children: /*#__PURE__*/ _jsx(Button, {
39
+ disabled: retrying || test.preflightPending || test.hasUnsaved || test.saving === 'saving',
40
+ onClick: ()=>{
41
+ void retry();
42
+ },
43
+ children: C.retry
44
+ })
45
+ }) : null
46
+ ]
47
+ }) : null
48
+ });
49
+ }
50
+ export function SaveStatus({ test, messageInBlockerList }) {
23
51
  const message = saveStatusMessage(test);
24
52
  return /*#__PURE__*/ _jsxs("div", {
25
53
  className: "xp-save-status",
@@ -29,25 +57,10 @@ export function SaveStatus({ test }) {
29
57
  role: test.saving === 'error' ? 'alert' : 'status',
30
58
  children: message
31
59
  }) : null,
32
- test.preflightError ? /*#__PURE__*/ _jsxs("div", {
33
- children: [
34
- /*#__PURE__*/ _jsx("span", {
35
- role: "alert",
36
- children: test.preflightError
37
- }),
38
- ' ',
39
- /*#__PURE__*/ _jsx("span", {
40
- title: test.hasUnsaved || test.saving === 'saving' ? C.saveFirst : undefined,
41
- children: /*#__PURE__*/ _jsx(Button, {
42
- disabled: retrying || test.preflightPending || test.hasUnsaved || test.saving === 'saving',
43
- onClick: ()=>{
44
- void retry();
45
- },
46
- children: C.retry
47
- })
48
- })
49
- ]
50
- }) : null
60
+ /*#__PURE__*/ _jsx(ReadinessReadStatus, {
61
+ test: test,
62
+ messageInBlockerList: messageInBlockerList
63
+ })
51
64
  ]
52
65
  });
53
66
  }
@@ -1,9 +1,7 @@
1
1
  'use client';
2
- import { Banner } from './Banner.js';
3
2
  import { SaveStatus } from './SaveStatus.js';
4
3
  import { sectionDone } from './readiness.model.js';
5
4
  export const readinessParts = {
6
- Banner,
7
5
  SaveStatus,
8
6
  sectionDone
9
7
  };
@@ -4,6 +4,7 @@ import type { TestDocument } from '../testDocument.model.js';
4
4
  import type { SurfaceProps } from '../contracts.js';
5
5
  import { type SectionId } from '../contracts.js';
6
6
  export type ReadinessContext = Pick<TestDocument, 'arms' | 'unitType' | 'flagPoint'> & {
7
+ editorPlacementMessage?: string;
7
8
  collectionLabel?: string;
8
9
  pagePlacements?: PreflightResult['pagePlacements'];
9
10
  flagPoints?: readonly Pick<SerializedFlagPoint, 'id' | 'params'>[];
@@ -14,6 +15,12 @@ export declare const READINESS: Record<ReadinessCode, {
14
15
  next(detail: unknown, ctx: ReadinessContext): string | null;
15
16
  nextStep?: string | ((detail: unknown, ctx: ReadinessContext) => string);
16
17
  }>;
18
+ export declare function blockingSteps(preflight: PreflightResult | null, ctx: ReadinessContext): {
19
+ arm?: import("../../../types/contracts.js").ArmKey | undefined;
20
+ section: "header" | SectionId;
21
+ sentence: string;
22
+ code: ReadinessCode;
23
+ }[];
17
24
  export declare function nextStep(preflight: PreflightResult | null, ctx: ReadinessContext): {
18
25
  nextStep?: string | undefined;
19
26
  arm?: import("../../../types/contracts.js").ArmKey | undefined;
@@ -21,8 +28,14 @@ export declare function nextStep(preflight: PreflightResult | null, ctx: Readine
21
28
  sentence: string;
22
29
  code: ReadinessCode;
23
30
  } | null;
31
+ export declare function errorSection(path: string): SectionId | undefined;
32
+ export declare function sectionBlocked(test: {
33
+ preflight: PreflightResult | null;
34
+ errors?: Record<string, string>;
35
+ }, section: SectionId): boolean;
24
36
  export declare function sectionDone(test: {
25
37
  preflight: PreflightResult | null;
38
+ doc?: Pick<TestDocument, 'targeting'> | null;
26
39
  }): Record<SectionId, boolean>;
27
40
  export declare function displayDate(value: unknown): string | null;
28
41
  export declare function daysRemaining(doc: TestDocument, now: number): number | null;