@delmaredigital/payload-experiments 0.4.0-rc.10 → 0.4.0-rc.11

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 (140) hide show
  1. package/dist/admin/MetricSourceSelect.js +10 -3
  2. package/dist/admin/copy/blocks.js +3 -3
  3. package/dist/admin/copy/goals.d.ts +15 -8
  4. package/dist/admin/copy/goals.js +18 -8
  5. package/dist/admin/copy/newTest.d.ts +3 -2
  6. package/dist/admin/copy/newTest.js +3 -2
  7. package/dist/admin/surface/SurfaceShell.d.ts +4 -2
  8. package/dist/admin/surface/SurfaceShell.js +25 -3
  9. package/dist/admin/surface/TestRowMenu.d.ts +7 -0
  10. package/dist/admin/surface/TestRowMenu.js +9 -2
  11. package/dist/admin/surface/TestsHome.js +8 -1
  12. package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
  13. package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
  14. package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
  15. package/dist/admin/surface/goals/GoalForm.js +280 -191
  16. package/dist/admin/surface/goals/GoalsList.js +102 -33
  17. package/dist/admin/surface/goals/data.d.ts +2 -0
  18. package/dist/admin/surface/goals/data.js +9 -0
  19. package/dist/admin/surface/goals/goals.css +3 -2
  20. package/dist/admin/surface/goals/goals.model.d.ts +2 -2
  21. package/dist/admin/surface/goals/goals.model.js +7 -12
  22. package/dist/admin/surface/home.model.d.ts +1 -0
  23. package/dist/admin/surface/home.model.js +5 -1
  24. package/dist/admin/surface/newTest/NewTest.js +56 -29
  25. package/dist/admin/surface/newTest/PageWizard.d.ts +3 -1
  26. package/dist/admin/surface/newTest/PageWizard.js +14 -14
  27. package/dist/admin/surface/newTest/newTest.css +3 -3
  28. package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
  29. package/dist/admin/surface/results/ResultsHeader.js +69 -41
  30. package/dist/admin/surface/surface.css +20 -1
  31. package/dist/admin/surface/test/TestPage.js +46 -34
  32. package/dist/admin/surface/useXpStepNav.d.ts +11 -0
  33. package/dist/admin/surface/useXpStepNav.js +14 -0
  34. package/dist/admin/views/TestsSurfaceClient.js +27 -3
  35. package/dist/blocks/createExperimentBlock.js +1 -1
  36. package/dist/blocks/formState.js +1 -1
  37. package/dist/collections/metrics.js +12 -5
  38. package/dist/collections/serialize.js +3 -2
  39. package/dist/db/snapshots.d.ts +1 -0
  40. package/dist/goals/sourceLabel.d.ts +2 -0
  41. package/dist/goals/sourceLabel.js +4 -0
  42. package/dist/plugin.js +51 -1
  43. package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
  44. package/dist/puck/editor/ExperimentSlotEditor.js +96 -43
  45. package/dist/puck/editor/QuickTestActions.d.ts +2 -2
  46. package/dist/puck/editor/QuickTestActions.js +42 -27
  47. package/dist/puck/editor/ResultsReadout.d.ts +3 -1
  48. package/dist/puck/editor/ResultsReadout.js +28 -16
  49. package/dist/puck/editor/VersionBuilder.d.ts +2 -1
  50. package/dist/puck/editor/VersionBuilder.js +14 -8
  51. package/dist/puck/editor/copy.d.ts +3 -3
  52. package/dist/puck/editor/copy.js +4 -4
  53. package/dist/puck/editor/editor.chrome.css +9 -1
  54. package/dist/puck/editor/editor.css +10 -1
  55. package/dist/puck/nestedTestCopy.js +1 -1
  56. package/dist/puck/slotConfig.d.ts +1 -1
  57. package/dist/puck/slotConfig.js +1 -1
  58. package/dist/results/analyse.d.ts +2 -0
  59. package/dist/results/analyse.js +2 -2
  60. package/dist/results/verdict.d.ts +1 -1
  61. package/dist/results/verdict.js +7 -6
  62. package/dist/server/runResults.js +2 -1
  63. package/dist/testSurface/PreviewLinks.d.ts +2 -1
  64. package/dist/testSurface/PreviewLinks.js +3 -3
  65. package/dist/testSurface/actions/DecideDialog.d.ts +3 -2
  66. package/dist/testSurface/actions/DecideDialog.js +21 -12
  67. package/dist/testSurface/actions/LifecycleAction.d.ts +2 -1
  68. package/dist/testSurface/actions/LifecycleAction.js +3 -1
  69. package/dist/testSurface/actions/actions.model.js +6 -5
  70. package/dist/testSurface/actions/decide.model.d.ts +1 -0
  71. package/dist/testSurface/actions/decide.model.js +1 -0
  72. package/dist/testSurface/allocation.model.js +6 -3
  73. package/dist/testSurface/copy/actions.d.ts +12 -9
  74. package/dist/testSurface/copy/actions.js +12 -9
  75. package/dist/testSurface/copy/advanced.d.ts +10 -0
  76. package/dist/testSurface/copy/advanced.js +10 -0
  77. package/dist/testSurface/copy/arms.d.ts +1 -1
  78. package/dist/testSurface/copy/arms.js +1 -1
  79. package/dist/testSurface/copy/audience.d.ts +4 -3
  80. package/dist/testSurface/copy/audience.js +5 -4
  81. package/dist/testSurface/copy/common.d.ts +2 -2
  82. package/dist/testSurface/copy/common.js +2 -2
  83. package/dist/testSurface/copy/metrics.d.ts +6 -0
  84. package/dist/testSurface/copy/metrics.js +8 -0
  85. package/dist/testSurface/copy/readiness.d.ts +3 -3
  86. package/dist/testSurface/copy/readiness.js +5 -5
  87. package/dist/testSurface/copy/recommendation.d.ts +4 -4
  88. package/dist/testSurface/copy/recommendation.js +4 -4
  89. package/dist/testSurface/copy/results.d.ts +13 -9
  90. package/dist/testSurface/copy/results.js +15 -9
  91. package/dist/testSurface/copy/review.d.ts +12 -9
  92. package/dist/testSurface/copy/review.js +13 -9
  93. package/dist/testSurface/copy/setting.d.ts +1 -2
  94. package/dist/testSurface/copy/setting.js +1 -2
  95. package/dist/testSurface/copy/surface.js +1 -1
  96. package/dist/testSurface/copy/testPage.d.ts +13 -9
  97. package/dist/testSurface/copy/testPage.js +16 -13
  98. package/dist/testSurface/format/date.d.ts +1 -0
  99. package/dist/testSurface/format/date.js +11 -0
  100. package/dist/testSurface/labels.d.ts +1 -2
  101. package/dist/testSurface/labels.js +2 -3
  102. package/dist/testSurface/lockedNotice.model.d.ts +2 -0
  103. package/dist/testSurface/lockedNotice.model.js +31 -0
  104. package/dist/testSurface/results/results.model.d.ts +3 -2
  105. package/dist/testSurface/results/results.model.js +10 -9
  106. package/dist/testSurface/surface/pageBlock/pageBlock.model.js +1 -1
  107. package/dist/testSurface/surface/pageBlock/parts.js +17 -7
  108. package/dist/testSurface/surface/pagePicker/PageCombobox.js +0 -5
  109. package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +1 -1
  110. package/dist/testSurface/surface/readiness/ActionDialogs.js +54 -33
  111. package/dist/testSurface/surface/readiness/Banner.d.ts +3 -1
  112. package/dist/testSurface/surface/readiness/Banner.js +86 -75
  113. package/dist/testSurface/surface/readiness/SaveStatus.d.ts +5 -2
  114. package/dist/testSurface/surface/readiness/SaveStatus.js +8 -7
  115. package/dist/testSurface/surface/readiness/readiness.model.js +1 -1
  116. package/dist/testSurface/surface/results/ResultsBody.d.ts +4 -1
  117. package/dist/testSurface/surface/results/ResultsBody.js +119 -80
  118. package/dist/testSurface/surface/results/recommendation.model.js +3 -3
  119. package/dist/testSurface/surface/setting/parts.js +31 -28
  120. package/dist/testSurface/surface/setting/setting.css +2 -1
  121. package/dist/testSurface/surface/test/AdvancedSection.js +10 -4
  122. package/dist/testSurface/surface/test/GoalSection.js +11 -11
  123. package/dist/testSurface/surface/test/LengthSection.js +20 -13
  124. package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
  125. package/dist/testSurface/surface/test/PageHoldout.js +7 -7
  126. package/dist/testSurface/surface/test/ReadinessBar.d.ts +1 -1
  127. package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
  128. package/dist/testSurface/surface/test/Section.js +8 -0
  129. package/dist/testSurface/surface/test/TargetingSection.js +7 -2
  130. package/dist/testSurface/surface/test/VersionsSection.js +88 -68
  131. package/dist/testSurface/surface/test/fields.d.ts +4 -3
  132. package/dist/testSurface/surface/test/fields.js +10 -16
  133. package/dist/testSurface/surface/test/pageParts.js +3 -1
  134. package/dist/testSurface/surface/test/testPage.css +9 -1
  135. package/dist/testSurface/surfaceUrls.d.ts +1 -0
  136. package/dist/testSurface/surfaceUrls.js +4 -0
  137. package/dist/ui/Dialog.js +25 -0
  138. package/dist/ui/Inputs.js +0 -1
  139. package/dist/ui/ui.css +1 -0
  140. package/package.json +1 -1
