@delmaredigital/payload-experiments 0.4.0-rc.5 → 0.4.0-rc.7
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/blocks/BlockPanel.js +6 -4
- package/dist/admin/blocks/inject.js +1 -0
- package/dist/admin/blocks/model.d.ts +3 -2
- package/dist/admin/blocks/model.js +8 -4
- package/dist/admin/copy/blocks.d.ts +3 -2
- package/dist/admin/copy/blocks.js +7 -6
- package/dist/admin/copy/newTest.d.ts +1 -1
- package/dist/admin/copy/newTest.js +1 -1
- package/dist/admin/surface/ResultsRoute.js +2 -1
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +91 -37
- package/dist/admin/surface/TestsSurface.js +3 -0
- package/dist/admin/surface/home.model.d.ts +2 -0
- package/dist/admin/surface/newTest/NewTest.js +16 -18
- package/dist/admin/surface/newTest/PageWizard.js +1 -0
- package/dist/admin/surface/newTest/newTest.css +3 -1
- package/dist/admin/views/TestsSurfaceClient.d.ts +3 -0
- package/dist/admin/views/TestsSurfaceClient.js +11 -0
- package/dist/admin/views/buildSurfaceProps.js +10 -3
- package/dist/blocks/bindings.js +8 -14
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +23 -7
- package/dist/blocks/placementLocale.js +221 -66
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.js +8 -4
- package/dist/endpoints/contentLocale.d.ts +6 -0
- package/dist/endpoints/contentLocale.js +15 -0
- package/dist/endpoints/deleteImpact.d.ts +6 -0
- package/dist/endpoints/deleteImpact.js +206 -0
- package/dist/endpoints/index.js +7 -0
- package/dist/endpoints/pages.js +7 -3
- package/dist/endpoints/placementStatus.js +6 -1
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/exports/adminClient.d.ts +1 -1
- package/dist/exports/adminClient.js +1 -1
- package/dist/exports/index.d.ts +1 -1
- package/dist/goals/fairness.js +43 -34
- package/dist/hooks/blockRemovalRule.d.ts +4 -3
- package/dist/hooks/blockRemovalRule.js +33 -9
- package/dist/hooks/pageGuard.d.ts +3 -0
- package/dist/hooks/pageGuard.js +34 -24
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/lib/placementPages.d.ts +2 -1
- package/dist/lib/placementPages.js +10 -2
- package/dist/manifest/compile.d.ts +2 -1
- package/dist/manifest/compile.js +5 -1
- package/dist/puck/ExperimentPicker.d.ts +2 -1
- package/dist/puck/ExperimentPicker.js +37 -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.d.ts +8 -4
- package/dist/puck/editor/ConfigureTestDrawer.js +4 -2
- package/dist/puck/editor/CreateExperimentDrawer.d.ts +2 -1
- package/dist/puck/editor/CreateExperimentDrawer.js +24 -20
- package/dist/puck/editor/EditorControls.d.ts +1 -1
- package/dist/puck/editor/EditorControls.js +1 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +405 -394
- package/dist/puck/editor/LeftoverVersions.d.ts +4 -2
- package/dist/puck/editor/LeftoverVersions.js +23 -44
- package/dist/puck/editor/QuickTestActions.js +2 -2
- package/dist/puck/editor/VersionBuilder.d.ts +41 -13
- package/dist/puck/editor/VersionBuilder.js +461 -224
- package/dist/puck/editor/armWrites.d.ts +9 -2
- package/dist/puck/editor/armWrites.js +40 -2
- package/dist/puck/editor/armsCache.d.ts +1 -1
- package/dist/puck/editor/armsCache.js +2 -1
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/copy.d.ts +27 -26
- package/dist/puck/editor/copy.js +28 -26
- package/dist/puck/editor/createTest.d.ts +3 -0
- package/dist/puck/editor/createTest.js +33 -0
- package/dist/puck/editor/editor.chrome.css +138 -17
- package/dist/puck/editor/editor.css +156 -22
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +3 -3
- package/dist/puck/editor/experimentOutlinePlugin.js +1 -1
- package/dist/puck/editor/localPlacements.d.ts +5 -2
- package/dist/puck/editor/localPlacements.js +32 -18
- package/dist/puck/editor/placementsCache.d.ts +18 -12
- package/dist/puck/editor/placementsCache.js +52 -47
- package/dist/puck/editor/sidebar.d.ts +2 -6
- package/dist/puck/editor/sidebar.js +3 -6
- package/dist/puck/editor/usePlacementNotice.d.ts +1 -1
- package/dist/puck/editor/usePlacementNotice.js +4 -3
- package/dist/puck/experimentSlug.d.ts +2 -0
- package/dist/puck/experimentSlug.js +3 -0
- package/dist/puck/nestedTestCopy.d.ts +8 -0
- package/dist/puck/nestedTestCopy.js +22 -0
- package/dist/puck/nestedTests.d.ts +17 -0
- package/dist/puck/nestedTests.js +30 -0
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +17 -4
- package/dist/puck/visibility.d.ts +20 -0
- package/dist/puck/visibility.js +81 -0
- package/dist/server/recordContentChange.js +37 -20
- package/dist/server/resolveExperimentData.js +6 -3
- package/dist/testSurface/PreviewLinks.js +6 -2
- package/dist/testSurface/api.d.ts +6 -3
- package/dist/testSurface/api.js +10 -6
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/testSurface/copy/common.d.ts +4 -0
- package/dist/testSurface/copy/common.js +8 -4
- package/dist/testSurface/copy/languages.d.ts +11 -0
- package/dist/testSurface/copy/languages.js +7 -0
- package/dist/testSurface/copy/readiness.d.ts +2 -1
- package/dist/testSurface/copy/readiness.js +2 -1
- package/dist/testSurface/copy/testPage.d.ts +28 -6
- package/dist/testSurface/copy/testPage.js +28 -6
- package/dist/testSurface/placementLabel.d.ts +8 -0
- package/dist/testSurface/placementLabel.js +24 -0
- package/dist/testSurface/placements/placementLabels.d.ts +2 -0
- package/dist/testSurface/placements/placementLabels.js +2 -1
- 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 +2 -0
- package/dist/testSurface/surface/editorPlacement.d.ts +5 -0
- package/dist/testSurface/surface/editorPlacement.js +18 -0
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +2 -1
- package/dist/testSurface/surface/pageBlock/parts.js +24 -6
- package/dist/testSurface/surface/readiness/ActionDialogs.js +28 -34
- package/dist/testSurface/surface/readiness/readiness.model.js +9 -2
- package/dist/testSurface/surface/results/useResults.d.ts +4 -1
- package/dist/testSurface/surface/test/DeleteTest.d.ts +15 -0
- package/dist/testSurface/surface/test/DeleteTest.js +171 -0
- package/dist/testSurface/surface/test/GoalSection.js +101 -74
- package/dist/testSurface/surface/test/TestSurface.js +29 -9
- package/dist/testSurface/surface/test/fields.d.ts +1 -3
- package/dist/testSurface/surface/test/fields.js +5 -35
- package/dist/testSurface/surface/useTestDocument.d.ts +2 -1
- package/dist/testSurface/surface/useTestDocument.js +20 -4
- package/dist/testSurface/useApi.d.ts +4 -1
- package/dist/transitions/checkStart.d.ts +4 -1
- package/dist/transitions/checkStart.js +117 -14
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/makeContent.js +29 -9
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +33 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/placementInteractions.js +7 -4
- package/dist/transitions/placements.d.ts +26 -1
- package/dist/transitions/placements.js +239 -87
- package/dist/transitions/preflightData.d.ts +2 -1
- package/dist/transitions/preflightData.js +66 -3
- package/dist/transitions/start.js +4 -1
- package/dist/types/endpoints.d.ts +35 -1
- package/dist/types/endpoints.js +1 -1
- package/dist/types/puck.d.ts +1 -0
- package/dist/types/surface.d.ts +2 -0
- package/dist/ui/Button.js +2 -2
- package/dist/ui/Inputs.d.ts +4 -3
- package/dist/ui/Inputs.js +7 -4
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/Tabs.d.ts +0 -1
- package/dist/ui/Tabs.js +28 -40
- package/dist/ui/ui.css +18 -5
- package/package.json +3 -2
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { placementReader } from '../blocks/placementLocale.js';
|
|
2
|
+
import { puckExperimentSlug } from '../puck/experimentSlug.js';
|
|
3
|
+
import { puckVisibility } from '../puck/visibility.js';
|
|
1
4
|
import { EXPERIMENT_BLOCK_SLUG, hostBlocks } from '../blocks/model.js';
|
|
2
5
|
import { safeError } from '../log.js';
|
|
3
6
|
import { isDeepStrictEqual } from 'node:util';
|
|
@@ -7,7 +10,7 @@ import { pageContentBindings } from '../db/pageBindings.js';
|
|
|
7
10
|
import { sortLockKeys } from '../db/locks.js';
|
|
8
11
|
import { normalisePath } from '../runtime/normalisePath.js';
|
|
9
12
|
import { comparableContent } from '../transitions/pageVersions.js';
|
|
10
|
-
import {
|
|
13
|
+
import { puckCollections } from '../options.js';
|
|
11
14
|
import { withTransition } from '../transitions/kernel.js';
|
|
12
15
|
import { normaliseContentRelationships } from './normaliseContentRelationships.js';
|
|
13
16
|
const slots = [
|
|
@@ -19,6 +22,7 @@ const slots = [
|
|
|
19
22
|
const object = (value)=>value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
20
23
|
function bindings(data, puck) {
|
|
21
24
|
const found = new Map();
|
|
25
|
+
const visibility = puck ? puckVisibility(data) : undefined;
|
|
22
26
|
function add(field, value, content) {
|
|
23
27
|
const key = field + ':' + value;
|
|
24
28
|
const binding = found.get(key) ?? {
|
|
@@ -34,10 +38,10 @@ function bindings(data, puck) {
|
|
|
34
38
|
value.forEach(walk);
|
|
35
39
|
return;
|
|
36
40
|
}
|
|
37
|
-
if (!object(value)) return;
|
|
41
|
+
if (!object(value) || visibility?.get(value)?.hidden) return;
|
|
38
42
|
if (puck && value.type === 'ExperimentSlot' && object(value.props)) {
|
|
39
43
|
const props = value.props;
|
|
40
|
-
const slug =
|
|
44
|
+
const slug = puckExperimentSlug(props.experiment);
|
|
41
45
|
if (typeof slug === 'string' && slug) add('slug', slug, {
|
|
42
46
|
id: props.id,
|
|
43
47
|
...Object.fromEntries(slots.map((slot)=>[
|
|
@@ -102,9 +106,10 @@ async function auditContentChange({ doc, previousDoc, req, collection }) {
|
|
|
102
106
|
}
|
|
103
107
|
const options = req.payload.config.custom?.xp;
|
|
104
108
|
const registration = puckCollections(options ?? {}).find((entry)=>entry.slug === collection.slug);
|
|
105
|
-
const
|
|
106
|
-
|
|
107
|
-
const
|
|
109
|
+
const reader = placementReader(req, collection.slug, options ?? {});
|
|
110
|
+
const changesOne = (previous, current)=>{
|
|
111
|
+
const after = bindings(registration && object(current) ? current[registration.field] : current, Boolean(registration) && reader.read(object(current) ? current : undefined, 'localized').editor === 'puck');
|
|
112
|
+
const before = bindings(registration && object(previous) ? previous[registration.field] : previous, Boolean(registration) && reader.read(object(previous) ? previous : undefined, 'localized').editor === 'puck');
|
|
108
113
|
const blockRegistration = options?.blocks?.collections.find((entry)=>entry.slug === collection.slug);
|
|
109
114
|
for (const [row, found] of [
|
|
110
115
|
[
|
|
@@ -116,7 +121,7 @@ async function auditContentChange({ doc, previousDoc, req, collection }) {
|
|
|
116
121
|
after
|
|
117
122
|
]
|
|
118
123
|
]){
|
|
119
|
-
if (!blockRegistration || !object(row) ||
|
|
124
|
+
if (!blockRegistration || !object(row) || reader.read(row, 'localized').editor !== 'blocks') continue;
|
|
120
125
|
for (const block of hostBlocks(row[blockRegistration.field])){
|
|
121
126
|
if (block.blockType !== (blockRegistration.blockSlug ?? EXPERIMENT_BLOCK_SLUG) || typeof block.experiment !== 'string') continue;
|
|
122
127
|
const key = 'slug:' + block.experiment;
|
|
@@ -136,6 +141,9 @@ async function auditContentChange({ doc, previousDoc, req, collection }) {
|
|
|
136
141
|
])
|
|
137
142
|
].filter((key)=>!isDeepStrictEqual(before.get(key)?.contents, after.get(key)?.contents)).map((key)=>after.get(key) ?? before.get(key));
|
|
138
143
|
};
|
|
144
|
+
const changes = (previous, current, input)=>(input === 'all-locales' ? reader.documentViews : [
|
|
145
|
+
undefined
|
|
146
|
+
]).flatMap((view)=>changesOne(reader.read(object(previous) ? previous : undefined, input, view).doc, reader.read(object(current) ? current : undefined, input, view).doc));
|
|
139
147
|
// Include discovery reads in the savepoint: a SQL read error also aborts Postgres.
|
|
140
148
|
// An explicit host call must supply its afterChange request's transaction.
|
|
141
149
|
const executor = txExecutor(req);
|
|
@@ -152,11 +160,11 @@ async function auditContentChange({ doc, previousDoc, req, collection }) {
|
|
|
152
160
|
if (!current) throw new Error('The saved content row was not found.');
|
|
153
161
|
beforeRow = baseline.doc;
|
|
154
162
|
afterRow = current;
|
|
155
|
-
changed = changes(beforeRow, afterRow);
|
|
163
|
+
changed = changes(beforeRow, afterRow, 'all-locales');
|
|
156
164
|
} else {
|
|
157
165
|
beforeRow = normalise(previousDoc);
|
|
158
166
|
afterRow = normalise(doc);
|
|
159
|
-
changed = changes(beforeRow, afterRow);
|
|
167
|
+
changed = changes(beforeRow, afterRow, 'localized');
|
|
160
168
|
}
|
|
161
169
|
const experiments = new Map();
|
|
162
170
|
for (const binding of changed){
|
|
@@ -164,17 +172,26 @@ async function auditContentChange({ doc, previousDoc, req, collection }) {
|
|
|
164
172
|
if (experiment) experiments.set(String(experiment.id), experiment.id);
|
|
165
173
|
}
|
|
166
174
|
const page = options?.pages?.collections.find((entry)=>entry.slug === collection.slug);
|
|
167
|
-
if (page?.contentOf
|
|
168
|
-
const
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
175
|
+
if (page?.contentOf) {
|
|
176
|
+
const input = baseline || req.locale === 'all' ? 'all-locales' : 'localized';
|
|
177
|
+
const paths = new Set();
|
|
178
|
+
for (const view of input === 'all-locales' ? reader.documentViews : [
|
|
179
|
+
undefined
|
|
180
|
+
]){
|
|
181
|
+
const before = reader.read(object(beforeRow) ? beforeRow : undefined, input, view).doc;
|
|
182
|
+
const after = reader.read(object(afterRow) ? afterRow : undefined, input, view).doc;
|
|
183
|
+
if (isDeepStrictEqual(comparableContent(before ? page.contentOf(before) : undefined), comparableContent(after ? page.contentOf(after) : undefined))) continue;
|
|
184
|
+
for (const doc of [
|
|
185
|
+
before,
|
|
186
|
+
after
|
|
187
|
+
]){
|
|
188
|
+
const path = doc ? page.pathOf(doc) : null;
|
|
189
|
+
if (path !== null) paths.add(normalisePath(path));
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
if (paths.size) for (const id of (await pageContentBindings(executor, collection.slug, sortLockKeys([
|
|
193
|
+
...paths
|
|
194
|
+
]))))experiments.set(String(id), id);
|
|
178
195
|
}
|
|
179
196
|
// Successful audit locks persist until commit; acquire multiple E locks in order.
|
|
180
197
|
for (const key of sortLockKeys([
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
import { puckExperimentSlug } from '../puck/experimentSlug.js';
|
|
2
|
+
import { puckVisibility } from '../puck/visibility.js';
|
|
1
3
|
import { manifestOf, suppressExposure } from './context.js';
|
|
2
4
|
export function resolveExperimentData(puckData, assignments) {
|
|
5
|
+
const visibility = puckVisibility(puckData);
|
|
3
6
|
const rendered = new Map();
|
|
4
7
|
const slots = [
|
|
5
8
|
'control',
|
|
@@ -9,8 +12,9 @@ export function resolveExperimentData(puckData, assignments) {
|
|
|
9
12
|
];
|
|
10
13
|
const manifest = manifestOf(assignments);
|
|
11
14
|
function walk(value) {
|
|
12
|
-
if (Array.isArray(value)) return value.map(walk);
|
|
15
|
+
if (Array.isArray(value)) return value.map(walk).filter((item)=>item !== undefined);
|
|
13
16
|
if (!value || typeof value !== 'object') return value;
|
|
17
|
+
if (visibility.get(value)?.hidden) return undefined;
|
|
14
18
|
const node = value;
|
|
15
19
|
if (node.type !== 'ExperimentSlot') return Object.fromEntries(Object.entries(node).map(([key, item])=>[
|
|
16
20
|
key,
|
|
@@ -24,8 +28,7 @@ export function resolveExperimentData(puckData, assignments) {
|
|
|
24
28
|
delete clean.xpSlot;
|
|
25
29
|
delete clean.xpArm;
|
|
26
30
|
delete clean.xpExpose;
|
|
27
|
-
const
|
|
28
|
-
const slug = typeof ref?.slug === 'string' ? ref.slug : undefined;
|
|
31
|
+
const slug = puckExperimentSlug(props.experiment);
|
|
29
32
|
const assignment = slug && Object.hasOwn(assignments.bySlug, slug) ? assignments.bySlug[slug] : undefined;
|
|
30
33
|
const experiment = manifest?.experiments.find((e)=>e.slug === slug);
|
|
31
34
|
const arm = experiment?.arms.find((a)=>a.key === assignment?.arm);
|
|
@@ -5,6 +5,7 @@ import { Button } from '../ui/Button.js';
|
|
|
5
5
|
import { armLabel } from './labels.js';
|
|
6
6
|
import { useApi } from './useApi.js';
|
|
7
7
|
import { REVIEW_COPY as C } from './copy/review.js';
|
|
8
|
+
import { placementLabel } from './placementLabel.js';
|
|
8
9
|
import { TEST_PAGE } from './copy/testPage.js';
|
|
9
10
|
import { API_MESSAGES, refusalMessage } from './copy/common.js';
|
|
10
11
|
import { actionablePreviewPages } from './previewLinks.model.js';
|
|
@@ -55,15 +56,16 @@ export function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRou
|
|
|
55
56
|
setBusy(false);
|
|
56
57
|
}
|
|
57
58
|
}
|
|
59
|
+
const pages = actionablePreviewPages(placements, flagPoint);
|
|
58
60
|
return /*#__PURE__*/ _jsxs("div", {
|
|
59
61
|
className: "xp-preview-links",
|
|
60
62
|
children: [
|
|
61
|
-
|
|
63
|
+
pages.map((placement)=>/*#__PURE__*/ _jsxs("div", {
|
|
62
64
|
className: "xp-preview-row",
|
|
63
65
|
children: [
|
|
64
66
|
/*#__PURE__*/ _jsxs("p", {
|
|
65
67
|
children: [
|
|
66
|
-
placement
|
|
68
|
+
placementLabel(placement),
|
|
67
69
|
placement.slotCount > 1 ? ` ${C.placedTimes(placement.slotCount)}` : null
|
|
68
70
|
]
|
|
69
71
|
}),
|
|
@@ -73,6 +75,7 @@ export function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRou
|
|
|
73
75
|
placement.url ? arms.filter((arm)=>arm.kind !== 'holdout' && arm.key !== 'holdout').map((arm)=>/*#__PURE__*/ _jsxs(Button, {
|
|
74
76
|
variant: "secondary",
|
|
75
77
|
size: "sm",
|
|
78
|
+
"aria-label": pages.length > 1 ? `${C.preview} ${arm.label?.trim() || armLabel(arm.key)}: ${placementLabel(placement)}` : undefined,
|
|
76
79
|
disabled: busy,
|
|
77
80
|
onClick: ()=>{
|
|
78
81
|
void preview(placement.url, arm.key);
|
|
@@ -87,6 +90,7 @@ export function PreviewLinks({ experimentId, placements, arms, flagPoint, apiRou
|
|
|
87
90
|
variant: "link",
|
|
88
91
|
size: "sm",
|
|
89
92
|
href: placement.editorUrl,
|
|
93
|
+
"aria-label": pages.length > 1 ? `${TEST_PAGE.editOnPage}: ${placementLabel(placement)}` : undefined,
|
|
90
94
|
children: TEST_PAGE.editOnPage
|
|
91
95
|
}) : null
|
|
92
96
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { DocId } from '../types/contracts.js';
|
|
2
|
-
import type { WrapBlockBody, PagesResult, PlacementStatusBody, PlacementStatusResult, RestoreContentEntryBody, RestoreContentEntryResult, DismissContentEntryBody, DismissContentEntryResult, AddMetricBody, AllocateBody, ArchiveBody, DecideBody, MakeContentResult, AddMetricResult, ClickKeysResult, PreflightResult, PreviewTokenResult, RefusalCode, ResultsResponse, SummaryResponse, TransitionSuccess } from '../types/endpoints.js';
|
|
2
|
+
import type { DeleteImpactResult, WrapBlockBody, PagesResult, PlacementStatusBody, PlacementStatusResult, RestoreContentEntryBody, RestoreContentEntryResult, DismissContentEntryBody, DismissContentEntryResult, AddMetricBody, AllocateBody, ArchiveBody, DecideBody, MakeContentResult, AddMetricResult, ClickKeysResult, PreflightResult, PreviewTokenResult, RefusalCode, ResultsResponse, SummaryResponse, TransitionSuccess } from '../types/endpoints.js';
|
|
3
3
|
import { refusalMessage } from './copy/common.js';
|
|
4
4
|
export type ApiResult<T> = {
|
|
5
5
|
ok: true;
|
|
@@ -12,14 +12,16 @@ export type ApiResult<T> = {
|
|
|
12
12
|
retryable: boolean;
|
|
13
13
|
};
|
|
14
14
|
type RequestOptions = NonNullable<Parameters<typeof refusalMessage>[3]>;
|
|
15
|
-
export declare function createApi(apiBase: string): {
|
|
15
|
+
export declare function createApi(apiBase: string, contentLocale?: string): {
|
|
16
16
|
findTestIdBySlug: (slug: string) => Promise<Extract<ApiResult<DocId>, {
|
|
17
17
|
ok: false;
|
|
18
18
|
}> | {
|
|
19
19
|
ok: true;
|
|
20
20
|
data: DocId;
|
|
21
21
|
}>;
|
|
22
|
-
deleteTest: (id: DocId
|
|
22
|
+
deleteTest: (id: DocId, { draft }?: {
|
|
23
|
+
draft?: boolean;
|
|
24
|
+
}) => Promise<ApiResult<unknown>>;
|
|
23
25
|
wrapBlock: (body: WrapBlockBody) => Promise<ApiResult<Record<string, unknown>>>;
|
|
24
26
|
pages: (query: {
|
|
25
27
|
collection: string;
|
|
@@ -40,6 +42,7 @@ export declare function createApi(apiBase: string): {
|
|
|
40
42
|
restoreContentEntry: (id: DocId, body: RestoreContentEntryBody) => Promise<ApiResult<RestoreContentEntryResult>>;
|
|
41
43
|
archive: (id: DocId, body: ArchiveBody) => Promise<ApiResult<TransitionSuccess>>;
|
|
42
44
|
clickKeys: (id: DocId) => Promise<ApiResult<ClickKeysResult>>;
|
|
45
|
+
deleteImpact: (id: DocId, signal?: AbortSignal) => Promise<ApiResult<DeleteImpactResult>>;
|
|
43
46
|
preflight: (id: DocId) => Promise<ApiResult<PreflightResult>>;
|
|
44
47
|
previewToken: (id: DocId, arm: string) => Promise<ApiResult<PreviewTokenResult>>;
|
|
45
48
|
results: (id: DocId, options?: {
|
package/dist/testSurface/api.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { contentLocaleURL } from './contentLocaleURL.js';
|
|
1
2
|
import { API_MESSAGES, refusalMessage } from './copy/common.js';
|
|
2
3
|
import { CONTENT_ENTRY_REFUSALS } from './copy/actions.js';
|
|
3
|
-
export function createApi(apiBase) {
|
|
4
|
+
export function createApi(apiBase, contentLocale) {
|
|
4
5
|
const collectionBase = `${apiBase.replace(/\/$/, '')}/xp-experiments`;
|
|
5
6
|
const base = `${apiBase.replace(/\/$/, '')}/xp/experiments`;
|
|
6
7
|
const route = (id, action)=>`${base}/${encodeURIComponent(id)}/${action}`;
|
|
@@ -83,11 +84,13 @@ export function createApi(apiBase) {
|
|
|
83
84
|
data: id
|
|
84
85
|
};
|
|
85
86
|
},
|
|
86
|
-
deleteTest: (id)=>request(()=>`${collectionBase}/${encodeURIComponent(id)}`, 'DELETE', undefined, {
|
|
87
|
-
notFound: API_MESSAGES.
|
|
88
|
-
|
|
87
|
+
deleteTest: (id, { draft = false } = {})=>request(()=>`${collectionBase}/${encodeURIComponent(id)}`, 'DELETE', undefined, {
|
|
88
|
+
notFound: API_MESSAGES.testAlreadyDeleted,
|
|
89
|
+
...draft ? {
|
|
90
|
+
forbidden: API_MESSAGES.testNoLongerDraft
|
|
91
|
+
} : {},
|
|
89
92
|
codes: {
|
|
90
|
-
'invalid-status': API_MESSAGES.testNoLongerDraft
|
|
93
|
+
'invalid-status': draft ? API_MESSAGES.testNoLongerDraft : API_MESSAGES.deleteInvalidStatus
|
|
91
94
|
}
|
|
92
95
|
}),
|
|
93
96
|
wrapBlock: (body)=>request(()=>`${apiBase.replace(/\/$/, '')}/xp/blocks/wrap`, 'POST', body),
|
|
@@ -116,7 +119,8 @@ export function createApi(apiBase) {
|
|
|
116
119
|
restoreContentEntry: (id, body)=>post(id, 'content-report/restore', body, CONTENT_ENTRY_REFUSALS),
|
|
117
120
|
archive: (id, body)=>post(id, 'archive', body),
|
|
118
121
|
clickKeys: (id)=>request(()=>route(id, 'click-keys'), 'GET'),
|
|
119
|
-
|
|
122
|
+
deleteImpact: (id, signal)=>request(()=>contentLocaleURL(route(id, 'delete-impact'), contentLocale), 'GET', undefined, undefined, signal),
|
|
123
|
+
preflight: (id)=>request(()=>contentLocaleURL(route(id, 'preflight'), contentLocale), 'GET'),
|
|
120
124
|
previewToken: (id, arm)=>request(()=>`${route(id, 'preview-token')}?arm=${encodeURIComponent(arm)}`, 'GET'),
|
|
121
125
|
results: (id, options = {})=>request(()=>{
|
|
122
126
|
const query = new URLSearchParams();
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const API_MESSAGES: {
|
|
2
2
|
readonly testAlreadyDeleted: "This test was already deleted. Reload the page.";
|
|
3
|
+
readonly deleteInvalidStatus: "This test has changed and cannot be deleted now. Reload the page.";
|
|
3
4
|
readonly testNoLongerDraft: "This test is no longer a draft. Reload the page.";
|
|
4
5
|
readonly notFound: "This test no longer exists.";
|
|
5
6
|
readonly goalNotFound: "That goal no longer exists. Choose another goal.";
|
|
@@ -28,3 +29,6 @@ export declare function refusalMessage(code: string | undefined, status: number,
|
|
|
28
29
|
codes?: Readonly<Record<string, string>>;
|
|
29
30
|
fallback?: string;
|
|
30
31
|
}, detail?: unknown): string;
|
|
32
|
+
export declare const INPUT_COPY: {
|
|
33
|
+
readonly selectRequired: "Choose an option.";
|
|
34
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { unpublishedPlacementsCopy } from './readiness.js';
|
|
2
2
|
export const API_MESSAGES = {
|
|
3
3
|
testAlreadyDeleted: 'This test was already deleted. Reload the page.',
|
|
4
|
+
deleteInvalidStatus: 'This test has changed and cannot be deleted now. Reload the page.',
|
|
4
5
|
testNoLongerDraft: 'This test is no longer a draft. Reload the page.',
|
|
5
6
|
notFound: 'This test no longer exists.',
|
|
6
7
|
goalNotFound: 'That goal no longer exists. Choose another goal.',
|
|
@@ -24,14 +25,17 @@ export const LOCKED_MESSAGES = {
|
|
|
24
25
|
other: "Can't be changed in this state."
|
|
25
26
|
};
|
|
26
27
|
export function refusalMessage(code, status, message, options, detail) {
|
|
27
|
-
//
|
|
28
|
+
// Authorization takes priority over code copy; entry-specific 404s still name the missing entry.
|
|
28
29
|
const mapped = code && options?.codes && Object.hasOwn(options.codes, code) ? options.codes[code] : undefined;
|
|
29
|
-
if (mapped !== undefined) return mapped;
|
|
30
30
|
if (code === 'unauthenticated' || status === 401) return API_MESSAGES.unauthenticated;
|
|
31
|
-
if (code === '
|
|
31
|
+
if (code === 'forbidden' || status === 403) return options?.forbidden ?? API_MESSAGES.forbidden;
|
|
32
|
+
if (code === 'not-found' || status === 404) return mapped ?? options?.notFound ?? API_MESSAGES.notFound;
|
|
32
33
|
if (code === 'commit-unverified') return API_MESSAGES.commitUnverified;
|
|
33
34
|
if (code === 'not-implemented' || status === 501) return API_MESSAGES.notImplemented;
|
|
34
|
-
if (
|
|
35
|
+
if (mapped !== undefined) return mapped;
|
|
35
36
|
if (code === 'placement-unpublished') return unpublishedPlacementsCopy(detail);
|
|
36
37
|
return options?.fallback ?? (message || API_MESSAGES.failed);
|
|
37
38
|
}
|
|
39
|
+
export const INPUT_COPY = {
|
|
40
|
+
selectRequired: 'Choose an option.'
|
|
41
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** Shared by server readiness checks and client placement lists. */
|
|
2
|
+
export declare const PLACEMENT_LANGUAGES: {
|
|
3
|
+
readonly allLocales: "All languages";
|
|
4
|
+
readonly locales: (names: string) => string;
|
|
5
|
+
};
|
|
6
|
+
export interface PlacementLanguages {
|
|
7
|
+
locales?: readonly string[];
|
|
8
|
+
allLocales?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/** Shared suffix for server findings, placement rows, and delete-impact details. */
|
|
11
|
+
export declare function placementLanguageSuffix({ locales, allLocales }: PlacementLanguages): string;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Shared by server readiness checks and client placement lists. */ export const PLACEMENT_LANGUAGES = {
|
|
2
|
+
allLocales: 'All languages',
|
|
3
|
+
locales: (names)=>`Languages: ${names}`
|
|
4
|
+
};
|
|
5
|
+
/** Shared suffix for server findings, placement rows, and delete-impact details. */ export function placementLanguageSuffix({ locales, allLocales }) {
|
|
6
|
+
return allLocales ? ` · ${PLACEMENT_LANGUAGES.allLocales}` : locales?.length ? ` · ${PLACEMENT_LANGUAGES.locales(locales.join(', '))}` : '';
|
|
7
|
+
}
|
|
@@ -71,7 +71,7 @@ export declare const placementFailureCopy: (reason: unknown) => "Couldn't check
|
|
|
71
71
|
export declare const fixFieldsNext: (name: string) => string;
|
|
72
72
|
export declare const nextCopy: (sentence: string) => string;
|
|
73
73
|
export declare const versionsNext: (detail: string) => string;
|
|
74
|
-
export declare const contentNext: (group: string) => string;
|
|
74
|
+
export declare const contentNext: (group: string, page?: string) => string;
|
|
75
75
|
export declare const parameterNext: (parameter: string, group: string) => string;
|
|
76
76
|
export declare const placementNext: (group: string, detail: string) => string;
|
|
77
77
|
export declare const goalPeopleNext: (people: string) => string;
|
|
@@ -81,6 +81,7 @@ export declare const stoppedCopy: (date: string | null) => string;
|
|
|
81
81
|
export declare const decidedCopy: (date: string | null, winner: string) => string;
|
|
82
82
|
export declare const runningCopy: (date: string | null, people: number | null, days: number | null) => string;
|
|
83
83
|
export declare const lastBlockPlacementCopy: (name: string, removingPage?: boolean) => string;
|
|
84
|
+
export declare const hiddenBlockPlacementCopy: (name: string) => string;
|
|
84
85
|
export declare const bulkBlockRemovalCopy: (name: string) => string;
|
|
85
86
|
export declare const pendingBlockRemovalCopy: (name: string) => string;
|
|
86
87
|
/** After archive the guard protects the winner and the Original; only the winner page is "the winner". */
|
|
@@ -68,7 +68,7 @@ const withoutPeriod = (value)=>value.trim().replace(/[.!?]+$/, '');
|
|
|
68
68
|
export const fixFieldsNext = (name)=>`Fix the highlighted fields in ${name}.`;
|
|
69
69
|
export const nextCopy = (sentence)=>`Next: ${sentence}`;
|
|
70
70
|
export const versionsNext = (detail)=>`Fix the versions: ${withoutPeriod(detail)}.`;
|
|
71
|
-
export const contentNext = (group)=>`Add content for ${group} on
|
|
71
|
+
export const contentNext = (group, page = 'the page')=>`Add content for ${group} on ${page}.`;
|
|
72
72
|
export const parameterNext = (parameter, group)=>`Set a value for ${parameter} on ${group}.`;
|
|
73
73
|
export const placementNext = (group, detail)=>`Add content for ${group} wherever this setting is used${detail.trim() ? `: ${withoutPeriod(detail)}` : ''}.`;
|
|
74
74
|
export const goalPeopleNext = (people)=>`This goal can't be measured for ${people}. Choose another goal.`;
|
|
@@ -82,6 +82,7 @@ export const runningCopy = (date, people, days)=>[
|
|
|
82
82
|
days === null ? null : `about ${days} days to go`
|
|
83
83
|
].filter(Boolean).join(' · ');
|
|
84
84
|
export const lastBlockPlacementCopy = (name, removingPage = false)=>removingPage ? `“${name}” is running and this page is the only published place it appears. Stop the test first.` : `“${name}” is running and this is the only published place it appears. Stop the test, or keep its block on this page.`;
|
|
85
|
+
export const hiddenBlockPlacementCopy = (name)=>`“${name}” is running and this is the only published place it appears. Stop the test first, or keep its block visible on this page.`;
|
|
85
86
|
export const bulkBlockRemovalCopy = (name)=>`“${name}” is running and the pages in this change are the only published places it appears. Stop the test first.`;
|
|
86
87
|
export const pendingBlockRemovalCopy = (name)=>`“${name}” is running and the pages in this change are the only published places it appears. Stop the test first, or change these pages one at a time.`;
|
|
87
88
|
/** After archive the guard protects the winner and the Original; only the winner page is "the winner". */ export const pageGuardCopy = (name, status, role = 'winner')=>status === 'archived' ? role === 'original' ? `This page's address now shows the winner of the finished test "${name}". To free it, open the test and choose "Release pages".` : `This page is shown at other addresses because the finished test "${name}" made it the winner. To free it, open the test and choose "Release pages".` : status === 'decided' ? `This page is part of the decided test "${name}". Choose "Make it the content" or "Discard winner" on the test before you delete, rename or unpublish it.` : `This page is part of the running test "${name}". Stop the test before you delete, rename or unpublish it.`;
|
|
@@ -2,7 +2,6 @@ export declare const TEST_PAGE: {
|
|
|
2
2
|
readonly noAudienceRules: "No audience choices are available here. Everyone eligible takes part; leave this section as it is.";
|
|
3
3
|
readonly editVersionsOnCanvas: "Edit version content on the canvas.";
|
|
4
4
|
readonly clickPageGroup: "On this test's page";
|
|
5
|
-
readonly clickGoalsNote: "Goals inside linked documents aren't shown. Goals added in code (data-xp-goal) work but aren't listed here.";
|
|
6
5
|
readonly clickGoalHelp: "A click shows interest, not the result you want.";
|
|
7
6
|
readonly staleEdit: "Someone else changed this test. Reload to see their changes.";
|
|
8
7
|
readonly reload: "Reload";
|
|
@@ -62,15 +61,17 @@ export declare const TEST_PAGE: {
|
|
|
62
61
|
readonly holdoutPrefix: "Holdout: ";
|
|
63
62
|
readonly allocation: "How many people take part";
|
|
64
63
|
readonly traffic: "How people are split";
|
|
64
|
+
readonly otherGoals: "Other goals (optional)";
|
|
65
|
+
readonly otherGoalsTitle: "Other goals";
|
|
66
|
+
readonly dontTrack: "Don't track";
|
|
67
|
+
readonly watch: "Watch";
|
|
68
|
+
readonly mustNotWorsen: "Must not get worse";
|
|
69
|
+
readonly otherGoalsHelp: "Watch: shown in results. Must not get worse: you're warned if a version makes it worse.";
|
|
65
70
|
readonly goal: "Goal";
|
|
66
|
-
readonly goalHelp: "The
|
|
71
|
+
readonly goalHelp: "The one thing you want more of. It decides the winner.";
|
|
67
72
|
readonly guardrailsShort: "Must not get worse";
|
|
68
|
-
readonly guardrails: "Must not get worse (optional)";
|
|
69
|
-
readonly guardrailHelp: "If a version makes one of these worse, you'll be warned.";
|
|
70
73
|
readonly secondaryShort: "Also keep an eye on";
|
|
71
|
-
readonly secondary: "Also keep an eye on (optional)";
|
|
72
74
|
readonly manageGoals: "Manage goals";
|
|
73
|
-
readonly searchGoals: "Search goals";
|
|
74
75
|
readonly chooseGoal: "Choose a goal";
|
|
75
76
|
readonly goalsError: "Couldn't load goals. Try again.";
|
|
76
77
|
readonly noGoal: "None selected";
|
|
@@ -106,3 +107,24 @@ export declare const NUMBER_COMPARISONS: {
|
|
|
106
107
|
readonly lte: "is at most";
|
|
107
108
|
};
|
|
108
109
|
export declare const placementCount: (count: number) => string;
|
|
110
|
+
export declare const DELETE_TEST: {
|
|
111
|
+
readonly blockWinner: (label: string) => string;
|
|
112
|
+
readonly currentSite: "This list reflects the site right now.";
|
|
113
|
+
readonly changedPages: (count: number) => string;
|
|
114
|
+
readonly unreadablePages: (count: number, total: number) => string;
|
|
115
|
+
readonly pageWinner: "These addresses will change where they send visitors:";
|
|
116
|
+
readonly content: "Deleting the test does not delete your page content. An Experiment block that used this test stays on its page and says the test was deleted.";
|
|
117
|
+
readonly allLocales: "All languages";
|
|
118
|
+
readonly locales: (names: string) => string;
|
|
119
|
+
readonly action: "Delete test";
|
|
120
|
+
readonly cancel: "Cancel";
|
|
121
|
+
readonly deleted: "Test deleted.";
|
|
122
|
+
readonly title: (name: string) => string;
|
|
123
|
+
readonly consequences: "This permanently deletes the test and all its rounds and results.";
|
|
124
|
+
readonly alreadyDeleted: "This test was already deleted.";
|
|
125
|
+
readonly checking: "Checking what visitors will see…";
|
|
126
|
+
readonly checkFailed: "Couldn’t check what visitors will see after deletion. You can still choose to delete this test.";
|
|
127
|
+
readonly noEffect: "Deleting this test will not change what visitors see.";
|
|
128
|
+
readonly versionChange: (before: string, after: string) => string;
|
|
129
|
+
readonly morePages: (count: number) => string;
|
|
130
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { PLACEMENT_LANGUAGES } from './languages.js';
|
|
1
2
|
const guardrailsShort = 'Must not get worse';
|
|
2
3
|
const secondaryShort = 'Also keep an eye on';
|
|
3
4
|
export const TEST_PAGE = {
|
|
4
5
|
noAudienceRules: 'No audience choices are available here. Everyone eligible takes part; leave this section as it is.',
|
|
5
6
|
editVersionsOnCanvas: 'Edit version content on the canvas.',
|
|
6
7
|
clickPageGroup: "On this test's page",
|
|
7
|
-
clickGoalsNote: "Goals inside linked documents aren't shown. Goals added in code (data-xp-goal) work but aren't listed here.",
|
|
8
8
|
clickGoalHelp: 'A click shows interest, not the result you want.',
|
|
9
9
|
staleEdit: 'Someone else changed this test. Reload to see their changes.',
|
|
10
10
|
reload: 'Reload',
|
|
@@ -64,15 +64,17 @@ export const TEST_PAGE = {
|
|
|
64
64
|
holdoutPrefix: 'Holdout: ',
|
|
65
65
|
allocation: 'How many people take part',
|
|
66
66
|
traffic: 'How people are split',
|
|
67
|
+
otherGoals: 'Other goals (optional)',
|
|
68
|
+
otherGoalsTitle: 'Other goals',
|
|
69
|
+
dontTrack: "Don't track",
|
|
70
|
+
watch: 'Watch',
|
|
71
|
+
mustNotWorsen: 'Must not get worse',
|
|
72
|
+
otherGoalsHelp: "Watch: shown in results. Must not get worse: you're warned if a version makes it worse.",
|
|
67
73
|
goal: 'Goal',
|
|
68
|
-
goalHelp: 'The
|
|
74
|
+
goalHelp: 'The one thing you want more of. It decides the winner.',
|
|
69
75
|
guardrailsShort,
|
|
70
|
-
guardrails: `${guardrailsShort} (optional)`,
|
|
71
|
-
guardrailHelp: "If a version makes one of these worse, you'll be warned.",
|
|
72
76
|
secondaryShort,
|
|
73
|
-
secondary: `${secondaryShort} (optional)`,
|
|
74
77
|
manageGoals: 'Manage goals',
|
|
75
|
-
searchGoals: 'Search goals',
|
|
76
78
|
chooseGoal: 'Choose a goal',
|
|
77
79
|
goalsError: "Couldn't load goals. Try again.",
|
|
78
80
|
noGoal: 'None selected',
|
|
@@ -108,3 +110,23 @@ export const NUMBER_COMPARISONS = {
|
|
|
108
110
|
lte: 'is at most'
|
|
109
111
|
};
|
|
110
112
|
export const placementCount = (count)=>` (placed ${count} times)`;
|
|
113
|
+
export const DELETE_TEST = {
|
|
114
|
+
action: 'Delete test',
|
|
115
|
+
cancel: 'Cancel',
|
|
116
|
+
deleted: 'Test deleted.',
|
|
117
|
+
title: (name)=>`Delete “${name}”?`,
|
|
118
|
+
consequences: 'This permanently deletes the test and all its rounds and results.',
|
|
119
|
+
alreadyDeleted: 'This test was already deleted.',
|
|
120
|
+
checking: 'Checking what visitors will see…',
|
|
121
|
+
checkFailed: "Couldn’t check what visitors will see after deletion. You can still choose to delete this test.",
|
|
122
|
+
noEffect: 'Deleting this test will not change what visitors see.',
|
|
123
|
+
versionChange: (before, after)=>`${before} → ${after}`,
|
|
124
|
+
morePages: (count)=>`${count} more ${count === 1 ? 'page' : 'pages'}.`,
|
|
125
|
+
...PLACEMENT_LANGUAGES,
|
|
126
|
+
blockWinner: (label)=>`On these pages, visitors will see ${label} again, or nothing where it is empty:`,
|
|
127
|
+
currentSite: 'This list reflects the site right now.',
|
|
128
|
+
changedPages: (count)=>`${count} ${count === 1 ? 'page' : 'pages'} will change`,
|
|
129
|
+
unreadablePages: (count, total)=>total === 1 ? "You can't open this page." : count === total ? "You can't open any of these pages." : `You can't open ${count} of these pages.`,
|
|
130
|
+
pageWinner: 'These addresses will change where they send visitors:',
|
|
131
|
+
content: 'Deleting the test does not delete your page content. An Experiment block that used this test stays on its page and says the test was deleted.'
|
|
132
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PreflightResult } from '../types/endpoints.js';
|
|
2
|
+
type Placement = PreflightResult['placements'][number];
|
|
3
|
+
/** Shared row identity. Legacy previews and edit links omit publication state;
|
|
4
|
+
* Binding already showed it on single-language sites. */
|
|
5
|
+
export declare function placementLabel(placement: Placement, showState?: boolean, states?: string[]): string;
|
|
6
|
+
/** A shared editor link describes the union of its rows, retaining their first page title. */
|
|
7
|
+
export declare function placementGroupLabel(placements: readonly Placement[], configuredLanguages?: readonly string[]): string;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { placementLanguageSuffix } from './copy/languages.js';
|
|
2
|
+
/** Shared row identity. Legacy previews and edit links omit publication state;
|
|
3
|
+
* Binding already showed it on single-language sites. */ export function placementLabel(placement, showState = Boolean(placement.allLocales || placement.locales?.length), states = [
|
|
4
|
+
placement.detail === 'Published' ? 'Published' : 'Draft'
|
|
5
|
+
]) {
|
|
6
|
+
return `${placement.title}${showState ? ` (${states.join(', ')})` : ''}${placementLanguageSuffix(placement)}`;
|
|
7
|
+
}
|
|
8
|
+
/** A shared editor link describes the union of its rows, retaining their first page title. */ export function placementGroupLabel(placements, configuredLanguages) {
|
|
9
|
+
const first = placements[0];
|
|
10
|
+
const locales = [
|
|
11
|
+
...new Set(placements.flatMap((row)=>row.locales ?? []))
|
|
12
|
+
];
|
|
13
|
+
const allLocales = placements.some((row)=>row.allLocales) || Boolean(configuredLanguages?.length && configuredLanguages.every((name)=>locales.includes(name)));
|
|
14
|
+
const states = [
|
|
15
|
+
...new Set(placements.map((row)=>row.detail === 'Published' ? 'Published' : 'Draft'))
|
|
16
|
+
];
|
|
17
|
+
return placementLabel({
|
|
18
|
+
...first,
|
|
19
|
+
locales,
|
|
20
|
+
...allLocales ? {
|
|
21
|
+
allLocales: true
|
|
22
|
+
} : {}
|
|
23
|
+
}, true, states);
|
|
24
|
+
}
|
|
@@ -7,5 +7,7 @@ export declare function resolvedPlacementLabel(value: unknown, match: {
|
|
|
7
7
|
id?: DocId | null;
|
|
8
8
|
title?: string;
|
|
9
9
|
editorUrl?: string;
|
|
10
|
+
locales?: string[];
|
|
11
|
+
allLocales?: true;
|
|
10
12
|
} | undefined, adminRoute: string): PlacementLabel;
|
|
11
13
|
export declare function preflightPlacementLabel(value: unknown, preflight: PreflightResult, adminRoute: string): PlacementLabel;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { placementLanguageSuffix } from '../copy/languages.js';
|
|
1
2
|
import { formatAdminURL } from '../format/adminURL.js';
|
|
2
3
|
import { placementDetail } from './placementLabels.model.js';
|
|
3
4
|
export { placementDetailKey, placementDetail, fallbackPlacementLabel } from './placementLabels.model.js';
|
|
@@ -5,7 +6,7 @@ export function resolvedPlacementLabel(value, match, adminRoute) {
|
|
|
5
6
|
const detail = placementDetail(value);
|
|
6
7
|
const id = match?.id ?? detail.id;
|
|
7
8
|
return {
|
|
8
|
-
title: match?.title?.trim() || detail.path || 'This page'
|
|
9
|
+
title: `${match?.title?.trim() || detail.path || 'This page'}${placementLanguageSuffix(match ?? {})}`,
|
|
9
10
|
...id != null && detail.collection ? {
|
|
10
11
|
href: match?.editorUrl || formatAdminURL({
|
|
11
12
|
adminRoute,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
:where(.xp-test-surface) .xp-verdict-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--xp-space-3); margin-top: var(--xp-space-5); padding-top: var(--xp-space-4); border-top: 1px solid var(--xp-border); color: var(--xp-text-3); font: var(--xp-text-small); }
|
|
7
7
|
:where(.xp-test-surface) .xp-round-meta { display: flex; align-items: center; flex-wrap: wrap; gap: var(--xp-space-2); min-width: 0; }
|
|
8
8
|
:where(.xp-test-surface) .xp-round-meta .xp-ui-field { display: flex; align-items: center; gap: var(--xp-space-2); margin: 0; min-width: 0; }
|
|
9
|
-
:where(.xp-test-surface) .xp-round-meta
|
|
9
|
+
:where(.xp-test-surface) .xp-round-meta .xp-ui-combobox-wrap { width: auto; max-width: 100%; }
|
|
10
10
|
:where(.xp-test-surface) .xp-results-chips { display: flex; flex-wrap: wrap; gap: var(--xp-space-2); list-style: none; padding: 0; margin-bottom: 0; }
|
|
11
11
|
:where(.xp-test-surface) .xp-stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); border: 1px solid var(--xp-border); border-radius: var(--xp-radius-card); background: var(--xp-surface); overflow: hidden; }
|
|
12
12
|
:where(.xp-test-surface) .xp-stat-tile { padding: 20px; min-width: 0; }
|
|
@@ -80,7 +80,7 @@ export declare function armRows({ snapshot, phase, metricId }: {
|
|
|
80
80
|
}): ArmRow[];
|
|
81
81
|
export declare function guardrailChips(snapshot: DisplaySnapshot): {
|
|
82
82
|
name: string;
|
|
83
|
-
status: "
|
|
83
|
+
status: "Watch" | "OK" | "Failing" | "Too little data";
|
|
84
84
|
}[];
|
|
85
85
|
interface RoundLineInput {
|
|
86
86
|
snapshot: DisplaySnapshot;
|
|
@@ -17,6 +17,8 @@ export interface SurfaceProps {
|
|
|
17
17
|
editorPlacementMessage?: string;
|
|
18
18
|
adminRoute: string;
|
|
19
19
|
apiRoute: string;
|
|
20
|
+
contentLanguageLabels?: string[];
|
|
21
|
+
contentLocale?: string;
|
|
20
22
|
collectionTitles?: Record<string, string>;
|
|
21
23
|
userId?: string | number;
|
|
22
24
|
userCollection?: string;
|
|
@@ -19,3 +19,8 @@ export declare function sidebarReadinessBlockers(test: TestDocApi, surface: Surf
|
|
|
19
19
|
})[] | {
|
|
20
20
|
sentence: "Checking readiness…";
|
|
21
21
|
}[];
|
|
22
|
+
/** The local notice already names this pair. Keep other pairs and other pages. */
|
|
23
|
+
export declare function editorNestedChecks(checks: PreflightResult['checks'], page: NonNullable<SurfaceProps['editorPage']>, identity: {
|
|
24
|
+
outerSlug: string;
|
|
25
|
+
innerSlug: string;
|
|
26
|
+
}): PreflightResult['checks'];
|
|
@@ -58,3 +58,21 @@ export { SAVE_PAGE, PUBLISH_PAGE, RUNNING_PUBLISH_PAGE, RUNNING_SAVE_PAGE } from
|
|
|
58
58
|
}
|
|
59
59
|
] : blockers.filter((step)=>step.sentence !== notice);
|
|
60
60
|
}
|
|
61
|
+
/** The local notice already names this pair. Keep other pairs and other pages. */ export function editorNestedChecks(checks, page, identity) {
|
|
62
|
+
return checks.flatMap((check)=>{
|
|
63
|
+
if (check.code !== 'nested-tests' || check.ok || !Array.isArray(check.detail)) return [
|
|
64
|
+
check
|
|
65
|
+
];
|
|
66
|
+
const detail = check.detail.filter((value)=>{
|
|
67
|
+
if (!value || typeof value !== 'object') return true;
|
|
68
|
+
const pair = value;
|
|
69
|
+
return pair.collection !== page.collection || String(pair.id) !== String(page.id) || pair.outerSlug !== identity.outerSlug || pair.innerSlug !== identity.innerSlug;
|
|
70
|
+
});
|
|
71
|
+
return detail.length ? [
|
|
72
|
+
{
|
|
73
|
+
...check,
|
|
74
|
+
detail
|
|
75
|
+
}
|
|
76
|
+
] : [];
|
|
77
|
+
});
|
|
78
|
+
}
|