@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,6 +1,7 @@
|
|
|
1
1
|
import { TEST_PAGE as C } from '../../copy/testPage.js';
|
|
2
|
+
import { placementLabel } from '../../placementLabel.js';
|
|
2
3
|
export function placementLine(placement) {
|
|
3
|
-
return `${C.onPage} ${
|
|
4
|
+
return `${C.onPage} ${placementLabel(placement, true)}`;
|
|
4
5
|
}
|
|
5
6
|
export function slotReady(placement, arm) {
|
|
6
7
|
const slot = arm.kind === 'holdout' ? 'control' : arm.slot;
|
|
@@ -5,8 +5,10 @@ import { Button } from '../../../ui/Button.js';
|
|
|
5
5
|
import { placementPages } from '../../../lib/placementPages.js';
|
|
6
6
|
import { TEST_PAGE as C, placementCount } from '../../copy/testPage.js';
|
|
7
7
|
import { placementLine, slotReady } from './pageBlock.model.js';
|
|
8
|
+
import { placementLabel, placementGroupLabel } from '../../placementLabel.js';
|
|
8
9
|
function Binding({ test, surface }) {
|
|
9
10
|
const placements = test.preflight?.placements ?? [];
|
|
11
|
+
const pages = placementPages(placements);
|
|
10
12
|
return /*#__PURE__*/ _jsx("div", {
|
|
11
13
|
className: "xp-page-binding",
|
|
12
14
|
children: surface.editorPlacementMessage ? test.doc?.status === 'running' ? /*#__PURE__*/ _jsxs(Banner, {
|
|
@@ -20,7 +22,7 @@ function Binding({ test, surface }) {
|
|
|
20
22
|
]
|
|
21
23
|
}) : null : placements.length ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
22
24
|
children: [
|
|
23
|
-
|
|
25
|
+
pages.map((placement)=>/*#__PURE__*/ _jsxs("p", {
|
|
24
26
|
className: "xp-ui-button-group",
|
|
25
27
|
children: [
|
|
26
28
|
placementLine(placement),
|
|
@@ -30,6 +32,7 @@ function Binding({ test, surface }) {
|
|
|
30
32
|
variant: "link",
|
|
31
33
|
size: "sm",
|
|
32
34
|
href: placement.editorUrl,
|
|
35
|
+
"aria-label": pages.length > 1 ? `${C.openPage}: ${placementLabel(placement, true)}` : undefined,
|
|
33
36
|
children: C.openPage
|
|
34
37
|
}) : null
|
|
35
38
|
]
|
|
@@ -43,7 +46,7 @@ function Binding({ test, surface }) {
|
|
|
43
46
|
})
|
|
44
47
|
});
|
|
45
48
|
}
|
|
46
|
-
function VersionContent({ test, armIndex, summary }) {
|
|
49
|
+
function VersionContent({ test, surface, armIndex, summary }) {
|
|
47
50
|
const arm = test.doc?.arms[armIndex];
|
|
48
51
|
if (!arm) return null;
|
|
49
52
|
if (arm.kind === 'holdout') return /*#__PURE__*/ _jsx("span", {
|
|
@@ -52,6 +55,15 @@ function VersionContent({ test, armIndex, summary }) {
|
|
|
52
55
|
});
|
|
53
56
|
const placements = test.preflight?.placements ?? [];
|
|
54
57
|
const pages = placementPages(placements);
|
|
58
|
+
const localized = pages.some((page)=>page.allLocales || page.locales?.length);
|
|
59
|
+
const editPages = new Map();
|
|
60
|
+
for (const page of pages){
|
|
61
|
+
if (!page.editorUrl) continue;
|
|
62
|
+
const key = localized ? page.editorUrl : page.key;
|
|
63
|
+
const group = editPages.get(key) ?? [];
|
|
64
|
+
group.push(page);
|
|
65
|
+
editPages.set(key, group);
|
|
66
|
+
}
|
|
55
67
|
const ready = placements.length > 0 && placements.every((placement)=>slotReady(placement, arm));
|
|
56
68
|
return /*#__PURE__*/ _jsxs("div", {
|
|
57
69
|
className: "xp-version-content",
|
|
@@ -62,13 +74,19 @@ function VersionContent({ test, armIndex, summary }) {
|
|
|
62
74
|
}),
|
|
63
75
|
/*#__PURE__*/ _jsx("div", {
|
|
64
76
|
className: "xp-ui-button-group",
|
|
65
|
-
children: !summary ?
|
|
77
|
+
children: !summary ? [
|
|
78
|
+
...editPages.values()
|
|
79
|
+
].map((group)=>{
|
|
80
|
+
const page = group[0];
|
|
81
|
+
const label = localized ? `${C.editOnPage}: ${placementGroupLabel(group, surface.contentLanguageLabels)}` : C.editOnPage;
|
|
82
|
+
return /*#__PURE__*/ _jsx(Button, {
|
|
66
83
|
variant: "link",
|
|
67
84
|
size: "sm",
|
|
68
85
|
href: page.editorUrl,
|
|
69
|
-
"aria-label": pages.length > 1 ? `${C.editOnPage}: ${page.title}` : undefined,
|
|
70
|
-
children:
|
|
71
|
-
}, page.key)
|
|
86
|
+
"aria-label": localized ? label : pages.length > 1 ? `${C.editOnPage}: ${page.title}` : undefined,
|
|
87
|
+
children: label
|
|
88
|
+
}, page.key);
|
|
89
|
+
}) : null
|
|
72
90
|
})
|
|
73
91
|
]
|
|
74
92
|
});
|
|
@@ -6,7 +6,7 @@ import { usePlacementLabels, placementDetailKey } from '../../placements/usePlac
|
|
|
6
6
|
import { placementUncheckedCopy } from '../../copy/readiness.js';
|
|
7
7
|
import { useEffect, useState } from 'react';
|
|
8
8
|
import { Button } from '../../../ui/Button.js';
|
|
9
|
-
import { TextInput } from '../../../ui/Inputs.js';
|
|
9
|
+
import { TextInput, Select } from '../../../ui/Inputs.js';
|
|
10
10
|
import { Dialog } from '../../../ui/Dialog.js';
|
|
11
11
|
import { MakeContentResult } from '../../actions/MakeContentResult.js';
|
|
12
12
|
import { expectedConfirm, matchesConfirm } from '../../../transitions/confirmPhrases.js';
|
|
@@ -273,44 +273,38 @@ import { useTransition } from './useTransition.js';
|
|
|
273
273
|
role: "status",
|
|
274
274
|
children: R.loadingMetrics
|
|
275
275
|
}) : null,
|
|
276
|
-
/*#__PURE__*/ _jsxs(
|
|
276
|
+
/*#__PURE__*/ _jsxs(Select, {
|
|
277
|
+
id: "xp-add-goal-role",
|
|
278
|
+
label: R.role,
|
|
279
|
+
value: role,
|
|
280
|
+
disabled: disabled,
|
|
281
|
+
onChange: (event)=>setRole(event.target.value),
|
|
277
282
|
children: [
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
value: "secondary",
|
|
286
|
-
children: R.supporting
|
|
287
|
-
}),
|
|
288
|
-
/*#__PURE__*/ _jsx("option", {
|
|
289
|
-
value: "guardrail",
|
|
290
|
-
children: R.guardrail
|
|
291
|
-
})
|
|
292
|
-
]
|
|
283
|
+
/*#__PURE__*/ _jsx("option", {
|
|
284
|
+
value: "secondary",
|
|
285
|
+
children: R.supporting
|
|
286
|
+
}),
|
|
287
|
+
/*#__PURE__*/ _jsx("option", {
|
|
288
|
+
value: "guardrail",
|
|
289
|
+
children: R.guardrail
|
|
293
290
|
})
|
|
294
291
|
]
|
|
295
292
|
}),
|
|
296
|
-
/*#__PURE__*/ _jsxs(
|
|
293
|
+
/*#__PURE__*/ _jsxs(Select, {
|
|
294
|
+
id: "xp-add-goal-metric",
|
|
295
|
+
label: R.metric,
|
|
296
|
+
value: metric,
|
|
297
|
+
disabled: disabled || loading,
|
|
298
|
+
onChange: (event)=>setMetric(event.target.value),
|
|
297
299
|
children: [
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
children: R.chooseMetric
|
|
307
|
-
}),
|
|
308
|
-
available.map((item)=>/*#__PURE__*/ _jsx("option", {
|
|
309
|
-
value: String(item.id),
|
|
310
|
-
children: item.name
|
|
311
|
-
}, item.id))
|
|
312
|
-
]
|
|
313
|
-
})
|
|
300
|
+
/*#__PURE__*/ _jsx("option", {
|
|
301
|
+
value: "",
|
|
302
|
+
children: R.chooseMetric
|
|
303
|
+
}),
|
|
304
|
+
available.map((item)=>/*#__PURE__*/ _jsx("option", {
|
|
305
|
+
value: String(item.id),
|
|
306
|
+
children: item.name
|
|
307
|
+
}, item.id))
|
|
314
308
|
]
|
|
315
309
|
}),
|
|
316
310
|
!loading && !loadError && !available.length ? /*#__PURE__*/ _jsx("p", {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nestedTestCopy } from '../../../puck/nestedTestCopy.js';
|
|
1
2
|
import { SURFACE_COPY } from '../../copy/surface.js';
|
|
2
3
|
import { formatDate } from '../../format/date.js';
|
|
3
4
|
import { actionGroupLabel } from '../../actions/actions.model.js';
|
|
@@ -13,6 +14,10 @@ const group = (key, ctx)=>{
|
|
|
13
14
|
const found = ctx.arms.find((item)=>item.key === key);
|
|
14
15
|
return found ? actionGroupLabel(found.key, found.label) : C.groupFallback;
|
|
15
16
|
};
|
|
17
|
+
const hasLanguages = (value)=>object(value).allLocales === true || Array.isArray(object(value).locales);
|
|
18
|
+
const detailRows = (detail)=>Array.isArray(detail) && detail.length && detail.some(hasLanguages) ? detail : [
|
|
19
|
+
first(detail)
|
|
20
|
+
];
|
|
16
21
|
const row = (section, next)=>({
|
|
17
22
|
section,
|
|
18
23
|
next
|
|
@@ -36,15 +41,17 @@ const versions = row('versions', (detail)=>versionsNext(detailText(detail, C.ver
|
|
|
36
41
|
nextStep: 'Publish the page'
|
|
37
42
|
},
|
|
38
43
|
'duplicate-version-row': {
|
|
39
|
-
...row('versions', (detail)=>`The Experiment block on ${text(
|
|
40
|
-
nextStep: (detail)=>`Edit ${text(
|
|
44
|
+
...row('versions', (detail)=>detailRows(detail).map((value)=>`The Experiment block on ${text(object(value).title, 'this page')} has the same version twice. Remove one of them, then save.`).join('\n')),
|
|
45
|
+
nextStep: (detail)=>detailRows(detail).map((value)=>`Edit ${text(object(value).title, 'this page')}`).join('\n')
|
|
41
46
|
},
|
|
47
|
+
'nested-tests': row('versions', (detail)=>nestedTestCopy.readiness(detail)),
|
|
42
48
|
'interacting-tests': {
|
|
43
49
|
...row('versions', (detail)=>interactingTestsCopy(text(first(detail).path, 'this page'), text(first(detail).status, 'running'), text(first(detail).name, 'another test'), first(detail).version === true)),
|
|
44
50
|
nextStep: (detail)=>`Open ${text(first(detail).name, 'the test')}${first(detail).version === true ? `\nEdit ${text(first(detail).path, 'this page')}` : ''}`
|
|
45
51
|
},
|
|
46
52
|
'empty-slot': row('versions', (detail, ctx)=>{
|
|
47
53
|
const placements = Array.isArray(detail) ? detail : [];
|
|
54
|
+
if (placements.some(hasLanguages)) return placements.flatMap((placement)=>ctx.arms.filter((arm)=>arm.kind !== 'holdout' && (!arm.slot || !(Number(object(object(placement).slots)[arm.slot]) > 0))).map((arm)=>contentNext(group(arm.key, ctx), text(object(placement).title, 'the page')))).join('\n');
|
|
48
55
|
const missing = ctx.arms.find((item)=>item.kind !== 'holdout' && placements.some((placement)=>{
|
|
49
56
|
const slots = object(object(placement).slots);
|
|
50
57
|
return !item.slot || !(typeof slots[item.slot] === 'number' && Number(slots[item.slot]) > 0);
|
|
@@ -35,7 +35,9 @@ export declare function useResults(id: DocId, { apiRoute, canReadResults, canMan
|
|
|
35
35
|
ok: true;
|
|
36
36
|
data: DocId;
|
|
37
37
|
}>;
|
|
38
|
-
deleteTest: (id: DocId
|
|
38
|
+
deleteTest: (id: DocId, { draft }?: {
|
|
39
|
+
draft?: boolean;
|
|
40
|
+
}) => Promise<ApiResult<unknown>>;
|
|
39
41
|
wrapBlock: (body: import("../../../types/endpoints.js").WrapBlockBody) => Promise<ApiResult<Record<string, unknown>>>;
|
|
40
42
|
pages: (query: {
|
|
41
43
|
collection: string;
|
|
@@ -66,6 +68,7 @@ export declare function useResults(id: DocId, { apiRoute, canReadResults, canMan
|
|
|
66
68
|
restoreContentEntry: (id: DocId, body: import("../../../types/endpoints.js").RestoreContentEntryBody) => Promise<ApiResult<import("../../../types/endpoints.js").RestoreContentEntryResult>>;
|
|
67
69
|
archive: (id: DocId, body: import("../../../types/endpoints.js").ArchiveBody) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
68
70
|
clickKeys: (id: DocId) => Promise<ApiResult<import("../../../types/endpoints.js").ClickKeysResult>>;
|
|
71
|
+
deleteImpact: (id: DocId, signal?: AbortSignal) => Promise<ApiResult<import("../../../types/endpoints.js").DeleteImpactResult>>;
|
|
69
72
|
preflight: (id: DocId) => Promise<ApiResult<import("../../../types/endpoints.js").PreflightResult>>;
|
|
70
73
|
previewToken: (id: DocId, arm: string) => Promise<ApiResult<import("../../../types/endpoints.js").PreviewTokenResult>>;
|
|
71
74
|
results: (id: DocId, options?: {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DocId } from '../../../types/contracts.js';
|
|
2
|
+
export type DeleteOutcome = 'done' | 'already';
|
|
3
|
+
export declare const DELETE_IMPACT_TIMEOUT_MS = 15000;
|
|
4
|
+
/** Matches deleteExperiment's status guard; the server rechecks under its lock. */
|
|
5
|
+
export declare function DeleteTest({ test, canManage, apiRoute, contentLocale, onDeleted }: {
|
|
6
|
+
test: {
|
|
7
|
+
id: DocId;
|
|
8
|
+
name: string;
|
|
9
|
+
status: string;
|
|
10
|
+
};
|
|
11
|
+
canManage: boolean;
|
|
12
|
+
apiRoute: string;
|
|
13
|
+
contentLocale?: string;
|
|
14
|
+
onDeleted: (outcome: DeleteOutcome) => void;
|
|
15
|
+
}): import("react").JSX.Element | null;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { placementLanguageSuffix } from '../../copy/languages.js';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { createApi } from '../../api.js';
|
|
6
|
+
import { DELETE_TEST as C } from '../../copy/testPage.js';
|
|
7
|
+
import { Button } from '../../../ui/Button.js';
|
|
8
|
+
import { Dialog } from '../../../ui/Dialog.js';
|
|
9
|
+
const VISIBLE_PAGES = 5;
|
|
10
|
+
export const DELETE_IMPACT_TIMEOUT_MS = 15_000;
|
|
11
|
+
/** Matches deleteExperiment's status guard; the server rechecks under its lock. */ export function DeleteTest({ test, canManage, apiRoute, contentLocale, onDeleted }) {
|
|
12
|
+
const [open, setOpen] = useState(false);
|
|
13
|
+
const [busy, setBusy] = useState(false);
|
|
14
|
+
const pending = useRef(false);
|
|
15
|
+
const [error, setError] = useState();
|
|
16
|
+
const [impact, setImpact] = useState({
|
|
17
|
+
state: 'loading'
|
|
18
|
+
});
|
|
19
|
+
useEffect(()=>{
|
|
20
|
+
if (!open) return;
|
|
21
|
+
let current = true;
|
|
22
|
+
const controller = new AbortController();
|
|
23
|
+
const timer = setTimeout(()=>{
|
|
24
|
+
if (!current) return;
|
|
25
|
+
current = false;
|
|
26
|
+
controller.abort();
|
|
27
|
+
setImpact({
|
|
28
|
+
state: 'failed'
|
|
29
|
+
});
|
|
30
|
+
}, DELETE_IMPACT_TIMEOUT_MS);
|
|
31
|
+
setImpact({
|
|
32
|
+
state: 'loading'
|
|
33
|
+
});
|
|
34
|
+
void createApi(apiRoute, contentLocale).deleteImpact(test.id, controller.signal).then((result)=>{
|
|
35
|
+
if (!current) return;
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
setImpact(result.ok && result.data && [
|
|
38
|
+
'none',
|
|
39
|
+
'block',
|
|
40
|
+
'page'
|
|
41
|
+
].includes(result.data.effect) ? {
|
|
42
|
+
state: 'ready',
|
|
43
|
+
data: result.data
|
|
44
|
+
} : {
|
|
45
|
+
state: 'failed'
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
return ()=>{
|
|
49
|
+
current = false;
|
|
50
|
+
clearTimeout(timer);
|
|
51
|
+
controller.abort();
|
|
52
|
+
};
|
|
53
|
+
}, [
|
|
54
|
+
open,
|
|
55
|
+
test.id,
|
|
56
|
+
apiRoute,
|
|
57
|
+
contentLocale
|
|
58
|
+
]);
|
|
59
|
+
if (!canManage || ![
|
|
60
|
+
'draft',
|
|
61
|
+
'archived'
|
|
62
|
+
].includes(test.status)) return null;
|
|
63
|
+
const checking = impact.state === 'loading';
|
|
64
|
+
async function remove() {
|
|
65
|
+
if (checking || pending.current) return;
|
|
66
|
+
pending.current = true;
|
|
67
|
+
setBusy(true);
|
|
68
|
+
setError(undefined);
|
|
69
|
+
const result = await createApi(apiRoute).deleteTest(test.id);
|
|
70
|
+
if (result.ok || result.status === 404) {
|
|
71
|
+
setOpen(false);
|
|
72
|
+
onDeleted(result.ok ? 'done' : 'already');
|
|
73
|
+
} else setError(result.message);
|
|
74
|
+
pending.current = false;
|
|
75
|
+
setBusy(false);
|
|
76
|
+
}
|
|
77
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
78
|
+
children: [
|
|
79
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
80
|
+
variant: "quiet",
|
|
81
|
+
size: "sm",
|
|
82
|
+
onClick: ()=>{
|
|
83
|
+
setError(undefined);
|
|
84
|
+
setImpact({
|
|
85
|
+
state: 'loading'
|
|
86
|
+
});
|
|
87
|
+
setOpen(true);
|
|
88
|
+
},
|
|
89
|
+
children: C.action
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ _jsxs(Dialog, {
|
|
92
|
+
open: open,
|
|
93
|
+
title: C.title(test.name),
|
|
94
|
+
initialFocus: "cancel",
|
|
95
|
+
dismissible: !busy,
|
|
96
|
+
onClose: ()=>setOpen(false),
|
|
97
|
+
children: [
|
|
98
|
+
/*#__PURE__*/ _jsx("p", {
|
|
99
|
+
children: C.consequences
|
|
100
|
+
}),
|
|
101
|
+
/*#__PURE__*/ _jsx("p", {
|
|
102
|
+
children: C.content
|
|
103
|
+
}),
|
|
104
|
+
/*#__PURE__*/ _jsx("p", {
|
|
105
|
+
role: "status",
|
|
106
|
+
"aria-atomic": "true",
|
|
107
|
+
children: checking ? C.checking : impact.state === 'failed' ? C.checkFailed : impact.state === 'ready' ? impactSummary(impact.data) : ''
|
|
108
|
+
}),
|
|
109
|
+
impact.state === 'ready' ? /*#__PURE__*/ _jsx(ImpactDetails, {
|
|
110
|
+
impact: impact.data
|
|
111
|
+
}) : null,
|
|
112
|
+
error ? /*#__PURE__*/ _jsx("p", {
|
|
113
|
+
role: "alert",
|
|
114
|
+
children: error
|
|
115
|
+
}) : null,
|
|
116
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
117
|
+
className: "xp-ui-button-group",
|
|
118
|
+
children: [
|
|
119
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
120
|
+
"data-dialog-cancel": true,
|
|
121
|
+
disabled: busy,
|
|
122
|
+
onClick: ()=>setOpen(false),
|
|
123
|
+
children: C.cancel
|
|
124
|
+
}),
|
|
125
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
126
|
+
variant: "danger",
|
|
127
|
+
disabled: checking,
|
|
128
|
+
"aria-disabled": busy || checking || undefined,
|
|
129
|
+
"aria-busy": busy || undefined,
|
|
130
|
+
onClick: ()=>void remove(),
|
|
131
|
+
children: C.action
|
|
132
|
+
})
|
|
133
|
+
]
|
|
134
|
+
})
|
|
135
|
+
]
|
|
136
|
+
})
|
|
137
|
+
]
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function impactSummary(impact) {
|
|
141
|
+
return impact.effect === 'none' ? C.noEffect : C.changedPages(impact.effect === 'block' ? impact.pageCount : impact.addresses.length);
|
|
142
|
+
}
|
|
143
|
+
function ImpactDetails({ impact }) {
|
|
144
|
+
if (impact.effect === 'none') return null;
|
|
145
|
+
const places = impact.effect === 'block' ? impact.placements.map((place)=>`${place.title}${place.path ? ` (${place.path})` : ''}${placementLanguageSuffix(place)}: ${C.versionChange(place.before.label, place.after.label)}`) : impact.addresses.map((path)=>`${path}: ${C.versionChange(impact.winnerPath, impact.afterPaths?.[path] ?? path)}`);
|
|
146
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
147
|
+
children: [
|
|
148
|
+
places.length ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
149
|
+
children: [
|
|
150
|
+
/*#__PURE__*/ _jsx("p", {
|
|
151
|
+
children: impact.effect === 'block' ? C.blockWinner(impact.controlLabel) : C.pageWinner
|
|
152
|
+
}),
|
|
153
|
+
/*#__PURE__*/ _jsx("p", {
|
|
154
|
+
children: C.currentSite
|
|
155
|
+
})
|
|
156
|
+
]
|
|
157
|
+
}) : null,
|
|
158
|
+
places.length ? /*#__PURE__*/ _jsx("ul", {
|
|
159
|
+
children: places.slice(0, VISIBLE_PAGES).map((place, index)=>/*#__PURE__*/ _jsx("li", {
|
|
160
|
+
children: place
|
|
161
|
+
}, index))
|
|
162
|
+
}) : null,
|
|
163
|
+
places.length > VISIBLE_PAGES ? /*#__PURE__*/ _jsx("p", {
|
|
164
|
+
children: C.morePages(places.length - VISIBLE_PAGES)
|
|
165
|
+
}) : null,
|
|
166
|
+
impact.effect === 'block' && impact.unreadablePages > 0 ? /*#__PURE__*/ _jsx("p", {
|
|
167
|
+
children: C.unreadablePages(impact.unreadablePages, impact.pageCount)
|
|
168
|
+
}) : null
|
|
169
|
+
]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { fetchAllDocs } from '../../../lib/fetchAllDocs.js';
|
|
4
|
+
import { Select } from '../../../ui/Inputs.js';
|
|
5
|
+
import { useId } from 'react';
|
|
4
6
|
import { Button } from '../../../ui/Button.js';
|
|
5
7
|
import { useEffect, useMemo, useState } from 'react';
|
|
6
8
|
import { surfaceUrls } from '../../surfaceUrls.js';
|
|
@@ -10,7 +12,7 @@ import { isClickSource } from '../../../goals/key.js';
|
|
|
10
12
|
import { createApi } from '../../api.js';
|
|
11
13
|
import { sourceFor } from '../../metricSource.model.js';
|
|
12
14
|
import { reviewView } from '../../review/review.model.js';
|
|
13
|
-
import {
|
|
15
|
+
import { FieldErrors, reasonFor, save, SelectEdit } from './fields.js';
|
|
14
16
|
import { Section } from './Section.js';
|
|
15
17
|
export function GoalSection({ test, surface, embedded = false }) {
|
|
16
18
|
const api = useMemo(()=>createApi(surface.apiRoute), [
|
|
@@ -137,28 +139,38 @@ export function GoalSection({ test, surface, embedded = false }) {
|
|
|
137
139
|
value: id,
|
|
138
140
|
label: unknownGoal
|
|
139
141
|
});
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
142
|
+
const otherGoals = visible.filter((option)=>option.value !== String(doc.metrics?.primary ?? ''));
|
|
143
|
+
const otherCount = new Set([
|
|
144
|
+
...doc.metrics?.guardrails ?? [],
|
|
145
|
+
...doc.metrics?.secondary ?? []
|
|
146
|
+
].map(String).filter((id)=>id !== String(doc.metrics?.primary ?? ''))).size;
|
|
147
|
+
const [otherOpen, setOtherOpen] = useState(otherCount > 0);
|
|
148
|
+
const [previousCount, setPreviousCount] = useState(otherCount);
|
|
149
|
+
if (previousCount !== otherCount) {
|
|
150
|
+
setPreviousCount(otherCount);
|
|
151
|
+
if (previousCount === 0 && otherCount > 0) setOtherOpen(true);
|
|
152
|
+
}
|
|
153
|
+
const roleId = useId();
|
|
154
|
+
const goalGroups = onPage.size ? [
|
|
155
|
+
{
|
|
156
|
+
options: [
|
|
157
|
+
{
|
|
158
|
+
value: '',
|
|
159
|
+
label: C.chooseGoal
|
|
160
|
+
}
|
|
161
|
+
]
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
label: C.clickPageGroup,
|
|
165
|
+
options: visible.filter((option)=>onPage.has(option.value)).map((option)=>({
|
|
166
|
+
...option,
|
|
167
|
+
label: onPage.get(option.value)
|
|
168
|
+
}))
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
options: visible.filter((option)=>!onPage.has(option.value))
|
|
172
|
+
}
|
|
173
|
+
] : undefined;
|
|
162
174
|
const originalId = (value)=>metrics.find((metric)=>String(metric.id) === value)?.id ?? [
|
|
163
175
|
test.doc.metrics?.primary,
|
|
164
176
|
...test.doc.metrics?.guardrails ?? [],
|
|
@@ -170,21 +182,28 @@ export function GoalSection({ test, surface, embedded = false }) {
|
|
|
170
182
|
save(test, 'metrics', ()=>({
|
|
171
183
|
metrics: {
|
|
172
184
|
...test.doc.metrics,
|
|
173
|
-
primary: id
|
|
185
|
+
primary: id,
|
|
186
|
+
guardrails: test.doc.metrics?.guardrails?.filter((saved)=>String(saved) !== value),
|
|
187
|
+
secondary: test.doc.metrics?.secondary?.filter((saved)=>String(saved) !== value)
|
|
174
188
|
}
|
|
175
189
|
}));
|
|
176
190
|
};
|
|
177
|
-
const
|
|
191
|
+
const setRole = (value, role)=>save(test, 'metrics', ()=>{
|
|
178
192
|
const current = test.doc.metrics;
|
|
179
|
-
const ids = current?.[role] ?? [];
|
|
180
193
|
const id = originalId(value);
|
|
194
|
+
const guardrails = (current?.guardrails ?? []).filter((saved)=>String(saved) !== value);
|
|
195
|
+
const secondary = (current?.secondary ?? []).filter((saved)=>String(saved) !== value);
|
|
181
196
|
return {
|
|
182
197
|
metrics: {
|
|
183
198
|
...current,
|
|
184
|
-
|
|
185
|
-
...
|
|
199
|
+
guardrails: role === 'guardrails' && id != null ? [
|
|
200
|
+
...guardrails,
|
|
186
201
|
id
|
|
187
|
-
] :
|
|
202
|
+
] : guardrails,
|
|
203
|
+
secondary: role === 'secondary' && id != null ? [
|
|
204
|
+
...secondary,
|
|
205
|
+
id
|
|
206
|
+
] : secondary
|
|
188
207
|
}
|
|
189
208
|
};
|
|
190
209
|
});
|
|
@@ -232,19 +251,9 @@ export function GoalSection({ test, surface, embedded = false }) {
|
|
|
232
251
|
value: '',
|
|
233
252
|
label: C.chooseGoal
|
|
234
253
|
},
|
|
235
|
-
...
|
|
254
|
+
...visible
|
|
236
255
|
],
|
|
237
|
-
groups:
|
|
238
|
-
{
|
|
239
|
-
options: [
|
|
240
|
-
{
|
|
241
|
-
value: '',
|
|
242
|
-
label: C.chooseGoal
|
|
243
|
-
}
|
|
244
|
-
]
|
|
245
|
-
},
|
|
246
|
-
...roleGroups('primary')
|
|
247
|
-
] : undefined,
|
|
256
|
+
groups: goalGroups,
|
|
248
257
|
reason: reason,
|
|
249
258
|
readOnlyValue: display(doc.metrics?.primary == null ? [] : [
|
|
250
259
|
doc.metrics.primary
|
|
@@ -267,39 +276,57 @@ export function GoalSection({ test, surface, embedded = false }) {
|
|
|
267
276
|
test: test,
|
|
268
277
|
path: "metrics.primary"
|
|
269
278
|
}),
|
|
270
|
-
/*#__PURE__*/
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
279
|
+
otherGoals.length ? /*#__PURE__*/ _jsxs("details", {
|
|
280
|
+
className: "xp-other-goals",
|
|
281
|
+
open: otherOpen,
|
|
282
|
+
onToggle: (event)=>setOtherOpen(event.currentTarget.open),
|
|
283
|
+
children: [
|
|
284
|
+
/*#__PURE__*/ _jsx("summary", {
|
|
285
|
+
children: otherCount ? `${C.otherGoalsTitle} · ${otherCount}` : C.otherGoals
|
|
286
|
+
}),
|
|
287
|
+
/*#__PURE__*/ _jsx("div", {
|
|
288
|
+
className: "xp-other-goal-list",
|
|
289
|
+
children: otherGoals.map((option, index)=>{
|
|
290
|
+
const role = doc.metrics?.guardrails?.some((id)=>String(id) === option.value) ? 'guardrails' : doc.metrics?.secondary?.some((id)=>String(id) === option.value) ? 'secondary' : '';
|
|
291
|
+
return /*#__PURE__*/ _jsxs(Select, {
|
|
292
|
+
id: `${roleId}-${index}`,
|
|
293
|
+
label: onPage.get(option.value) ?? option.label,
|
|
294
|
+
value: role,
|
|
295
|
+
disabled: Boolean(reason),
|
|
296
|
+
onChange: (event)=>setRole(option.value, event.target.value),
|
|
297
|
+
children: [
|
|
298
|
+
/*#__PURE__*/ _jsx("option", {
|
|
299
|
+
value: "",
|
|
300
|
+
children: C.dontTrack
|
|
301
|
+
}),
|
|
302
|
+
/*#__PURE__*/ _jsx("option", {
|
|
303
|
+
value: "secondary",
|
|
304
|
+
children: C.watch
|
|
305
|
+
}),
|
|
306
|
+
/*#__PURE__*/ _jsx("option", {
|
|
307
|
+
value: "guardrails",
|
|
308
|
+
children: C.mustNotWorsen
|
|
309
|
+
})
|
|
310
|
+
]
|
|
311
|
+
}, option.value);
|
|
312
|
+
})
|
|
313
|
+
}),
|
|
314
|
+
/*#__PURE__*/ _jsx("p", {
|
|
315
|
+
children: C.otherGoalsHelp
|
|
316
|
+
}),
|
|
317
|
+
reason ? /*#__PURE__*/ _jsx("p", {
|
|
318
|
+
className: "xp-ui-help",
|
|
319
|
+
children: reason
|
|
320
|
+
}) : null,
|
|
321
|
+
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
322
|
+
test: test,
|
|
323
|
+
path: "metrics.guardrails"
|
|
324
|
+
}),
|
|
325
|
+
/*#__PURE__*/ _jsx(FieldErrors, {
|
|
326
|
+
test: test,
|
|
327
|
+
path: "metrics.secondary"
|
|
328
|
+
})
|
|
329
|
+
]
|
|
303
330
|
}) : null,
|
|
304
331
|
test.errors.metrics ? /*#__PURE__*/ _jsx("p", {
|
|
305
332
|
role: "alert",
|