@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.
- package/dist/admin/MetricSourceSelect.js +10 -3
- package/dist/admin/copy/blocks.js +3 -3
- package/dist/admin/copy/goals.d.ts +15 -8
- package/dist/admin/copy/goals.js +18 -8
- package/dist/admin/copy/newTest.d.ts +3 -2
- package/dist/admin/copy/newTest.js +3 -2
- package/dist/admin/surface/SurfaceShell.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +25 -3
- package/dist/admin/surface/TestRowMenu.d.ts +7 -0
- package/dist/admin/surface/TestRowMenu.js +9 -2
- package/dist/admin/surface/TestsHome.js +8 -1
- package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
- package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
- package/dist/admin/surface/goals/GoalForm.js +280 -191
- package/dist/admin/surface/goals/GoalsList.js +102 -33
- package/dist/admin/surface/goals/data.d.ts +2 -0
- package/dist/admin/surface/goals/data.js +9 -0
- package/dist/admin/surface/goals/goals.css +3 -2
- package/dist/admin/surface/goals/goals.model.d.ts +2 -2
- package/dist/admin/surface/goals/goals.model.js +7 -12
- package/dist/admin/surface/home.model.d.ts +1 -0
- package/dist/admin/surface/home.model.js +5 -1
- package/dist/admin/surface/newTest/NewTest.js +56 -29
- package/dist/admin/surface/newTest/PageWizard.d.ts +3 -1
- package/dist/admin/surface/newTest/PageWizard.js +14 -14
- package/dist/admin/surface/newTest/newTest.css +3 -3
- package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
- package/dist/admin/surface/results/ResultsHeader.js +69 -41
- package/dist/admin/surface/surface.css +20 -1
- package/dist/admin/surface/test/TestPage.js +46 -34
- package/dist/admin/surface/useXpStepNav.d.ts +11 -0
- package/dist/admin/surface/useXpStepNav.js +14 -0
- package/dist/admin/views/TestsSurfaceClient.js +27 -3
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +1 -1
- package/dist/collections/metrics.js +12 -5
- package/dist/collections/serialize.js +3 -2
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -0
- package/dist/plugin.js +51 -1
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +96 -43
- package/dist/puck/editor/QuickTestActions.d.ts +2 -2
- package/dist/puck/editor/QuickTestActions.js +42 -27
- package/dist/puck/editor/ResultsReadout.d.ts +3 -1
- package/dist/puck/editor/ResultsReadout.js +28 -16
- package/dist/puck/editor/VersionBuilder.d.ts +2 -1
- package/dist/puck/editor/VersionBuilder.js +14 -8
- package/dist/puck/editor/copy.d.ts +3 -3
- package/dist/puck/editor/copy.js +4 -4
- package/dist/puck/editor/editor.chrome.css +9 -1
- package/dist/puck/editor/editor.css +10 -1
- package/dist/puck/nestedTestCopy.js +1 -1
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +1 -1
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/verdict.d.ts +1 -1
- package/dist/results/verdict.js +7 -6
- package/dist/server/runResults.js +2 -1
- package/dist/testSurface/PreviewLinks.d.ts +2 -1
- package/dist/testSurface/PreviewLinks.js +3 -3
- package/dist/testSurface/actions/DecideDialog.d.ts +3 -2
- package/dist/testSurface/actions/DecideDialog.js +21 -12
- package/dist/testSurface/actions/LifecycleAction.d.ts +2 -1
- package/dist/testSurface/actions/LifecycleAction.js +3 -1
- package/dist/testSurface/actions/actions.model.js +6 -5
- package/dist/testSurface/actions/decide.model.d.ts +1 -0
- package/dist/testSurface/actions/decide.model.js +1 -0
- package/dist/testSurface/allocation.model.js +6 -3
- package/dist/testSurface/copy/actions.d.ts +12 -9
- package/dist/testSurface/copy/actions.js +12 -9
- package/dist/testSurface/copy/advanced.d.ts +10 -0
- package/dist/testSurface/copy/advanced.js +10 -0
- package/dist/testSurface/copy/arms.d.ts +1 -1
- package/dist/testSurface/copy/arms.js +1 -1
- package/dist/testSurface/copy/audience.d.ts +4 -3
- package/dist/testSurface/copy/audience.js +5 -4
- package/dist/testSurface/copy/common.d.ts +2 -2
- package/dist/testSurface/copy/common.js +2 -2
- package/dist/testSurface/copy/metrics.d.ts +6 -0
- package/dist/testSurface/copy/metrics.js +8 -0
- package/dist/testSurface/copy/readiness.d.ts +3 -3
- package/dist/testSurface/copy/readiness.js +5 -5
- package/dist/testSurface/copy/recommendation.d.ts +4 -4
- package/dist/testSurface/copy/recommendation.js +4 -4
- package/dist/testSurface/copy/results.d.ts +13 -9
- package/dist/testSurface/copy/results.js +15 -9
- package/dist/testSurface/copy/review.d.ts +12 -9
- package/dist/testSurface/copy/review.js +13 -9
- package/dist/testSurface/copy/setting.d.ts +1 -2
- package/dist/testSurface/copy/setting.js +1 -2
- package/dist/testSurface/copy/surface.js +1 -1
- package/dist/testSurface/copy/testPage.d.ts +13 -9
- package/dist/testSurface/copy/testPage.js +16 -13
- package/dist/testSurface/format/date.d.ts +1 -0
- package/dist/testSurface/format/date.js +11 -0
- package/dist/testSurface/labels.d.ts +1 -2
- package/dist/testSurface/labels.js +2 -3
- package/dist/testSurface/lockedNotice.model.d.ts +2 -0
- package/dist/testSurface/lockedNotice.model.js +31 -0
- package/dist/testSurface/results/results.model.d.ts +3 -2
- package/dist/testSurface/results/results.model.js +10 -9
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +1 -1
- package/dist/testSurface/surface/pageBlock/parts.js +17 -7
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +0 -5
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +1 -1
- package/dist/testSurface/surface/readiness/ActionDialogs.js +54 -33
- package/dist/testSurface/surface/readiness/Banner.d.ts +3 -1
- package/dist/testSurface/surface/readiness/Banner.js +86 -75
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +5 -2
- package/dist/testSurface/surface/readiness/SaveStatus.js +8 -7
- package/dist/testSurface/surface/readiness/readiness.model.js +1 -1
- package/dist/testSurface/surface/results/ResultsBody.d.ts +4 -1
- package/dist/testSurface/surface/results/ResultsBody.js +119 -80
- package/dist/testSurface/surface/results/recommendation.model.js +3 -3
- package/dist/testSurface/surface/setting/parts.js +31 -28
- package/dist/testSurface/surface/setting/setting.css +2 -1
- package/dist/testSurface/surface/test/AdvancedSection.js +10 -4
- package/dist/testSurface/surface/test/GoalSection.js +11 -11
- package/dist/testSurface/surface/test/LengthSection.js +20 -13
- package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
- package/dist/testSurface/surface/test/PageHoldout.js +7 -7
- package/dist/testSurface/surface/test/ReadinessBar.d.ts +1 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
- package/dist/testSurface/surface/test/Section.js +8 -0
- package/dist/testSurface/surface/test/TargetingSection.js +7 -2
- package/dist/testSurface/surface/test/VersionsSection.js +88 -68
- package/dist/testSurface/surface/test/fields.d.ts +4 -3
- package/dist/testSurface/surface/test/fields.js +10 -16
- package/dist/testSurface/surface/test/pageParts.js +3 -1
- package/dist/testSurface/surface/test/testPage.css +9 -1
- package/dist/testSurface/surfaceUrls.d.ts +1 -0
- package/dist/testSurface/surfaceUrls.js +4 -0
- package/dist/ui/Dialog.js +25 -0
- package/dist/ui/Inputs.js +0 -1
- package/dist/ui/ui.css +1 -0
- package/package.json +1 -1
|
@@ -3,22 +3,33 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
import { surfaceUrls } from '../../../testSurface/surfaceUrls.js';
|
|
4
4
|
import { sourceFor } from '../../../testSurface/metricSource.model.js';
|
|
5
5
|
import { useEffect, useState } from 'react';
|
|
6
|
+
import { useRouter } from 'next/navigation.js';
|
|
6
7
|
import { formatAdminURL } from 'payload/shared';
|
|
7
8
|
import { Banner, EmptyState } from '../../../ui/Feedback.js';
|
|
8
9
|
import { Button } from '../../../ui/Button.js';
|
|
9
|
-
import { SearchInput } from '../../../ui/
|
|
10
|
+
import { SearchInput } from '../../../ui/SearchInput.js';
|
|
10
11
|
import { SurfaceShell } from '../SurfaceShell.js';
|
|
12
|
+
import { useXpStepNav } from '../useXpStepNav.js';
|
|
13
|
+
import { RowMenu } from '../TestRowMenu.js';
|
|
11
14
|
import { SURFACE_COPY } from '../../../testSurface/copy/surface.js';
|
|
12
15
|
import { GOALS_COPY as C, goalsNoMatches, goalUsedBy } from '../../copy/goals.js';
|
|
13
16
|
import { METRIC_KIND_LABELS } from '../../../testSurface/copy/metrics.js';
|
|
14
17
|
import { goalUsage } from './goals.model.js';
|
|
15
18
|
import { goalPages } from './data.js';
|
|
19
|
+
import { DeleteGoalDialog } from './DeleteGoalDialog.js';
|
|
16
20
|
import './goals.css';
|
|
17
21
|
export function GoalsList({ surface, returnToTest }) {
|
|
22
|
+
useXpStepNav([
|
|
23
|
+
{
|
|
24
|
+
label: C.title
|
|
25
|
+
}
|
|
26
|
+
]);
|
|
27
|
+
const router = useRouter();
|
|
18
28
|
const [data, setData] = useState();
|
|
19
29
|
const [error, setError] = useState('');
|
|
20
30
|
const [attempt, setAttempt] = useState(0);
|
|
21
31
|
const [search, setSearch] = useState('');
|
|
32
|
+
const [deleting, setDeleting] = useState();
|
|
22
33
|
const returnQuery = returnToTest ? `?${new URLSearchParams({
|
|
23
34
|
return: returnToTest
|
|
24
35
|
})}` : '';
|
|
@@ -48,14 +59,14 @@ export function GoalsList({ surface, returnToTest }) {
|
|
|
48
59
|
attempt
|
|
49
60
|
]);
|
|
50
61
|
const usage = goalUsage(data?.tests ?? []);
|
|
51
|
-
const
|
|
52
|
-
const goals = data?.goals.filter((goal)
|
|
62
|
+
const query = search.trim().toLocaleLowerCase('en-US');
|
|
63
|
+
const goals = data?.goals.filter((goal)=>goal.name.toLocaleLowerCase('en-US').includes(query)) ?? [];
|
|
53
64
|
const newGoal = surface.canManage ? /*#__PURE__*/ _jsx(Button, {
|
|
54
65
|
variant: "primary",
|
|
55
66
|
href: url(`/experiments/goals/new${returnQuery}`),
|
|
56
67
|
children: C.newGoal
|
|
57
68
|
}) : null;
|
|
58
|
-
return /*#__PURE__*/
|
|
69
|
+
return /*#__PURE__*/ _jsxs(SurfaceShell, {
|
|
59
70
|
adminRoute: surface.adminRoute,
|
|
60
71
|
title: C.title,
|
|
61
72
|
crumbs: [
|
|
@@ -69,6 +80,35 @@ export function GoalsList({ surface, returnToTest }) {
|
|
|
69
80
|
],
|
|
70
81
|
actions: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
71
82
|
children: [
|
|
83
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
84
|
+
className: "xp-tests-search",
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ _jsxs("svg", {
|
|
87
|
+
viewBox: "0 0 16 16",
|
|
88
|
+
fill: "none",
|
|
89
|
+
stroke: "currentColor",
|
|
90
|
+
strokeWidth: "1.5",
|
|
91
|
+
"aria-hidden": "true",
|
|
92
|
+
children: [
|
|
93
|
+
/*#__PURE__*/ _jsx("circle", {
|
|
94
|
+
cx: "7",
|
|
95
|
+
cy: "7",
|
|
96
|
+
r: "4.5"
|
|
97
|
+
}),
|
|
98
|
+
/*#__PURE__*/ _jsx("path", {
|
|
99
|
+
d: "m10.5 10.5 3.5 3.5"
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
}),
|
|
103
|
+
/*#__PURE__*/ _jsx(SearchInput, {
|
|
104
|
+
id: "xp-goals-search",
|
|
105
|
+
label: C.search,
|
|
106
|
+
placeholder: C.search,
|
|
107
|
+
value: search,
|
|
108
|
+
onChange: (event)=>setSearch(event.target.value)
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
}),
|
|
72
112
|
returnToTest ? /*#__PURE__*/ _jsx(Button, {
|
|
73
113
|
variant: "quiet",
|
|
74
114
|
href: url(`/experiments/${encodeURIComponent(returnToTest)}`),
|
|
@@ -77,17 +117,10 @@ export function GoalsList({ surface, returnToTest }) {
|
|
|
77
117
|
newGoal
|
|
78
118
|
]
|
|
79
119
|
}),
|
|
80
|
-
children:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
id: "xp-goals-search",
|
|
85
|
-
label: C.search,
|
|
86
|
-
placeholder: C.search,
|
|
87
|
-
value: search,
|
|
88
|
-
onChange: (event)=>setSearch(event.target.value)
|
|
89
|
-
}) : null,
|
|
90
|
-
error ? /*#__PURE__*/ _jsx(Banner, {
|
|
120
|
+
children: [
|
|
121
|
+
/*#__PURE__*/ _jsx("div", {
|
|
122
|
+
className: "xp-goals",
|
|
123
|
+
children: error ? /*#__PURE__*/ _jsx(Banner, {
|
|
91
124
|
tone: "error",
|
|
92
125
|
action: /*#__PURE__*/ _jsx(Button, {
|
|
93
126
|
size: "sm",
|
|
@@ -101,13 +134,19 @@ export function GoalsList({ surface, returnToTest }) {
|
|
|
101
134
|
}) : !data.goals.length ? /*#__PURE__*/ _jsx(EmptyState, {
|
|
102
135
|
action: newGoal,
|
|
103
136
|
children: C.empty
|
|
104
|
-
}) : !goals.length ? /*#__PURE__*/
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
137
|
+
}) : !goals.length ? /*#__PURE__*/ _jsxs("div", {
|
|
138
|
+
className: "xp-tests-no-matches",
|
|
139
|
+
children: [
|
|
140
|
+
/*#__PURE__*/ _jsx("p", {
|
|
141
|
+
children: goalsNoMatches(search)
|
|
142
|
+
}),
|
|
143
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
144
|
+
variant: "quiet",
|
|
145
|
+
size: "sm",
|
|
146
|
+
onClick: ()=>setSearch(''),
|
|
147
|
+
children: C.clearSearch
|
|
148
|
+
})
|
|
149
|
+
]
|
|
111
150
|
}) : /*#__PURE__*/ _jsx("div", {
|
|
112
151
|
className: "xp-tests-list",
|
|
113
152
|
children: goals.map((goal)=>{
|
|
@@ -115,6 +154,25 @@ export function GoalsList({ surface, returnToTest }) {
|
|
|
115
154
|
const kind = sourceFor(goal.source, surface.metricSources)?.kind;
|
|
116
155
|
const label = kind && Object.hasOwn(METRIC_KIND_LABELS, kind) ? METRIC_KIND_LABELS[kind] : undefined;
|
|
117
156
|
const href = url(`/experiments/goals/${encodeURIComponent(String(goal.id))}${returnQuery}`);
|
|
157
|
+
const returnHref = returnToTest ? url(`/experiments/${encodeURIComponent(returnToTest)}?${new URLSearchParams({
|
|
158
|
+
goal: String(goal.id)
|
|
159
|
+
})}`) : undefined;
|
|
160
|
+
const actions = [
|
|
161
|
+
...returnHref ? [
|
|
162
|
+
{
|
|
163
|
+
id: 'use',
|
|
164
|
+
label: C.useGoal,
|
|
165
|
+
tone: 'primary'
|
|
166
|
+
}
|
|
167
|
+
] : [],
|
|
168
|
+
...surface.canManage && !count ? [
|
|
169
|
+
{
|
|
170
|
+
id: 'delete',
|
|
171
|
+
label: C.remove,
|
|
172
|
+
tone: 'danger'
|
|
173
|
+
}
|
|
174
|
+
] : []
|
|
175
|
+
];
|
|
118
176
|
return /*#__PURE__*/ _jsxs("article", {
|
|
119
177
|
className: "xp-tests-row",
|
|
120
178
|
children: [
|
|
@@ -151,20 +209,31 @@ export function GoalsList({ surface, returnToTest }) {
|
|
|
151
209
|
})
|
|
152
210
|
]
|
|
153
211
|
}),
|
|
154
|
-
/*#__PURE__*/ _jsx(
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
})
|
|
212
|
+
actions.length ? /*#__PURE__*/ _jsx(RowMenu, {
|
|
213
|
+
label: `Actions for ${goal.name}`,
|
|
214
|
+
actions: actions,
|
|
215
|
+
onSelect: (action)=>{
|
|
216
|
+
if (action.id === 'use' && returnHref) router.push(returnHref);
|
|
217
|
+
else if (action.id === 'delete') setDeleting(goal);
|
|
218
|
+
}
|
|
219
|
+
}) : null
|
|
163
220
|
]
|
|
164
221
|
}, `${typeof goal.id}:${goal.id}`);
|
|
165
222
|
})
|
|
166
223
|
})
|
|
167
|
-
|
|
168
|
-
|
|
224
|
+
}),
|
|
225
|
+
deleting ? /*#__PURE__*/ _jsx(DeleteGoalDialog, {
|
|
226
|
+
goal: deleting,
|
|
227
|
+
apiRoute: surface.apiRoute,
|
|
228
|
+
onClose: ()=>setDeleting(undefined),
|
|
229
|
+
onDeleted: ()=>{
|
|
230
|
+
setData((current)=>current && {
|
|
231
|
+
...current,
|
|
232
|
+
goals: current.goals.filter((goal)=>goal.id !== deleting.id)
|
|
233
|
+
});
|
|
234
|
+
setDeleting(undefined);
|
|
235
|
+
}
|
|
236
|
+
}) : null
|
|
237
|
+
]
|
|
169
238
|
});
|
|
170
239
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { DocId } from '../../../types/contracts.js';
|
|
1
2
|
export declare class GoalResponseError extends Error {
|
|
2
3
|
readonly fields: Record<string, string>;
|
|
3
4
|
constructor(message: string, fields: Record<string, string>);
|
|
@@ -7,3 +8,4 @@ export declare function goalResponse(response: Response, fallback: string, optio
|
|
|
7
8
|
notFound?: string;
|
|
8
9
|
}): Promise<unknown>;
|
|
9
10
|
export declare function goalPages<T>(base: string, collection: 'xp-metrics' | 'xp-experiments', signal: AbortSignal): Promise<T[]>;
|
|
11
|
+
export declare function deleteGoal(apiRoute: string, id: DocId): Promise<void>;
|
|
@@ -33,3 +33,12 @@ export async function goalPages(base, collection, signal) {
|
|
|
33
33
|
if (!result.ok) goalRefusal(result.body, result.status, C.loadError);
|
|
34
34
|
return result.docs;
|
|
35
35
|
}
|
|
36
|
+
export async function deleteGoal(apiRoute, id) {
|
|
37
|
+
const response = await fetch(`${apiRoute.replace(/\/$/, '')}/xp-metrics/${encodeURIComponent(id)}`, {
|
|
38
|
+
method: 'DELETE',
|
|
39
|
+
credentials: 'include'
|
|
40
|
+
});
|
|
41
|
+
await goalResponse(response, C.deleteError, {
|
|
42
|
+
notFound: C.notFound
|
|
43
|
+
});
|
|
44
|
+
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
/* Compact rows reuse surface.css's xp-tests-list / xp-tests-row classes. */
|
|
2
2
|
.xp-goals { display: grid; gap: var(--xp-space-4); }
|
|
3
|
-
.xp-goals > .xp-ui-field { max-width: 20rem; }
|
|
4
3
|
.xp-goal-form { max-width: 48rem; display: grid; gap: var(--xp-space-4); }
|
|
5
4
|
.xp-goal-card { display: grid; gap: var(--xp-space-4); }
|
|
6
5
|
.xp-goal-card > h2 { margin: 0; font: var(--xp-text-title); }
|
|
@@ -10,10 +9,12 @@
|
|
|
10
9
|
.xp-goal-advanced > summary { padding: var(--xp-space-4); cursor: pointer; font: var(--xp-text-body); }
|
|
11
10
|
.xp-goal-advanced > summary:focus-visible { outline: 2px solid var(--xp-focus); outline-offset: 2px; }
|
|
12
11
|
.xp-goal-advanced-fields { display: grid; gap: var(--xp-space-4); padding: 0 var(--xp-space-4) var(--xp-space-4); }
|
|
12
|
+
.xp-goal-advanced-fields h3 { margin: 0; font: var(--xp-text-title); }
|
|
13
|
+
.xp-goal-save { position: sticky; bottom: 0; background: var(--xp-surface); padding: var(--xp-space-3) 0; }
|
|
13
14
|
|
|
14
15
|
.xp-goal-usage { display: grid; gap: var(--xp-space-3); }
|
|
15
16
|
.xp-goal-usage > h2, .xp-goal-usage > ul { margin: 0; }
|
|
16
17
|
.xp-goal-usage > h2 { font: var(--xp-text-title); }
|
|
17
18
|
.xp-goal-usage > ul { display: grid; gap: var(--xp-space-3); padding-inline-start: var(--xp-space-5); }
|
|
18
|
-
.xp-goal-usage
|
|
19
|
+
.xp-goal-usage-roles { margin-inline: var(--xp-space-2); color: var(--xp-text-2); font: var(--xp-text-small); }
|
|
19
20
|
.xp-goal-usage > .xp-ui-button { justify-self: start; }
|
|
@@ -28,12 +28,12 @@ export interface GoalUsageTest {
|
|
|
28
28
|
}
|
|
29
29
|
/** Count each experiment once per goal, retaining the API's id types. */
|
|
30
30
|
export declare function goalUsage(tests: readonly GoalUsageTest[]): Map<DocId, number>;
|
|
31
|
-
export { goalSlug } from '../../../goals/picker/clickGoalPicker.model.js';
|
|
31
|
+
export { clickGoalSlug as goalSlug } from '../../../goals/picker/clickGoalPicker.model.js';
|
|
32
32
|
/** One row per readable test returned by the API, retaining every role. */
|
|
33
33
|
export declare function goalUsageRows(tests: readonly GoalUsageTest[], goalId: DocId): {
|
|
34
34
|
id: DocId;
|
|
35
35
|
name: string;
|
|
36
36
|
roles: string[];
|
|
37
|
-
status?:
|
|
37
|
+
status?: Status | null;
|
|
38
38
|
}[];
|
|
39
39
|
export declare function visibleGoalUsage<T>(rows: readonly T[], expanded: boolean): readonly T[];
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { statusLabel } from '../../../testSurface/labels.js';
|
|
1
|
+
import { GOALS_COPY } from '../../copy/goals.js';
|
|
3
2
|
/** Count each experiment once per goal, retaining the API's id types. */ export function goalUsage(tests) {
|
|
4
3
|
const byGoal = new Map();
|
|
5
4
|
for (const test of tests){
|
|
@@ -23,13 +22,9 @@ import { statusLabel } from '../../../testSurface/labels.js';
|
|
|
23
22
|
tests.size
|
|
24
23
|
]));
|
|
25
24
|
}
|
|
26
|
-
export { goalSlug } from '../../../goals/picker/clickGoalPicker.model.js';
|
|
25
|
+
export { clickGoalSlug as goalSlug } from '../../../goals/picker/clickGoalPicker.model.js';
|
|
27
26
|
const referenceId = (reference)=>reference && typeof reference === 'object' ? reference.id : reference;
|
|
28
|
-
const usageLabels =
|
|
29
|
-
primary: TEST_PAGE.goal,
|
|
30
|
-
guardrails: TEST_PAGE.guardrailsShort,
|
|
31
|
-
secondary: TEST_PAGE.secondaryShort
|
|
32
|
-
};
|
|
27
|
+
const usageLabels = GOALS_COPY.roles;
|
|
33
28
|
/** One row per readable test returned by the API, retaining every role. */ export function goalUsageRows(tests, goalId) {
|
|
34
29
|
const rows = new Map();
|
|
35
30
|
for (const test of tests){
|
|
@@ -37,11 +32,11 @@ const usageLabels = {
|
|
|
37
32
|
...referenceId(test.metrics?.primary) === goalId ? [
|
|
38
33
|
usageLabels.primary
|
|
39
34
|
] : [],
|
|
40
|
-
...test.metrics?.guardrails?.some((reference)=>referenceId(reference) === goalId) ? [
|
|
41
|
-
usageLabels.guardrails
|
|
42
|
-
] : [],
|
|
43
35
|
...test.metrics?.secondary?.some((reference)=>referenceId(reference) === goalId) ? [
|
|
44
36
|
usageLabels.secondary
|
|
37
|
+
] : [],
|
|
38
|
+
...test.metrics?.guardrails?.some((reference)=>referenceId(reference) === goalId) ? [
|
|
39
|
+
usageLabels.guardrails
|
|
45
40
|
] : []
|
|
46
41
|
];
|
|
47
42
|
if (!roles.length) continue;
|
|
@@ -55,7 +50,7 @@ const usageLabels = {
|
|
|
55
50
|
...roles
|
|
56
51
|
])
|
|
57
52
|
],
|
|
58
|
-
status: test.status
|
|
53
|
+
status: test.status
|
|
59
54
|
});
|
|
60
55
|
}
|
|
61
56
|
return [
|
|
@@ -57,7 +57,11 @@ export function homeCard(test, summary, adminRoute, flagPoints, goalNames = {},
|
|
|
57
57
|
});
|
|
58
58
|
if (sentence) line = nextCopy(next.code === 'page-no-targets' ? READINESS_COPY.choosePages : sentence);
|
|
59
59
|
}
|
|
60
|
-
if (test.status === 'running')
|
|
60
|
+
if (test.status === 'running') {
|
|
61
|
+
const start = Date.parse(test.startedAt ?? '');
|
|
62
|
+
const elapsed = Number.isFinite(start) ? (Date.now() - start) / 86_400_000 : summary?.days ?? 0;
|
|
63
|
+
line = runningLine(number(Math.max(1, Math.floor(elapsed) + 1)), number(test.analysis?.plannedDurationDays), number(summary?.exposures));
|
|
64
|
+
}
|
|
61
65
|
if (test.status === 'decided') {
|
|
62
66
|
const winner = test.decision?.winnerArm;
|
|
63
67
|
const winnerLabel = test.arms?.find((arm)=>arm.key === winner)?.label?.trim();
|
|
@@ -5,6 +5,8 @@ import { fetchAllDocs } from '../../../lib/fetchAllDocs.js';
|
|
|
5
5
|
import { useEffect, useId, useRef, useState } from 'react';
|
|
6
6
|
import { useRouter } from 'next/navigation.js';
|
|
7
7
|
import { formatAdminURL } from 'payload/shared';
|
|
8
|
+
import { useXpStepNav } from '../useXpStepNav.js';
|
|
9
|
+
import { SURFACE_COPY } from '../../../testSurface/copy/surface.js';
|
|
8
10
|
import { NEW_TEST_COPY as C } from '../../copy/newTest.js';
|
|
9
11
|
import { CreateRefused, createTest } from '../../../puck/editor/createTest.js';
|
|
10
12
|
import { PageWizard } from './PageWizard.js';
|
|
@@ -14,6 +16,15 @@ import { PageCombobox } from '../../../testSurface/surface/pagePicker/PageCombob
|
|
|
14
16
|
import { Select } from '../../../ui/Select.js';
|
|
15
17
|
import './newTest.css';
|
|
16
18
|
export function NewTest({ surface, blockPageCollections = [] }) {
|
|
19
|
+
useXpStepNav([
|
|
20
|
+
{
|
|
21
|
+
label: SURFACE_COPY.title,
|
|
22
|
+
url: surfaceUrls.home(surface.adminRoute)
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
label: SURFACE_COPY.newTest
|
|
26
|
+
}
|
|
27
|
+
]);
|
|
17
28
|
const router = useRouter();
|
|
18
29
|
const id = useId();
|
|
19
30
|
const [blockCollection, setBlockCollection] = useState('');
|
|
@@ -84,6 +95,7 @@ export function NewTest({ surface, blockPageCollections = [] }) {
|
|
|
84
95
|
});
|
|
85
96
|
if (kind === 'page') {
|
|
86
97
|
setCreated(id);
|
|
98
|
+
inFlight.current = false;
|
|
87
99
|
setPending(false);
|
|
88
100
|
return;
|
|
89
101
|
}
|
|
@@ -97,13 +109,36 @@ export function NewTest({ surface, blockPageCollections = [] }) {
|
|
|
97
109
|
setPending(false);
|
|
98
110
|
}
|
|
99
111
|
}
|
|
100
|
-
|
|
112
|
+
const changeKind = ()=>{
|
|
113
|
+
setError('');
|
|
114
|
+
setStep('kind');
|
|
115
|
+
};
|
|
116
|
+
const choice = step === 'block' ? C.block : kind === 'page' ? C.page : C.setting;
|
|
117
|
+
const kindChip = (busy = pending)=>/*#__PURE__*/ _jsxs("div", {
|
|
118
|
+
className: "xp-new-test-kind",
|
|
119
|
+
children: [
|
|
120
|
+
/*#__PURE__*/ _jsx("span", {
|
|
121
|
+
className: "xp-tests-kind",
|
|
122
|
+
children: choice
|
|
123
|
+
}),
|
|
124
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
125
|
+
variant: "link",
|
|
126
|
+
size: "sm",
|
|
127
|
+
disabled: busy,
|
|
128
|
+
onClick: changeKind,
|
|
129
|
+
children: C.change
|
|
130
|
+
})
|
|
131
|
+
]
|
|
132
|
+
});
|
|
133
|
+
if (created !== undefined && step === 'name' && kind === 'page') return /*#__PURE__*/ _jsx(PageWizard, {
|
|
101
134
|
id: created,
|
|
102
|
-
surface: surface
|
|
135
|
+
surface: surface,
|
|
136
|
+
kindChip: kindChip
|
|
103
137
|
});
|
|
104
138
|
return /*#__PURE__*/ _jsxs("div", {
|
|
105
139
|
className: "xp-new-test",
|
|
106
140
|
children: [
|
|
141
|
+
step !== 'kind' ? kindChip() : null,
|
|
107
142
|
step === 'kind' ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
108
143
|
children: [
|
|
109
144
|
/*#__PURE__*/ _jsx("h2", {
|
|
@@ -121,11 +156,8 @@ export function NewTest({ surface, blockPageCollections = [] }) {
|
|
|
121
156
|
children: C.block
|
|
122
157
|
}),
|
|
123
158
|
/*#__PURE__*/ _jsx("span", {
|
|
124
|
-
children: C.blockMeaning
|
|
125
|
-
})
|
|
126
|
-
surface.admin?.descriptions?.block ? /*#__PURE__*/ _jsx("span", {
|
|
127
|
-
children: surface.admin?.descriptions?.block
|
|
128
|
-
}) : null
|
|
159
|
+
children: surface.admin?.descriptions?.block?.trim() || C.blockMeaning
|
|
160
|
+
})
|
|
129
161
|
]
|
|
130
162
|
}) : null,
|
|
131
163
|
surface.pageCollections?.length ? /*#__PURE__*/ _jsxs("button", {
|
|
@@ -140,11 +172,8 @@ export function NewTest({ surface, blockPageCollections = [] }) {
|
|
|
140
172
|
children: C.page
|
|
141
173
|
}),
|
|
142
174
|
/*#__PURE__*/ _jsx("span", {
|
|
143
|
-
children: C.pageMeaning
|
|
144
|
-
})
|
|
145
|
-
surface.admin?.descriptions?.page ? /*#__PURE__*/ _jsx("span", {
|
|
146
|
-
children: surface.admin?.descriptions?.page
|
|
147
|
-
}) : null
|
|
175
|
+
children: surface.admin?.descriptions?.page?.trim() || C.pageMeaning
|
|
176
|
+
})
|
|
148
177
|
]
|
|
149
178
|
}) : null,
|
|
150
179
|
surface.flagPoints.length > 0 ? /*#__PURE__*/ _jsxs("button", {
|
|
@@ -159,11 +188,8 @@ export function NewTest({ surface, blockPageCollections = [] }) {
|
|
|
159
188
|
children: C.setting
|
|
160
189
|
}),
|
|
161
190
|
/*#__PURE__*/ _jsx("span", {
|
|
162
|
-
children: C.settingMeaning
|
|
163
|
-
})
|
|
164
|
-
surface.admin?.descriptions?.setting ? /*#__PURE__*/ _jsx("span", {
|
|
165
|
-
children: surface.admin?.descriptions.setting
|
|
166
|
-
}) : null
|
|
191
|
+
children: surface.admin?.descriptions?.setting?.trim() || C.settingMeaning
|
|
192
|
+
})
|
|
167
193
|
]
|
|
168
194
|
}) : null
|
|
169
195
|
]
|
|
@@ -335,6 +361,7 @@ export function NewTest({ surface, blockPageCollections = [] }) {
|
|
|
335
361
|
})
|
|
336
362
|
]
|
|
337
363
|
}) : /*#__PURE__*/ _jsxs("form", {
|
|
364
|
+
id: `${id}-details`,
|
|
338
365
|
className: "xp-new-test-form",
|
|
339
366
|
onSubmit: (event)=>{
|
|
340
367
|
event.preventDefault();
|
|
@@ -362,28 +389,21 @@ export function NewTest({ surface, blockPageCollections = [] }) {
|
|
|
362
389
|
error ? /*#__PURE__*/ _jsx("p", {
|
|
363
390
|
role: "alert",
|
|
364
391
|
children: error
|
|
365
|
-
}) : null
|
|
366
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
367
|
-
type: "submit",
|
|
368
|
-
variant: "primary",
|
|
369
|
-
busy: pending,
|
|
370
|
-
disabled: !name.trim(),
|
|
371
|
-
children: pending ? C.creating : C.createTest
|
|
372
|
-
})
|
|
392
|
+
}) : null
|
|
373
393
|
]
|
|
374
394
|
}),
|
|
375
395
|
/*#__PURE__*/ _jsxs("div", {
|
|
376
396
|
className: "xp-new-test-actions",
|
|
377
397
|
children: [
|
|
378
398
|
/*#__PURE__*/ _jsx(Button, {
|
|
379
|
-
variant: "
|
|
399
|
+
variant: "secondary",
|
|
380
400
|
disabled: pending,
|
|
381
401
|
onClick: ()=>{
|
|
382
402
|
if (step === 'kind') router.push(surfaceUrls.home(surface.adminRoute));
|
|
383
|
-
else {
|
|
403
|
+
else if (step === 'name' && kind === 'flag') {
|
|
384
404
|
setError('');
|
|
385
|
-
setStep(
|
|
386
|
-
}
|
|
405
|
+
setStep('setting');
|
|
406
|
+
} else changeKind();
|
|
387
407
|
},
|
|
388
408
|
children: C.back
|
|
389
409
|
}),
|
|
@@ -392,6 +412,13 @@ export function NewTest({ surface, blockPageCollections = [] }) {
|
|
|
392
412
|
disabled: !point,
|
|
393
413
|
onClick: ()=>setStep('name'),
|
|
394
414
|
children: C.next
|
|
415
|
+
}) : step === 'name' ? /*#__PURE__*/ _jsx(Button, {
|
|
416
|
+
type: "submit",
|
|
417
|
+
form: `${id}-details`,
|
|
418
|
+
variant: "primary",
|
|
419
|
+
busy: pending,
|
|
420
|
+
disabled: !name.trim(),
|
|
421
|
+
children: pending ? C.creating : C.createTest
|
|
395
422
|
}) : null
|
|
396
423
|
]
|
|
397
424
|
})
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
import { type ReactNode } from 'react';
|
|
1
2
|
import type { DocId } from '../../../types/contracts.js';
|
|
2
3
|
import type { SurfaceProps } from '../../../testSurface/surface/contracts.js';
|
|
3
4
|
import './newTest.css';
|
|
4
5
|
/** One session stays mounted across Collection, all page steps and Review. */
|
|
5
|
-
export declare function PageWizard({ id, surface }: {
|
|
6
|
+
export declare function PageWizard({ id, surface, kindChip }: {
|
|
6
7
|
id: DocId;
|
|
7
8
|
surface: SurfaceProps;
|
|
9
|
+
kindChip?: (busy: boolean) => ReactNode;
|
|
8
10
|
}): import("react").JSX.Element;
|
|
@@ -23,7 +23,7 @@ import { Button } from '../../../ui/Button.js';
|
|
|
23
23
|
import { Banner } from '../../../ui/Feedback.js';
|
|
24
24
|
import { Select } from '../../../ui/Select.js';
|
|
25
25
|
import './newTest.css';
|
|
26
|
-
/** One session stays mounted across Collection, all page steps and Review. */ export function PageWizard({ id, surface }) {
|
|
26
|
+
/** One session stays mounted across Collection, all page steps and Review. */ export function PageWizard({ id, surface, kindChip }) {
|
|
27
27
|
const router = useRouter();
|
|
28
28
|
const collections = surface.pageCollections ?? [];
|
|
29
29
|
const [copying, setCopying] = useState(false);
|
|
@@ -98,6 +98,7 @@ import './newTest.css';
|
|
|
98
98
|
return /*#__PURE__*/ _jsxs("div", {
|
|
99
99
|
className: "xp-new-test xp-page-wizard",
|
|
100
100
|
children: [
|
|
101
|
+
kindChip?.(busy),
|
|
101
102
|
/*#__PURE__*/ _jsxs("div", {
|
|
102
103
|
className: "xp-page-wizard-heading",
|
|
103
104
|
children: [
|
|
@@ -168,17 +169,6 @@ import './newTest.css';
|
|
|
168
169
|
ready ? /*#__PURE__*/ _jsx("p", {
|
|
169
170
|
children: READINESS_COPY.ready
|
|
170
171
|
}) : null,
|
|
171
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
172
|
-
variant: "primary",
|
|
173
|
-
disabled: busy || test.preflightPending || !test.preflight || test.statusReadPending || ready && (!start || !canStartTest(test, surface.editorPlacementMessage) || !!actionWaitMessage(test)),
|
|
174
|
-
onClick: (event)=>{
|
|
175
|
-
if (start) {
|
|
176
|
-
event.currentTarget.focus();
|
|
177
|
-
setConfirmation(start);
|
|
178
|
-
} else if (next) jump(next.section, next.arm);
|
|
179
|
-
},
|
|
180
|
-
children: start?.label ?? C.finishSetup
|
|
181
|
-
}),
|
|
182
172
|
confirmation ? /*#__PURE__*/ _jsx(ConfirmAction, {
|
|
183
173
|
test: test,
|
|
184
174
|
surface: surface,
|
|
@@ -212,7 +202,7 @@ import './newTest.css';
|
|
|
212
202
|
className: "xp-new-test-actions",
|
|
213
203
|
children: [
|
|
214
204
|
/*#__PURE__*/ _jsx(Button, {
|
|
215
|
-
variant: "
|
|
205
|
+
variant: "secondary",
|
|
216
206
|
disabled: busy,
|
|
217
207
|
onClick: ()=>{
|
|
218
208
|
const previous = steps[steps.indexOf(step) - 1];
|
|
@@ -232,7 +222,17 @@ import './newTest.css';
|
|
|
232
222
|
disabled: busy || step === 'collection' && !collection,
|
|
233
223
|
onClick: ()=>setStep(steps[steps.indexOf(step) + 1] ?? 'review'),
|
|
234
224
|
children: C.next
|
|
235
|
-
}) :
|
|
225
|
+
}) : /*#__PURE__*/ _jsx(Button, {
|
|
226
|
+
variant: "primary",
|
|
227
|
+
disabled: busy || test.preflightPending || !test.preflight || test.statusReadPending || ready && (!start || !canStartTest(test, surface.editorPlacementMessage) || !!actionWaitMessage(test)),
|
|
228
|
+
onClick: (event)=>{
|
|
229
|
+
if (start) {
|
|
230
|
+
event.currentTarget.focus();
|
|
231
|
+
setConfirmation(start);
|
|
232
|
+
} else if (next) jump(next.section, next.arm);
|
|
233
|
+
},
|
|
234
|
+
children: start?.label ?? C.finishSetup
|
|
235
|
+
})
|
|
236
236
|
]
|
|
237
237
|
}),
|
|
238
238
|
test.errors.pageCollection ? /*#__PURE__*/ _jsx("p", {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
.xp-new-test { display: grid; gap: var(--xp-space-4);
|
|
1
|
+
.xp-new-test { display: grid; gap: var(--xp-space-4); color: var(--xp-text); font: var(--xp-text-body); }
|
|
2
2
|
.xp-new-test h2 { margin: 0; font: var(--xp-text-title); }
|
|
3
3
|
.xp-new-test p { margin: 0; }
|
|
4
4
|
.xp-new-test-form { display: grid; gap: var(--xp-space-4); max-width: 36rem; }
|
|
5
|
-
.xp-new-test-form > .xp-ui-button { justify-self: start; }
|
|
6
5
|
.xp-new-test-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 15rem), 1fr)); gap: var(--xp-space-3); }
|
|
7
6
|
.xp-new-test-card {
|
|
8
7
|
display: grid; align-content: start; gap: var(--xp-space-2); padding: var(--xp-space-5); text-align: start; cursor: pointer;
|
|
@@ -16,7 +15,8 @@
|
|
|
16
15
|
.xp-new-test input[type='radio'] { margin-inline: 0 var(--xp-space-2); accent-color: var(--xp-accent); }
|
|
17
16
|
.xp-new-test-choice span { display: block; margin-inline-start: var(--xp-space-6); color: var(--xp-text-2); }
|
|
18
17
|
.xp-new-test summary { cursor: pointer; margin-bottom: var(--xp-space-2); }
|
|
19
|
-
.xp-new-test-actions { display: flex;
|
|
18
|
+
.xp-new-test-kind, .xp-new-test-actions { display: flex; gap: var(--xp-space-2); align-items: center; }
|
|
19
|
+
.xp-new-test-actions > .xp-ui-button--primary { margin-inline-start: auto; }
|
|
20
20
|
.xp-new-test-collection { max-width: 16rem; }
|
|
21
21
|
.xp-new-test-help { color: var(--xp-text-2); max-width: 65ch; }
|
|
22
22
|
.xp-page-wizard-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--xp-space-2) var(--xp-space-4); }
|
|
@@ -2,7 +2,7 @@ import type { ReactNode } from 'react';
|
|
|
2
2
|
import type { ResultsResponse } from '../../../types/endpoints.js';
|
|
3
3
|
import type { SectionProps } from '../../../testSurface/surface/contracts.js';
|
|
4
4
|
import type { ResultsPageParts } from '../../../testSurface/surface/results/ResultsBody.js';
|
|
5
|
-
export declare function ResultsHeader({ test, surface, resultsVersion, children,
|
|
5
|
+
export declare function ResultsHeader({ test, surface, resultsVersion, children, roundActions, editOnPage, refresh, released }: SectionProps & ResultsPageParts): import("react").JSX.Element;
|
|
6
6
|
export declare function ReaderResultsShell({ surface, children, data }: {
|
|
7
7
|
surface: SectionProps['surface'];
|
|
8
8
|
children: ReactNode;
|