@delmaredigital/payload-experiments 0.4.0-rc.4 → 0.4.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/surface/ResultsRoute.js +2 -10
- package/dist/admin/surface/newTest/PageWizard.js +10 -12
- package/dist/admin/surface/results/ResultsHeader.js +15 -8
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +1 -1
- package/dist/puck/editor/ConfigureTestDrawer.js +2 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +4 -0
- package/dist/puck/editor/EditorControls.d.ts +1 -1
- package/dist/puck/editor/EditorControls.js +1 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +425 -80
- package/dist/puck/editor/LeftoverVersions.d.ts +13 -0
- package/dist/puck/editor/LeftoverVersions.js +115 -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 +20 -6
- package/dist/puck/editor/VersionBuilder.js +78 -48
- package/dist/puck/editor/armWrites.d.ts +3 -1
- package/dist/puck/editor/armWrites.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 +24 -3
- package/dist/puck/editor/copy.js +24 -3
- package/dist/puck/editor/editor.chrome.css +11 -0
- package/dist/puck/editor/editor.css +29 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- 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 +12 -0
- package/dist/puck/editor/sidebar.js +77 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +14 -0
- 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 +17 -1
- package/dist/testSurface/copy/readiness.js +22 -1
- package/dist/testSurface/copy/testPage.d.ts +1 -0
- package/dist/testSurface/copy/testPage.js +1 -0
- 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/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 +37 -7
- 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 +1 -0
- 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/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/preflightData.js +1 -1
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/Tabs.d.ts +2 -1
- package/dist/ui/Tabs.js +19 -6
- package/dist/ui/ui.css +18 -0
- package/package.json +1 -1
|
@@ -60,20 +60,12 @@ function ManagedResults({ id, surface, onTitleChange }) {
|
|
|
60
60
|
children: [
|
|
61
61
|
/*#__PURE__*/ _jsx("p", {
|
|
62
62
|
role: "status",
|
|
63
|
-
children: test.
|
|
63
|
+
children: test.preflightRead?.message ?? (test.loadState === 'loading' ? C.loading : C.error)
|
|
64
64
|
}),
|
|
65
|
-
test.
|
|
65
|
+
test.preflightRead?.retry ? /*#__PURE__*/ _jsx(Button, {
|
|
66
66
|
onClick: ()=>void test.reload(),
|
|
67
67
|
children: C.retry
|
|
68
68
|
}) : null,
|
|
69
|
-
test.errors._section ? /*#__PURE__*/ _jsx("p", {
|
|
70
|
-
role: "alert",
|
|
71
|
-
children: test.errors._section
|
|
72
|
-
}) : null,
|
|
73
|
-
test.preflightError ? /*#__PURE__*/ _jsx("p", {
|
|
74
|
-
role: "alert",
|
|
75
|
-
children: test.preflightError
|
|
76
|
-
}) : null,
|
|
77
69
|
test.loadState !== 'loading' && test.loadState !== 'missing' && test.loadState !== 'forbidden' ? /*#__PURE__*/ _jsx(ResultsBody, {
|
|
78
70
|
id: id,
|
|
79
71
|
surface: surface,
|
|
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { useEffect, useState } from 'react';
|
|
4
4
|
import { useRouter } from 'next/navigation.js';
|
|
5
5
|
import { formatAdminURL } from 'payload/shared';
|
|
6
|
+
import { canStartTest, readyToStart } from '../../../testSurface/readinessRead.js';
|
|
6
7
|
import { useTestDocument } from '../../../testSurface/surface/useTestDocument.js';
|
|
7
8
|
import { CopyRoute } from '../../../testSurface/surface/pagePicker/CopyRoute.js';
|
|
8
9
|
import { PageCombobox } from '../../../testSurface/surface/pagePicker/PageCombobox.js';
|
|
@@ -29,7 +30,7 @@ import { useTransition } from '../../../testSurface/surface/readiness/useTransit
|
|
|
29
30
|
adminRoute: surface.adminRoute,
|
|
30
31
|
path: `/experiments/${encodeURIComponent(String(id))}`
|
|
31
32
|
});
|
|
32
|
-
const transition = useTransition(test, ()=>router.push(testUrl));
|
|
33
|
+
const transition = useTransition(test, ()=>router.push(testUrl), surface);
|
|
33
34
|
useEffect(()=>{
|
|
34
35
|
if (step === 'review') void test.refreshPreflight();
|
|
35
36
|
}, [
|
|
@@ -45,13 +46,13 @@ import { useTransition } from '../../../testSurface/surface/readiness/useTransit
|
|
|
45
46
|
children: [
|
|
46
47
|
/*#__PURE__*/ _jsx("p", {
|
|
47
48
|
role: "alert",
|
|
48
|
-
children: test.
|
|
49
|
+
children: test.preflightRead?.message ?? TEST_PAGE.error
|
|
49
50
|
}),
|
|
50
|
-
/*#__PURE__*/ _jsx("button", {
|
|
51
|
+
test.preflightRead?.retry ? /*#__PURE__*/ _jsx("button", {
|
|
51
52
|
type: "button",
|
|
52
53
|
onClick: ()=>void test.reload(),
|
|
53
54
|
children: TEST_PAGE.retry
|
|
54
|
-
}),
|
|
55
|
+
}) : null,
|
|
55
56
|
/*#__PURE__*/ _jsx("button", {
|
|
56
57
|
type: "button",
|
|
57
58
|
onClick: leave,
|
|
@@ -72,7 +73,7 @@ import { useTransition } from '../../../testSurface/surface/readiness/useTransit
|
|
|
72
73
|
const arm = arms.find((item)=>item.key === step);
|
|
73
74
|
const ctx = pageReadinessContext(doc, test.preflight, surface);
|
|
74
75
|
const next = nextStep(test.preflight, ctx);
|
|
75
|
-
const ready =
|
|
76
|
+
const ready = readyToStart(test);
|
|
76
77
|
const busy = test.hasUnsaved || test.saving === 'saving' || transition.busy;
|
|
77
78
|
const jump = (section, key)=>{
|
|
78
79
|
if (section === 'versions') setStep(key ?? arms.find((item)=>!item.pageTarget)?.key ?? 'control');
|
|
@@ -91,7 +92,8 @@ import { useTransition } from '../../../testSurface/surface/readiness/useTransit
|
|
|
91
92
|
children: step === 'collection' ? C.collection : step === 'review' ? C.review : arm?.kind === 'control' ? C.original : pageStepCopy(arm?.label ?? '')
|
|
92
93
|
}),
|
|
93
94
|
/*#__PURE__*/ _jsx(SaveStatus, {
|
|
94
|
-
test: test
|
|
95
|
+
test: test,
|
|
96
|
+
messageInBlockerList: step === 'review' && !!test.preflight && !test.preflightError
|
|
95
97
|
}),
|
|
96
98
|
test.errors._section ? /*#__PURE__*/ _jsx("p", {
|
|
97
99
|
role: "alert",
|
|
@@ -122,10 +124,6 @@ import { useTransition } from '../../../testSurface/surface/readiness/useTransit
|
|
|
122
124
|
]
|
|
123
125
|
}) : step === 'review' ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
124
126
|
children: [
|
|
125
|
-
test.preflightError ? /*#__PURE__*/ _jsx("p", {
|
|
126
|
-
role: "alert",
|
|
127
|
-
children: test.preflightError
|
|
128
|
-
}) : null,
|
|
129
127
|
/*#__PURE__*/ _jsx("ul", {
|
|
130
128
|
children: test.preflight?.checks.map((check, index)=>{
|
|
131
129
|
if (!Object.hasOwn(READINESS, check.code)) return check.ok ? null : /*#__PURE__*/ _jsx("li", {
|
|
@@ -151,9 +149,9 @@ import { useTransition } from '../../../testSurface/surface/readiness/useTransit
|
|
|
151
149
|
}) : null,
|
|
152
150
|
/*#__PURE__*/ _jsx("button", {
|
|
153
151
|
type: "button",
|
|
154
|
-
disabled: busy || test.preflightPending || !test.preflight,
|
|
152
|
+
disabled: busy || test.preflightPending || !test.preflight || ready && (!canStartTest(test) || transition.checking),
|
|
155
153
|
onClick: ()=>{
|
|
156
|
-
if (ready) void transition.run(()=>createApi(surface.apiRoute).start(id));
|
|
154
|
+
if (ready) void transition.run('start', ()=>createApi(surface.apiRoute).start(id));
|
|
157
155
|
else if (next) jump(next.section, next.arm);
|
|
158
156
|
},
|
|
159
157
|
children: ready ? C.start : C.finishSetup
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { canStartTest, readyToStart } from '../../../testSurface/readinessRead.js';
|
|
4
|
+
import { BlockerList } from '../../../testSurface/surface/readiness/BlockerList.js';
|
|
5
|
+
import { ReadinessReadStatus } from '../../../testSurface/surface/readiness/SaveStatus.js';
|
|
3
6
|
import { surfaceUrls } from '../../../testSurface/surfaceUrls.js';
|
|
4
7
|
import { useEffect, useState } from 'react';
|
|
5
8
|
import { formatAdminURL } from 'payload/shared';
|
|
@@ -9,7 +12,7 @@ import { Banner, StatusChip } from '../../../ui/Feedback.js';
|
|
|
9
12
|
import { createApi } from '../../../testSurface/api.js';
|
|
10
13
|
import { availableActions, actionGroupLabel } from '../../../testSurface/actions/actions.model.js';
|
|
11
14
|
import { AllocateAction, ConfirmAction } from '../../../testSurface/surface/readiness/ActionDialogs.js';
|
|
12
|
-
import { READINESS, daysRemaining, displayDate,
|
|
15
|
+
import { READINESS, daysRemaining, displayDate, blockingSteps, pageReadinessContext } from '../../../testSurface/surface/readiness/readiness.model.js';
|
|
13
16
|
import { READINESS_COPY as R, runningCopy, stoppedCopy, decidedCopy } from '../../../testSurface/copy/readiness.js';
|
|
14
17
|
import { RESULTS_COPY as C } from '../../../testSurface/copy/results.js';
|
|
15
18
|
import { TEST_PAGE } from '../../../testSurface/copy/testPage.js';
|
|
@@ -55,9 +58,10 @@ export function ResultsHeader({ test, surface, resultsVersion, children, actions
|
|
|
55
58
|
'allocate',
|
|
56
59
|
'stop'
|
|
57
60
|
].indexOf(b.id) : 0);
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
const
|
|
61
|
+
const setup = doc.status === 'draft' || doc.status === 'stopped';
|
|
62
|
+
const blockers = blockingSteps(test.preflight, pageReadinessContext(doc, test.preflight, surface));
|
|
63
|
+
const ready = readyToStart(test);
|
|
64
|
+
const startReason = test.preflightError ?? blockers[0]?.sentence ?? (!ready ? R.checking : undefined);
|
|
61
65
|
const action = available.find((item)=>item.id === selected);
|
|
62
66
|
const sentence = doc.status === 'running' ? runningCopy(displayDate(doc.startedAt), people, daysRemaining(doc, Date.now())) : doc.status === 'stopped' ? stoppedCopy(displayDate(doc.stoppedAt)) : doc.status === 'decided' ? decidedCopy(displayDate(doc.decidedAt), winner) : doc.status === 'archived' ? R.archived : null;
|
|
63
67
|
const testURL = formatAdminURL({
|
|
@@ -114,7 +118,7 @@ export function ResultsHeader({ test, surface, resultsVersion, children, actions
|
|
|
114
118
|
}),
|
|
115
119
|
available.map((item)=>/*#__PURE__*/ _jsx(Button, {
|
|
116
120
|
variant: item.tone === 'danger' ? 'danger' : 'secondary',
|
|
117
|
-
disabled: item.id === 'start' &&
|
|
121
|
+
disabled: item.id === 'start' && !canStartTest(test) || !!selected || test.hasUnsaved || test.saving === 'saving' || item.id === 'allocate' && doc.allocation >= 100,
|
|
118
122
|
title: item.id === 'start' ? startReason : item.id === 'allocate' && doc.allocation >= 100 ? R.everyone : undefined,
|
|
119
123
|
onClick: ()=>setSelected(item.id),
|
|
120
124
|
children: item.id === 'allocate' ? R.allocate : item.label
|
|
@@ -127,9 +131,12 @@ export function ResultsHeader({ test, surface, resultsVersion, children, actions
|
|
|
127
131
|
tone: "error",
|
|
128
132
|
children: test.errors._section
|
|
129
133
|
}) : null,
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
134
|
+
/*#__PURE__*/ _jsx(ReadinessReadStatus, {
|
|
135
|
+
test: test,
|
|
136
|
+
messageInBlockerList: setup && !!test.preflight && !test.preflightError
|
|
137
|
+
}),
|
|
138
|
+
setup ? /*#__PURE__*/ _jsx(BlockerList, {
|
|
139
|
+
steps: blockers
|
|
133
140
|
}) : null,
|
|
134
141
|
children,
|
|
135
142
|
action?.id === 'allocate' ? /*#__PURE__*/ _jsx(AllocateAction, {
|
package/dist/goals/fairness.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { PayloadRequest } from 'payload';
|
|
2
2
|
import type { Arm, DocId, ResolvedOptions } from '../types/contracts.js';
|
|
3
3
|
import type { PlacementDoc } from '../db/placements.js';
|
|
4
|
-
export declare const OUTSIDE_GOAL
|
|
4
|
+
export declare const OUTSIDE_GOAL: (name?: string, kind?: string) => string;
|
|
5
5
|
export declare const LEGACY_FAIRNESS = "Goal fairness isn't checked for tests started before this update.";
|
|
6
6
|
export interface GoalPlacement {
|
|
7
7
|
collection?: string;
|
package/dist/goals/fairness.js
CHANGED
|
@@ -5,7 +5,7 @@ import { EXPERIMENT_BLOCK_SLUG, hostBlocks, isObject, slotBlocks } from '../bloc
|
|
|
5
5
|
import { resolvePageCollection } from '../transitions/pageCollection.js';
|
|
6
6
|
import { scanPlacements, uniquePlacementDocs } from '../transitions/placementInteractions.js';
|
|
7
7
|
import { CLICK_KEY } from './key.js';
|
|
8
|
-
export const OUTSIDE_GOAL =
|
|
8
|
+
export const OUTSIDE_GOAL = (name = 'Selected goal', kind = 'block')=>kind === 'block' ? `Heads up: the click goal “${name}” is outside this test's block, so every version shows the same button. The test can still start. To compare different buttons, move the goal inside each version.` : `Heads up: the click goal “${name}” isn't on any of this test's pages. The test can still start. Add the goal to every version's page to measure those clicks.`;
|
|
9
9
|
export const LEGACY_FAIRNESS = "Goal fairness isn't checked for tests started before this update.";
|
|
10
10
|
/** Inspect inline JSON only; depth-zero relationship ids never dereference another document. */ function collect(value, into, label = '', labels) {
|
|
11
11
|
if (Array.isArray(value)) {
|
|
@@ -10,7 +10,7 @@ import { TEST_PAGE } from '../../testSurface/copy/testPage.js';
|
|
|
10
10
|
import { readSurface, useEditorSurface } from './editorSurface.js';
|
|
11
11
|
import { editorCopy as C } from './copy.js';
|
|
12
12
|
import { publishExperiment } from './armsCache.js';
|
|
13
|
-
import {
|
|
13
|
+
import { readEditorPreflight } from './placementsCache.js';
|
|
14
14
|
import './editor.css';
|
|
15
15
|
export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
16
16
|
const [title, setTitle] = useState(C.configure);
|
|
@@ -67,7 +67,7 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
67
67
|
embedded: true,
|
|
68
68
|
onTitleChange: setTitle,
|
|
69
69
|
onDocument: (doc)=>publishExperiment(id, doc),
|
|
70
|
-
|
|
70
|
+
requestPreflight: (signal, supersede)=>readEditorPreflight(routes.api, id, signal, supersede)
|
|
71
71
|
}) : /*#__PURE__*/ _jsxs("div", {
|
|
72
72
|
role: state.error ? 'alert' : 'status',
|
|
73
73
|
children: [
|
|
@@ -75,6 +75,10 @@ export function CreateExperimentDrawer({ onCreate, onClose, initialName = '', ar
|
|
|
75
75
|
tone: "error",
|
|
76
76
|
children: error
|
|
77
77
|
}) : null,
|
|
78
|
+
!name.trim() ? /*#__PURE__*/ _jsx("p", {
|
|
79
|
+
className: "xp-ui-help",
|
|
80
|
+
children: editorCopy.enterName
|
|
81
|
+
}) : null,
|
|
78
82
|
/*#__PURE__*/ _jsxs("div", {
|
|
79
83
|
className: "xp-ui-button-group",
|
|
80
84
|
children: [
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from 'react';
|
|
2
|
-
export declare const CONTROL_SELECTOR = "button, a, label, input, select, textarea, [role=\"tab\"], [role=\"menu\"], [role=\"listbox\"], dialog, [role=\"dialog\"], [contenteditable=\"true\"]";
|
|
2
|
+
export declare const CONTROL_SELECTOR = "button, a, summary, label, input, select, textarea, [role=\"tab\"], [role=\"menu\"], .xp-slot-version-menu, [role=\"listbox\"], dialog, [role=\"dialog\"], [contenteditable=\"true\"]";
|
|
3
3
|
/** Give React a delegation boundary before Puck's native component click listeners.
|
|
4
4
|
* A normal React onClick runs too late: native child/parent selection already ran.
|
|
5
5
|
* The portal target is this chrome element in the canvas's ownerDocument, so
|
|
@@ -3,7 +3,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
3
3
|
import { registerOverlayPortal, useGetPuck } from '@puckeditor/core';
|
|
4
4
|
import { useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
|
-
export const CONTROL_SELECTOR = 'button, a, label, input, select, textarea, [role="tab"], [role="menu"], [role="listbox"], dialog, [role="dialog"], [contenteditable="true"]';
|
|
6
|
+
export const CONTROL_SELECTOR = 'button, a, summary, label, input, select, textarea, [role="tab"], [role="menu"], .xp-slot-version-menu, [role="listbox"], dialog, [role="dialog"], [contenteditable="true"]';
|
|
7
7
|
/** Give React a delegation boundary before Puck's native component click listeners.
|
|
8
8
|
* A normal React onClick runs too late: native child/parent selection already ran.
|
|
9
9
|
* The portal target is this chrome element in the canvas's ownerDocument, so
|