@delmaredigital/payload-experiments 0.4.0-rc.6 → 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/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/PageWizard.js +1 -0
- package/dist/admin/surface/newTest/newTest.css +1 -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 +3 -2
- package/dist/blocks/placementLanguages.d.ts +7 -0
- package/dist/blocks/placementLanguages.js +27 -0
- package/dist/blocks/placementLocale.d.ts +21 -7
- package/dist/blocks/placementLocale.js +218 -67
- 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 +38 -31
- package/dist/hooks/blockRemovalRule.d.ts +2 -2
- package/dist/hooks/blockRemovalRule.js +16 -14
- package/dist/hooks/pageGuard.d.ts +3 -0
- package/dist/hooks/pageGuard.js +33 -23
- 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.js +40 -37
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
- package/dist/puck/editor/ConfigureTestDrawer.js +4 -2
- package/dist/puck/editor/ExperimentSlotEditor.js +135 -104
- package/dist/puck/editor/LeftoverVersions.d.ts +1 -1
- package/dist/puck/editor/LeftoverVersions.js +40 -43
- package/dist/puck/editor/VersionBuilder.d.ts +18 -1
- package/dist/puck/editor/VersionBuilder.js +217 -39
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/copy.d.ts +8 -1
- package/dist/puck/editor/copy.js +9 -1
- package/dist/puck/editor/editor.chrome.css +117 -3
- package/dist/puck/editor/editor.css +130 -8
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +2 -2
- package/dist/puck/editor/localPlacements.d.ts +1 -0
- package/dist/puck/editor/localPlacements.js +12 -0
- package/dist/puck/editor/placementsCache.d.ts +18 -12
- package/dist/puck/editor/placementsCache.js +52 -47
- 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 +2 -3
- package/dist/puck/visibility.js +11 -7
- package/dist/server/recordContentChange.js +34 -19
- package/dist/server/resolveExperimentData.js +2 -2
- 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 +1 -1
- package/dist/testSurface/copy/readiness.js +1 -1
- package/dist/testSurface/copy/testPage.d.ts +21 -0
- package/dist/testSurface/copy/testPage.js +21 -0
- 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/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/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/TestSurface.js +29 -9
- 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 +5 -4
- 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 +219 -56
- 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/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 +9 -9
- package/dist/ui/SelectControl.d.ts +33 -0
- package/dist/ui/SelectControl.js +504 -0
- package/dist/ui/ui.css +13 -5
- package/package.json +3 -2
|
@@ -29,13 +29,15 @@ import { armsFromBlock, bannerFor, currentPuckDocument, isSharedTest, tabsFor }
|
|
|
29
29
|
import { cloneSlot, countSlotBlocks } from './cloneSlot.js';
|
|
30
30
|
import { openCreateExperimentDrawer } from './CreateExperimentDrawer.js';
|
|
31
31
|
import { editorCopy } from './copy.js';
|
|
32
|
+
import { nestedTestLabel, nearestOuterTest } from '../nestedTests.js';
|
|
33
|
+
import { experimentClipboard } from './blockClipboard.js';
|
|
32
34
|
import { acquireArms, loadArms, publishExperiment, useArms } from './armsCache.js';
|
|
33
|
-
import { AddVariant, RemoveVersion, VersionName, VersionWeights, useArmWrites } from './VersionBuilder.js';
|
|
35
|
+
import { AddVariant, RemoveVersion, VersionCard, VersionName, VersionWeights, VersionLock, useArmWrites } from './VersionBuilder.js';
|
|
34
36
|
import { ResultsReadout } from './ResultsReadout.js';
|
|
35
37
|
import { EditorControls } from './EditorControls.js';
|
|
36
38
|
import { acquirePlacements, cachedPreflight, cachedReadinessRead, placementsPending, placementsBlocking, placementReadError, invalidatePlacements, refreshPlacements, focusPlacements } from './placementsCache.js';
|
|
37
|
-
import { sidebarReadinessBlockers, editorPlacementMessage } from '../../testSurface/surface/editorPlacement.js';
|
|
38
|
-
import { localPlacements, localBlockVisibility } from './localPlacements.js';
|
|
39
|
+
import { sidebarReadinessBlockers, editorPlacementMessage, editorNestedChecks } from '../../testSurface/surface/editorPlacement.js';
|
|
40
|
+
import { localPlacements, localBlockVisibility, localNestedTests } from './localPlacements.js';
|
|
39
41
|
import { usePlacementNotice } from './usePlacementNotice.js';
|
|
40
42
|
import { useEditorSurface } from './editorSurface.js';
|
|
41
43
|
import { createBlockTest, CreateRefused } from './createTest.js';
|
|
@@ -62,6 +64,9 @@ function EditorRender(props) {
|
|
|
62
64
|
const sidebar = useSidebarTargets(props.id);
|
|
63
65
|
const { admin, api } = usePuckRoutes();
|
|
64
66
|
const access = useEditorSurface(api);
|
|
67
|
+
// The neutral Puck surface can read an explicit editing locale from the admin URL.
|
|
68
|
+
// Without localization or a known locale, omit it and use the server default.
|
|
69
|
+
const contentLocale = access.surface?.contentLanguageLabels?.length ? new URLSearchParams(window.location.search).get('locale') || undefined : undefined;
|
|
65
70
|
const root = useRef(null);
|
|
66
71
|
const [readAttempt, setReadAttempt] = useState(0);
|
|
67
72
|
const [mode, setMode] = useState('light');
|
|
@@ -225,15 +230,15 @@ function EditorRender(props) {
|
|
|
225
230
|
if (experimentId === undefined || !status || !access.surface?.canManage) return;
|
|
226
231
|
const release = acquirePlacements(api, experimentId, (placements)=>{
|
|
227
232
|
// Retain guidance only while revalidating; failures must show their own message.
|
|
228
|
-
setPlacements((current)=>placements === undefined && placementsPending(api, experimentId) && current?.id === experimentId ? current : {
|
|
233
|
+
setPlacements((current)=>placements === undefined && placementsPending(api, experimentId, contentLocale) && current?.id === experimentId ? current : {
|
|
229
234
|
id: experimentId,
|
|
230
235
|
value: placements
|
|
231
236
|
});
|
|
232
237
|
setPreflight({
|
|
233
238
|
id: experimentId,
|
|
234
|
-
value: cachedPreflight(api, experimentId),
|
|
235
|
-
pending: placementsPending(api, experimentId),
|
|
236
|
-
blocking: placementsBlocking(api, experimentId)
|
|
239
|
+
value: cachedPreflight(api, experimentId, contentLocale),
|
|
240
|
+
pending: placementsPending(api, experimentId, contentLocale),
|
|
241
|
+
blocking: placementsBlocking(api, experimentId, contentLocale)
|
|
237
242
|
});
|
|
238
243
|
const shared = placements === undefined ? undefined : isSharedTest(placements, currentPuckDocument(window.location.pathname, admin, placements));
|
|
239
244
|
setLoaded((value)=>({
|
|
@@ -241,9 +246,9 @@ function EditorRender(props) {
|
|
|
241
246
|
id: experimentId,
|
|
242
247
|
shared: shared ?? (value?.id === experimentId ? value.shared : undefined)
|
|
243
248
|
}));
|
|
244
|
-
});
|
|
249
|
+
}, false, contentLocale);
|
|
245
250
|
const focus = ()=>{
|
|
246
|
-
void focusPlacements(api, experimentId);
|
|
251
|
+
void focusPlacements(api, experimentId, contentLocale);
|
|
247
252
|
};
|
|
248
253
|
window.addEventListener('focus', focus);
|
|
249
254
|
return ()=>{
|
|
@@ -255,8 +260,19 @@ function EditorRender(props) {
|
|
|
255
260
|
admin,
|
|
256
261
|
experimentId,
|
|
257
262
|
status,
|
|
258
|
-
access.surface?.canManage
|
|
263
|
+
access.surface?.canManage,
|
|
264
|
+
contentLocale
|
|
259
265
|
]);
|
|
266
|
+
const outerLabel = usePuckSelector((state)=>{
|
|
267
|
+
const outer = nearestOuterTest(localNestedTests(state.appState.data), props.id);
|
|
268
|
+
return outer ? nestedTestLabel(outer) : false;
|
|
269
|
+
});
|
|
270
|
+
const outerId = usePuckSelector((state)=>{
|
|
271
|
+
const outer = nearestOuterTest(localNestedTests(state.appState.data), props.id);
|
|
272
|
+
const ref = outer?.props.experiment;
|
|
273
|
+
return ref?.id === undefined ? '' : String(ref.id);
|
|
274
|
+
});
|
|
275
|
+
const outerTest = useArms(outerId === '' ? undefined : outerId);
|
|
260
276
|
const blockVisibility = usePuckSelector((state)=>{
|
|
261
277
|
const visibility = localBlockVisibility(state.appState.data, props.id);
|
|
262
278
|
return visibility?.hidden ? 'hidden' : visibility?.hideOn.join(' and ') ?? '';
|
|
@@ -267,6 +283,7 @@ function EditorRender(props) {
|
|
|
267
283
|
const result = experimentId === undefined || loaded?.id !== experimentId ? undefined : loaded;
|
|
268
284
|
const shared = locallyShared || result?.shared === true;
|
|
269
285
|
const experiment = cachedExperiment ?? result?.doc;
|
|
286
|
+
const nestedNotice = outerLabel !== false ? hidden ? editorCopy.nestedHidden(outerTest?.doc?.name ?? outerLabel) : editorCopy.nested(outerTest?.doc?.name ?? outerLabel, experiment?.name ?? props.experiment?.slug) : undefined;
|
|
270
287
|
const noAccess = access.error === 'forbidden' || !!access.surface && !access.surface.canManage && !access.surface.canReadResults;
|
|
271
288
|
const resultsOnly = access.surface?.canReadResults === true && !access.surface.canManage;
|
|
272
289
|
const unavailable = result?.forbidden || result?.missing;
|
|
@@ -330,7 +347,7 @@ function EditorRender(props) {
|
|
|
330
347
|
isCurrent: isCurrentBinding,
|
|
331
348
|
onWrite: ()=>setClearError(null),
|
|
332
349
|
onSaved: ()=>{
|
|
333
|
-
invalidatePlacements(api, experimentId);
|
|
350
|
+
invalidatePlacements(api, experimentId, contentLocale);
|
|
334
351
|
}
|
|
335
352
|
});
|
|
336
353
|
// The slot arrays belong to the page; reading the test is unnecessary to edit them.
|
|
@@ -470,8 +487,8 @@ function EditorRender(props) {
|
|
|
470
487
|
const { getItemById, dispatch, getSelectorForId } = getPuck();
|
|
471
488
|
const item = getItemById(props.id), selector = getSelectorForId(props.id);
|
|
472
489
|
if (!item || !selector || String(item.props.experiment?.id) !== String(experimentId)) return false;
|
|
473
|
-
if (experimentId !== undefined) invalidatePlacements(api, experimentId);
|
|
474
|
-
if (experiment) invalidatePlacements(api, experiment.id);
|
|
490
|
+
if (experimentId !== undefined) invalidatePlacements(api, experimentId, contentLocale);
|
|
491
|
+
if (experiment) invalidatePlacements(api, experiment.id, contentLocale);
|
|
475
492
|
dispatch({
|
|
476
493
|
type: 'replace',
|
|
477
494
|
destinationIndex: selector.index,
|
|
@@ -532,7 +549,8 @@ function EditorRender(props) {
|
|
|
532
549
|
const created = await createBlockTest(api, pageTitle, await newTestArms());
|
|
533
550
|
if (bind(created)) configuration.current = openConfigureTestDrawer(source, {
|
|
534
551
|
admin,
|
|
535
|
-
api
|
|
552
|
+
api,
|
|
553
|
+
contentLocale
|
|
536
554
|
}, created.id);
|
|
537
555
|
else creation.current = openCreateExperimentDrawer(source, {
|
|
538
556
|
admin,
|
|
@@ -556,7 +574,8 @@ function EditorRender(props) {
|
|
|
556
574
|
editorPage,
|
|
557
575
|
apiRoute: api,
|
|
558
576
|
adminRoute: admin,
|
|
559
|
-
editorPlacementMessage: placementMessage
|
|
577
|
+
editorPlacementMessage: placementMessage,
|
|
578
|
+
contentLocale
|
|
560
579
|
} : undefined;
|
|
561
580
|
const quickTest = {
|
|
562
581
|
doc: experiment ? {
|
|
@@ -565,8 +584,8 @@ function EditorRender(props) {
|
|
|
565
584
|
kind: 'block'
|
|
566
585
|
} : null,
|
|
567
586
|
preflight: currentPreflight,
|
|
568
|
-
preflightRead: experimentId === undefined ? undefined : cachedReadinessRead(api, experimentId),
|
|
569
|
-
preflightError: !currentPreflight ? placementReadError(api, experimentId) ?? null : null,
|
|
587
|
+
preflightRead: experimentId === undefined ? undefined : cachedReadinessRead(api, experimentId, contentLocale),
|
|
588
|
+
preflightError: !currentPreflight ? placementReadError(api, experimentId, contentLocale) ?? null : null,
|
|
570
589
|
preflightPending: documentPending || !preflight || preflight.id !== experimentId || preflight.pending,
|
|
571
590
|
hasUnsaved: writes.busy || Object.keys(weightEdits).length > 0,
|
|
572
591
|
saving: writes.busy ? 'saving' : 'idle',
|
|
@@ -579,16 +598,16 @@ function EditorRender(props) {
|
|
|
579
598
|
choosePage: async ()=>{},
|
|
580
599
|
refreshPreflight: async (supersede)=>{
|
|
581
600
|
if (experimentId !== undefined) {
|
|
582
|
-
if (supersede) invalidatePlacements(api, experimentId);
|
|
583
|
-
await refreshPlacements(api, experimentId);
|
|
601
|
+
if (supersede) invalidatePlacements(api, experimentId, contentLocale);
|
|
602
|
+
await refreshPlacements(api, experimentId, contentLocale);
|
|
584
603
|
}
|
|
585
604
|
},
|
|
586
605
|
reload: async ()=>{
|
|
587
606
|
if (experimentId === undefined) return;
|
|
588
607
|
// A transition may succeed without a readable response body; recover its document too.
|
|
589
608
|
publishExperiment(experimentId, await readExperiment(`${api}/xp-experiments/${encodeURIComponent(experimentId)}?depth=0`));
|
|
590
|
-
invalidatePlacements(api, experimentId);
|
|
591
|
-
await refreshPlacements(api, experimentId);
|
|
609
|
+
invalidatePlacements(api, experimentId, contentLocale);
|
|
610
|
+
await refreshPlacements(api, experimentId, contentLocale);
|
|
592
611
|
},
|
|
593
612
|
acceptTransition: (result)=>{
|
|
594
613
|
const doc = result?.doc;
|
|
@@ -596,9 +615,13 @@ function EditorRender(props) {
|
|
|
596
615
|
}
|
|
597
616
|
};
|
|
598
617
|
const placementNotice = quickTest.preflightRead?.message ?? placementMessage;
|
|
599
|
-
usePlacementNotice(api, experimentId, canManage ? placementNotice : undefined);
|
|
618
|
+
usePlacementNotice(api, experimentId, canManage ? placementNotice : undefined, contentLocale);
|
|
600
619
|
const placementNoticeView = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
601
620
|
children: [
|
|
621
|
+
nestedNotice ? /*#__PURE__*/ _jsx(Banner, {
|
|
622
|
+
tone: "info",
|
|
623
|
+
children: nestedNotice
|
|
624
|
+
}) : null,
|
|
602
625
|
visibilityNotice ? /*#__PURE__*/ _jsx(Banner, {
|
|
603
626
|
tone: "info",
|
|
604
627
|
children: visibilityNotice
|
|
@@ -608,12 +631,22 @@ function EditorRender(props) {
|
|
|
608
631
|
message: placementMessage,
|
|
609
632
|
running: experiment?.status === 'running',
|
|
610
633
|
onRetry: ()=>{
|
|
611
|
-
if (experimentId !== undefined) void refreshPlacements(api, experimentId);
|
|
634
|
+
if (experimentId !== undefined) void refreshPlacements(api, experimentId, contentLocale);
|
|
612
635
|
}
|
|
613
636
|
}) : null
|
|
614
637
|
]
|
|
615
638
|
});
|
|
616
|
-
const
|
|
639
|
+
const sidebarTest = currentPreflight && editorPage && nestedNotice && !hidden ? {
|
|
640
|
+
...quickTest,
|
|
641
|
+
preflight: {
|
|
642
|
+
...currentPreflight,
|
|
643
|
+
checks: editorNestedChecks(currentPreflight.checks, editorPage, {
|
|
644
|
+
outerSlug: outerLabel || '',
|
|
645
|
+
innerSlug: props.experiment?.slug ?? ''
|
|
646
|
+
})
|
|
647
|
+
}
|
|
648
|
+
} : quickTest;
|
|
649
|
+
const sidebarBlockers = surface ? sidebarReadinessBlockers(sidebarTest, surface) : [];
|
|
617
650
|
const leftoverControls = experiment && orphanSlots.length ? /*#__PURE__*/ _jsx(LeftoverVersions, {
|
|
618
651
|
slots: orphanSlots,
|
|
619
652
|
active: slot,
|
|
@@ -673,8 +706,9 @@ function EditorRender(props) {
|
|
|
673
706
|
children: resultsOnly ? pickerCopy.resultsOnly : pickerCopy.forbidden
|
|
674
707
|
}) : /*#__PURE__*/ _jsx(Banner, {
|
|
675
708
|
tone: experiment?.status === 'running' ? 'warning' : 'info',
|
|
676
|
-
children: experimentId === undefined ? bannerFor() : experiment ? bannerFor(experiment.status, winner, originalLabel) : editorCopy.loading
|
|
709
|
+
children: experimentId === undefined ? bannerFor() : experiment ? bannerFor(experiment.status, winner, originalLabel, experiment.decision ?? null) : editorCopy.loading
|
|
677
710
|
});
|
|
711
|
+
const versionLockMessage = editable || !experiment ? undefined : canManage ? editorCopy.locked[experiment.status] ?? editorCopy.lockedGeneric : editorCopy.readOnlyVersions;
|
|
678
712
|
const removeDialog = removing?.key === bindingKey ? /*#__PURE__*/ _jsx(RemoveVersion, {
|
|
679
713
|
count: countSlotBlocks(getPuck().getItemById(props.id)?.props[removing.arm.key]),
|
|
680
714
|
shared: locallyShared ? true : result?.shared,
|
|
@@ -699,7 +733,8 @@ function EditorRender(props) {
|
|
|
699
733
|
label: editorCopy.testGroup,
|
|
700
734
|
collapsible: false,
|
|
701
735
|
children: [
|
|
702
|
-
experiment ? /*#__PURE__*/ _jsxs(
|
|
736
|
+
experiment ? /*#__PURE__*/ _jsxs("div", {
|
|
737
|
+
className: "xp-slot-test-heading",
|
|
703
738
|
children: [
|
|
704
739
|
/*#__PURE__*/ _jsx("strong", {
|
|
705
740
|
children: experiment.name
|
|
@@ -724,7 +759,8 @@ function EditorRender(props) {
|
|
|
724
759
|
id: experimentId,
|
|
725
760
|
routes: {
|
|
726
761
|
admin,
|
|
727
|
-
api
|
|
762
|
+
api,
|
|
763
|
+
contentLocale
|
|
728
764
|
}
|
|
729
765
|
}) : null,
|
|
730
766
|
canManage && experiment && surface ? /*#__PURE__*/ _jsx(QuickTestActions, {
|
|
@@ -757,26 +793,23 @@ function EditorRender(props) {
|
|
|
757
793
|
children: [
|
|
758
794
|
experiment && access.surface && !noAccess ? /*#__PURE__*/ _jsx("section", {
|
|
759
795
|
"aria-label": editorCopy.versionsGroup,
|
|
760
|
-
children: /*#__PURE__*/
|
|
796
|
+
children: /*#__PURE__*/ _jsx(FieldGroup, {
|
|
761
797
|
label: editorCopy.versionsGroup,
|
|
762
798
|
collapsible: false,
|
|
763
|
-
children:
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
children: [
|
|
778
|
-
leftoverControls,
|
|
779
|
-
editable ? /*#__PURE__*/ _jsx(AddVariant, {
|
|
799
|
+
children: /*#__PURE__*/ _jsx(VersionLock, {
|
|
800
|
+
message: versionLockMessage,
|
|
801
|
+
children: (lockId)=>/*#__PURE__*/ _jsx(_Fragment, {
|
|
802
|
+
children: /*#__PURE__*/ _jsx(VersionWeights, {
|
|
803
|
+
edits: weightEdits,
|
|
804
|
+
setEdits: setWeightEdits,
|
|
805
|
+
groupId: props.id,
|
|
806
|
+
splitIntent: splitIntent,
|
|
807
|
+
experiment: experiment,
|
|
808
|
+
writes: writes,
|
|
809
|
+
editable: editable,
|
|
810
|
+
showSplit: canManage,
|
|
811
|
+
beforeActions: leftoverControls,
|
|
812
|
+
beforeSplit: editable ? /*#__PURE__*/ _jsx(AddVariant, {
|
|
780
813
|
experiment: experiment,
|
|
781
814
|
writes: writes,
|
|
782
815
|
onSelect: (slot)=>{
|
|
@@ -785,65 +818,62 @@ function EditorRender(props) {
|
|
|
785
818
|
slot
|
|
786
819
|
});
|
|
787
820
|
}
|
|
788
|
-
}) : null
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
})
|
|
845
|
-
}, bindingKey)
|
|
846
|
-
]
|
|
821
|
+
}) : null,
|
|
822
|
+
renderRow: (arm, input)=>/*#__PURE__*/ _jsxs(VersionCard, {
|
|
823
|
+
label: arm.label,
|
|
824
|
+
active: arm.kind !== 'holdout' && slot === arm.key,
|
|
825
|
+
dragging: dragging,
|
|
826
|
+
interactive: arm.kind !== 'holdout',
|
|
827
|
+
onSelect: ()=>setActive({
|
|
828
|
+
id: experimentId,
|
|
829
|
+
slot: arm.kind === 'holdout' ? 'control' : arm.key
|
|
830
|
+
}),
|
|
831
|
+
children: [
|
|
832
|
+
/*#__PURE__*/ _jsx(VersionName, {
|
|
833
|
+
arm: arm,
|
|
834
|
+
writes: writes,
|
|
835
|
+
editable: editable
|
|
836
|
+
}, `${experimentId}-${arm.key}`),
|
|
837
|
+
input,
|
|
838
|
+
arm.kind === 'variant' || arm.kind === 'holdout' && editable ? /*#__PURE__*/ _jsxs("div", {
|
|
839
|
+
className: "xp-slot-version-actions",
|
|
840
|
+
children: [
|
|
841
|
+
arm.kind === 'variant' ? /*#__PURE__*/ _jsx(Button, {
|
|
842
|
+
size: "sm",
|
|
843
|
+
disabled: originalEmpty,
|
|
844
|
+
"aria-disabled": writes.busy || undefined,
|
|
845
|
+
onClick: ()=>{
|
|
846
|
+
if (!writes.busy) requestCopy(arm.key);
|
|
847
|
+
},
|
|
848
|
+
children: editorCopy.copy(originalLabel)
|
|
849
|
+
}) : null,
|
|
850
|
+
editable ? /*#__PURE__*/ _jsx(Button, {
|
|
851
|
+
size: "sm",
|
|
852
|
+
"aria-describedby": lockId,
|
|
853
|
+
"aria-disabled": writes.busy || undefined,
|
|
854
|
+
onClick: ()=>{
|
|
855
|
+
if (!writes.busy) setRemoving({
|
|
856
|
+
key: bindingKey,
|
|
857
|
+
arm
|
|
858
|
+
});
|
|
859
|
+
},
|
|
860
|
+
children: editorCopy.removeVersion
|
|
861
|
+
}) : null
|
|
862
|
+
]
|
|
863
|
+
}) : null,
|
|
864
|
+
arm.kind === 'holdout' ? /*#__PURE__*/ _jsx("p", {
|
|
865
|
+
className: "xp-ui-help xp-slot-version-help",
|
|
866
|
+
children: editorCopy.holdoutContent
|
|
867
|
+
}) : null,
|
|
868
|
+
arm.kind === 'variant' && originalEmpty ? /*#__PURE__*/ _jsx("p", {
|
|
869
|
+
className: "xp-ui-help xp-slot-version-help",
|
|
870
|
+
children: editorCopy.copyEmpty(originalLabel)
|
|
871
|
+
}) : null
|
|
872
|
+
]
|
|
873
|
+
})
|
|
874
|
+
}, bindingKey)
|
|
875
|
+
})
|
|
876
|
+
}, bindingKey)
|
|
847
877
|
})
|
|
848
878
|
}) : null,
|
|
849
879
|
access.surface?.canManage && experimentId !== undefined ? /*#__PURE__*/ _jsx(FieldGroup, {
|
|
@@ -1026,6 +1056,7 @@ export function createExperimentSlotEditor({ routes: inputRoutes, accent } = {})
|
|
|
1026
1056
|
}
|
|
1027
1057
|
},
|
|
1028
1058
|
defaultProps: experimentSlotDefaultProps,
|
|
1059
|
+
...experimentClipboard,
|
|
1029
1060
|
render: (props)=>/*#__PURE__*/ _jsx(PuckHostProvider, {
|
|
1030
1061
|
routes: routes,
|
|
1031
1062
|
children: /*#__PURE__*/ _jsx(EditorRender, {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ArmSlot } from '../../types/puck.js';
|
|
2
2
|
import type { EditorExperiment } from './editor.model.js';
|
|
3
|
-
import type
|
|
3
|
+
import { type ArmWrites } from './VersionBuilder.js';
|
|
4
4
|
/** Page content stays editable even when it does not belong to the selected test. */
|
|
5
5
|
export declare function LeftoverVersions({ slots, experiment, writes, canManage, countBlocks, onDelete, onSelect, active, dragging }: {
|
|
6
6
|
active: ArmSlot;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from 'react';
|
|
4
|
-
import { FieldGroup } from '@puckeditor/core';
|
|
5
4
|
import { Button } from '../../ui/Button.js';
|
|
6
5
|
import { Dialog } from '../../ui/Dialog.js';
|
|
7
6
|
import { slotLabels } from '../copy.js';
|
|
8
7
|
import { editorCopy as C } from './copy.js';
|
|
9
8
|
import { tabsFor } from './editor.model.js';
|
|
9
|
+
import { VersionCard } from './VersionBuilder.js';
|
|
10
10
|
import { addLeftoverArms } from './armWrites.js';
|
|
11
11
|
/** Page content stays editable even when it does not belong to the selected test. */ export function LeftoverVersions({ slots, experiment, writes, canManage, countBlocks, onDelete, onSelect, active, dragging }) {
|
|
12
12
|
const [deleting, setDeleting] = useState(null);
|
|
@@ -14,48 +14,45 @@ import { addLeftoverArms } from './armWrites.js';
|
|
|
14
14
|
style: 'long',
|
|
15
15
|
type: 'conjunction'
|
|
16
16
|
}).format(tabsFor(experiment).map((tab)=>tab.label));
|
|
17
|
-
const notice = (slot)=>/*#__PURE__*/
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
})
|
|
57
|
-
]
|
|
58
|
-
})
|
|
17
|
+
const notice = (slot)=>/*#__PURE__*/ _jsxs(VersionCard, {
|
|
18
|
+
label: C.outsideTest(slotLabels[slot]),
|
|
19
|
+
openLabel: slotLabels[slot],
|
|
20
|
+
active: active === slot,
|
|
21
|
+
dragging: dragging,
|
|
22
|
+
onSelect: ()=>onSelect(slot),
|
|
23
|
+
children: [
|
|
24
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
25
|
+
className: "xp-slot-version-label",
|
|
26
|
+
children: C.outsideTest(slotLabels[slot])
|
|
27
|
+
}),
|
|
28
|
+
/*#__PURE__*/ _jsx("p", {
|
|
29
|
+
className: "xp-ui-help xp-slot-version-help",
|
|
30
|
+
children: C.orphan(slotLabels[slot], versions)
|
|
31
|
+
}),
|
|
32
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
33
|
+
className: "xp-slot-version-actions",
|
|
34
|
+
children: [
|
|
35
|
+
canManage && experiment.status === 'draft' ? /*#__PURE__*/ _jsx(Button, {
|
|
36
|
+
size: "sm",
|
|
37
|
+
"aria-disabled": writes.busy || undefined,
|
|
38
|
+
onClick: async ()=>{
|
|
39
|
+
if (writes.busy) return;
|
|
40
|
+
const saved = await writes.write((arms)=>addLeftoverArms(arms, slot), {
|
|
41
|
+
draftOnly: true,
|
|
42
|
+
errorKey: `leftover:${slot}`
|
|
43
|
+
});
|
|
44
|
+
if (saved) onSelect(slot);
|
|
45
|
+
},
|
|
46
|
+
children: C.addLeftover
|
|
47
|
+
}) : null,
|
|
48
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
49
|
+
size: "sm",
|
|
50
|
+
onClick: ()=>setDeleting(slot),
|
|
51
|
+
children: C.deleteContent
|
|
52
|
+
})
|
|
53
|
+
]
|
|
54
|
+
})
|
|
55
|
+
]
|
|
59
56
|
}, slot);
|
|
60
57
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
61
58
|
children: [
|
|
@@ -2,6 +2,21 @@ import { type Dispatch, type ReactNode, type RefObject, type SetStateAction } fr
|
|
|
2
2
|
import type { Arm, ArmKey } from '../../types/contracts.js';
|
|
3
3
|
import type { ArmSlot } from '../../types/puck.js';
|
|
4
4
|
import type { EditorExperiment } from './editor.model.js';
|
|
5
|
+
/** A pointer shortcut supplements the explicit, keyboard-accessible open marker. */
|
|
6
|
+
export declare function VersionCard({ label, openLabel, active, dragging, interactive, onSelect, children }: {
|
|
7
|
+
label: string;
|
|
8
|
+
openLabel?: string;
|
|
9
|
+
active: boolean;
|
|
10
|
+
dragging: boolean;
|
|
11
|
+
interactive?: boolean;
|
|
12
|
+
onSelect: () => void;
|
|
13
|
+
children: ReactNode;
|
|
14
|
+
}): import("react").JSX.Element;
|
|
15
|
+
/** Keep unavailable controls reachable, and explain an attempted edit in place. */
|
|
16
|
+
export declare function VersionLock({ message, children }: {
|
|
17
|
+
message?: string;
|
|
18
|
+
children: (noticeId?: string) => ReactNode;
|
|
19
|
+
}): import("react").JSX.Element;
|
|
5
20
|
export declare function useArmWrites({ url, bindingKey, status, controlKeys, publish, isCurrent, onWrite, onSaved }: {
|
|
6
21
|
url: string;
|
|
7
22
|
bindingKey: string;
|
|
@@ -46,7 +61,7 @@ export declare function RemoveVersion({ arm, writes, count, shared, onRemove, on
|
|
|
46
61
|
onClose: () => void;
|
|
47
62
|
}): import("react").JSX.Element;
|
|
48
63
|
export type WeightEdits = Partial<Record<ArmKey, string>>;
|
|
49
|
-
export declare function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable, beforeSplit, renderRow }: {
|
|
64
|
+
export declare function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable, showSplit, beforeSplit, beforeActions, renderRow }: {
|
|
50
65
|
experiment: EditorExperiment;
|
|
51
66
|
writes: ArmWrites;
|
|
52
67
|
edits: WeightEdits;
|
|
@@ -54,6 +69,8 @@ export declare function VersionWeights({ experiment, writes, edits, setEdits, gr
|
|
|
54
69
|
groupId: string;
|
|
55
70
|
splitIntent: RefObject<boolean>;
|
|
56
71
|
editable?: boolean;
|
|
72
|
+
showSplit?: boolean;
|
|
57
73
|
beforeSplit?: ReactNode;
|
|
74
|
+
beforeActions?: ReactNode;
|
|
58
75
|
renderRow?: (arm: EditorExperiment['arms'][number], input: ReactNode) => ReactNode;
|
|
59
76
|
}): import("react").JSX.Element;
|