@delmaredigital/payload-experiments 0.4.0-rc.4 → 0.4.0-rc.6
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.
- package/dist/admin/copy/newTest.d.ts +1 -1
- package/dist/admin/copy/newTest.js +1 -1
- package/dist/admin/surface/ResultsRoute.js +2 -10
- package/dist/admin/surface/newTest/NewTest.js +16 -18
- package/dist/admin/surface/newTest/PageWizard.js +10 -12
- package/dist/admin/surface/newTest/newTest.css +3 -1
- package/dist/admin/surface/results/ResultsHeader.js +15 -8
- package/dist/blocks/bindings.js +6 -13
- package/dist/blocks/placementLocale.d.ts +2 -0
- package/dist/blocks/placementLocale.js +16 -12
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +9 -7
- package/dist/hooks/blockRemovalRule.d.ts +2 -1
- package/dist/hooks/blockRemovalRule.js +27 -5
- package/dist/hooks/pageGuard.js +2 -2
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +34 -30
- package/dist/puck/ExperimentSlot.js +3 -1
- package/dist/puck/copy.d.ts +1 -0
- package/dist/puck/copy.js +1 -0
- package/dist/puck/editor/ConfigureTestDrawer.js +2 -2
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +2 -1
- package/dist/puck/editor/CreateExperimentDrawer.js +24 -16
- package/dist/puck/editor/EditorControls.d.ts +1 -1
- package/dist/puck/editor/EditorControls.js +1 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +624 -299
- package/dist/puck/editor/LeftoverVersions.d.ts +15 -0
- package/dist/puck/editor/LeftoverVersions.js +97 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +3 -0
- package/dist/puck/editor/QuickTestActions.js +50 -0
- package/dist/puck/editor/ResultsReadout.js +5 -0
- package/dist/puck/editor/VersionBuilder.d.ts +37 -12
- package/dist/puck/editor/VersionBuilder.js +273 -184
- package/dist/puck/editor/armWrites.d.ts +11 -2
- package/dist/puck/editor/armWrites.js +42 -3
- package/dist/puck/editor/armsCache.d.ts +1 -1
- package/dist/puck/editor/armsCache.js +2 -1
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +35 -20
- package/dist/puck/editor/copy.js +35 -20
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +32 -14
- package/dist/puck/editor/editor.css +58 -17
- package/dist/puck/editor/editor.model.d.ts +1 -1
- package/dist/puck/editor/editor.model.js +2 -2
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/localPlacements.d.ts +4 -2
- package/dist/puck/editor/localPlacements.js +20 -18
- package/dist/puck/editor/outlineVersion.d.ts +5 -0
- package/dist/puck/editor/outlineVersion.js +36 -0
- package/dist/puck/editor/placementsCache.d.ts +33 -2
- package/dist/puck/editor/placementsCache.js +208 -33
- package/dist/puck/editor/sidebar.d.ts +8 -0
- package/dist/puck/editor/sidebar.js +74 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +14 -0
- package/dist/puck/visibility.d.ts +21 -0
- package/dist/puck/visibility.js +77 -0
- package/dist/server/recordContentChange.js +3 -1
- package/dist/server/resolveExperimentData.js +4 -1
- package/dist/testSurface/api.js +1 -1
- package/dist/testSurface/copy/common.d.ts +1 -1
- package/dist/testSurface/copy/common.js +3 -1
- package/dist/testSurface/copy/readiness.d.ts +18 -1
- package/dist/testSurface/copy/readiness.js +23 -1
- package/dist/testSurface/copy/testPage.d.ts +8 -6
- package/dist/testSurface/copy/testPage.js +8 -6
- package/dist/testSurface/readPreflight.d.ts +9 -0
- package/dist/testSurface/readPreflight.js +38 -0
- package/dist/testSurface/readinessRead.d.ts +50 -0
- package/dist/testSurface/readinessRead.js +46 -0
- package/dist/testSurface/results/results.css +1 -1
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/surface/contracts.d.ts +6 -2
- package/dist/testSurface/surface/editorPlacement.d.ts +21 -0
- package/dist/testSurface/surface/editorPlacement.js +60 -0
- package/dist/testSurface/surface/pageBlock/parts.js +13 -3
- package/dist/testSurface/surface/readiness/ActionDialogs.js +65 -41
- package/dist/testSurface/surface/readiness/Banner.d.ts +1 -4
- package/dist/testSurface/surface/readiness/Banner.js +106 -68
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +6 -2
- package/dist/testSurface/surface/readiness/SaveStatus.js +35 -22
- package/dist/testSurface/surface/readiness/parts.js +0 -2
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +13 -0
- package/dist/testSurface/surface/readiness/readiness.model.js +51 -36
- package/dist/testSurface/surface/readiness/useTransition.d.ts +5 -2
- package/dist/testSurface/surface/readiness/useTransition.js +69 -7
- package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/GoalSection.js +102 -74
- package/dist/testSurface/surface/test/LengthSection.d.ts +1 -1
- package/dist/testSurface/surface/test/LengthSection.js +2 -1
- package/dist/testSurface/surface/test/Rail.js +7 -4
- package/dist/testSurface/surface/test/ReadinessBar.js +1 -2
- package/dist/testSurface/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +38 -6
- package/dist/testSurface/surface/test/TargetingSection.js +5 -0
- package/dist/testSurface/surface/test/TestSurface.d.ts +2 -1
- package/dist/testSurface/surface/test/TestSurface.js +68 -7
- package/dist/testSurface/surface/test/VersionsSection.js +1 -0
- package/dist/testSurface/surface/test/fields.d.ts +1 -3
- package/dist/testSurface/surface/test/fields.js +5 -35
- package/dist/testSurface/surface/test/testPage.css +12 -0
- package/dist/testSurface/surface/useTestDocument.d.ts +5 -2
- package/dist/testSurface/surface/useTestDocument.js +61 -46
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +24 -0
- package/dist/transitions/makeContent.js +24 -5
- package/dist/transitions/placements.js +23 -34
- package/dist/transitions/preflightData.js +1 -1
- package/dist/types/puck.d.ts +1 -0
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/Inputs.js +8 -5
- package/dist/ui/Tabs.d.ts +2 -2
- package/dist/ui/Tabs.js +33 -32
- package/dist/ui/ui.css +26 -3
- package/package.json +1 -1
|
@@ -2,13 +2,16 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useEffect, useRef, useState } from 'react';
|
|
4
4
|
import { SECTION_ORDER } from '../contracts.js';
|
|
5
|
+
import { sectionBlocked } from '../readiness/readiness.model.js';
|
|
5
6
|
import { readinessParts } from '../readiness/parts.js';
|
|
6
7
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
8
|
+
import { READINESS_COPY } from '../../copy/readiness.js';
|
|
7
9
|
import { jumpToSection } from './jumpToSection.js';
|
|
8
10
|
export function Rail({ test }) {
|
|
9
11
|
const [active, setActive] = useState('what');
|
|
10
12
|
const ref = useRef(null);
|
|
11
13
|
const done = readinessParts.sectionDone(test);
|
|
14
|
+
const blocked = (id)=>(test.doc?.status === 'draft' || test.doc?.status === 'stopped') && sectionBlocked(test, id);
|
|
12
15
|
useEffect(()=>{
|
|
13
16
|
if (typeof IntersectionObserver === 'undefined') return;
|
|
14
17
|
const visible = new Map();
|
|
@@ -53,7 +56,7 @@ export function Rail({ test }) {
|
|
|
53
56
|
children: SECTION_ORDER.map((id)=>/*#__PURE__*/ _jsx("li", {
|
|
54
57
|
children: /*#__PURE__*/ _jsxs("a", {
|
|
55
58
|
href: `#section-${id}`,
|
|
56
|
-
className: `xp-test-rail-item${id === 'advanced' ? ' xp-test-rail-item--advanced' : ''}${active === id ? ' is-active' : ''}`,
|
|
59
|
+
className: `xp-test-rail-item${blocked(id) ? ' is-blocked' : ''}${id === 'advanced' ? ' xp-test-rail-item--advanced' : ''}${active === id ? ' is-active' : ''}`,
|
|
57
60
|
"aria-current": active === id ? 'location' : undefined,
|
|
58
61
|
onClick: (event)=>{
|
|
59
62
|
event.preventDefault();
|
|
@@ -65,12 +68,12 @@ export function Rail({ test }) {
|
|
|
65
68
|
children: [
|
|
66
69
|
/*#__PURE__*/ _jsx("span", {
|
|
67
70
|
"aria-hidden": "true",
|
|
68
|
-
className: done[id] ? 'xp-test-rail-mark xp-test-rail-mark--done' : 'xp-test-rail-mark',
|
|
69
|
-
children: done[id] ? C.completeMark : C.incompleteMark
|
|
71
|
+
className: blocked(id) ? 'xp-test-rail-mark xp-test-rail-mark--blocked' : done[id] ? 'xp-test-rail-mark xp-test-rail-mark--done' : 'xp-test-rail-mark',
|
|
72
|
+
children: blocked(id) ? '!' : done[id] ? C.completeMark : C.incompleteMark
|
|
70
73
|
}),
|
|
71
74
|
/*#__PURE__*/ _jsx("span", {
|
|
72
75
|
className: "xp-test-sr-only",
|
|
73
|
-
children: done[id] ? C.completePrefix : C.incompletePrefix
|
|
76
|
+
children: blocked(id) ? READINESS_COPY.needsAttentionPrefix : done[id] ? C.completePrefix : C.incompletePrefix
|
|
74
77
|
})
|
|
75
78
|
]
|
|
76
79
|
}) : null,
|
|
@@ -26,8 +26,7 @@ import { ReadinessContent } from '../readiness/Banner.js';
|
|
|
26
26
|
role: "region",
|
|
27
27
|
"aria-label": C.label,
|
|
28
28
|
children: props.test.doc ? /*#__PURE__*/ _jsx(ReadinessContent, {
|
|
29
|
-
...props
|
|
30
|
-
bar: true
|
|
29
|
+
...props
|
|
31
30
|
}, `${props.test.doc.id}/${props.test.doc.status}`) : null
|
|
32
31
|
});
|
|
33
32
|
}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
2
|
import type { SectionId, TestDocApi } from '../contracts.js';
|
|
3
|
-
|
|
3
|
+
import type { SurfaceProps } from '../contracts.js';
|
|
4
|
+
export declare function Section({ test, sectionId, children, surface }: {
|
|
4
5
|
test: TestDocApi;
|
|
5
6
|
sectionId: SectionId;
|
|
6
7
|
children: ReactNode;
|
|
8
|
+
surface?: SurfaceProps;
|
|
7
9
|
}): import("react").JSX.Element;
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
+
import { blockingSteps, pageReadinessContext, sectionBlocked } from '../readiness/readiness.model.js';
|
|
4
5
|
import { readinessParts } from '../readiness/parts.js';
|
|
5
6
|
import { SectionCard } from '../../../ui/SectionCard.js';
|
|
6
7
|
import { SECTION_ORDER } from '../contracts.js';
|
|
8
|
+
import { fixFieldsNext } from '../../copy/readiness.js';
|
|
7
9
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
8
|
-
export function Section({ test, sectionId, children }) {
|
|
10
|
+
export function Section({ test, sectionId, children, surface }) {
|
|
9
11
|
const hasAdvancedError = Object.keys(test.errors).some((path)=>path.startsWith('analysis.') && ![
|
|
10
12
|
'analysis.reachPerDay',
|
|
11
13
|
'analysis.plannedDurationDays'
|
|
@@ -16,11 +18,34 @@ export function Section({ test, sectionId, children }) {
|
|
|
16
18
|
setPrevHasAdvancedError(hasAdvancedError);
|
|
17
19
|
if (hasAdvancedError) setOpen(true);
|
|
18
20
|
}
|
|
21
|
+
const setup = test.doc?.status === 'draft' || test.doc?.status === 'stopped';
|
|
22
|
+
const blocked = setup && sectionBlocked(test, sectionId);
|
|
23
|
+
const blockers = setup && test.doc ? blockingSteps(test.preflight, surface ? pageReadinessContext(test.doc, test.preflight, surface) : test.doc).filter((step)=>step.section === sectionId) : [];
|
|
19
24
|
const done = readinessParts.sectionDone(test)[sectionId];
|
|
25
|
+
const blockerLines = blockers.map((step, index)=>/*#__PURE__*/ _jsxs("p", {
|
|
26
|
+
className: "xp-ui-error xp-test-blocker",
|
|
27
|
+
children: [
|
|
28
|
+
/*#__PURE__*/ _jsx("span", {
|
|
29
|
+
"aria-hidden": "true",
|
|
30
|
+
children: "⊗ "
|
|
31
|
+
}),
|
|
32
|
+
step.sentence
|
|
33
|
+
]
|
|
34
|
+
}, `${step.code}-${index}`));
|
|
35
|
+
if (setup && sectionId === 'advanced' && hasAdvancedError) blockerLines.push(/*#__PURE__*/ _jsxs("p", {
|
|
36
|
+
className: "xp-ui-error xp-test-blocker",
|
|
37
|
+
children: [
|
|
38
|
+
/*#__PURE__*/ _jsx("span", {
|
|
39
|
+
"aria-hidden": "true",
|
|
40
|
+
children: "⊗ "
|
|
41
|
+
}),
|
|
42
|
+
fixFieldsNext(C.sections.advanced)
|
|
43
|
+
]
|
|
44
|
+
}, "advanced-validation"));
|
|
20
45
|
if (sectionId === 'advanced') return /*#__PURE__*/ _jsxs("details", {
|
|
21
46
|
open: open,
|
|
22
47
|
onToggle: (event)=>setOpen(event.currentTarget.open),
|
|
23
|
-
className:
|
|
48
|
+
className: `xp-test-advanced${blocked ? ' xp-ui-section--blocked' : ''}`,
|
|
24
49
|
id: "section-advanced",
|
|
25
50
|
children: [
|
|
26
51
|
/*#__PURE__*/ _jsx("summary", {
|
|
@@ -30,19 +55,26 @@ export function Section({ test, sectionId, children }) {
|
|
|
30
55
|
children: C.sections.advanced
|
|
31
56
|
})
|
|
32
57
|
}),
|
|
33
|
-
/*#__PURE__*/
|
|
58
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
34
59
|
className: "xp-ui-section-body",
|
|
35
|
-
children:
|
|
60
|
+
children: [
|
|
61
|
+
children,
|
|
62
|
+
blockerLines
|
|
63
|
+
]
|
|
36
64
|
})
|
|
37
65
|
]
|
|
38
66
|
});
|
|
39
|
-
return /*#__PURE__*/
|
|
67
|
+
return /*#__PURE__*/ _jsxs(SectionCard, {
|
|
40
68
|
number: SECTION_ORDER.indexOf(sectionId) + 1,
|
|
41
69
|
title: C.sections[sectionId],
|
|
42
70
|
complete: done,
|
|
71
|
+
blocked: blocked,
|
|
43
72
|
id: `section-${sectionId}`,
|
|
44
73
|
headingId: `title-${sectionId}`,
|
|
45
74
|
className: "xp-test-section",
|
|
46
|
-
children:
|
|
75
|
+
children: [
|
|
76
|
+
children,
|
|
77
|
+
blockerLines
|
|
78
|
+
]
|
|
47
79
|
});
|
|
48
80
|
}
|
|
@@ -22,6 +22,7 @@ export function TargetingSection({ test, surface }) {
|
|
|
22
22
|
const blockPath = (key)=>test.doc.kind === 'block' && key === 'path';
|
|
23
23
|
const keys = Object.keys(surface.attributeKeys).filter((key)=>!blockPath(key));
|
|
24
24
|
return /*#__PURE__*/ _jsxs(Section, {
|
|
25
|
+
surface: surface,
|
|
25
26
|
test: test,
|
|
26
27
|
sectionId: "who",
|
|
27
28
|
children: [
|
|
@@ -179,6 +180,10 @@ export function TargetingSection({ test, surface }) {
|
|
|
179
180
|
]
|
|
180
181
|
}, `${rowsRevision}-${index}`);
|
|
181
182
|
}),
|
|
183
|
+
!reason && !keys.length ? /*#__PURE__*/ _jsx("p", {
|
|
184
|
+
className: "xp-ui-help",
|
|
185
|
+
children: C.noAudienceRules
|
|
186
|
+
}) : null,
|
|
182
187
|
!reason ? /*#__PURE__*/ _jsx("div", {
|
|
183
188
|
className: "xp-ui-button-group",
|
|
184
189
|
children: /*#__PURE__*/ _jsx(Button, {
|
|
@@ -4,7 +4,7 @@ import type { SurfaceProps, TestDocApi } from '../contracts.js';
|
|
|
4
4
|
import type { TestDocument } from '../testDocument.model.js';
|
|
5
5
|
import type { PreflightResult } from '../../../types/endpoints.js';
|
|
6
6
|
import './testPage.css';
|
|
7
|
-
export declare function TestSurface({ id, surface, onTitleChange, renderFrame, embedded, onDocument, onPreflight }: {
|
|
7
|
+
export declare function TestSurface({ id, surface, onTitleChange, renderFrame, embedded, onDocument, onPreflight, requestPreflight }: {
|
|
8
8
|
id: DocId;
|
|
9
9
|
surface: SurfaceProps;
|
|
10
10
|
onTitleChange?: (title: string) => void;
|
|
@@ -15,4 +15,5 @@ export declare function TestSurface({ id, surface, onTitleChange, renderFrame, e
|
|
|
15
15
|
}) => ReactNode;
|
|
16
16
|
onDocument?: (doc: TestDocument) => void;
|
|
17
17
|
onPreflight?: (preflight: PreflightResult) => void;
|
|
18
|
+
requestPreflight?: (signal: AbortSignal, supersede?: boolean) => Promise<Response>;
|
|
18
19
|
}): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | import("react").ReactPortal | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | import("react").JSX.Element | null | undefined;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useState } from 'react';
|
|
3
|
+
import { useEffect, useState, useRef } from 'react';
|
|
4
4
|
import { useTestDocument } from '../useTestDocument.js';
|
|
5
|
+
import { API_MESSAGES } from '../../copy/common.js';
|
|
5
6
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
6
7
|
import { pageBlockParts } from '../pageBlock/parts.js';
|
|
7
8
|
import { settingParts } from '../setting/parts.js';
|
|
@@ -18,10 +19,14 @@ import { Banner } from '../../../ui/Feedback.js';
|
|
|
18
19
|
import { Rail } from './Rail.js';
|
|
19
20
|
import { ReadinessBar } from './ReadinessBar.js';
|
|
20
21
|
import { ResultsBody } from '../results/ResultsBody.js';
|
|
22
|
+
import { usePlacementNotice } from '../../../puck/editor/usePlacementNotice.js';
|
|
23
|
+
import { subscribePlacements, cachedPreflight, cachedReadinessRead, placementsPending, placementsBlocking, placementReadError } from '../../../puck/editor/placementsCache.js';
|
|
24
|
+
import { currentPuckDocument } from '../../../puck/editor/editor.model.js';
|
|
25
|
+
import { editorPlacementMessage, editorPreflight } from '../editorPlacement.js';
|
|
21
26
|
import './testPage.css';
|
|
22
|
-
export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded = false, onDocument, onPreflight }) {
|
|
27
|
+
export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded = false, onDocument, onPreflight, requestPreflight }) {
|
|
23
28
|
const [barHeight, setBarHeight] = useState();
|
|
24
|
-
const
|
|
29
|
+
const documentState = useTestDocument(id, {
|
|
25
30
|
apiRoute: surface.apiRoute,
|
|
26
31
|
refetchPreflightOnFocus: true,
|
|
27
32
|
...!surface.canManage ? {
|
|
@@ -32,8 +37,63 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
32
37
|
} : {},
|
|
33
38
|
...onPreflight ? {
|
|
34
39
|
onPreflight
|
|
40
|
+
} : {},
|
|
41
|
+
...requestPreflight ? {
|
|
42
|
+
requestPreflight
|
|
35
43
|
} : {}
|
|
36
44
|
});
|
|
45
|
+
const [placementRead, setPlacementRead] = useState();
|
|
46
|
+
const placementKey = JSON.stringify([
|
|
47
|
+
surface.apiRoute,
|
|
48
|
+
String(id)
|
|
49
|
+
]);
|
|
50
|
+
const watching = embedded && surface.canManage && documentState.loadState === 'ready';
|
|
51
|
+
useEffect(()=>{
|
|
52
|
+
if (!embedded || !surface.canManage) return;
|
|
53
|
+
return subscribePlacements(surface.apiRoute, id, ()=>setPlacementRead({
|
|
54
|
+
key: placementKey,
|
|
55
|
+
preflight: cachedPreflight(surface.apiRoute, id),
|
|
56
|
+
read: cachedReadinessRead(surface.apiRoute, id),
|
|
57
|
+
pending: placementsPending(surface.apiRoute, id),
|
|
58
|
+
blocking: placementsBlocking(surface.apiRoute, id),
|
|
59
|
+
error: placementReadError(surface.apiRoute, id)
|
|
60
|
+
}));
|
|
61
|
+
}, [
|
|
62
|
+
surface.apiRoute,
|
|
63
|
+
id,
|
|
64
|
+
embedded,
|
|
65
|
+
surface.canManage,
|
|
66
|
+
placementKey
|
|
67
|
+
]);
|
|
68
|
+
const currentRead = documentState.loadState === 'ready' && placementRead?.key === placementKey ? placementRead : undefined;
|
|
69
|
+
const preflight = currentRead ? currentRead.preflight ?? (currentRead.pending && !currentRead.error ? documentState.preflight : null) : documentState.preflight;
|
|
70
|
+
const sharedDocument = currentRead ? {
|
|
71
|
+
...documentState,
|
|
72
|
+
preflight,
|
|
73
|
+
preflightRead: currentRead.read,
|
|
74
|
+
preflightPending: currentRead.pending || documentState.preflightPending,
|
|
75
|
+
preflightError: !preflight ? currentRead.read?.message ?? null : null
|
|
76
|
+
} : documentState;
|
|
77
|
+
const placementFailed = preflight?.checks.some((check)=>!check.ok && check.code === 'no-placements' && check.detail !== undefined);
|
|
78
|
+
const lastPlacements = useRef(undefined);
|
|
79
|
+
if (preflight?.placements && !placementFailed) lastPlacements.current = {
|
|
80
|
+
key: placementKey,
|
|
81
|
+
value: preflight.placements
|
|
82
|
+
};
|
|
83
|
+
const placements = !placementFailed && !sharedDocument.preflightError && lastPlacements.current?.key === placementKey ? lastPlacements.current.value : undefined;
|
|
84
|
+
const editorPage = embedded ? currentPuckDocument(window.location.pathname, surface.adminRoute, placements) ?? surface.editorPage : surface.editorPage;
|
|
85
|
+
const message = editorPlacementMessage(placements, editorPage, documentState.doc?.status);
|
|
86
|
+
surface = {
|
|
87
|
+
...surface,
|
|
88
|
+
editorPage,
|
|
89
|
+
editorPlacementMessage: message
|
|
90
|
+
};
|
|
91
|
+
usePlacementNotice(surface.apiRoute, id, watching ? sharedDocument.preflightError ?? (placementFailed ? placementReadError(surface.apiRoute, id) : message) : undefined);
|
|
92
|
+
const setup = documentState.doc?.status === 'draft' || documentState.doc?.status === 'stopped';
|
|
93
|
+
const test = setup ? {
|
|
94
|
+
...sharedDocument,
|
|
95
|
+
preflight: editorPreflight(preflight, surface)
|
|
96
|
+
} : sharedDocument;
|
|
37
97
|
useEffect(()=>{
|
|
38
98
|
if (test.doc?.name) onTitleChange?.(test.doc.name);
|
|
39
99
|
}, [
|
|
@@ -60,9 +120,9 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
60
120
|
role: test.loadState === 'error' ? 'alert' : 'status',
|
|
61
121
|
children: [
|
|
62
122
|
/*#__PURE__*/ _jsx("p", {
|
|
63
|
-
children: test.loadState === 'forbidden' ? C.forbidden : test.loadState === 'missing' ? C.missing : test.loadState === 'error' ? C.error : C.loading
|
|
123
|
+
children: test.preflightRead?.kind === 'signed-out' ? API_MESSAGES.unauthenticated : test.loadState === 'forbidden' ? C.forbidden : test.loadState === 'missing' ? C.missing : test.loadState === 'error' ? C.error : C.loading
|
|
64
124
|
}),
|
|
65
|
-
test.loadState === 'error' ? /*#__PURE__*/ _jsx(Button, {
|
|
125
|
+
test.preflightRead?.retry ?? test.loadState === 'error' ? /*#__PURE__*/ _jsx(Button, {
|
|
66
126
|
onClick: ()=>void test.reload(),
|
|
67
127
|
children: C.retry
|
|
68
128
|
}) : null
|
|
@@ -90,13 +150,14 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
90
150
|
children: [
|
|
91
151
|
test.errors._section ? /*#__PURE__*/ _jsx(Banner, {
|
|
92
152
|
tone: "error",
|
|
93
|
-
action:
|
|
153
|
+
action: /*#__PURE__*/ _jsx(Button, {
|
|
94
154
|
onClick: ()=>void test.reload(),
|
|
95
155
|
children: C.reload
|
|
96
|
-
})
|
|
156
|
+
}),
|
|
97
157
|
children: test.errors._section
|
|
98
158
|
}) : null,
|
|
99
159
|
/*#__PURE__*/ _jsxs(Section, {
|
|
160
|
+
surface: surface,
|
|
100
161
|
test: test,
|
|
101
162
|
sectionId: "what",
|
|
102
163
|
children: [
|
|
@@ -54,7 +54,7 @@ export declare function SelectEdit({ label, value, options, groups, reason, onCo
|
|
|
54
54
|
labelAction?: ReactNode;
|
|
55
55
|
groups?: readonly OptionGroup[];
|
|
56
56
|
}): import("react").JSX.Element;
|
|
57
|
-
export declare function CheckboxList({ label, value, options,
|
|
57
|
+
export declare function CheckboxList({ label, value, options, reason, onToggle, readOnlyValue }: {
|
|
58
58
|
label: string;
|
|
59
59
|
value: string[];
|
|
60
60
|
options: readonly {
|
|
@@ -64,8 +64,6 @@ export declare function CheckboxList({ label, value, options, groups, reason, on
|
|
|
64
64
|
reason?: string | null;
|
|
65
65
|
onToggle: (value: string, checked: boolean) => void;
|
|
66
66
|
readOnlyValue?: string;
|
|
67
|
-
searchable?: boolean;
|
|
68
|
-
groups?: readonly OptionGroup[];
|
|
69
67
|
}): import("react").JSX.Element;
|
|
70
68
|
export declare function TestName({ test }: SectionProps): import("react").JSX.Element;
|
|
71
69
|
export declare function Hypothesis({ test }: SectionProps): import("react").JSX.Element;
|
|
@@ -1,7 +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 { useEffect, useId, useState } from 'react';
|
|
4
|
-
import { TextInput, NumberInput, Textarea, Select,
|
|
4
|
+
import { TextInput, NumberInput, Textarea, Select, CheckboxList as UICheckboxList } from '../../../ui/Inputs.js';
|
|
5
5
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
6
6
|
import { EDITABLE_BY_STATUS } from '../../../collections/experiments/editability.js';
|
|
7
7
|
import { lockedReason } from '../../lockedNotice.model.js';
|
|
@@ -128,52 +128,22 @@ export function SelectEdit({ label, value, options, groups, reason, onCommit, re
|
|
|
128
128
|
}, option.value))
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
|
-
export function CheckboxList({ label, value, options,
|
|
131
|
+
export function CheckboxList({ label, value, options, reason, onToggle, readOnlyValue }) {
|
|
132
132
|
const id = useId();
|
|
133
|
-
const [query, setQuery] = useState('');
|
|
134
|
-
const visible = searchable ? options.filter((option)=>value.includes(option.value) || option.label.toLowerCase().includes(query.toLowerCase())) : options;
|
|
135
133
|
if (reason) return /*#__PURE__*/ _jsx(ReadOnly, {
|
|
136
134
|
label: label,
|
|
137
135
|
reason: reason,
|
|
138
136
|
value: readOnlyValue ?? value.map((v)=>options.find((o)=>o.value === v)?.label ?? v).join(', ')
|
|
139
137
|
});
|
|
140
|
-
return /*#__PURE__*/
|
|
138
|
+
return /*#__PURE__*/ _jsx(UICheckboxList, {
|
|
141
139
|
id: id,
|
|
142
140
|
label: label,
|
|
143
141
|
value: value,
|
|
144
|
-
options:
|
|
142
|
+
options: options,
|
|
145
143
|
onChange: (next)=>{
|
|
146
144
|
const changed = options.find((option)=>next.includes(option.value) !== value.includes(option.value));
|
|
147
145
|
if (changed) onToggle(changed.value, next.includes(changed.value));
|
|
148
|
-
}
|
|
149
|
-
children: [
|
|
150
|
-
searchable ? /*#__PURE__*/ _jsx(SearchInput, {
|
|
151
|
-
id: `${id}-search`,
|
|
152
|
-
label: C.searchGoals,
|
|
153
|
-
value: query,
|
|
154
|
-
onChange: (event)=>setQuery(event.target.value)
|
|
155
|
-
}) : null,
|
|
156
|
-
groups ? groups.map((group, index)=>{
|
|
157
|
-
const items = group.options.filter((option)=>visible.some((item)=>item.value === option.value));
|
|
158
|
-
return items.length ? /*#__PURE__*/ _jsxs("div", {
|
|
159
|
-
children: [
|
|
160
|
-
group.label ? /*#__PURE__*/ _jsx("h3", {
|
|
161
|
-
children: group.label
|
|
162
|
-
}) : null,
|
|
163
|
-
/*#__PURE__*/ _jsx("ul", {
|
|
164
|
-
children: items.map((option)=>/*#__PURE__*/ _jsx("li", {
|
|
165
|
-
children: /*#__PURE__*/ _jsx(Checkbox, {
|
|
166
|
-
id: `${id}-${index}-${option.value}`,
|
|
167
|
-
label: option.label,
|
|
168
|
-
checked: value.includes(option.value),
|
|
169
|
-
onChange: (event)=>onToggle(option.value, event.target.checked)
|
|
170
|
-
})
|
|
171
|
-
}, option.value))
|
|
172
|
-
})
|
|
173
|
-
]
|
|
174
|
-
}, index) : null;
|
|
175
|
-
}) : null
|
|
176
|
-
]
|
|
146
|
+
}
|
|
177
147
|
});
|
|
178
148
|
}
|
|
179
149
|
export function TestName({ test }) {
|
|
@@ -90,3 +90,15 @@
|
|
|
90
90
|
|
|
91
91
|
:where(.xp-test-surface) .xp-ui-checkbox-list > .xp-ui-field:has(input[type="search"]) { flex-basis: 100%; }
|
|
92
92
|
:where(.xp-test-surface) .xp-targeting-row .xp-ui-chips { margin-block: 0; }
|
|
93
|
+
|
|
94
|
+
:where(.xp-test-surface) .xp-test-rail-mark--blocked { color: var(--xp-error); }
|
|
95
|
+
:where(.xp-test-surface) .xp-test-rail-item.is-blocked { border-color: var(--xp-error-border); }
|
|
96
|
+
:where(.xp-test-surface) .xp-ui-section--blocked h2:focus, :where(.xp-test-surface) .xp-test-rail-item.is-blocked:focus-visible { outline-color: var(--xp-error); }
|
|
97
|
+
:where(.xp-test-surface) .xp-readiness__warning { color: var(--xp-warning); border-inline-start: 3px solid var(--xp-warning-border); padding-inline-start: var(--xp-space-2); }
|
|
98
|
+
|
|
99
|
+
:where(.xp-test-surface) .xp-readiness--bar { grid-template-columns: minmax(0, 1fr); }
|
|
100
|
+
:where(.xp-test-surface) .xp-readiness--bar > .xp-readiness__actions { grid-column: 1; grid-row: auto; justify-content: flex-start; }
|
|
101
|
+
:where(.xp-test-surface) .xp-readiness-action-reason { display: block; }
|
|
102
|
+
|
|
103
|
+
:where(.xp-test-surface) .xp-test-advanced.xp-ui-section--blocked { border-color: var(--xp-error-border); }
|
|
104
|
+
:where(.xp-test-surface) .xp-test-rail-mark--blocked { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--xp-error-border); border-radius: 50%; }
|
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
import type { Arm, DocId } from '../../types/contracts.js';
|
|
2
2
|
import type { PreflightResult } from '../../types/endpoints.js';
|
|
3
|
+
import { type ReadinessRead } from '../readinessRead.js';
|
|
3
4
|
import type { TestDocument, TestDocumentPatch } from './testDocument.model.js';
|
|
4
5
|
/** Section data only: staging never saves. Call commit on blur or a section action. */
|
|
5
|
-
export declare function useTestDocument(id: DocId, { apiRoute, refetchPreflightOnFocus, enabled, onDocument, onPreflight }: {
|
|
6
|
+
export declare function useTestDocument(id: DocId, { apiRoute, refetchPreflightOnFocus, enabled, onDocument, onPreflight, requestPreflight }: {
|
|
6
7
|
apiRoute: string;
|
|
7
8
|
refetchPreflightOnFocus?: boolean;
|
|
8
9
|
enabled?: boolean;
|
|
9
10
|
onDocument?: (doc: TestDocument) => void;
|
|
10
11
|
onPreflight?: (preflight: PreflightResult) => void;
|
|
12
|
+
requestPreflight?: (signal: AbortSignal, supersede?: boolean) => Promise<Response>;
|
|
11
13
|
}): {
|
|
12
14
|
stage: (partial: TestDocumentPatch) => void;
|
|
13
15
|
commit: () => Promise<void>;
|
|
14
16
|
reload: () => Promise<void>;
|
|
15
|
-
refreshPreflight: () => Promise<void>;
|
|
17
|
+
refreshPreflight: (supersede?: boolean) => Promise<void>;
|
|
16
18
|
choosePage: (arm: Arm["key"], page: {
|
|
17
19
|
id: DocId;
|
|
18
20
|
path: string;
|
|
@@ -27,6 +29,7 @@ export declare function useTestDocument(id: DocId, { apiRoute, refetchPreflightO
|
|
|
27
29
|
}>>;
|
|
28
30
|
doc: TestDocument | null;
|
|
29
31
|
preflight: PreflightResult | null;
|
|
32
|
+
preflightRead?: ReadinessRead;
|
|
30
33
|
preflightError: string | null;
|
|
31
34
|
preflightPending: boolean;
|
|
32
35
|
/** Includes staged edits and all queued or in-flight PATCHes. */
|