@@ -3,12 +3,15 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { Button } from '../../../ui/Button.js';
4
4
  import { TEST_PAGE as C, suggestedWeeks, weeksHint } from '../../copy/testPage.js';
5
5
  import { durationSuggestion } from './testPage.model.js';
6
- import { FieldErrors, positiveInteger, reasonFor, save, TextEdit } from './fields.js';
6
+ import { FieldErrors, positiveInteger, ReadOnly, reasonFor, save, TextEdit } from './fields.js';
7
+ import { formatDate } from '../../format/date.js';
7
8
  import { Section } from './Section.js';
8
9
  export function LengthSection({ test, surface }) {
9
10
  const doc = test.doc;
10
11
  const reason = reasonFor(test, 'analysis');
11
- const suggestion = durationSuggestion(test.preflight, doc.analysis?.plannedDurationDays);
12
+ const days = doc.analysis?.plannedDurationDays ?? 28;
13
+ const suggestion = !reason ? durationSuggestion(test.preflight, days) : null;
14
+ const end = typeof doc.startedAt === 'string' ? Date.parse(doc.startedAt) + days * 86_400_000 : NaN;
12
15
  const required = [
13
16
  'manual',
14
17
  'viewport'
@@ -27,7 +30,7 @@ export function LengthSection({ test, surface }) {
27
30
  /*#__PURE__*/ _jsxs("div", {
28
31
  className: "xp-field-grid",
29
32
  children: [
30
- /*#__PURE__*/ _jsxs("div", {
33
+ !reason || test.fieldDrafts?.['analysis.reachPerDay'] ? /*#__PURE__*/ _jsxs("div", {
31
34
  children: [
32
35
  /*#__PURE__*/ _jsx(TextEdit, {
33
36
  test: test,
@@ -37,38 +40,42 @@ export function LengthSection({ test, surface }) {
37
40
  type: "number",
38
41
  min: 1,
39
42
  reason: reason,
40
- required: required,
43
+ required: required && !reason,
41
44
  onCommit: (value)=>change('reachPerDay', value)
42
45
  }),
43
- /*#__PURE__*/ _jsx("p", {
46
+ !reason ? /*#__PURE__*/ _jsx("p", {
44
47
  className: "xp-ui-help",
45
48
  children: C.reachHelp
46
- }),
49
+ }) : null,
47
50
  /*#__PURE__*/ _jsx(FieldErrors, {
48
51
  test: test,
49
52
  path: "analysis.reachPerDay"
50
53
  })
51
54
  ]
52
- }),
55
+ }, "reach") : null,
53
56
  /*#__PURE__*/ _jsxs("div", {
54
57
  children: [
55
58
  /*#__PURE__*/ _jsx(TextEdit, {
56
59
  test: test,
57
60
  label: C.duration,
58
- value: doc.analysis?.plannedDurationDays ?? 28,
61
+ value: days,
59
62
  type: "number",
60
63
  min: 1,
61
64
  reason: reason,
62
65
  isValid: positiveInteger,
63
66
  onCommit: (value)=>change('plannedDurationDays', value),
64
- help: weeksHint(doc.analysis?.plannedDurationDays ?? 28)
67
+ help: !reason ? weeksHint(days) : undefined
65
68
  }),
66
69
  /*#__PURE__*/ _jsx(FieldErrors, {
67
70
  test: test,
68
71
  path: "analysis.plannedDurationDays"
69
72
  })
70
73
  ]
71
- })
74
+ }, "duration"),
75
+ reason ? /*#__PURE__*/ _jsx(ReadOnly, {
76
+ label: C.endDate,
77
+ value: formatDate(end)
78
+ }) : null
72
79
  ]
73
80
  }),
74
81
  suggestion ? /*#__PURE__*/ _jsxs("div", {
@@ -77,7 +84,7 @@ export function LengthSection({ test, surface }) {
77
84
  /*#__PURE__*/ _jsx("p", {
78
85
  children: suggestedWeeks(suggestion.weeks)
79
86
  }),
80
- !reason ? /*#__PURE__*/ _jsx(Button, {
87
+ /*#__PURE__*/ _jsx(Button, {
81
88
  onClick: ()=>save(test, 'analysis', ()=>({
82
89
  analysis: {
83
90
  ...test.doc.analysis,
@@ -86,12 +93,12 @@ export function LengthSection({ test, surface }) {
86
93
  }
87
94
  })),
88
95
  children: C.apply
89
- }) : null,
96
+ }),
90
97
  !suggestion.feasible ? /*#__PURE__*/ _jsx("p", {
91
98
  children: C.infeasible
92
99
  }) : null
93
100
  ]
94
- }) : !test.preflight?.estimate ? /*#__PURE__*/ _jsx("p", {
101
+ }) : !reason && !test.preflight?.estimate ? /*#__PURE__*/ _jsx("p", {
95
102
  children: doc.analysis?.reachPerDay == null ? C.noSuggestion : C.chooseGoalSuggestion
96
103
  }) : null,
97
104
  test.errors.analysis ? /*#__PURE__*/ _jsx("p", {
@@ -1,3 +1,3 @@
1
1
  import type { SectionProps } from '../contracts.js';
2
2
  /** Whole-page holdouts have no page of their own; their controls live under Advanced. */
3
- export declare function PageHoldout({ test }: SectionProps): import("react").JSX.Element;
3
+ export declare function PageHoldout({ test }: SectionProps): import("react").JSX.Element | null;
@@ -1,6 +1,7 @@
1
1
  'use client';
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { TEST_PAGE as C } from '../../copy/testPage.js';
4
+ import { actionGroupLabel } from '../../actions/actions.model.js';
4
5
  import { ARMS_COPY } from '../../copy/arms.js';
5
6
  import { addHoldoutArm, removeArm, splitEvenly } from '../../arms/arms.model.js';
6
7
  import { balanceWeight, trafficSplit } from './testPage.model.js';
@@ -11,6 +12,7 @@ import { Button } from '../../../ui/Button.js';
11
12
  const arm = doc.arms.find((item)=>item.kind === 'holdout');
12
13
  const index = doc.arms.findIndex((item)=>item.kind === 'holdout');
13
14
  const reason = reasonFor(test, 'arms');
15
+ if (reason && !arm) return null;
14
16
  return /*#__PURE__*/ _jsxs("div", {
15
17
  children: [
16
18
  arm ? /*#__PURE__*/ _jsxs(_Fragment, {
@@ -46,24 +48,22 @@ import { Button } from '../../../ui/Button.js';
46
48
  test: test,
47
49
  path: `arms.${index}`
48
50
  }),
49
- /*#__PURE__*/ _jsx(Button, {
50
- disabled: !!reason,
51
+ !reason ? /*#__PURE__*/ _jsx(Button, {
51
52
  onClick: ()=>save(test, 'arms', ()=>({
52
53
  arms: splitEvenly(removeArm(doc.arms, arm.key))
53
54
  })),
54
55
  children: C.remove
55
- })
56
+ }) : null
56
57
  ]
57
- }) : /*#__PURE__*/ _jsx(Button, {
58
- disabled: !!reason,
58
+ }) : !reason ? /*#__PURE__*/ _jsx(Button, {
59
59
  onClick: ()=>save(test, 'arms', ()=>({
60
60
  arms: addHoldoutArm(doc.arms)
61
61
  })),
62
62
  children: C.addHoldout
63
- }),
63
+ }) : null,
64
64
  /*#__PURE__*/ _jsx("p", {
65
65
  className: "xp-ui-help",
66
- children: ARMS_COPY.holdout
66
+ children: ARMS_COPY.holdout(actionGroupLabel('control', doc.arms.find((arm)=>arm.key === 'control')?.label))
67
67
  })
68
68
  ]
69
69
  });
