@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
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { createPortal } from 'react-dom';
4
4
  import { createUsePuck, useGetPuck, FieldGroup } from '@puckeditor/core';
5
- import { useCallback, useEffect, useRef, useState } from 'react';
5
+ import { useCallback, useEffect, useId, useRef, useState } from 'react';
6
6
  import { defaultArms } from '../../arms/model.js';
7
7
  import { BLOCK_SLOTS } from '../../blocks/model.js';
8
8
  import { publishOutlineVersion } from './outlineVersion.js';
@@ -19,6 +19,8 @@ import { documentChanged, readPreflight, statusOrRoundChanged } from '../../test
19
19
  import { classifyReadinessRead } from '../../testSurface/readinessRead.js';
20
20
  import { READINESS_COPY } from '../../testSurface/copy/readiness.js';
21
21
  import { TEST_PAGE } from '../../testSurface/copy/testPage.js';
22
+ import { lockedReason } from '../../testSurface/lockedNotice.model.js';
23
+ import { EDITABLE_BY_STATUS } from '../../collections/experiments/editability.js';
22
24
  import { useOnTestReturn } from '../../testSurface/useOnTestReturn.js';
23
25
  import { useReadinessPolling } from '../../testSurface/useReadinessPolling.js';
24
26
  import { PlacementNotice } from './PlacementNotice.js';
@@ -65,6 +67,42 @@ function isExperiment(value) {
65
67
  'holdout'
66
68
  ].includes(arm.kind) && typeof arm.label === 'string');
67
69
  }
