@delmaredigital/payload-experiments 0.4.0-rc.9 → 0.4.0
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 +2 -8
- 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
package/dist/plugin.js
CHANGED
|
@@ -2,6 +2,7 @@ import { buildCollections } from './collections/index.js';
|
|
|
2
2
|
import { buildEndpoints } from './endpoints/index.js';
|
|
3
3
|
import { contentChangesBeforeHook, contentChangesHook } from './hooks/contentChanges.js';
|
|
4
4
|
import { puckGoalsBeforeChange } from './hooks/puckGoals.js';
|
|
5
|
+
import { trackPageCopies } from './hooks/trackPageCopies.js';
|
|
5
6
|
import { pageGuardAfterChange, pageGuardAfterOperation, pageGuardEnterOperation, pageGuardBeforeChange, pageGuardBeforeDelete, pageGuardBeforeOperation } from './hooks/pageGuard.js';
|
|
6
7
|
import { createOnInit } from './onInit.js';
|
|
7
8
|
import { puckCollections, resolveOptions } from './options.js';
|
|
@@ -39,9 +40,59 @@ export function createExperimentsPlugin(input) {
|
|
|
39
40
|
...config.admin?.components,
|
|
40
41
|
views: {
|
|
41
42
|
...config.admin?.components?.views,
|
|
43
|
+
xpNewTest: {
|
|
44
|
+
Component: paths.XP_TESTS_VIEW,
|
|
45
|
+
path: '/experiments/new',
|
|
46
|
+
exact: true,
|
|
47
|
+
meta: {
|
|
48
|
+
title: {
|
|
49
|
+
absolute: 'New test · Tests'
|
|
50
|
+
},
|
|
51
|
+
titleSuffix: ''
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
xpNewGoal: {
|
|
55
|
+
Component: paths.XP_TESTS_VIEW,
|
|
56
|
+
path: '/experiments/goals/new',
|
|
57
|
+
exact: true,
|
|
58
|
+
meta: {
|
|
59
|
+
title: {
|
|
60
|
+
absolute: 'New goal · Tests'
|
|
61
|
+
},
|
|
62
|
+
titleSuffix: ''
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
xpGoal: {
|
|
66
|
+
Component: paths.XP_TESTS_VIEW,
|
|
67
|
+
path: '/experiments/goals/:id',
|
|
68
|
+
exact: true,
|
|
69
|
+
meta: {
|
|
70
|
+
title: {
|
|
71
|
+
absolute: 'Goal · Tests'
|
|
72
|
+
},
|
|
73
|
+
titleSuffix: ''
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
xpResults: {
|
|
77
|
+
Component: paths.XP_TESTS_VIEW,
|
|
78
|
+
path: '/experiments/:id/results',
|
|
79
|
+
exact: true,
|
|
80
|
+
meta: {
|
|
81
|
+
title: {
|
|
82
|
+
absolute: 'Results · Tests'
|
|
83
|
+
},
|
|
84
|
+
titleSuffix: ''
|
|
85
|
+
}
|
|
86
|
+
},
|
|
42
87
|
xpTests: {
|
|
43
88
|
Component: paths.XP_TESTS_VIEW,
|
|
44
|
-
path: '/experiments/:segments*'
|
|
89
|
+
path: '/experiments/:segments*',
|
|
90
|
+
meta: {
|
|
91
|
+
title: {
|
|
92
|
+
absolute: 'Test · Tests'
|
|
93
|
+
},
|
|
94
|
+
titleSuffix: ''
|
|
95
|
+
}
|
|
45
96
|
}
|
|
46
97
|
}
|
|
47
98
|
}
|
|
@@ -53,7 +104,7 @@ export function createExperimentsPlugin(input) {
|
|
|
53
104
|
].map((slug)=>collections.find((collection)=>collection.slug === slug)),
|
|
54
105
|
...(config.collections ?? []).map((collection)=>{
|
|
55
106
|
const puck = options.puck?.enabled && registrations.find((entry)=>entry.slug === collection.slug);
|
|
56
|
-
const page = options.pages?.collections.
|
|
107
|
+
const page = options.pages?.collections.find((entry)=>entry.slug === collection.slug);
|
|
57
108
|
const blocks = options.blocks?.collections.find((entry)=>entry.slug === collection.slug);
|
|
58
109
|
if (!puck && !page && !blocks) return collection;
|
|
59
110
|
return {
|
|
@@ -97,6 +148,9 @@ export function createExperimentsPlugin(input) {
|
|
|
97
148
|
...collection.hooks?.afterOperation ?? []
|
|
98
149
|
],
|
|
99
150
|
afterChange: [
|
|
151
|
+
...page?.copy ? [
|
|
152
|
+
trackPageCopies
|
|
153
|
+
] : [],
|
|
100
154
|
...collection.hooks?.afterChange ?? [],
|
|
101
155
|
pageGuardAfterChange,
|
|
102
156
|
contentChangesHook
|
|
@@ -1,25 +1,25 @@
|
|
|
1
1
|
import type { DocId } from '../../types/contracts.js';
|
|
2
|
+
import type { BlockVersionContent } from '../../testSurface/surface/contracts.js';
|
|
2
3
|
import type { resolvePuckRoutes } from '../routes.js';
|
|
3
4
|
import './editor.css';
|
|
4
5
|
type ConfigureRoutes = ReturnType<typeof resolvePuckRoutes> & {
|
|
5
6
|
contentLocale?: string;
|
|
6
7
|
};
|
|
7
|
-
export declare function ConfigureTestDrawer({ id, routes, onClose }: {
|
|
8
|
+
export declare function ConfigureTestDrawer({ id, routes, versionContent, onClose }: {
|
|
8
9
|
id: DocId;
|
|
9
10
|
routes: ConfigureRoutes;
|
|
11
|
+
versionContent?: BlockVersionContent;
|
|
10
12
|
onClose: () => void;
|
|
11
13
|
}): import("react").JSX.Element;
|
|
12
14
|
/** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */
|
|
13
|
-
export declare function openConfigureTestDrawer(source: HTMLElement, routes: ConfigureRoutes, id: DocId): {
|
|
15
|
+
export declare function openConfigureTestDrawer(source: HTMLElement, routes: ConfigureRoutes, id: DocId, versionContent?: BlockVersionContent, onClose?: () => void): {
|
|
14
16
|
close: () => void;
|
|
17
|
+
updateVersionContent: (content: BlockVersionContent | undefined) => void;
|
|
15
18
|
};
|
|
16
19
|
/** The canvas already has current permissions; use them without a second read. */
|
|
17
|
-
export declare function ConfigureTestControl({ id, routes }: {
|
|
20
|
+
export declare function ConfigureTestControl({ id, routes, versionContent }: {
|
|
18
21
|
id: DocId;
|
|
19
22
|
routes: ConfigureRoutes;
|
|
23
|
+
versionContent?: BlockVersionContent;
|
|
20
24
|
}): import("react").JSX.Element;
|
|
21
|
-
export declare function ConfigureTestButton({ id, routes }: {
|
|
22
|
-
id: DocId;
|
|
23
|
-
routes: ConfigureRoutes;
|
|
24
|
-
}): import("react").JSX.Element | null;
|
|
25
25
|
export {};
|
|
@@ -7,12 +7,12 @@ import { TestSurface } from '../../testSurface/surface/test/TestSurface.js';
|
|
|
7
7
|
import { Drawer } from '../../ui/Drawer.js';
|
|
8
8
|
import { Button } from '../../ui/Button.js';
|
|
9
9
|
import { TEST_PAGE } from '../../testSurface/copy/testPage.js';
|
|
10
|
-
import { readSurface
|
|
10
|
+
import { readSurface } from './editorSurface.js';
|
|
11
11
|
import { editorCopy as C } from './copy.js';
|
|
12
12
|
import { publishExperiment } from './armsCache.js';
|
|
13
13
|
import { readEditorPreflight } from './placementsCache.js';
|
|
14
14
|
import './editor.css';
|
|
15
|
-
export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
15
|
+
export function ConfigureTestDrawer({ id, routes, versionContent, onClose }) {
|
|
16
16
|
const [title, setTitle] = useState(C.configure);
|
|
17
17
|
const [state, setState] = useState({});
|
|
18
18
|
const [attempt, setAttempt] = useState(0);
|
|
@@ -39,6 +39,9 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
39
39
|
// Unknown permissions use the test page's authoritative admin access check.
|
|
40
40
|
const testUrl = `${routes.admin}/experiments/${encodeURIComponent(id)}`;
|
|
41
41
|
const openUrl = state.surface && !state.surface.canManage && state.surface.canReadResults ? `${testUrl}/results` : testUrl;
|
|
42
|
+
const editorPage = versionContent ? {
|
|
43
|
+
versionContent
|
|
44
|
+
} : undefined;
|
|
42
45
|
return /*#__PURE__*/ _jsx(Drawer, {
|
|
43
46
|
title: title,
|
|
44
47
|
closeLabel: C.closeConfigure,
|
|
@@ -65,7 +68,8 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
65
68
|
id: id,
|
|
66
69
|
surface: {
|
|
67
70
|
...state.surface,
|
|
68
|
-
contentLocale: routes.contentLocale
|
|
71
|
+
contentLocale: routes.contentLocale,
|
|
72
|
+
editorPage
|
|
69
73
|
},
|
|
70
74
|
embedded: true,
|
|
71
75
|
onTitleChange: setTitle,
|
|
@@ -86,7 +90,7 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
86
90
|
})
|
|
87
91
|
});
|
|
88
92
|
}
|
|
89
|
-
/** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */ export function openConfigureTestDrawer(source, routes, id) {
|
|
93
|
+
/** Separate document root, like the creation dialog: Puck has no ancestor handlers here. */ export function openConfigureTestDrawer(source, routes, id, versionContent, onClose) {
|
|
90
94
|
// A canvas iframe's modal would cover only the canvas. Mount over the whole editor.
|
|
91
95
|
const doc = source.ownerDocument.defaultView?.frameElement?.ownerDocument ?? source.ownerDocument;
|
|
92
96
|
const container = doc.createElement('div');
|
|
@@ -109,42 +113,48 @@ export function ConfigureTestDrawer({ id, routes, onClose }) {
|
|
|
109
113
|
container.remove();
|
|
110
114
|
if (source.isConnected) source.focus();
|
|
111
115
|
});
|
|
116
|
+
onClose?.();
|
|
112
117
|
};
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
const updateVersionContent = (content)=>{
|
|
119
|
+
if (closed) return;
|
|
120
|
+
root.render(/*#__PURE__*/ _jsx("div", {
|
|
121
|
+
onClick: (event)=>event.stopPropagation(),
|
|
122
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
123
|
+
onPointerMove: (event)=>event.stopPropagation(),
|
|
124
|
+
onPointerUp: (event)=>event.stopPropagation(),
|
|
125
|
+
children: /*#__PURE__*/ _jsx(ConfigureTestDrawer, {
|
|
126
|
+
id: id,
|
|
127
|
+
routes: routes,
|
|
128
|
+
versionContent: content,
|
|
129
|
+
onClose: close
|
|
130
|
+
})
|
|
131
|
+
}));
|
|
132
|
+
};
|
|
133
|
+
updateVersionContent(versionContent);
|
|
124
134
|
return {
|
|
125
|
-
close
|
|
135
|
+
close,
|
|
136
|
+
updateVersionContent
|
|
126
137
|
};
|
|
127
138
|
}
|
|
128
|
-
/** The canvas already has current permissions; use them without a second read. */ export function ConfigureTestControl({ id, routes }) {
|
|
139
|
+
/** The canvas already has current permissions; use them without a second read. */ export function ConfigureTestControl({ id, routes, versionContent }) {
|
|
129
140
|
const drawer = useRef(undefined);
|
|
130
141
|
useEffect(()=>()=>drawer.current?.close(), [
|
|
131
142
|
id,
|
|
132
143
|
routes.api
|
|
133
144
|
]);
|
|
145
|
+
useEffect(()=>{
|
|
146
|
+
drawer.current?.updateVersionContent(versionContent);
|
|
147
|
+
}, [
|
|
148
|
+
versionContent
|
|
149
|
+
]);
|
|
134
150
|
return /*#__PURE__*/ _jsx(Button, {
|
|
135
151
|
variant: "primary",
|
|
136
152
|
onClick: (event)=>{
|
|
137
153
|
drawer.current?.close();
|
|
138
|
-
drawer.current = openConfigureTestDrawer(event.currentTarget, routes, id)
|
|
154
|
+
drawer.current = openConfigureTestDrawer(event.currentTarget, routes, id, versionContent, ()=>{
|
|
155
|
+
drawer.current = undefined;
|
|
156
|
+
});
|
|
139
157
|
},
|
|
140
158
|
children: C.configure
|
|
141
159
|
});
|
|
142
160
|
}
|
|
143
|
-
export function ConfigureTestButton({ id, routes }) {
|
|
144
|
-
const access = useEditorSurface(routes.api);
|
|
145
|
-
if (!access.surface || !access.surface.canManage && !access.surface.canReadResults) return null;
|
|
146
|
-
return /*#__PURE__*/ _jsx(ConfigureTestControl, {
|
|
147
|
-
id: id,
|
|
148
|
-
routes: routes
|
|
149
|
-
});
|
|
150
|
-
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ComponentConfig } from '@puckeditor/core';
|
|
2
|
+
import { type ReactNode } from 'react';
|
|
2
3
|
import type { ExperimentSlotProps } from '../../types/puck.js';
|
|
3
4
|
import { type PuckRoutes } from '../routes.js';
|
|
4
5
|
import './editor.css';
|
|
@@ -12,7 +13,7 @@ export declare const ExperimentSlotEditor: {
|
|
|
12
13
|
defaultProps?: ExperimentSlotProps | undefined;
|
|
13
14
|
fields?: import("@puckeditor/core").Fields<ExperimentSlotProps, {}> | undefined;
|
|
14
15
|
renderFields?: ((props: {
|
|
15
|
-
fields: Partial<Record<keyof ExperimentSlotProps,
|
|
16
|
+
fields: Partial<Record<keyof ExperimentSlotProps, ReactNode>>;
|
|
16
17
|
}) => import("react").ReactElement) | undefined;
|
|
17
18
|
permissions?: Partial<import("@puckeditor/core").Permissions>;
|
|
18
19
|
inline?: boolean;
|