@@ -3,4 +3,4 @@ import type { SectionProps } from '../contracts.js';
3
3
  export declare function ReadinessBar({ onHeightChange, ...props }: SectionProps & {
4
4
  onHeightChange: (height: number) => void;
5
5
  embedded?: boolean;
6
- }): import("react").JSX.Element;
6
+ }): import("react").JSX.Element | null;
@@ -1,7 +1,6 @@
1
1
  'use client';
2
2
  import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { useLayoutEffect, useRef } from 'react';
4
- import { READINESS_COPY as C } from '../../copy/readiness.js';
5
4
  import { ReadinessContent } from '../readiness/Banner.js';
6
5
  /** Measure wrapping actions/copy so the final section always clears the fixed bar. */ export function ReadinessBar({ onHeightChange, ...props }) {
7
6
  const ref = useRef(null);
@@ -20,13 +19,8 @@ import { ReadinessContent } from '../readiness/Banner.js';
20
19
  }, [
21
20
  onHeightChange
22
21
  ]);
23
- return /*#__PURE__*/ _jsx("div", {
24
- ref: ref,
25
- className: "xp-test-readiness-bar",
26
- role: "region",
27
- "aria-label": C.label,
28
- children: props.test.doc ? /*#__PURE__*/ _jsx(ReadinessContent, {
29
- ...props
30
- }, props.test.doc.id) : null
31
- });
22
+ return props.test.doc ? /*#__PURE__*/ _jsx(ReadinessContent, {
23
+ ...props,
24
+ barRef: ref
25
+ }, props.test.doc.id) : null;
32
26
  }
