@delmaredigital/payload-experiments 0.4.0-rc.9 → 0.4.1
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/README.md +3 -7
- package/dist/admin/MetricSourceSelect.js +10 -3
- package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +75 -29
- package/dist/admin/blocks/model.js +5 -4
- package/dist/admin/copy/blocks.d.ts +14 -11
- package/dist/admin/copy/blocks.js +33 -22
- package/dist/admin/copy/goals.d.ts +15 -8
- package/dist/admin/copy/goals.js +18 -8
- package/dist/admin/copy/newTest.d.ts +10 -7
- package/dist/admin/copy/newTest.js +14 -7
- package/dist/admin/copy/status.d.ts +1 -1
- package/dist/admin/copy/status.js +2 -1
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/placementStatus.model.js +5 -3
- package/dist/admin/status.model.d.ts +1 -0
- package/dist/admin/status.model.js +2 -1
- package/dist/admin/surface/ResultsRoute.js +4 -8
- package/dist/admin/surface/SurfaceShell.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +28 -3
- package/dist/admin/surface/TestRowMenu.d.ts +13 -0
- package/dist/admin/surface/TestRowMenu.js +163 -0
- package/dist/admin/surface/TestsHome.d.ts +4 -3
- package/dist/admin/surface/TestsHome.js +186 -47
- package/dist/admin/surface/TestsSurface.js +2 -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 -198
- 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 +15 -8
- package/dist/admin/surface/home.model.js +22 -18
- package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
- package/dist/admin/surface/newTest/NewTest.js +156 -96
- package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
- package/dist/admin/surface/newTest/PageWizard.js +93 -68
- package/dist/admin/surface/newTest/newTest.css +28 -11
- package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
- package/dist/admin/surface/results/ResultsHeader.js +90 -63
- package/dist/admin/surface/surface.css +29 -0
- package/dist/admin/surface/test/TestPage.js +46 -38
- 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/admin/views/buildSurfaceProps.js +18 -66
- package/dist/arms/copy.d.ts +13 -3
- package/dist/arms/copy.js +5 -4
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +1 -1
- package/dist/collections/experiments/armInvariants.js +8 -5
- package/dist/collections/metrics.js +12 -5
- package/dist/collections/serialize.js +3 -2
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +414 -0
- package/dist/endpoints/editorSurface.js +1 -1
- package/dist/endpoints/index.js +20 -0
- package/dist/endpoints/pages.js +245 -66
- package/dist/endpoints/placementStatus.js +1 -0
- package/dist/endpoints/results.js +3 -0
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +4 -5
- package/dist/exports/index.d.ts +1 -1
- package/dist/goals/picker/copy.js +1 -1
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/labels/arms.d.ts +3 -0
- package/dist/labels/arms.js +8 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +18 -2
- package/dist/plugin.js +56 -2
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
- package/dist/puck/editor/ConfigureTestDrawer.js +36 -26
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +219 -106
- package/dist/puck/editor/LeftoverVersions.js +17 -32
- package/dist/puck/editor/QuickTestActions.d.ts +2 -2
- package/dist/puck/editor/QuickTestActions.js +44 -34
- package/dist/puck/editor/ResultsReadout.d.ts +3 -1
- package/dist/puck/editor/ResultsReadout.js +28 -16
- package/dist/puck/editor/VersionBuilder.d.ts +4 -2
- package/dist/puck/editor/VersionBuilder.js +42 -63
- package/dist/puck/editor/armWrites.js +1 -1
- package/dist/puck/editor/copy.d.ts +10 -6
- package/dist/puck/editor/copy.js +22 -12
- package/dist/puck/editor/editor.chrome.css +9 -8
- package/dist/puck/editor/editor.css +14 -9
- package/dist/puck/editor/placementsCache.d.ts +1 -1
- package/dist/puck/editor/placementsCache.js +9 -17
- package/dist/puck/editor/usePageSaveReadiness.d.ts +1 -4
- package/dist/puck/editor/usePageSaveReadiness.js +18 -21
- package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
- package/dist/puck/editor/usePlacementNotice.js +4 -5
- package/dist/puck/nestedTestCopy.js +2 -2
- 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 +4 -4
- package/dist/results/verdict.js +13 -10
- 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 +7 -4
- package/dist/testSurface/actions/DecideDialog.js +71 -59
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/testSurface/actions/MakeContentResult.js +1 -1
- package/dist/testSurface/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +75 -22
- 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/api.d.ts +4 -1
- package/dist/testSurface/api.js +22 -14
- package/dist/testSurface/copy/actions.d.ts +36 -14
- package/dist/testSurface/copy/actions.js +39 -17
- 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 +6 -6
- package/dist/testSurface/copy/common.js +6 -6
- package/dist/testSurface/copy/metrics.d.ts +6 -0
- package/dist/testSurface/copy/metrics.js +8 -0
- package/dist/testSurface/copy/pages.d.ts +67 -7
- package/dist/testSurface/copy/pages.js +74 -7
- package/dist/testSurface/copy/readiness.d.ts +8 -6
- package/dist/testSurface/copy/readiness.js +19 -10
- package/dist/testSurface/copy/recommendation.d.ts +1 -22
- package/dist/testSurface/copy/recommendation.js +2 -22
- package/dist/testSurface/copy/results.d.ts +16 -10
- package/dist/testSurface/copy/results.js +19 -11
- package/dist/testSurface/copy/review.d.ts +13 -10
- package/dist/testSurface/copy/review.js +14 -10
- package/dist/testSurface/copy/setting.d.ts +1 -2
- package/dist/testSurface/copy/setting.js +1 -2
- package/dist/testSurface/copy/surface.d.ts +11 -2
- package/dist/testSurface/copy/surface.js +14 -11
- package/dist/testSurface/copy/testPage.d.ts +16 -10
- package/dist/testSurface/copy/testPage.js +24 -18
- package/dist/testSurface/format/date.d.ts +5 -2
- package/dist/testSurface/format/date.js +24 -8
- package/dist/testSurface/format/roundProgress.d.ts +6 -0
- package/dist/testSurface/format/roundProgress.js +15 -0
- package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
- package/dist/testSurface/format/useDateFormatter.js +8 -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/readPreflight.d.ts +0 -1
- package/dist/testSurface/readPreflight.js +0 -1
- package/dist/testSurface/results/CiChart.js +2 -1
- package/dist/testSurface/results/DataTable.d.ts +1 -1
- package/dist/testSurface/results/DataTable.js +4 -3
- package/dist/testSurface/results/VerdictHero.d.ts +1 -1
- package/dist/testSurface/results/legacy.d.ts +0 -5
- package/dist/testSurface/results/legacy.js +0 -14
- package/dist/testSurface/results/results.css +2 -2
- package/dist/testSurface/results/results.model.d.ts +8 -3
- package/dist/testSurface/results/results.model.js +25 -21
- package/dist/testSurface/results/snapshot.d.ts +2 -0
- package/dist/testSurface/results/snapshot.js +3 -0
- package/dist/testSurface/surface/contracts.d.ts +6 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +1 -1
- package/dist/testSurface/surface/editorPlacement.js +1 -1
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +1 -1
- package/dist/testSurface/surface/pageBlock/parts.js +25 -12
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +298 -209
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
- package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
- package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +5 -3
- package/dist/testSurface/surface/readiness/ActionDialogs.js +213 -207
- package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
- package/dist/testSurface/surface/readiness/Banner.js +109 -148
- 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.d.ts +14 -5
- package/dist/testSurface/surface/readiness/readiness.model.js +62 -12
- package/dist/testSurface/surface/readiness/useTransition.d.ts +3 -1
- package/dist/testSurface/surface/readiness/useTransition.js +49 -8
- package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -3
- package/dist/testSurface/surface/results/ReleasePages.js +41 -41
- package/dist/testSurface/surface/results/ResultsBody.d.ts +7 -2
- package/dist/testSurface/surface/results/ResultsBody.js +170 -110
- package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
- package/dist/testSurface/surface/results/recommendation.model.js +15 -59
- package/dist/testSurface/surface/results/useResults.d.ts +6 -2
- 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/DeleteTest.d.ts +5 -1
- package/dist/testSurface/surface/test/DeleteTest.js +63 -55
- package/dist/testSurface/surface/test/GoalSection.js +11 -11
- package/dist/testSurface/surface/test/LengthSection.js +21 -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 +2 -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/TestSurface.js +17 -43
- package/dist/testSurface/surface/test/VersionsSection.js +93 -70
- 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 +13 -7
- package/dist/testSurface/surface/test/testPage.css +9 -2
- package/dist/testSurface/surface/useTestDocument.d.ts +1 -3
- package/dist/testSurface/surface/useTestDocument.js +110 -52
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +1 -0
- package/dist/testSurface/surfaceUrls.js +4 -0
- package/dist/testSurface/useApi.d.ts +3 -0
- package/dist/transitions/addMetric.d.ts +1 -1
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/kernel.d.ts +2 -0
- package/dist/transitions/kernel.js +1 -1
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.d.ts +1 -1
- package/dist/transitions/preflightData.js +10 -2
- package/dist/transitions/start.d.ts +1 -1
- package/dist/transitions/start.js +8 -5
- package/dist/types/armKey.d.ts +2 -0
- package/dist/types/armKey.js +1 -0
- package/dist/types/contracts.d.ts +11 -1
- package/dist/types/endpoints.d.ts +38 -9
- package/dist/types/endpoints.js +1 -1
- package/dist/types/surface.d.ts +7 -9
- package/dist/ui/Dialog.d.ts +21 -2
- package/dist/ui/Dialog.js +101 -4
- package/dist/ui/Inputs.js +0 -1
- package/dist/ui/ui.css +5 -1
- package/package.json +2 -2
|
@@ -1,24 +1,30 @@
|
|
|
1
|
+
import { BLOCK_COPY } from './blocks.js';
|
|
1
2
|
export const NEW_TEST_COPY = {
|
|
2
3
|
question: 'What do you want to test?',
|
|
3
4
|
block: 'A block on a page',
|
|
4
5
|
setting: 'A setting',
|
|
5
6
|
page: 'A whole page',
|
|
6
7
|
pageMeaning: 'Show different versions of a whole page at the same address, and see which one works better.',
|
|
7
|
-
collection: '
|
|
8
|
+
collection: 'Which type of page?',
|
|
8
9
|
original: 'Original',
|
|
9
10
|
originalHelp: 'Choose the page visitors see today.',
|
|
10
11
|
review: 'Review',
|
|
11
12
|
backToTest: 'Back to the test',
|
|
12
13
|
finishSetup: 'Finish setup',
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
blocksHandoff: `Choose '${BLOCK_COPY.testBlock}' to pick the block to test.`,
|
|
15
|
+
blocksOnlyHandoff: `Open the page you want to test, then choose '${BLOCK_COPY.testBlock}' to pick the block to test.`,
|
|
16
|
+
pageType: 'Page type',
|
|
17
|
+
choosePageType: 'Choose a page type',
|
|
15
18
|
blockMeaning: 'Compare different versions of content on a page.',
|
|
16
19
|
settingMeaning: 'Compare different choices for a setting on your site.',
|
|
17
20
|
unavailable: 'A developer needs to set up pages or settings before you can create a test.',
|
|
18
|
-
handoff: 'Open the page
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
handoff: 'Open the page you want to test, then follow these steps in the editor.',
|
|
22
|
+
mixedEditorHandoff: 'Open the page you want to test, then follow the steps for its editor.',
|
|
23
|
+
pagesMarked: (editor)=>`Pages marked ${editor}:`,
|
|
24
|
+
handoffSteps: [
|
|
25
|
+
'Add a Test block to the page.',
|
|
26
|
+
'Choose Set up test in the sidebar.'
|
|
27
|
+
],
|
|
22
28
|
chooseSetting: 'Which setting do you want to test?',
|
|
23
29
|
people: 'Count people as:',
|
|
24
30
|
visitors: 'Visitors',
|
|
@@ -35,6 +41,7 @@ export const NEW_TEST_COPY = {
|
|
|
35
41
|
name: 'Name',
|
|
36
42
|
hypothesis: 'Why are you testing this? (optional)',
|
|
37
43
|
back: 'Back',
|
|
44
|
+
change: 'Change',
|
|
38
45
|
next: 'Next',
|
|
39
46
|
createTest: 'Create',
|
|
40
47
|
creating: 'Creating…',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare const STATUS_TOOLTIPS: {
|
|
2
2
|
readonly draft: "Draft";
|
|
3
3
|
readonly running: "Running";
|
|
4
|
-
readonly stopped:
|
|
4
|
+
readonly stopped: (label?: string) => string;
|
|
5
5
|
readonly decided: "Decided — everyone sees the winner";
|
|
6
6
|
readonly decidedWithHoldout: "Decided — everyone sees the winner, except the holdout";
|
|
7
7
|
readonly archived: "Archived";
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import { controlVersionName } from '../../labels/arms.js';
|
|
1
2
|
export const STATUS_TOOLTIPS = {
|
|
2
3
|
draft: 'Draft',
|
|
3
4
|
running: 'Running',
|
|
4
|
-
stopped:
|
|
5
|
+
stopped: (label)=>`Stopped — everyone sees ${controlVersionName(label)}`,
|
|
5
6
|
decided: 'Decided — everyone sees the winner',
|
|
6
7
|
decidedWithHoldout: 'Decided — everyone sees the winner, except the holdout',
|
|
7
8
|
archived: 'Archived'
|
|
@@ -3,6 +3,7 @@ import type { ExperimentsPageCollection } from '../types/contracts.js';
|
|
|
3
3
|
export declare function serializePageCollections(collections: ExperimentsPageCollection[], req: PayloadRequest): {
|
|
4
4
|
copyUrl: string;
|
|
5
5
|
copyLabel: string;
|
|
6
|
+
copyEnabled?: true | undefined;
|
|
6
7
|
copyHint?: string | undefined;
|
|
7
8
|
slug: string;
|
|
8
9
|
label: string;
|
|
@@ -10,6 +10,9 @@ export function serializePageCollections(collections, req) {
|
|
|
10
10
|
...entry.copyHint ? {
|
|
11
11
|
copyHint: entry.copyHint
|
|
12
12
|
} : {},
|
|
13
|
+
...entry.copy ? {
|
|
14
|
+
copyEnabled: true
|
|
15
|
+
} : {},
|
|
13
16
|
copyUrl: entry.copyUrl ?? formatAdminURL({
|
|
14
17
|
adminRoute: req.payload.config.routes.admin,
|
|
15
18
|
path: `/collections/${entry.slug}`
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { controlVersionName } from '../labels/arms.js';
|
|
1
2
|
export function pageStatusCopy(test) {
|
|
2
3
|
if (test.pagesReleased) return null;
|
|
3
4
|
const winner = `${test.winnerLabel ?? 'the winner'}${test.winnerTitle ? ` (${test.winnerTitle})` : ''}`;
|
|
@@ -6,14 +7,15 @@ export function pageStatusCopy(test) {
|
|
|
6
7
|
return `This page is ${test.armLabel} in the draft test ${test.name}.`;
|
|
7
8
|
case 'stopped':
|
|
8
9
|
{
|
|
9
|
-
const
|
|
10
|
+
const control = controlVersionName(test.controlLabel);
|
|
11
|
+
const visitors = test.role === 'original' ? 'Visitors see this page.' : !test.originalPath ? `Visitors see ${control}.` : `Visitors to ${test.originalPath === '/' ? 'the homepage (/)' : test.originalPath} see ${control}.`;
|
|
10
12
|
return `This page is ${test.armLabel} in the stopped test ${test.name}. ${visitors}`;
|
|
11
13
|
}
|
|
12
14
|
case 'running':
|
|
13
15
|
return `This page is the ${test.armLabel} of a running test: ${test.name}.`;
|
|
14
16
|
case 'decided':
|
|
15
|
-
return `This page is ${test.armLabel} of a decided test; ${test.rollout ? `most visitors see ${winner}; a holdout still sees
|
|
17
|
+
return `This page is ${test.armLabel} of a decided test; ${test.rollout ? `most visitors see ${winner}; a holdout still sees ${controlVersionName(test.controlLabel ?? (test.role === 'original' ? test.armLabel : undefined))}` : `visitors see ${winner}`}.`;
|
|
16
18
|
case 'archived':
|
|
17
|
-
return test.winner ? `This page is also shown at the other versions' addresses because test ${test.name} made it the winner.
|
|
19
|
+
return test.winner ? `This page is also shown at the other versions' addresses because test ${test.name} made it the winner. Use "Release pages" on the test to free it.` : test.role === 'original' ? `This page's address now shows the winner of test ${test.name}. Use "Release pages" on the test to free it.` : `This page's address now shows ${winner}. Use "Release pages" on the test to show this page again.`;
|
|
18
20
|
}
|
|
19
21
|
}
|
|
@@ -9,9 +9,10 @@ const TONES = {
|
|
|
9
9
|
};
|
|
10
10
|
export function statusPill({ status, arms = [], decision }) {
|
|
11
11
|
const holdout = status === 'decided' && arms?.some((group)=>group.key === 'holdout') && Boolean(decision?.winnerArm) && decision?.winnerArm !== 'control' && !decision?.holdoutReleasedAt;
|
|
12
|
+
const tooltip = status === 'stopped' ? STATUS_TOOLTIPS.stopped(arms?.find((group)=>group.key === 'control')?.label) : holdout ? STATUS_TOOLTIPS.decidedWithHoldout : STATUS_TOOLTIPS[status];
|
|
12
13
|
return {
|
|
13
14
|
label: statusLabel(status),
|
|
14
15
|
tone: TONES[status],
|
|
15
|
-
tooltip
|
|
16
|
+
tooltip
|
|
16
17
|
};
|
|
17
18
|
}
|
|
@@ -23,9 +23,7 @@ export function ResultsRoute(props) {
|
|
|
23
23
|
function ManagedResults({ id, surface, onTitleChange }) {
|
|
24
24
|
const test = useTestDocument(id, {
|
|
25
25
|
apiRoute: surface.apiRoute,
|
|
26
|
-
contentLocale: surface.contentLocale
|
|
27
|
-
refetchDocumentOnFocus: true,
|
|
28
|
-
refetchPreflightOnFocus: true
|
|
26
|
+
contentLocale: surface.contentLocale
|
|
29
27
|
});
|
|
30
28
|
useEffect(()=>{
|
|
31
29
|
if (test.doc?.name) onTitleChange?.(test.doc.name);
|
|
@@ -48,10 +46,8 @@ function ManagedResults({ id, surface, onTitleChange }) {
|
|
|
48
46
|
id: id,
|
|
49
47
|
surface: surface,
|
|
50
48
|
onRecomputed: ()=>setResultsVersion((value)=>value + 1),
|
|
51
|
-
onChanged: (
|
|
52
|
-
test.acceptTransition?.(
|
|
53
|
-
doc
|
|
54
|
-
});
|
|
49
|
+
onChanged: (transition)=>{
|
|
50
|
+
if (transition) test.acceptTransition?.(transition);
|
|
55
51
|
void test.reload();
|
|
56
52
|
},
|
|
57
53
|
renderPage: (parts)=>/*#__PURE__*/ _jsx(ResultsHeader, {
|
|
@@ -59,7 +55,7 @@ function ManagedResults({ id, surface, onTitleChange }) {
|
|
|
59
55
|
surface: surface,
|
|
60
56
|
resultsVersion: resultsVersion,
|
|
61
57
|
...parts
|
|
62
|
-
},
|
|
58
|
+
}, test.doc.id)
|
|
63
59
|
});
|
|
64
60
|
return /*#__PURE__*/ _jsx(ReaderResultsShell, {
|
|
65
61
|
surface: surface,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import '../theme.css';
|
|
2
|
-
import type
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
3
3
|
import './surface.css';
|
|
4
4
|
export interface SurfaceShellProps {
|
|
5
5
|
adminRoute: string;
|
|
@@ -12,5 +12,7 @@ export interface SurfaceShellProps {
|
|
|
12
12
|
status?: ReactNode;
|
|
13
13
|
actions?: ReactNode;
|
|
14
14
|
subtitle?: ReactNode;
|
|
15
|
+
className?: string;
|
|
16
|
+
dynamicTitle?: boolean;
|
|
15
17
|
}
|
|
16
|
-
export declare function SurfaceShell({ adminRoute, children, crumbs, title, status, actions, subtitle }: SurfaceShellProps): import("react").JSX.Element;
|
|
18
|
+
export declare function SurfaceShell({ adminRoute, children, crumbs, title, status, actions, subtitle, className, dynamicTitle }: SurfaceShellProps): import("react").JSX.Element;
|
|
@@ -1,18 +1,41 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import '../theme.css';
|
|
4
|
+
import { useContext, useEffect } from 'react';
|
|
4
5
|
import { formatAdminURL } from 'payload/shared';
|
|
5
6
|
import { Breadcrumb } from '../../ui/Breadcrumb.js';
|
|
6
7
|
import { Button } from '../../ui/Button.js';
|
|
7
8
|
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
9
|
+
import { XpStepNavContext } from './useXpStepNav.js';
|
|
8
10
|
import './surface.css';
|
|
9
11
|
export function SurfaceShell({ adminRoute, children, crumbs = [
|
|
10
12
|
{
|
|
11
13
|
label: SURFACE_COPY.title
|
|
12
14
|
}
|
|
13
|
-
], title = SURFACE_COPY.title, status, actions, subtitle }) {
|
|
15
|
+
], title = SURFACE_COPY.title, status, actions, subtitle, className, dynamicTitle = false }) {
|
|
16
|
+
const stepNav = useContext(XpStepNavContext);
|
|
17
|
+
const route = stepNav?.route;
|
|
18
|
+
const items = stepNav?.items.length && route !== 'home' && route !== 'goals' ? stepNav.items.map(({ label, url })=>({
|
|
19
|
+
label,
|
|
20
|
+
href: url
|
|
21
|
+
})) : crumbs;
|
|
22
|
+
// Custom view metadata is static in Payload 3. Use the name already loaded by the screen.
|
|
23
|
+
useEffect(()=>{
|
|
24
|
+
if (!dynamicTitle && route !== 'goal') return;
|
|
25
|
+
const previous = document.title;
|
|
26
|
+
const next = `${title} · ${SURFACE_COPY.title}`;
|
|
27
|
+
document.title = next;
|
|
28
|
+
return ()=>{
|
|
29
|
+
if (document.title === next) document.title = previous;
|
|
30
|
+
};
|
|
31
|
+
}, [
|
|
32
|
+
title,
|
|
33
|
+
dynamicTitle,
|
|
34
|
+
route
|
|
35
|
+
]);
|
|
14
36
|
return /*#__PURE__*/ _jsxs("div", {
|
|
15
|
-
className:
|
|
37
|
+
className: `xp-tests-surface xp-test-surface${className ? ` ${className}` : ''}`,
|
|
38
|
+
"data-dialog-focus-scope": true,
|
|
16
39
|
children: [
|
|
17
40
|
/*#__PURE__*/ _jsxs("header", {
|
|
18
41
|
className: "xp-tests-shell-header",
|
|
@@ -21,7 +44,7 @@ export function SurfaceShell({ adminRoute, children, crumbs = [
|
|
|
21
44
|
className: "xp-tests-container xp-tests-shell-top",
|
|
22
45
|
children: [
|
|
23
46
|
/*#__PURE__*/ _jsx(Breadcrumb, {
|
|
24
|
-
items:
|
|
47
|
+
items: items
|
|
25
48
|
}),
|
|
26
49
|
/*#__PURE__*/ _jsx(Button, {
|
|
27
50
|
variant: "quiet",
|
|
@@ -43,6 +66,8 @@ export function SurfaceShell({ adminRoute, children, crumbs = [
|
|
|
43
66
|
className: "xp-tests-shell-title",
|
|
44
67
|
children: [
|
|
45
68
|
/*#__PURE__*/ _jsx("h1", {
|
|
69
|
+
tabIndex: -1,
|
|
70
|
+
"data-dialog-focus-fallback": true,
|
|
46
71
|
children: title
|
|
47
72
|
}),
|
|
48
73
|
status
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ExperimentAction } from '../../testSurface/actions/actions.model.js';
|
|
2
|
+
export declare function TestRowMenu({ name, actions, onSelect }: {
|
|
3
|
+
name: string;
|
|
4
|
+
actions: ExperimentAction[];
|
|
5
|
+
onSelect: (action: ExperimentAction) => void;
|
|
6
|
+
}): import("react").JSX.Element;
|
|
7
|
+
export declare function RowMenu<T extends Pick<ExperimentAction, 'label' | 'tone' | 'unavailable' | 'hint'> & {
|
|
8
|
+
id: string;
|
|
9
|
+
}>({ label, actions, onSelect, }: {
|
|
10
|
+
label: string;
|
|
11
|
+
actions: T[];
|
|
12
|
+
onSelect: (action: T) => void;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useEffect, useId, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { Button } from '../../ui/Button.js';
|
|
5
|
+
import { actionsForTest } from '../../testSurface/copy/actions.js';
|
|
6
|
+
export function TestRowMenu({ name, actions, onSelect }) {
|
|
7
|
+
return /*#__PURE__*/ _jsx(RowMenu, {
|
|
8
|
+
label: actionsForTest(name),
|
|
9
|
+
actions: actions,
|
|
10
|
+
onSelect: onSelect
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
export function RowMenu({ label, actions, onSelect }) {
|
|
14
|
+
const root = useRef(null);
|
|
15
|
+
const menu = useRef(null);
|
|
16
|
+
const triggerId = useId();
|
|
17
|
+
const menuId = useId();
|
|
18
|
+
const [open, setOpen] = useState(false);
|
|
19
|
+
const startAtEnd = useRef(false);
|
|
20
|
+
const menuItems = ()=>[
|
|
21
|
+
...menu.current?.querySelectorAll('[role="menuitem"]') ?? []
|
|
22
|
+
];
|
|
23
|
+
function close(restoreFocus) {
|
|
24
|
+
if (restoreFocus) root.current?.querySelector('button')?.focus();
|
|
25
|
+
setOpen(false);
|
|
26
|
+
}
|
|
27
|
+
useLayoutEffect(()=>{
|
|
28
|
+
if (!open) return;
|
|
29
|
+
const items = menuItems();
|
|
30
|
+
(startAtEnd.current ? items.at(-1) : items[0])?.focus();
|
|
31
|
+
}, [
|
|
32
|
+
open
|
|
33
|
+
]);
|
|
34
|
+
useEffect(()=>{
|
|
35
|
+
if (!open) return;
|
|
36
|
+
const element = root.current;
|
|
37
|
+
if (!element) return;
|
|
38
|
+
const doc = element.ownerDocument;
|
|
39
|
+
const dismiss = (event)=>{
|
|
40
|
+
if (!element.contains(event.target)) setOpen(false);
|
|
41
|
+
};
|
|
42
|
+
doc.addEventListener('pointerdown', dismiss, true);
|
|
43
|
+
return ()=>doc.removeEventListener('pointerdown', dismiss, true);
|
|
44
|
+
}, [
|
|
45
|
+
open
|
|
46
|
+
]);
|
|
47
|
+
return /*#__PURE__*/ _jsxs("div", {
|
|
48
|
+
className: "xp-tests-row-menu",
|
|
49
|
+
ref: root,
|
|
50
|
+
onBlur: (event)=>{
|
|
51
|
+
if (open && !event.currentTarget.contains(event.relatedTarget)) close(false);
|
|
52
|
+
},
|
|
53
|
+
children: [
|
|
54
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
55
|
+
id: triggerId,
|
|
56
|
+
className: "xp-tests-row-menu-trigger",
|
|
57
|
+
variant: "quiet",
|
|
58
|
+
size: "sm",
|
|
59
|
+
"aria-label": label,
|
|
60
|
+
"aria-haspopup": "menu",
|
|
61
|
+
"aria-expanded": open,
|
|
62
|
+
"aria-controls": open ? menuId : undefined,
|
|
63
|
+
onClick: ()=>{
|
|
64
|
+
if (open) close(true);
|
|
65
|
+
else {
|
|
66
|
+
startAtEnd.current = false;
|
|
67
|
+
setOpen(true);
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
onKeyDown: (event)=>{
|
|
71
|
+
if (event.key !== 'ArrowDown' && event.key !== 'ArrowUp') return;
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
startAtEnd.current = event.key === 'ArrowUp';
|
|
74
|
+
if (open) {
|
|
75
|
+
const items = menuItems();
|
|
76
|
+
(startAtEnd.current ? items.at(-1) : items[0])?.focus();
|
|
77
|
+
} else setOpen(true);
|
|
78
|
+
},
|
|
79
|
+
children: /*#__PURE__*/ _jsxs("svg", {
|
|
80
|
+
width: "18",
|
|
81
|
+
height: "18",
|
|
82
|
+
viewBox: "0 0 18 18",
|
|
83
|
+
fill: "currentColor",
|
|
84
|
+
"aria-hidden": "true",
|
|
85
|
+
children: [
|
|
86
|
+
/*#__PURE__*/ _jsx("circle", {
|
|
87
|
+
cx: "4",
|
|
88
|
+
cy: "9",
|
|
89
|
+
r: "1.3"
|
|
90
|
+
}),
|
|
91
|
+
/*#__PURE__*/ _jsx("circle", {
|
|
92
|
+
cx: "9",
|
|
93
|
+
cy: "9",
|
|
94
|
+
r: "1.3"
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ _jsx("circle", {
|
|
97
|
+
cx: "14",
|
|
98
|
+
cy: "9",
|
|
99
|
+
r: "1.3"
|
|
100
|
+
})
|
|
101
|
+
]
|
|
102
|
+
})
|
|
103
|
+
}),
|
|
104
|
+
open ? /*#__PURE__*/ _jsx("div", {
|
|
105
|
+
id: menuId,
|
|
106
|
+
ref: menu,
|
|
107
|
+
role: "menu",
|
|
108
|
+
"aria-labelledby": triggerId,
|
|
109
|
+
className: "xp-tests-row-menu-items",
|
|
110
|
+
onKeyDown: (event)=>{
|
|
111
|
+
const items = menuItems();
|
|
112
|
+
const index = items.findIndex((item)=>item === event.target);
|
|
113
|
+
const key = event.key;
|
|
114
|
+
if (key === 'Tab') {
|
|
115
|
+
close(true);
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
if (key === 'Escape') {
|
|
119
|
+
event.preventDefault();
|
|
120
|
+
close(true);
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const next = key === 'Home' ? items[0] : key === 'End' ? items.at(-1) : key === 'ArrowDown' ? items[(index + 1) % items.length] : key === 'ArrowUp' ? items[(index - 1 + items.length) % items.length] : key.length === 1 && key !== ' ' && !event.altKey && !event.ctrlKey && !event.metaKey ? [
|
|
124
|
+
...items.slice(index + 1),
|
|
125
|
+
...items.slice(0, index + 1)
|
|
126
|
+
].find((item)=>item.textContent?.trim().toLowerCase().startsWith(key.toLowerCase())) : undefined;
|
|
127
|
+
if (next) {
|
|
128
|
+
event.preventDefault();
|
|
129
|
+
next.focus();
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
children: actions.map((action, index)=>{
|
|
133
|
+
const detail = action.unavailable ?? action.hint;
|
|
134
|
+
const detailId = `${menuId}-${index}`;
|
|
135
|
+
return /*#__PURE__*/ _jsxs("button", {
|
|
136
|
+
type: "button",
|
|
137
|
+
role: "menuitem",
|
|
138
|
+
tabIndex: -1,
|
|
139
|
+
"aria-label": action.label,
|
|
140
|
+
"aria-disabled": action.unavailable ? true : undefined,
|
|
141
|
+
className: `xp-tests-menu-item${action.tone === 'secondary' ? '' : ` xp-tests-menu-item--${action.tone}`}`,
|
|
142
|
+
"aria-describedby": detail ? detailId : undefined,
|
|
143
|
+
onClick: ()=>{
|
|
144
|
+
if (action.unavailable) return;
|
|
145
|
+
close(true);
|
|
146
|
+
onSelect(action);
|
|
147
|
+
},
|
|
148
|
+
children: [
|
|
149
|
+
/*#__PURE__*/ _jsx("span", {
|
|
150
|
+
children: action.label
|
|
151
|
+
}),
|
|
152
|
+
detail ? /*#__PURE__*/ _jsx("span", {
|
|
153
|
+
id: detailId,
|
|
154
|
+
className: "xp-ui-help",
|
|
155
|
+
children: detail
|
|
156
|
+
}) : null
|
|
157
|
+
]
|
|
158
|
+
}, action.id);
|
|
159
|
+
})
|
|
160
|
+
}) : null
|
|
161
|
+
]
|
|
162
|
+
});
|
|
163
|
+
}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { SurfaceShellProps } from './SurfaceShell.js';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function TestsHome({ adminRoute, apiRoute, contentLocale, canManage, crumbs, flagPoints }: {
|
|
2
|
+
import type { SurfaceProps } from '../../testSurface/surface/contracts.js';
|
|
3
|
+
export declare function TestsHome({ adminRoute, apiRoute, contentLocale, canManage, canReadResults, crumbs, flagPoints }: {
|
|
4
4
|
adminRoute: string;
|
|
5
5
|
apiRoute: string;
|
|
6
6
|
contentLocale?: string;
|
|
7
7
|
canManage?: boolean;
|
|
8
|
+
canReadResults?: boolean;
|
|
8
9
|
crumbs?: SurfaceShellProps['crumbs'];
|
|
9
|
-
flagPoints?:
|
|
10
|
+
flagPoints?: SurfaceProps['flagPoints'];
|
|
10
11
|
}): import("react").JSX.Element;
|