70
+ function SidebarMore({ children }) {
71
+ const id = useId();
72
+ const [open, setOpen] = useState(false);
73
+ return /*#__PURE__*/ _jsxs("div", {
74
+ className: "xp-slot-more",
75
+ children: [
76
+ /*#__PURE__*/ _jsxs(Button, {
77
+ variant: "quiet",
78
+ size: "sm",
79
+ "aria-expanded": open,
80
+ "aria-controls": id,
81
+ onClick: ()=>setOpen((current)=>!current),
82
+ children: [
83
+ editorCopy.moreGroup,
84
+ /*#__PURE__*/ _jsx("svg", {
85
+ width: "12",
86
+ height: "12",
87
+ viewBox: "0 0 12 12",
88
+ fill: "none",
89
+ "aria-hidden": "true",
90
+ children: /*#__PURE__*/ _jsx("path", {
91
+ d: "M2.5 4.5 6 8l3.5-3.5",
92
+ stroke: "currentColor",
93
+ strokeWidth: "1.5"
94
+ })
95
+ })
96
+ ]
97
+ }),
98
+ /*#__PURE__*/ _jsx("div", {
99
+ id: id,
100
+ hidden: !open,
101
+ children: children
102
+ })
103
+ ]
104
+ });
105
+ }
68
106
  function EditorRender(props) {
69
107
  const getPuck = useGetPuck();
70
108
  const sidebar = useSidebarTargets(props.id);
@@ -142,7 +180,8 @@ function EditorRender(props) {
142
180
  const creation = useRef(undefined);
143
181
  useEffect(()=>()=>creation.current?.closeIfIdle(), []);
144
182
  // A non-empty variant is only overwritten after an explicit second confirmation.
145
- const [confirming, setConfirming] = useState(null);
183
+ const [copyConfirmation, setCopyConfirmation] = useState(null);
184
+ const confirming = copyConfirmation?.key === bindingKey ? copyConfirmation.slot : undefined;
146
185
  // A Remove refusal stays with its open dialog, even if the version disappears or the test locks.
147
186
  // Close on a binding change, Cancel/Escape, or success; only then discard its refusal.
148
187
  // Split/Add refusals survive the locking read, then clear on a later status change;
@@ -339,7 +378,14 @@ function EditorRender(props) {
339
378
  readinessRead,
340
379
  readTest
341
380
  ]);
342
- const editable = canManage && setupStatus && !statusChanged;
381
+ const editable = canManage && !!experiment && !lockedReason(experiment.status, 'arms', EDITABLE_BY_STATUS) && !statusChanged;
382
+ useEffect(()=>{
383
+ if (!editable || copyConfirmation && copyConfirmation.key !== bindingKey) setCopyConfirmation(null);
384
+ }, [
385
+ bindingKey,
386
+ copyConfirmation,
387
+ editable
388
+ ]);
343
389
  const [removed, setRemoved] = useState(null);
344
390
  useEffect(()=>{
345
391
  // Dialog cleanup must close the native modal before an outside tab can receive focus.
@@ -462,13 +508,18 @@ function EditorRender(props) {
462
508
  });
463
509
  }
464
510
  function requestCopy(variant) {
511
+ if (!editable || !isCurrentBinding()) return;
465
512
  const item = getPuck().getItemById(props.id);
466
513
  const target = item?.props[variant];
467
- if (Array.isArray(target) && target.length) setConfirming(variant);
514
+ if (Array.isArray(target) && target.length) setCopyConfirmation({
515
+ key: bindingKey,
516
+ slot: variant
517
+ });
468
518
  else copyTo(variant);
469
519
  }
470
520
  function copyTo(variant) {
471
- setConfirming(null);
521
+ setCopyConfirmation(null);
522
+ if (!editable || !isCurrentBinding()) return;
472
523
  const { getItemById, dispatch, getSelectorForId } = getPuck();
473
524
  const item = getItemById(props.id);
474
525
  if (!item || !Array.isArray(item.props.control) || !item.props.control.length) return;
@@ -708,26 +759,28 @@ function EditorRender(props) {
708
759
  const contentNotice = sidebar && editable && surface && quickTest.doc ? editorContentNotice(currentPreflight, pageReadinessContext(quickTest.doc, currentPreflight, surface)) : undefined;
709
760
  usePlacementNotice(api, experimentId, canManage ? placementNotice ?? contentNotice : undefined, contentLocale);
710
761
  usePageSaveReadiness(api, sidebar && canManage ? experimentId : undefined, editorPage, contentLocale);
711
- const placementNoticeView = /*#__PURE__*/ _jsxs(_Fragment, {
712
- children: [
713
- nestedNotice ? /*#__PURE__*/ _jsx(Banner, {
714
- tone: "info",
715
- children: nestedNotice
716
- }) : null,
717
- visibilityNotice ? /*#__PURE__*/ _jsx(Banner, {
718
- tone: "info",
719
- children: visibilityNotice
720
- }) : null,
721
- canManage ? /*#__PURE__*/ _jsx(PlacementNotice, {
722
- read: quickTest.preflightRead,
723
- message: placementMessage,
724
- running: experiment?.status === 'running',
725
- onRetry: ()=>{
726
- if (experimentId !== undefined) void refreshPlacements(api, experimentId, contentLocale);
727
- }
728
- }) : null
729
- ]
730
- });
762
+ const runningInSidebar = !!(sidebar && showVersions && experiment.status === 'running' && !statusChanged);
763
+ const runningPlacement = runningInSidebar && canManage && !quickTest.preflightRead?.message ? placementMessage : undefined;
764
+ const placementNoticeView = (inSidebar)=>/*#__PURE__*/ _jsxs(_Fragment, {
765
+ children: [
766
+ nestedNotice ? /*#__PURE__*/ _jsx(Banner, {
767
+ tone: "info",
768
+ children: nestedNotice
769
+ }) : null,
770
+ visibilityNotice ? /*#__PURE__*/ _jsx(Banner, {
771
+ tone: "info",
772
+ children: visibilityNotice
773
+ }) : null,
774
+ canManage && (inSidebar || !runningInSidebar) ? /*#__PURE__*/ _jsx(PlacementNotice, {
775
+ read: quickTest.preflightRead,
776
+ message: runningPlacement ? undefined : placementMessage,
777
+ running: experiment?.status === 'running',
778
+ onRetry: ()=>{
779
+ if (experimentId !== undefined) void refreshPlacements(api, experimentId, contentLocale);
780
+ }
781
+ }) : null
782
+ ]
783
+ });
731
784
  const sidebarTest = currentPreflight && editorPage && nestedNotice && !hidden ? {
732
785
  ...quickTest,
733
786
  preflight: {
@@ -796,7 +849,7 @@ function EditorRender(props) {
796
849
  }) : experimentId !== undefined && (noAccess || unavailable || resultsOnly) ? /*#__PURE__*/ _jsx("p", {
797
850
  className: "xp-ui-help",
798
851
  children: resultsOnly ? pickerCopy.resultsOnly : pickerCopy.forbidden
799
- }) : /*#__PURE__*/ _jsxs(Banner, {
852
+ }) : runningInSidebar ? null : /*#__PURE__*/ _jsxs(Banner, {
800
853
  tone: experiment?.status === 'running' ? 'warning' : 'info',
801
854
  children: [
802
855
  experimentId === undefined ? bannerFor() : experiment ? statusChanged ? READINESS_COPY.checking : bannerFor(experiment.status, winner, originalLabel, experiment.decision ?? null) : editorCopy.loading,
@@ -825,6 +878,13 @@ function EditorRender(props) {
825
878
  onClose: ()=>setRemoving(null)
826
879
  }) : null;
827
880
  const replacingLabel = confirming ? tabs.find((tab)=>tab.slot === confirming)?.label ?? confirming : undefined;
881
+ const more = access.surface?.canManage && experimentId !== undefined ? /*#__PURE__*/ _jsx(SidebarMore, {
882
+ children: /*#__PURE__*/ _jsx(Button, {
883
+ disabled: hasSidebarDraft,
884
+ onClick: ()=>setChoosing(true),
885
+ children: editorCopy.differentTest
886
+ })
887
+ }) : null;
828
888
  return /*#__PURE__*/ _jsxs("section", {
829
889
  ref: root,
830
890
  className: "xp-slot-root xp-slot-editor",
@@ -859,7 +919,7 @@ function EditorRender(props) {
859
919
  tone: "info",
860
920
  children: editorCopy.sharedTest
861
921
  }) : null,
862
- placementNoticeView,
922
+ placementNoticeView(true),
863
923
  editable ? /*#__PURE__*/ _jsx(BlockerList, {
864
924
  steps: sidebarBlockers
865
925
  }) : null,
@@ -935,6 +995,7 @@ function EditorRender(props) {
935
995
  collapsible: false,
936
996
  children: /*#__PURE__*/ _jsx(VersionLock, {
937
997
  message: versionLockMessage,
998
+ detail: runningPlacement,
938
999
  children: (lockId)=>/*#__PURE__*/ _jsx(_Fragment, {
939
1000
  children: /*#__PURE__*/ _jsx(VersionWeights, {
940
1001
  edits: weightEdits,
@@ -944,7 +1005,7 @@ function EditorRender(props) {
944
1005
  experiment: experiment,
945
1006
  writes: writes,
946
1007
  editable: editable,
947
- showSplit: canManage,
1008
+ showSplit: editable,
948
1009
  beforeActions: leftoverControls,
949
1010
  beforeSplit: editable ? /*#__PURE__*/ _jsx(AddVariant, {
950
1011
  experiment: experiment,
@@ -978,7 +1039,7 @@ function EditorRender(props) {
978
1039
  ]
979
1040
  }, `${experimentId}-${arm.key}`),
980
1041
  input,
981
- arm.kind === 'variant' || arm.kind === 'holdout' && editable ? /*#__PURE__*/ _jsxs("div", {
1042
+ editable && (arm.kind === 'variant' || arm.kind === 'holdout') ? /*#__PURE__*/ _jsxs("div", {
982
1043
  className: "xp-slot-version-actions",
983
1044
  children: [
984
1045
  arm.kind === 'variant' ? /*#__PURE__*/ _jsx(Button, {
@@ -1014,7 +1075,7 @@ function EditorRender(props) {
1014
1075
  className: "xp-ui-help xp-slot-version-help",
1015
1076
  children: editorCopy.holdoutContent
1016
1077
  }) : null,
1017
- arm.kind === 'variant' && originalEmpty ? /*#__PURE__*/ _jsx("p", {
1078
+ editable && arm.kind === 'variant' && originalEmpty ? /*#__PURE__*/ _jsx("p", {
1018
1079
  className: "xp-ui-help xp-slot-version-help",
1019
1080
  children: editorCopy.copyEmpty(originalLabel)
1020
1081
  }) : null
@@ -1025,15 +1086,6 @@ function EditorRender(props) {
1025
1086
  }, bindingKey)
1026
1087
  })
1027
1088
  }) : null,
1028
- access.surface?.canManage && experimentId !== undefined ? /*#__PURE__*/ _jsx(FieldGroup, {
1029
- label: editorCopy.moreGroup,
1030
- defaultExpanded: false,
1031
- children: /*#__PURE__*/ _jsx(Button, {
1032
- disabled: hasSidebarDraft,
1033
- onClick: ()=>setChoosing(true),
1034
- children: editorCopy.differentTest
1035
- })
1036
- }) : null,
1037
1089
  writes.busy ? /*#__PURE__*/ _jsx("p", {
1038
1090
  role: "status",
1039
1091
  children: editorCopy.savingVersions
@@ -1062,14 +1114,15 @@ function EditorRender(props) {
1062
1114
  id: experimentId,
1063
1115
  api: api,
1064
1116
  experiment: experiment,
1117
+ more: more,
1065
1118
  onRefresh: canManage && experiment.status === 'stopped' ? ()=>{
1066
1119
  void quickTest.refreshPreflight(true);
1067
1120
  } : undefined
1068
- }, `results-${experimentId}`) : null,
1069
- confirming && replacingLabel ? /*#__PURE__*/ _jsx(ConfirmDialog, {
1121
+ }, `results-${experimentId}`) : more,
1122
+ editable && confirming && replacingLabel ? /*#__PURE__*/ _jsx(ConfirmDialog, {
1070
1123
  title: editorCopy.replaceTitle(replacingLabel, experiment?.name),
1071
1124
  description: editorCopy.replaceConfirm(replacingLabel, originalLabel),
1072
- onClose: ()=>setConfirming(null),
1125
+ onClose: ()=>setCopyConfirmation(null),
1073
1126
  cancelLabel: editorCopy.cancel,
1074
1127
  confirm: {
1075
1128
  label: editorCopy.replace,
@@ -1142,7 +1195,7 @@ function EditorRender(props) {
1142
1195
  tone: "info",
1143
1196
  children: editorCopy.sharedTest
1144
1197
  }) : null,
1145
- placementNoticeView,
1198
+ placementNoticeView(false),
1146
1199
  setupError && canSetUp ? /*#__PURE__*/ _jsx("p", {
1147
1200
  role: sidebar ? undefined : 'alert',
1148
1201
  children: setupError
@@ -1,6 +1,6 @@
1
1
  import type { ActionTestApi, SurfaceProps } from '../../testSurface/surface/contracts.js';
2
- /** Same transition runner and confirmation as the drawer; Decide stays there. */
2
+ /** Render sidebar actions in the lifecycle model's order. */
3
3
  export declare function QuickTestActions({ test, surface }: {
4
4
  test: ActionTestApi;
5
5
  surface: SurfaceProps;
6
- }): import("react").JSX.Element | null;
6
+ }): import("react").JSX.Element;
@@ -4,26 +4,30 @@ import { READINESS_COPY } from '../../testSurface/copy/readiness.js';
4
4
  import { canStartTest, hasBrowserWritablePrimary, readyToStart } from '../../testSurface/readinessRead.js';
5
5
  import { METRICS_COPY } from '../../testSurface/copy/metrics.js';
6
6
  import { useState } from 'react';
7
- import { Button } from '../../ui/Button.js';
8
7
  import { Banner } from '../../ui/Feedback.js';
9
8
  import { availableActions } from '../../testSurface/actions/actions.model.js';
10
- import { ConfirmAction } from '../../testSurface/surface/readiness/ActionDialogs.js';
9
+ import { LifecycleButton, LifecycleDialog } from '../../testSurface/actions/LifecycleAction.js';
11
10
  import { actionWaitMessage } from '../../testSurface/surface/readiness/SaveStatus.js';
12
- /** Same transition runner and confirmation as the drawer; Decide stays there. */ export function QuickTestActions({ test, surface }) {
11
+ /** Render sidebar actions in the lifecycle model's order. */ export function QuickTestActions({ test, surface }) {
13
12
  const [confirm, setConfirm] = useState(null);
14
13
  const doc = test.doc;
15
- const action = availableActions({
14
+ const actions = availableActions({
16
15
  ...doc,
17
- canManage: surface.canManage
18
- }).find((item)=>doc.status === 'draft' || doc.status === 'stopped' ? item.id === 'start' : doc.status === 'running' && item.id === 'stop');
19
- if (!action && !confirm) return null;
20
- const displayedAction = confirm ?? action;
16
+ canManage: surface.canManage,
17
+ canReadResults: surface.canReadResults
18
+ }).filter((action)=>doc.status === 'running' || action.id === 'start');
19
+ const start = actions.some((action)=>action.id === 'start');
20
+ const startVisible = start && readyToStart(test, surface.editorPlacementMessage) && !test.hasUnsaved;
21
21
  const ready = canStartTest(test, surface.editorPlacementMessage);
22
- const showAction = displayedAction.id !== 'start' || readyToStart(test, surface.editorPlacementMessage) && !test.hasUnsaved;
23
- const wait = displayedAction.id === 'start' ? actionWaitMessage(test) : undefined;
22
+ const wait = start ? actionWaitMessage(test) : undefined;
23
+ const visible = test.statusReadPending ? [] : actions.filter((action)=>action.id !== 'start' || startVisible);
24
+ const triggers = confirm && !visible.some((action)=>action.id === confirm.id) ? [
25
+ ...visible,
26
+ confirm
27
+ ] : visible;
24
28
  return /*#__PURE__*/ _jsxs(_Fragment, {
25
29
  children: [
26
- !test.statusReadPending && displayedAction.id === 'start' && hasBrowserWritablePrimary(test.preflight, doc.metrics?.primary) ? /*#__PURE__*/ _jsx(Banner, {
30
+ !test.statusReadPending && start && hasBrowserWritablePrimary(test.preflight, doc.metrics?.primary) ? /*#__PURE__*/ _jsx(Banner, {
27
31
  tone: "warning",
28
32
  children: METRICS_COPY.browserWritablePrimary
29
33
  }) : null,
@@ -31,26 +35,37 @@ import { actionWaitMessage } from '../../testSurface/surface/readiness/SaveStatu
31
35
  role: "status",
32
36
  children: wait
33
37
  }) : null,
34
- showAction && displayedAction.id === 'start' ? /*#__PURE__*/ _jsx("p", {
38
+ startVisible ? /*#__PURE__*/ _jsx("p", {
35
39
  role: "status",
36
40
  children: READINESS_COPY.ready
37
41
  }) : null,
38
- confirm || showAction && !test.statusReadPending ? /*#__PURE__*/ _jsx(Button, {
39
- disabled: !confirm && displayedAction.id === 'start' && !ready,
40
- "aria-disabled": !!confirm || undefined,
41
- onClick: (event)=>{
42
- if (confirm || !action) return;
43
- event.currentTarget.focus();
44
- setConfirm(action);
45
- },
46
- children: displayedAction.label
42
+ triggers.length ? /*#__PURE__*/ _jsx("div", {
43
+ className: "xp-ui-button-group xp-slot-lifecycle",
44
+ children: triggers.map((action)=>/*#__PURE__*/ _jsx(LifecycleButton, {
45
+ action: action,
46
+ reason: action.unavailable,
47
+ disabled: action.id === 'start' && !ready && !confirm,
48
+ ariaDisabled: !!confirm,
49
+ onClick: ()=>{
50
+ if (!confirm) setConfirm(action);
51
+ }
52
+ }, action.id))
47
53
  }) : null,
48
- confirm ? /*#__PURE__*/ _jsx(ConfirmAction, {
49
- test: test,
50
- surface: surface,
51
- action: confirm,
52
- winnerLabel: "",
53
- onClose: ()=>setConfirm(null)
54
+ confirm ? /*#__PURE__*/ _jsx("div", {
55
+ onClickCapture: (event)=>{
56
+ // Goal creation and other dialog links must leave the current page open.
57
+ const link = event.target.closest('a[href]');
58
+ if (link && !link.getAttribute('href')?.startsWith('#')) {
59
+ link.target = '_blank';
60
+ link.rel = 'noopener noreferrer';
61
+ }
62
+ },
63
+ children: /*#__PURE__*/ _jsx(LifecycleDialog, {
64
+ test: test,
65
+ surface: surface,
66
+ action: confirm,
67
+ onClose: ()=>setConfirm(null)
68
+ })
54
69
  }) : null
55
70
  ]
56
71
  });
@@ -1,7 +1,9 @@
1
+ import type { ReactNode } from 'react';
1
2
  import type { EditorExperiment } from './editor.model.js';
2
- export declare function ResultsReadout({ id, api, experiment, onRefresh }: {
3
+ export declare function ResultsReadout({ id, api, experiment, more, onRefresh }: {
3
4
  id: string | number;
4
5
  api: string;
5
6
  experiment: EditorExperiment;
7
+ more?: ReactNode;
6
8
  onRefresh?: () => void;
7
9
  }): import("react").JSX.Element;
@@ -4,7 +4,7 @@ import { useEffect, useRef, useState } from 'react';
4
4
  import { Button } from '../../ui/Button.js';
5
5
  import { formatCount } from '../../testSurface/results/format.js';
6
6
  import { editorCopy as C } from './copy.js';
7
- export function ResultsReadout({ id, api, experiment, onRefresh }) {
7
+ export function ResultsReadout({ id, api, experiment, more, onRefresh }) {
8
8
  const [data, setData] = useState(null);
9
9
  const [refresh, setRefresh] = useState(0);
10
10
  const pending = useRef(false);
@@ -56,17 +56,41 @@ export function ResultsReadout({ id, api, experiment, onRefresh }) {
56
56
  refresh,
57
57
  experiment.status
58
58
  ]);
59
+ const collecting = data && data !== 'unavailable' && data.headline === C.collecting;
59
60
  return /*#__PURE__*/ _jsxs("div", {
60
61
  className: "xp-slot-readout",
61
62
  children: [
63
+ /*#__PURE__*/ _jsxs("div", {
64
+ className: "xp-slot-readout-bar",
65
+ children: [
66
+ more,
67
+ collecting ? /*#__PURE__*/ _jsx("strong", {
68
+ className: "xp-slot-readout-status",
69
+ children: C.collecting
70
+ }) : null,
71
+ /*#__PURE__*/ _jsx(Button, {
72
+ variant: "quiet",
73
+ size: "sm",
74
+ className: "xp-slot-readout-refresh",
75
+ disabled: busy,
76
+ onClick: ()=>{
77
+ if (pending.current) return;
78
+ pending.current = true;
79
+ setRefresh((value)=>value + 1);
80
+ onRefresh?.();
81
+ },
82
+ children: C.refresh
83
+ })
84
+ ]
85
+ }),
62
86
  data === 'unavailable' ? /*#__PURE__*/ _jsx("p", {
63
87
  className: "xp-ui-help",
64
88
  children: C.resultsUnavailable
65
89
  }) : data ? /*#__PURE__*/ _jsxs(_Fragment, {
66
90
  children: [
67
- /*#__PURE__*/ _jsx("strong", {
91
+ !collecting ? /*#__PURE__*/ _jsx("strong", {
68
92
  children: data.headline
69
- }),
93
+ }) : null,
70
94
  data.people ? /*#__PURE__*/ _jsx("div", {
71
95
  className: "xp-slot-people",
72
96
  children: [
@@ -85,19 +109,7 @@ export function ResultsReadout({ id, api, experiment, onRefresh }) {
85
109
  role: "status",
86
110
  className: "xp-ui-help",
87
111
  children: C.refreshing
88
- }) : null,
89
- /*#__PURE__*/ _jsx(Button, {
90
- variant: "quiet",
91
- size: "sm",
92
- disabled: busy,
93
- onClick: ()=>{
94
- if (pending.current) return;
95
- pending.current = true;
96
- setRefresh((value)=>value + 1);
97
- onRefresh?.();
98
- },
99
- children: C.refresh
100
- })
112
+ }) : null
101
113
  ]
102
114
  });
103
115
  }
@@ -13,8 +13,9 @@ export declare function VersionCard({ label, openLabel, active, dragging, intera
13
13
  children: ReactNode;
14
14
  }): import("react").JSX.Element;
15
15
  /** Keep unavailable controls reachable, and explain an attempted edit in place. */
16
- export declare function VersionLock({ message, children }: {
16
+ export declare function VersionLock({ message, detail, children }: {
17
17
  message?: string;
18
+ detail?: string;
18
19
  children: (noticeId?: string) => ReactNode;
19
20
  }): import("react").JSX.Element;
20
21
  export declare function useArmWrites({ url, bindingKey, status, controlKeys, publish, isCurrent, onWrite, onSaved }: {
@@ -43,7 +43,7 @@ const VersionLockContext = /*#__PURE__*/ createContext(undefined);
43
43
  })
44
44
  });
45
45
  }
46
- /** Keep unavailable controls reachable, and explain an attempted edit in place. */ export function VersionLock({ message, children }) {
46
+ /** Keep unavailable controls reachable, and explain an attempted edit in place. */ export function VersionLock({ message, detail, children }) {
47
47
  const id = useId();
48
48
  const controls = useRef(null);
49
49
  const notice = useRef(null);
@@ -141,17 +141,23 @@ const VersionLockContext = /*#__PURE__*/ createContext(undefined);
141
141
  }
142
142
  },
143
143
  children: [
144
- message ? /*#__PURE__*/ _jsx("div", {
144
+ message ? /*#__PURE__*/ _jsxs("div", {
145
145
  ref: notice,
146
146
  id: id,
147
147
  className: "xp-slot-lock-notice",
148
148
  "data-attention": attention,
149
- children: attention ? /*#__PURE__*/ _jsx("span", {
150
- role: "alert",
151
- children: message
152
- }, "attention") : /*#__PURE__*/ _jsx("span", {
153
- children: message
154
- }, "rest")
149
+ children: [
150
+ attention ? /*#__PURE__*/ _jsx("span", {
151
+ role: "alert",
152
+ children: message
153
+ }, "attention") : /*#__PURE__*/ _jsx("span", {
154
+ children: message
155
+ }, "rest"),
156
+ detail ? /*#__PURE__*/ _jsx("p", {
157
+ className: "xp-slot-lock-detail",
158
+ children: detail
159
+ }) : null
160
+ ]
155
161
  }) : null,
156
162
  children(message ? id : undefined)
157
163
  ]
@@ -20,7 +20,7 @@ export declare const editorCopy: {
20
20
  readonly closeConfigure: "Close";
21
21
  readonly selectBlock: "Select this test block";
22
22
  readonly deleted: "The test for this block was deleted.";
23
- readonly unbound: "This Experiment block has no test yet.";
23
+ readonly unbound: "This Test block has no test yet.";
24
24
  readonly draft: (label: string) => string;
25
25
  readonly running: "Changing this content mid-test mixes two versions in one result";
26
26
  readonly decided: (winner: string) => string;
@@ -77,7 +77,7 @@ export declare const editorCopy: {
77
77
  readonly removed: "Save the page to finish removing this version's content.";
78
78
  readonly removeUnclearedSteps: readonly ["Delete the leftover content from the outline.", "Save the page."];
79
79
  readonly archivedStepsWhy: "To keep this content on the page without the test, move it into regular blocks.";
80
- readonly archivedSteps: readonly ["Move the content out of the Experiment block on the canvas.", "Remove the Experiment block."];
80
+ readonly archivedSteps: readonly ["Move the content out of the Test block on the canvas.", "Remove the Test block."];
81
81
  readonly removeUncleared: "The version was removed from the test. Its content still needs to be removed from the page.";
82
82
  readonly lockedGeneric: "This test's versions can't change. View the test page for details.";
83
83
  readonly holdoutContent: "Holdout visitors see the Original.";
@@ -86,7 +86,7 @@ export declare const editorCopy: {
86
86
  readonly invalidShare: "Use a whole number from 0 to 100.";
87
87
  readonly split: "Split evenly";
88
88
  readonly locked: {
89
- readonly running: "This test is running, so its versions can't change. Stop it on the test page to edit them.";
89
+ readonly running: "This test is running, so its versions can't change. Editing content during the test mixes two versions in one result.";
90
90
  readonly decided: "This test has a decision, so its versions can't change. View the results on the test page.";
91
91
  readonly archived: "This test is archived, so its versions can't change. View the results on the test page.";
92
92
  };
@@ -16,7 +16,7 @@ export const editorCopy = {
16
16
  closeConfigure: 'Close',
17
17
  selectBlock: 'Select this test block',
18
18
  deleted: 'The test for this block was deleted.',
19
- unbound: 'This Experiment block has no test yet.',
19
+ unbound: 'This Test block has no test yet.',
20
20
  draft: (label)=>`This block shows the ${label} to everyone until the test starts.`,
21
21
  running: 'Changing this content mid-test mixes two versions in one result',
22
22
  decided: (winner)=>`Decided: ${winner}. Use 'Make it the content' on the test to finish.`,
@@ -77,8 +77,8 @@ export const editorCopy = {
77
77
  ],
78
78
  archivedStepsWhy: 'To keep this content on the page without the test, move it into regular blocks.',
79
79
  archivedSteps: [
80
- 'Move the content out of the Experiment block on the canvas.',
81
- 'Remove the Experiment block.'
80
+ 'Move the content out of the Test block on the canvas.',
81
+ 'Remove the Test block.'
82
82
  ],
83
83
  removeUncleared: "The version was removed from the test. Its content still needs to be removed from the page.",
84
84
  lockedGeneric: "This test's versions can't change. View the test page for details.",
@@ -88,7 +88,7 @@ export const editorCopy = {
88
88
  invalidShare: 'Use a whole number from 0 to 100.',
89
89
  split: 'Split evenly',
90
90
  locked: {
91
- running: "This test is running, so its versions can't change. Stop it on the test page to edit them.",
91
+ running: "This test is running, so its versions can't change. Editing content during the test mixes two versions in one result.",
92
92
  decided: "This test has a decision, so its versions can't change. View the results on the test page.",
93
93
  archived: "This test is archived, so its versions can't change. View the results on the test page."
94
94
  },
@@ -115,13 +115,21 @@
115
115
  .xp-slot-weight-inputs { align-items: flex-start; }
116
116
  .xp-slot-weight-inputs .xp-ui-field { flex: 1 1 120px; max-width: 200px; }
117
117
  .xp-slot-readout { display: grid; gap: var(--xp-space-2); }
118
- .xp-slot-readout > .xp-ui-button { justify-self: start; }
118
+ .xp-slot-readout-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: var(--xp-space-2); }
119
+ .xp-slot-readout-status { grid-column: 2; padding-block: var(--xp-space-2); font: var(--xp-text-small); }
120
+ .xp-slot-readout-refresh { grid-column: 3; }
121
+ .xp-slot-more { grid-column: 1; min-width: 0; }
122
+ .xp-slot-more > button { gap: var(--xp-space-2); }
123
+ .xp-slot-more > button[aria-expanded='true'] svg { transform: rotate(180deg); }
124
+ .xp-slot-more > div > button { white-space: normal; }
125
+ .xp-slot-lock-detail { margin: var(--xp-space-2) 0 0; }
119
126
  .xp-slot-editor .xp-ui-tablist { flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
120
127
  .xp-slot-root.xp-puck-field { display: grid; gap: var(--xp-space-3); min-width: 0; }
121
128
 
122
129
  /* Puck's inline field sidebar stays light, including under Payload's dark-mode text overrides. */
123
130
  [class*="_PuckFields"] .xp-slot-root .xp-ui-button--secondary { color: var(--xp-text); }
124
131
  [class*="_PuckFields"] .xp-slot-root .xp-ui-button--primary { color: var(--xp-accent-fg); }
132
+ [class*="_PuckFields"] .xp-slot-root .xp-ui-button--danger { color: var(--xp-error); }
125
133
  [class*="_PuckFields"] .xp-slot-root .xp-ui-error { color: var(--xp-error); }
126
134
  [class*="_PuckFields"] .xp-slot-root .xp-ui-help { color: var(--xp-text-2); }
127
135
  [class*="_PuckFields"] .xp-slot-root .xp-ui-field label { color: var(--xp-text); }
@@ -330,6 +330,7 @@
330
330
  .xp-ui-breadcrumb [aria-current] { color: var(--xp-text); }
331
331
  .xp-ui-dialog { width: min(480px, calc(100% - 32px)); max-height: calc(100% - 32px); overflow: auto; padding: 24px; border: 1px solid var(--xp-border); border-radius: var(--xp-radius-card); background: var(--xp-surface); color: var(--xp-text); font: var(--xp-text-body); box-shadow: 0 16px 48px var(--xp-overlay); }
332
332
  .xp-ui-dialog h2 { margin: 0 0 16px; font: var(--xp-text-title); overflow-wrap: anywhere; }
333
+ .xp-ui-dialog > [id]:has(+ :is(.xp-ui-field, .xp-ui-banner)), .xp-ui-dialog > .xp-ui-banner:has(+ .xp-ui-field) { margin-block-end: var(--xp-space-4); }
333
334
  .xp-ui-dialog::backdrop { background: var(--xp-overlay); }
334
335
  .xp-ui-chips { width: 100%; max-width: 100%; min-width: 0; display: grid; gap: var(--xp-space-2); margin-block: var(--xp-space-4); color: var(--xp-text); font-family: var(--xp-font-body); }
335
336
  .xp-ui-chips-control { width: 100%; max-width: 100%; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: var(--xp-space-1); padding: var(--xp-space-2); border: 1px solid var(--xp-border-control); border-radius: var(--xp-radius); background: var(--xp-input-bg); }
@@ -512,13 +513,21 @@
512
513
  .xp-slot-weight-inputs { align-items: flex-start; }
513
514
  .xp-slot-weight-inputs .xp-ui-field { flex: 1 1 120px; max-width: 200px; }
514
515
  .xp-slot-readout { display: grid; gap: var(--xp-space-2); }
515
- .xp-slot-readout > .xp-ui-button { justify-self: start; }
516
+ .xp-slot-readout-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: start; gap: var(--xp-space-2); }
517
+ .xp-slot-readout-status { grid-column: 2; padding-block: var(--xp-space-2); font: var(--xp-text-small); }
518
+ .xp-slot-readout-refresh { grid-column: 3; }
519
+ .xp-slot-more { grid-column: 1; min-width: 0; }
520
+ .xp-slot-more > button { gap: var(--xp-space-2); }
521
+ .xp-slot-more > button[aria-expanded='true'] svg { transform: rotate(180deg); }
522
+ .xp-slot-more > div > button { white-space: normal; }
523
+ .xp-slot-lock-detail { margin: var(--xp-space-2) 0 0; }
516
524
  .xp-slot-editor .xp-ui-tablist { flex: 1 1 auto; min-width: 0; flex-wrap: wrap; }
517
525
  .xp-slot-root.xp-puck-field { display: grid; gap: var(--xp-space-3); min-width: 0; }
518
526
 
519
527
  /* Puck's inline field sidebar stays light, including under Payload's dark-mode text overrides. */
520
528
  [class*="_PuckFields"] .xp-slot-root .xp-ui-button--secondary { color: var(--xp-text); }
521
529
  [class*="_PuckFields"] .xp-slot-root .xp-ui-button--primary { color: var(--xp-accent-fg); }
530
+ [class*="_PuckFields"] .xp-slot-root .xp-ui-button--danger { color: var(--xp-error); }
522
531
  [class*="_PuckFields"] .xp-slot-root .xp-ui-error { color: var(--xp-error); }
523
532
  [class*="_PuckFields"] .xp-slot-root .xp-ui-help { color: var(--xp-text-2); }
524
533
  [class*="_PuckFields"] .xp-slot-root .xp-ui-field label { color: var(--xp-text); }
@@ -1,4 +1,4 @@
1
- const innerLabel = (inner)=>inner ? `“${inner}”` : 'An Experiment block with no test chosen';
1
+ const innerLabel = (inner)=>inner ? `“${inner}”` : 'A Test block with no test chosen';
2
2
  const outerLabel = (outer)=>outer ? `“${outer}”` : 'another test';
3
3
  const moveLabel = (inner)=>inner ? `“${inner}”` : 'that block';
4
4
  const location = (outer, inner)=>`${innerLabel(inner)} is inside a version of ${outerLabel(outer)}.`;