@@ -6,6 +6,7 @@ import { readinessParts } from '../readiness/parts.js';
6
6
  import { SectionCard } from '../../../ui/SectionCard.js';
7
7
  import { SECTION_ORDER } from '../contracts.js';
8
8
  import { fixFieldsNext } from '../../copy/readiness.js';
9
+ import { sectionLockNotice } from '../../lockedNotice.model.js';
9
10
  import { TEST_PAGE as C } from '../../copy/testPage.js';
10
11
  export function Section({ test, sectionId, children, surface }) {
11
12
  const hasAdvancedError = Object.keys(test.errors).some((path)=>path.startsWith('analysis.') && ![
@@ -18,6 +19,11 @@ export function Section({ test, sectionId, children, surface }) {
18
19
  setPrevHasAdvancedError(hasAdvancedError);
19
20
  if (hasAdvancedError) setOpen(true);
20
21
  }
22
+ const reason = test.doc && sectionLockNotice(test.doc.status, sectionId);
23
+ const notice = reason ? /*#__PURE__*/ _jsx("p", {
24
+ className: "xp-ui-help xp-section-lock",
25
+ children: reason
26
+ }) : null;
21
27
  const setup = test.doc?.status === 'draft' || test.doc?.status === 'stopped';
22
28
  const blocked = setup && sectionBlocked(test, sectionId);
23
29
  const blockers = setup && test.doc ? blockingSteps(test.preflight, surface ? pageReadinessContext(test.doc, test.preflight, surface) : test.doc).filter((step)=>step.section === sectionId) : [];
@@ -58,6 +64,7 @@ export function Section({ test, sectionId, children, surface }) {
58
64
  /*#__PURE__*/ _jsxs("div", {
59
65
  className: "xp-ui-section-body",
60
66
  children: [
67
+ notice,
61
68
  children,
62
69
  blockerLines
63
70
  ]
@@ -73,6 +80,7 @@ export function Section({ test, sectionId, children, surface }) {
73
80
  headingId: `title-${sectionId}`,
74
81
  className: "xp-test-section",
75
82
  children: [
83
+ notice,
76
84
  children,
77
85
  blockerLines
78
86
  ]
@@ -6,7 +6,7 @@ import { ChipsInput } from '../../../ui/ChipsInput.js';
6
6
  import { AUDIENCE_COPY } from '../../copy/audience.js';
7
7
  import { coerceValue, emptyListHint, humaniseAttribute, opLabel, opsFor, readListValue, readTargetingRules, valueInput } from '../../targeting/targeting.model.js';
8
8
  import { TEST_PAGE as C, NUMBER_COMPARISONS } from '../../copy/testPage.js';
9
- import { CheckboxList, FieldErrors, reasonFor, save, SavedValueChanged, SelectEdit, TextEdit, useDraftAnnouncement, useFieldDraft } from './fields.js';
9
+ import { CheckboxList, FieldErrors, ReadOnly, reasonFor, save, SavedValueChanged, SelectEdit, TextEdit, useDraftAnnouncement, useFieldDraft } from './fields.js';
10
10
  import { Section } from './Section.js';
11
11
  export function TargetingSection({ test, surface }) {
12
12
  const id = useId();
@@ -244,6 +244,10 @@ function TargetingChips({ test, draftKey, id, label, values, reason, onCommit })
244
244
  if (text !== draft.value || !draft.dirty) draft.change(text);
245
245
  draft.submit(()=>onCommit(next));
246
246
  };
247
+ if (reason && !draft.dirty) return /*#__PURE__*/ _jsx(ReadOnly, {
248
+ label: C.value,
249
+ value: values.join(', ')
250
+ });
247
251
  const choiceId = choice ? `${id}-new-value` : undefined;
248
252
  return /*#__PURE__*/ _jsxs(_Fragment, {
249
253
  children: [
@@ -252,7 +256,7 @@ function TargetingChips({ test, draftKey, id, label, values, reason, onCommit })
252
256
  label: C.value,
253
257
  value: values,
254
258
  disabled: locked,
255
- description: reason ?? AUDIENCE_COPY.listDescription,
259
+ description: reason ? undefined : AUDIENCE_COPY.listDescription,
256
260
  placeholder: AUDIENCE_COPY.listPlaceholder,
257
261
  onChange: onCommit,
258
262
  draft: {
@@ -267,6 +271,7 @@ function TargetingChips({ test, draftKey, id, label, values, reason, onCommit })
267
271
  id: choiceId,
268
272
  value: saved,
269
273
  reason: reason,
274
+ showReason: false,
270
275
  conflict: draft.conflict,
271
276
  announce: announcement,
272
277
  onKeep: !locked ? ()=>commit(draft.value, true) : undefined,
@@ -1,11 +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
3
  import { useId, useState } from 'react';
4
4
  import { Button } from '../../../ui/Button.js';
5
5
  import { Range } from '../../../ui/Inputs.js';
6
6
  import { TEST_PAGE as C } from '../../copy/testPage.js';
7
+ import { actionGroupLabel } from '../../actions/actions.model.js';
7
8
  import { ARMS_COPY, GROUP_LABELS, issueMessage } from '../../copy/arms.js';
8
9
  import { addHoldoutArm, addVariant, issuesByRow, removeArm, splitEvenly, totalWeight, withSlotsFor } from '../../arms/arms.model.js';
10
+ import { LOCKED_MESSAGES } from '../../copy/common.js';
9
11
  import { allocationSentence } from '../../allocation.model.js';
10
12
  import { balanceWeight, orderedVersions, trafficShares, trafficSplit } from './testPage.model.js';
11
13
  import { FieldErrors, ReadOnly, reasonFor, save, SavedValueChanged, TextEdit, useDraftAnnouncement, useFieldDraft } from './fields.js';
@@ -31,6 +33,7 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
31
33
  const allocationConflict = allocationEdit.dirty && !allocationEdit.saving && (allocationEdit.conflict || allocationEdit.retry || allocationReason) ? `${id}-new-value` : undefined;
32
34
  if (weightEdit && (weightEdit.split !== split || test.mountDraft && !test.fieldDrafts?.[`share:${weightEdit.key}`])) setWeightEdit(null);
33
35
  const reason = reasonFor(test, 'arms');
36
+ const setting = doc.kind === 'flag' || doc.kind === 'code';
34
37
  const live = weightEdit && !reason ? balanceWeight(doc.arms, weightEdit.key, weightEdit.weight) : doc.arms;
35
38
  const ordered = orderedVersions(live);
36
39
  const shares = trafficShares(ordered.map((row)=>row.arm));
@@ -60,12 +63,8 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
60
63
  contentOnCanvas ? /*#__PURE__*/ _jsx("p", {
61
64
  children: C.editVersionsOnCanvas
62
65
  }) : null,
63
- reason ? /*#__PURE__*/ _jsx("p", {
64
- className: "xp-ui-help",
65
- children: reason
66
- }) : null,
67
66
  /*#__PURE__*/ _jsxs("div", {
68
- className: "xp-version-rows",
67
+ className: `xp-version-rows${setting ? ' xp-version-rows--setting' : ''}`,
69
68
  children: [
70
69
  /*#__PURE__*/ _jsxs("div", {
71
70
  className: "xp-version-grid-head",
@@ -74,53 +73,78 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
74
73
  /*#__PURE__*/ _jsx("span", {
75
74
  children: C.label
76
75
  }),
77
- /*#__PURE__*/ _jsx("span", {
78
- children: C.weight
79
- }),
80
- /*#__PURE__*/ _jsx("span", {}),
81
- /*#__PURE__*/ _jsx("span", {})
76
+ setting ? /*#__PURE__*/ _jsx("span", {
77
+ children: C.valueColumn
78
+ }) : /*#__PURE__*/ _jsxs(_Fragment, {
79
+ children: [
80
+ /*#__PURE__*/ _jsx("span", {
81
+ children: C.weight
82
+ }),
83
+ /*#__PURE__*/ _jsx("span", {}),
84
+ /*#__PURE__*/ _jsx("span", {})
85
+ ]
86
+ })
82
87
  ]
83
88
  }),
84
- ordered.filter(({ arm })=>doc.kind !== 'page' || arm.kind !== 'holdout').map(({ arm, index })=>/*#__PURE__*/ _jsxs("article", {
89
+ ordered.filter(({ arm })=>doc.kind !== 'page' || arm.kind !== 'holdout').map(({ arm, index })=>{
90
+ const name = contentOnCanvas ? /*#__PURE__*/ _jsx("span", {
91
+ children: arm.label
92
+ }) : /*#__PURE__*/ _jsx(TextEdit, {
93
+ test: test,
94
+ label: `${GROUP_LABELS[arm.key]}: ${C.label}`,
95
+ value: arm.label,
96
+ reason: reason,
97
+ hideLabel: true,
98
+ onCommit: (label)=>update((arms)=>arms.map((current)=>current.key === arm.key ? {
99
+ ...current,
100
+ label
101
+ } : current))
102
+ });
103
+ const weight = /*#__PURE__*/ _jsx(TextEdit, {
104
+ test: test,
105
+ draftKey: `share:${arm.key}`,
106
+ label: `${GROUP_LABELS[arm.key]}: ${C.weight}`,
107
+ type: "number",
108
+ min: 0,
109
+ max: 100,
110
+ value: doc.arms[index].weight,
111
+ preview: weightEdit?.key !== arm.key ? arm.weight : undefined,
112
+ scope: split,
113
+ reason: reason,
114
+ hideLabel: !setting,
115
+ isValid: (raw)=>raw.trim() !== '' && Number.isInteger(Number(raw)) && Number(raw) >= 0 && Number(raw) <= 100,
116
+ invalidMessage: C.invalidShare,
117
+ onDraft: (value)=>setWeightEdit(value === null ? null : {
118
+ split,
119
+ key: arm.key,
120
+ weight: Number(value)
121
+ }),
122
+ onCommit: (value)=>update((arms)=>balanceWeight(arms, arm.key, Number(value)))
123
+ });
124
+ const remove = !reason && !contentOnCanvas && arm.kind !== 'control' ? /*#__PURE__*/ _jsx(Button, {
125
+ variant: "quiet",
126
+ size: "sm",
127
+ onClick: ()=>update((arms)=>splitEvenly(removeArm(arms, arm.key))),
128
+ children: C.remove
129
+ }) : null;
130
+ return /*#__PURE__*/ _jsxs("article", {
85
131
  className: "xp-version-row",
86
132
  id: `xp-version-${arm.key}`,
133
+ "aria-label": arm.label,
87
134
  tabIndex: -1,
88
135
  children: [
89
- contentOnCanvas ? /*#__PURE__*/ _jsx("span", {
90
- children: arm.label
91
- }) : /*#__PURE__*/ _jsx(TextEdit, {
92
- test: test,
93
- label: `${GROUP_LABELS[arm.key]}: ${C.label}`,
94
- value: arm.label,
95
- reason: reason,
96
- hideLabel: true,
97
- disabled: Boolean(reason),
98
- onCommit: (label)=>update((arms)=>arms.map((current)=>current.key === arm.key ? {
99
- ...current,
100
- label
101
- } : current))
102
- }),
103
- /*#__PURE__*/ _jsx(TextEdit, {
104
- test: test,
105
- draftKey: `share:${arm.key}`,
106
- label: `${GROUP_LABELS[arm.key]}: ${C.weight}`,
107
- type: "number",
108
- min: 0,
109
- max: 100,
110
- value: doc.arms[index].weight,
111
- preview: weightEdit?.key !== arm.key ? arm.weight : undefined,
112
- scope: split,
113
- reason: reason,
114
- hideLabel: true,
115
- disabled: Boolean(reason),
116
- isValid: (raw)=>raw.trim() !== '' && Number.isInteger(Number(raw)) && Number(raw) >= 0 && Number(raw) <= 100,
117
- invalidMessage: C.invalidShare,
118
- onDraft: (value)=>setWeightEdit(value === null ? null : {
119
- split,
120
- key: arm.key,
121
- weight: Number(value)
122
- }),
123
- onCommit: (value)=>update((arms)=>balanceWeight(arms, arm.key, Number(value)))
136
+ setting ? /*#__PURE__*/ _jsxs("div", {
137
+ className: "xp-setting-version-name",
138
+ children: [
139
+ name,
140
+ !reason || test.fieldDrafts?.[`share:${arm.key}`] ? weight : null,
141
+ remove
142
+ ]
143
+ }) : /*#__PURE__*/ _jsxs(_Fragment, {
144
+ children: [
145
+ name,
146
+ weight
147
+ ]
124
148
  }),
125
149
  /*#__PURE__*/ _jsx(parts.VersionContent, {
126
150
  test: test,
@@ -128,17 +152,10 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
128
152
  armIndex: index,
129
153
  summary: contentOnCanvas
130
154
  }),
131
- /*#__PURE__*/ _jsx("div", {
155
+ !setting && !reason ? /*#__PURE__*/ _jsx("div", {
132
156
  className: "xp-ui-button-group xp-version-remove",
133
- children: !contentOnCanvas && arm.kind !== 'control' ? /*#__PURE__*/ _jsx(Button, {
134
- variant: "quiet",
135
- size: "sm",
136
- disabled: Boolean(reason),
137
- title: reason ?? undefined,
138
- onClick: ()=>update((arms)=>splitEvenly(removeArm(arms, arm.key))),
139
- children: C.remove
140
- }) : null
141
- }),
157
+ children: remove
158
+ }) : null,
142
159
  issues.rows[index]?.map((issue, i)=>/*#__PURE__*/ _jsx("p", {
143
160
  role: "alert",
144
161
  children: issueMessage(issue, totalWeight(live))
@@ -148,7 +165,8 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
148
165
  path: `arms.${index}`
149
166
  })
150
167
  ]
151
- }, arm.key))
168
+ }, arm.key);
169
+ })
152
170
  ]
153
171
  }),
154
172
  /*#__PURE__*/ _jsx("div", {
@@ -178,10 +196,10 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
178
196
  ]
179
197
  }, arm.key))
180
198
  }),
181
- /*#__PURE__*/ _jsx("p", {
199
+ !reason ? /*#__PURE__*/ _jsx("p", {
182
200
  className: "xp-ui-help",
183
201
  children: C.balanceHelp
184
- }),
202
+ }) : null,
185
203
  issues.form.map((issue, i)=>/*#__PURE__*/ _jsx("p", {
186
204
  role: "alert",
187
205
  children: issueMessage(issue, totalWeight(live))
@@ -190,22 +208,20 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
190
208
  role: "alert",
191
209
  children: test.errors.arms
192
210
  }) : null,
193
- !contentOnCanvas ? /*#__PURE__*/ _jsxs("div", {
211
+ !reason && !contentOnCanvas ? /*#__PURE__*/ _jsxs("div", {
194
212
  className: "xp-section-actions xp-ui-button-group",
195
- title: reason ?? undefined,
196
213
  children: [
197
214
  /*#__PURE__*/ _jsx(Button, {
198
- disabled: Boolean(reason) || doc.arms.filter((arm)=>arm.kind === 'variant').length >= 3,
215
+ disabled: doc.arms.filter((arm)=>arm.kind === 'variant').length >= 3,
199
216
  onClick: ()=>update((arms)=>addVariant(arms, doc.kind)),
200
217
  children: C.addVersion
201
218
  }),
202
219
  doc.kind !== 'page' ? /*#__PURE__*/ _jsx(Button, {
203
- disabled: Boolean(reason) || doc.arms.some((arm)=>arm.kind === 'holdout'),
220
+ disabled: doc.arms.some((arm)=>arm.kind === 'holdout'),
204
221
  onClick: ()=>update(addHoldoutArm),
205
222
  children: C.addHoldout
206
223
  }) : null,
207
224
  /*#__PURE__*/ _jsx(Button, {
208
- disabled: Boolean(reason),
209
225
  onClick: ()=>update(splitEvenly),
210
226
  children: C.split
211
227
  })
@@ -213,12 +229,11 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
213
229
  }) : null,
214
230
  doc.kind !== 'page' && doc.arms.some((arm)=>arm.kind === 'holdout') ? /*#__PURE__*/ _jsx("p", {
215
231
  className: "xp-ui-help",
216
- children: ARMS_COPY.holdout
232
+ children: ARMS_COPY.holdout(actionGroupLabel('control', doc.arms.find((arm)=>arm.key === 'control')?.label))
217
233
  }) : null,
218
234
  allocationReason && !allocationEdit.dirty ? /*#__PURE__*/ _jsx(ReadOnly, {
219
235
  label: C.allocation,
220
- value: `${doc.allocation}%`,
221
- reason: allocationReason
236
+ value: `${doc.allocation}%`
222
237
  }) : /*#__PURE__*/ _jsx(Range, {
223
238
  id: id,
224
239
  label: C.allocation,
@@ -259,11 +274,16 @@ export function VersionsSection({ test, surface, parts, contentOnCanvas = false
259
274
  id: allocationConflict,
260
275
  value: `${doc.allocation}%`,
261
276
  reason: allocationReason,
277
+ showReason: false,
262
278
  conflict: allocationEdit.conflict,
263
279
  announce: announcement,
264
280
  onKeep: !allocationReason && !test.stale ? ()=>commitAllocation(true) : undefined,
265
281
  onDiscard: allocationEdit.discard
266
282
  }) : null,
283
+ doc.status === 'running' ? /*#__PURE__*/ _jsx("p", {
284
+ className: "xp-ui-help",
285
+ children: doc.allocation >= 100 ? C.everyoneMatches : LOCKED_MESSAGES.runningAllocation
286
+ }) : null,
267
287
  /*#__PURE__*/ _jsx("p", {
268
288
  children: allocationSentence({
269
289
  allocation: allocationReason ? doc.allocation : allocation,
@@ -8,11 +8,11 @@ export declare function FieldErrors({ test, path }: {
8
8
  test: TestDocApi;
9
9
  path: string;
10
10
  }): import("react").JSX.Element;
11
- export declare function ReadOnly({ label, value, reason, labelAction }: {
11
+ export declare function ReadOnly({ label, value, labelAction, hideLabel }: {
12
12
  label: string;
13
13
  value: ReactNode;
14
- reason: string | null;
15
14
  labelAction?: ReactNode;
15
+ hideLabel?: boolean;
16
16
  }): import("react").JSX.Element;
17
17
  export declare function useFieldDraft(test: TestDocApi, key: string, label: string, saved: string, scope?: string): {
18
18
  value: string;
@@ -24,10 +24,11 @@ export declare function useFieldDraft(test: TestDocApi, key: string, label: stri
24
24
  submit(save: () => boolean | void): void;
25
25
  discard(): void;
26
26
  };
27
- export declare function SavedValueChanged({ id, value, reason, conflict, announce, onKeep, onDiscard }: {
27
+ export declare function SavedValueChanged({ id, value, reason, showReason, conflict, announce, onKeep, onDiscard }: {
28
28
  id: string;
29
29
  value: string;
30
30
  reason?: string | null;
31
+ showReason?: boolean;
31
32
  conflict: boolean;
32
33
  announce: number;
33
34
  onKeep?: () => void;
@@ -24,12 +24,11 @@ export function FieldErrors({ test, path }) {
24
24
  }, key))
25
25
  });
26
26
  }
27
- export function ReadOnly({ label, value, reason, labelAction }) {
27
+ export function ReadOnly({ label, value, labelAction, hideLabel }) {
28
28
  return /*#__PURE__*/ _jsxs("div", {
29
29
  className: "xp-read-only",
30
- title: reason ?? undefined,
31
30
  children: [
32
- /*#__PURE__*/ _jsxs("div", {
31
+ !hideLabel ? /*#__PURE__*/ _jsxs("div", {
33
32
  className: "xp-ui-field-label",
34
33
  children: [
35
34
  /*#__PURE__*/ _jsx("strong", {
@@ -37,13 +36,10 @@ export function ReadOnly({ label, value, reason, labelAction }) {
37
36
  }),
38
37
  labelAction
39
38
  ]
40
- }),
39
+ }) : null,
41
40
  /*#__PURE__*/ _jsx("p", {
42
41
  children: value
43
- }),
44
- reason ? /*#__PURE__*/ _jsx("small", {
45
- children: reason
46
- }) : null
42
+ })
47
43
  ]
48
44
  });
49
45
  }
@@ -80,7 +76,7 @@ export function useFieldDraft(test, key, label, saved, scope) {
80
76
  }
81
77
  };
82
78
  }
83
- export function SavedValueChanged({ id, value, reason, conflict, announce, onKeep, onDiscard }) {
79
+ export function SavedValueChanged({ id, value, reason, showReason = true, conflict, announce, onKeep, onDiscard }) {
84
80
  return /*#__PURE__*/ _jsx("div", {
85
81
  id: id,
86
82
  className: "xp-field-draft-notice",
@@ -104,7 +100,7 @@ export function SavedValueChanged({ id, value, reason, conflict, announce, onKee
104
100
  }),
105
101
  children: /*#__PURE__*/ _jsxs("span", {
106
102
  children: [
107
- reason ?? (conflict ? C.savedValueChanged : null),
103
+ reason ? showReason ? reason : null : conflict ? C.savedValueChanged : null,
108
104
  ' ',
109
105
  onKeep && conflict ? C.conflictChoice : C.draftNotSaved,
110
106
  ' ',
@@ -158,15 +154,14 @@ export function SavedValueChanged({ id, value, reason, conflict, announce, onKee
158
154
  edit.submit(()=>onCommit(draft));
159
155
  onDraft?.(null);
160
156
  };
161
- if (reason && !disabled && !edit.dirty) return /*#__PURE__*/ _jsx(ReadOnly, {
157
+ if (reason && !edit.dirty) return /*#__PURE__*/ _jsx(ReadOnly, {
162
158
  label: label,
163
- value: value === '' && placeholder ? placeholder : value,
164
- reason: reason
159
+ hideLabel: hideLabel,
160
+ value: value === '' && placeholder ? placeholder : value
165
161
  });
166
162
  const Input = multiline ? Textarea : type === 'number' ? NumberInput : TextInput;
167
163
  return /*#__PURE__*/ _jsxs("div", {
168
164
  className: hideLabel ? 'xp-grid-field' : undefined,
169
- title: reason ?? undefined,
170
165
  children: [
171
166
  /*#__PURE__*/ _jsx(Input, {
172
167
  id: id,
@@ -206,6 +201,7 @@ export function SavedValueChanged({ id, value, reason, conflict, announce, onKee
206
201
  id: choiceId,
207
202
  value: String(value),
208
203
  reason: reason,
204
+ showReason: false,
209
205
  conflict: edit.conflict,
210
206
  announce: announcement,
211
207
  onKeep: !locked && !test.stale && !error ? ()=>commit(true) : undefined,
@@ -220,7 +216,6 @@ export function SelectEdit({ label, value, options, groups, reason, onCommit, re
220
216
  if (reason) {
221
217
  return /*#__PURE__*/ _jsx(ReadOnly, {
222
218
  label: label,
223
- reason: reason,
224
219
  labelAction: labelAction,
225
220
  value: readOnlyValue ?? options.find((o)=>o.value === value)?.label ?? value
226
221
  });
@@ -250,7 +245,6 @@ export function CheckboxList({ label, value, options, reason, onToggle, readOnly
250
245
  const id = useId();
251
246
  if (reason) return /*#__PURE__*/ _jsx(ReadOnly, {
252
247
  label: label,
253
- reason: reason,
254
248
  value: readOnlyValue ?? value.map((v)=>options.find((o)=>o.value === v)?.label ?? v).join(', ')
255
249
  });
256
250
  return /*#__PURE__*/ _jsx(UICheckboxList, {