@delmaredigital/payload-experiments 0.4.0-rc.6 → 0.4.0-rc.9
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 +12 -12
- 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 +9 -5
- package/dist/admin/copy/blocks.d.ts +3 -2
- package/dist/admin/copy/blocks.js +8 -7
- package/dist/admin/surface/ResultsRoute.js +18 -11
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +131 -44
- 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 +9 -2
- package/dist/admin/surface/newTest/newTest.css +1 -1
- package/dist/admin/surface/results/ResultsHeader.js +11 -6
- package/dist/admin/surface/test/TestPage.js +3 -3
- 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/formState.js +1 -1
- 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/collections/experiments/config.js +8 -3
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +5 -4
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/appends.d.ts +13 -0
- package/dist/db/appends.js +49 -0
- package/dist/db/bulkPlacementRemoval.js +8 -4
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +1 -0
- 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 +207 -0
- package/dist/endpoints/events.js +103 -39
- package/dist/endpoints/index.js +9 -8
- package/dist/endpoints/pages.js +7 -3
- package/dist/endpoints/placementStatus.js +13 -5
- package/dist/endpoints/preflight.d.ts +1 -1
- package/dist/endpoints/preflight.js +17 -2
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +6 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/transitions.js +37 -24
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +6 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- 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/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- 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/hostHook.js +6 -2
- package/dist/hooks/pageGuard.d.ts +3 -0
- package/dist/hooks/pageGuard.js +37 -23
- package/dist/hooks/puckNestedTests.d.ts +8 -0
- package/dist/hooks/puckNestedTests.js +36 -0
- package/dist/lib/fetchAllDocs.d.ts +1 -1
- 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 +13 -6
- package/dist/onInit.js +14 -0
- package/dist/options.js +5 -0
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/ExperimentPicker.js +40 -37
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +8 -4
- package/dist/puck/editor/ConfigureTestDrawer.js +5 -2
- package/dist/puck/editor/ExperimentSlotEditor.js +313 -158
- package/dist/puck/editor/LeftoverVersions.d.ts +1 -1
- package/dist/puck/editor/LeftoverVersions.js +40 -43
- package/dist/puck/editor/QuickTestActions.d.ts +5 -2
- package/dist/puck/editor/QuickTestActions.js +16 -4
- package/dist/puck/editor/ResultsReadout.d.ts +2 -1
- package/dist/puck/editor/ResultsReadout.js +2 -1
- package/dist/puck/editor/VersionBuilder.d.ts +31 -3
- package/dist/puck/editor/VersionBuilder.js +336 -74
- package/dist/puck/editor/armWrites.js +1 -1
- package/dist/puck/editor/armsCache.js +1 -3
- package/dist/puck/editor/blockClipboard.d.ts +16 -0
- package/dist/puck/editor/blockClipboard.js +20 -0
- package/dist/puck/editor/copy.d.ts +12 -2
- package/dist/puck/editor/copy.js +13 -2
- package/dist/puck/editor/editor.chrome.css +118 -3
- package/dist/puck/editor/editor.css +131 -8
- package/dist/puck/editor/editor.model.d.ts +3 -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 +22 -12
- package/dist/puck/editor/placementsCache.js +62 -49
- package/dist/puck/editor/usePageSaveReadiness.d.ts +9 -0
- package/dist/puck/editor/usePageSaveReadiness.js +34 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
- package/dist/puck/editor/usePlacementNotice.js +6 -4
- 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/results/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.js +2 -1
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +20 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +45 -21
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +4 -7
- package/dist/server/runResults.js +52 -14
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/testSurface/PreviewLinks.js +6 -2
- package/dist/testSurface/actions/DecideDialog.d.ts +4 -1
- package/dist/testSurface/actions/DecideDialog.js +32 -14
- package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
- package/dist/testSurface/actions/MakeContentResult.js +9 -1
- package/dist/testSurface/api.d.ts +11 -8
- package/dist/testSurface/api.js +27 -11
- package/dist/testSurface/contentLocaleURL.d.ts +2 -0
- package/dist/testSurface/contentLocaleURL.js +3 -0
- package/dist/testSurface/copy/actions.d.ts +1 -0
- package/dist/testSurface/copy/actions.js +1 -0
- package/dist/testSurface/copy/common.d.ts +6 -0
- package/dist/testSurface/copy/common.js +11 -5
- package/dist/testSurface/copy/languages.d.ts +12 -0
- package/dist/testSurface/copy/languages.js +8 -0
- package/dist/testSurface/copy/metrics.d.ts +1 -0
- package/dist/testSurface/copy/metrics.js +1 -0
- package/dist/testSurface/copy/readiness.d.ts +13 -2
- package/dist/testSurface/copy/readiness.js +19 -2
- package/dist/testSurface/copy/results.d.ts +5 -2
- package/dist/testSurface/copy/results.js +5 -2
- package/dist/testSurface/copy/testPage.d.ts +40 -1
- package/dist/testSurface/copy/testPage.js +53 -1
- 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/readPreflight.d.ts +5 -0
- package/dist/testSurface/readPreflight.js +7 -0
- package/dist/testSurface/readinessRead.d.ts +3 -0
- package/dist/testSurface/readinessRead.js +4 -0
- package/dist/testSurface/results/VerdictHero.d.ts +2 -1
- package/dist/testSurface/results/VerdictHero.js +5 -1
- package/dist/testSurface/results/results.css +1 -1
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/results/results.model.js +6 -2
- package/dist/testSurface/surface/contracts.d.ts +10 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +7 -2
- package/dist/testSurface/surface/editorPlacement.js +19 -1
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +4 -3
- package/dist/testSurface/surface/pageBlock/parts.js +24 -6
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +20 -6
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +4 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.js +39 -34
- package/dist/testSurface/surface/readiness/Banner.js +23 -12
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +4 -3
- package/dist/testSurface/surface/readiness/SaveStatus.js +15 -15
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +6 -1
- package/dist/testSurface/surface/readiness/readiness.model.js +116 -12
- package/dist/testSurface/surface/readiness/useTransition.d.ts +4 -4
- package/dist/testSurface/surface/readiness/useTransition.js +12 -10
- package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -2
- package/dist/testSurface/surface/results/ReleasePages.js +5 -4
- package/dist/testSurface/surface/results/ResultsBody.d.ts +4 -2
- package/dist/testSurface/surface/results/ResultsBody.js +86 -43
- package/dist/testSurface/surface/results/useResults.d.ts +11 -7
- package/dist/testSurface/surface/results/useResults.js +3 -2
- package/dist/testSurface/surface/setting/parts.js +58 -18
- package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/DeleteTest.d.ts +19 -0
- package/dist/testSurface/surface/test/DeleteTest.js +262 -0
- package/dist/testSurface/surface/test/GoalSection.js +7 -3
- package/dist/testSurface/surface/test/LengthSection.js +3 -0
- package/dist/testSurface/surface/test/PageHoldout.js +4 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +1 -1
- package/dist/testSurface/surface/test/TargetingSection.js +77 -12
- package/dist/testSurface/surface/test/TestSurface.js +97 -15
- package/dist/testSurface/surface/test/VersionsSection.js +56 -29
- package/dist/testSurface/surface/test/fields.d.ts +29 -4
- package/dist/testSurface/surface/test/fields.js +159 -39
- package/dist/testSurface/surface/test/pageParts.js +14 -5
- package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
- package/dist/testSurface/surface/test/testPage.model.js +6 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
- package/dist/testSurface/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +23 -4
- package/dist/testSurface/surface/useTestDocument.js +425 -162
- package/dist/testSurface/useApi.d.ts +9 -6
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.js +3 -1
- package/dist/transitions/addMetric.d.ts +1 -4
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +5 -1
- package/dist/transitions/checkStart.js +130 -16
- package/dist/transitions/contentFields.js +9 -5
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +5 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +2 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +17 -12
- package/dist/transitions/nestedPlacementNames.d.ts +5 -0
- package/dist/transitions/nestedPlacementNames.js +32 -0
- package/dist/transitions/pageVersions.js +3 -1
- package/dist/transitions/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +15 -11
- package/dist/transitions/placements.d.ts +28 -1
- package/dist/transitions/placements.js +223 -60
- package/dist/transitions/preflightData.d.ts +5 -3
- package/dist/transitions/preflightData.js +126 -37
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +6 -8
- package/dist/transitions/start.js +70 -34
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/contracts.d.ts +6 -3
- package/dist/types/endpoints.d.ts +86 -9
- package/dist/types/endpoints.js +1 -1
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +2 -0
- package/dist/ui/Button.js +2 -2
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- 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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { useEffect, useId, useRef, useState } from 'react';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useId, useRef, useState } from 'react';
|
|
4
4
|
import { balanceWeight, splitEvenly, totalWeight, withSlotsFor } from '../../arms/model.js';
|
|
5
5
|
import { checkArms } from '../../collections/experiments/armInvariants.js';
|
|
6
6
|
import { issueMessage } from '../../arms/copy.js';
|
|
@@ -9,6 +9,155 @@ import { Dialog } from '../../ui/Dialog.js';
|
|
|
9
9
|
import { NumberInput, TextInput } from '../../ui/Inputs.js';
|
|
10
10
|
import { addVersionArms, ArmWriteError, removeVersionArms, renameVersionArms, setVersionTraffic, writeArms } from './armWrites.js';
|
|
11
11
|
import { editorCopy as C } from './copy.js';
|
|
12
|
+
import { SavedValueChanged, useDraftAnnouncement } from '../../testSurface/surface/test/fields.js';
|
|
13
|
+
const VersionLockContext = /*#__PURE__*/ createContext(undefined);
|
|
14
|
+
/** A pointer shortcut supplements the explicit, keyboard-accessible open marker. */ export function VersionCard({ label, openLabel = label, active, dragging, interactive = true, onSelect, children }) {
|
|
15
|
+
return /*#__PURE__*/ _jsx("div", {
|
|
16
|
+
className: "xp-slot-version-group",
|
|
17
|
+
"data-active": active,
|
|
18
|
+
role: "group",
|
|
19
|
+
"aria-label": label,
|
|
20
|
+
"aria-current": active ? 'true' : undefined,
|
|
21
|
+
onClick: (event)=>{
|
|
22
|
+
if (interactive && !dragging && event.currentTarget.ownerDocument.getSelection()?.isCollapsed !== false && !event.target.closest('button, input, label, select, textarea, a, [role="button"], [contenteditable="true"]')) onSelect();
|
|
23
|
+
},
|
|
24
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
25
|
+
className: "xp-slot-version-row",
|
|
26
|
+
children: [
|
|
27
|
+
interactive ? /*#__PURE__*/ _jsx("button", {
|
|
28
|
+
type: "button",
|
|
29
|
+
className: "xp-slot-version-open",
|
|
30
|
+
"aria-label": C.showVersion(openLabel),
|
|
31
|
+
"aria-pressed": active,
|
|
32
|
+
disabled: dragging,
|
|
33
|
+
onClick: onSelect
|
|
34
|
+
}) : /*#__PURE__*/ _jsx("span", {
|
|
35
|
+
className: "xp-slot-version-open",
|
|
36
|
+
"aria-hidden": "true",
|
|
37
|
+
style: {
|
|
38
|
+
cursor: 'default'
|
|
39
|
+
}
|
|
40
|
+
}),
|
|
41
|
+
children
|
|
42
|
+
]
|
|
43
|
+
})
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/** Keep unavailable controls reachable, and explain an attempted edit in place. */ export function VersionLock({ message, children }) {
|
|
47
|
+
const id = useId();
|
|
48
|
+
const controls = useRef(null);
|
|
49
|
+
const notice = useRef(null);
|
|
50
|
+
const timer = useRef(undefined);
|
|
51
|
+
const [attention, setAttention] = useState(false);
|
|
52
|
+
useEffect(()=>{
|
|
53
|
+
setAttention(false);
|
|
54
|
+
return ()=>{
|
|
55
|
+
clearTimeout(timer.current);
|
|
56
|
+
timer.current = undefined;
|
|
57
|
+
};
|
|
58
|
+
}, [
|
|
59
|
+
message
|
|
60
|
+
]);
|
|
61
|
+
const explain = ()=>{
|
|
62
|
+
if (timer.current !== undefined) return;
|
|
63
|
+
setAttention(true);
|
|
64
|
+
notice.current?.scrollIntoView?.({
|
|
65
|
+
block: 'nearest'
|
|
66
|
+
});
|
|
67
|
+
timer.current = setTimeout(()=>{
|
|
68
|
+
timer.current = undefined;
|
|
69
|
+
setAttention(false);
|
|
70
|
+
}, 2000);
|
|
71
|
+
};
|
|
72
|
+
useEffect(()=>{
|
|
73
|
+
const node = controls.current;
|
|
74
|
+
if (!message || !node) return;
|
|
75
|
+
const edit = (event)=>{
|
|
76
|
+
if (event.target.closest('input[aria-disabled="true"], textarea[aria-disabled="true"]')) {
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
event.stopPropagation();
|
|
79
|
+
explain();
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
node.addEventListener('beforeinput', edit, true);
|
|
83
|
+
return ()=>node.removeEventListener('beforeinput', edit, true);
|
|
84
|
+
}, [
|
|
85
|
+
message
|
|
86
|
+
]);
|
|
87
|
+
return /*#__PURE__*/ _jsx(VersionLockContext.Provider, {
|
|
88
|
+
value: message ? id : undefined,
|
|
89
|
+
children: /*#__PURE__*/ _jsxs("div", {
|
|
90
|
+
ref: controls,
|
|
91
|
+
className: "xp-slot-version-controls",
|
|
92
|
+
onPasteCapture: (event)=>{
|
|
93
|
+
if (message && event.target.closest('input[aria-disabled="true"], textarea[aria-disabled="true"]')) {
|
|
94
|
+
event.preventDefault();
|
|
95
|
+
event.stopPropagation();
|
|
96
|
+
explain();
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
onCutCapture: (event)=>{
|
|
100
|
+
if (message && event.target.closest('input[aria-disabled="true"], textarea[aria-disabled="true"]')) {
|
|
101
|
+
event.preventDefault();
|
|
102
|
+
event.stopPropagation();
|
|
103
|
+
explain();
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
onClickCapture: (event)=>{
|
|
107
|
+
if (message && event.target.closest('button[aria-disabled="true"], [role="button"][aria-disabled="true"]')) {
|
|
108
|
+
event.preventDefault();
|
|
109
|
+
event.stopPropagation();
|
|
110
|
+
explain();
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
onKeyDownCapture: (event)=>{
|
|
114
|
+
// Leave Tab, caret navigation and copying available on read-only values.
|
|
115
|
+
const control = event.target.closest('[aria-disabled="true"]');
|
|
116
|
+
const stepping = control?.matches('input[type="number"]') && [
|
|
117
|
+
'ArrowUp',
|
|
118
|
+
'ArrowDown'
|
|
119
|
+
].includes(event.key);
|
|
120
|
+
const shortcut = (event.ctrlKey || event.metaKey) && [
|
|
121
|
+
'v',
|
|
122
|
+
'x'
|
|
123
|
+
].includes(event.key.toLowerCase()) || event.shiftKey && [
|
|
124
|
+
'Insert',
|
|
125
|
+
'Delete'
|
|
126
|
+
].includes(event.key);
|
|
127
|
+
const typing = !event.ctrlKey && !event.metaKey && !event.altKey && event.key.length === 1;
|
|
128
|
+
const deletion = [
|
|
129
|
+
'Backspace',
|
|
130
|
+
'Delete'
|
|
131
|
+
].includes(event.key);
|
|
132
|
+
const activation = control?.matches('button, [role="button"]') && [
|
|
133
|
+
'Enter',
|
|
134
|
+
' '
|
|
135
|
+
].includes(event.key);
|
|
136
|
+
const input = control?.matches('input, textarea');
|
|
137
|
+
if (message && control && (input && (shortcut || typing || deletion || stepping) || activation)) {
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
event.stopPropagation();
|
|
140
|
+
explain();
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
children: [
|
|
144
|
+
message ? /*#__PURE__*/ _jsx("div", {
|
|
145
|
+
ref: notice,
|
|
146
|
+
id: id,
|
|
147
|
+
className: "xp-slot-lock-notice",
|
|
148
|
+
"data-attention": attention,
|
|
149
|
+
children: attention ? /*#__PURE__*/ _jsx("span", {
|
|
150
|
+
role: "alert",
|
|
151
|
+
children: message
|
|
152
|
+
}, "attention") : /*#__PURE__*/ _jsx("span", {
|
|
153
|
+
children: message
|
|
154
|
+
}, "rest")
|
|
155
|
+
}) : null,
|
|
156
|
+
children(message ? id : undefined)
|
|
157
|
+
]
|
|
158
|
+
})
|
|
159
|
+
});
|
|
160
|
+
}
|
|
12
161
|
export function useArmWrites({ url, bindingKey, status, controlKeys, publish, isCurrent, onWrite, onSaved }) {
|
|
13
162
|
const guard = useRef(false);
|
|
14
163
|
const running = useRef(Promise.resolve());
|
|
@@ -119,6 +268,7 @@ export function useArmWrites({ url, bindingKey, status, controlKeys, publish, is
|
|
|
119
268
|
export function AddVariant({ experiment, writes, onSelect }) {
|
|
120
269
|
if (experiment.arms.filter((arm)=>arm.kind === 'variant').length >= 3) return null;
|
|
121
270
|
return /*#__PURE__*/ _jsx(Button, {
|
|
271
|
+
size: "sm",
|
|
122
272
|
"aria-disabled": writes.busy || undefined,
|
|
123
273
|
onClick: async ()=>{
|
|
124
274
|
if (writes.busy) return;
|
|
@@ -133,20 +283,19 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
133
283
|
children: C.add
|
|
134
284
|
});
|
|
135
285
|
}
|
|
136
|
-
|
|
286
|
+
export function VersionName({ arm, writes, editable, draftState }) {
|
|
137
287
|
const id = useId();
|
|
138
|
-
const
|
|
139
|
-
const
|
|
288
|
+
const lockId = useContext(VersionLockContext);
|
|
289
|
+
const localDraft = useState(null);
|
|
290
|
+
const [edit, setEdit] = draftState ?? localDraft;
|
|
140
291
|
const pending = useRef(null);
|
|
141
292
|
const [error, setError] = useState();
|
|
142
293
|
const [invalid, setInvalid] = useState(false);
|
|
143
294
|
const [saved, setSaved] = useState(false);
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
arm.label
|
|
149
|
-
]);
|
|
295
|
+
const [announcement, announce] = useDraftAnnouncement();
|
|
296
|
+
const changed = edit !== null && edit.base !== arm.label;
|
|
297
|
+
const name = changed && edit.submitted ? arm.label : edit?.draft ?? arm.label;
|
|
298
|
+
const conflict = changed && !edit.submitted && name !== arm.label;
|
|
150
299
|
useEffect(()=>{
|
|
151
300
|
if (!saved) return;
|
|
152
301
|
const timer = setTimeout(()=>setSaved(false), 2000);
|
|
@@ -154,13 +303,33 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
154
303
|
}, [
|
|
155
304
|
saved
|
|
156
305
|
]);
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
306
|
+
const unfinished = edit !== null && !edit.submitted;
|
|
307
|
+
const choice = unfinished && (conflict || !editable);
|
|
308
|
+
const choiceId = choice ? `${id}-new-value` : undefined;
|
|
309
|
+
const discard = ()=>{
|
|
310
|
+
if (pending.current?.started) return;
|
|
311
|
+
if (pending.current) pending.current.cancelled = true;
|
|
312
|
+
setEdit(null);
|
|
313
|
+
setInvalid(false);
|
|
314
|
+
setError(undefined);
|
|
315
|
+
setSaved(false);
|
|
316
|
+
};
|
|
317
|
+
async function commit(confirmed = false) {
|
|
318
|
+
if (pending.current || !edit || edit.submitted) return;
|
|
319
|
+
if (!editable || choice && !confirmed) {
|
|
320
|
+
announce();
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
if (name === arm.label) {
|
|
324
|
+
discard();
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
if (!name.trim()) {
|
|
160
328
|
setInvalid(true);
|
|
161
329
|
return;
|
|
162
330
|
}
|
|
163
|
-
const label =
|
|
331
|
+
const label = name.trim();
|
|
332
|
+
const base = confirmed ? arm.label : edit.base;
|
|
164
333
|
const attempt = {
|
|
165
334
|
started: false,
|
|
166
335
|
cancelled: false
|
|
@@ -169,7 +338,10 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
169
338
|
setError(undefined);
|
|
170
339
|
setSaved(false);
|
|
171
340
|
try {
|
|
172
|
-
const result = await writes.write((arms)=>
|
|
341
|
+
const result = await writes.write((arms)=>{
|
|
342
|
+
if (arms.find((current)=>current.key === arm.key)?.label !== base) throw new ArmWriteError(C.nameChanged);
|
|
343
|
+
return renameVersionArms(arms, arm.key, label);
|
|
344
|
+
}, {
|
|
173
345
|
onError: setError,
|
|
174
346
|
queue: true,
|
|
175
347
|
cancelled: ()=>attempt.cancelled,
|
|
@@ -177,11 +349,18 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
177
349
|
attempt.started = true;
|
|
178
350
|
}
|
|
179
351
|
});
|
|
180
|
-
if (result)
|
|
352
|
+
if (result) {
|
|
353
|
+
setEdit(draftState ? null : {
|
|
354
|
+
...edit,
|
|
355
|
+
submitted: true
|
|
356
|
+
});
|
|
357
|
+
setSaved(true);
|
|
358
|
+
}
|
|
181
359
|
} finally{
|
|
182
360
|
pending.current = null;
|
|
183
361
|
}
|
|
184
362
|
}
|
|
363
|
+
const message = !choice ? invalid ? C.emptyLabel : error : undefined;
|
|
185
364
|
return /*#__PURE__*/ _jsxs("div", {
|
|
186
365
|
className: "xp-slot-version-name",
|
|
187
366
|
children: [
|
|
@@ -191,37 +370,54 @@ export function AddVariant({ experiment, writes, onSelect }) {
|
|
|
191
370
|
"aria-label": `${arm.label} ${C.name}`,
|
|
192
371
|
value: name,
|
|
193
372
|
readOnly: !editable || writes.busy,
|
|
194
|
-
"aria-disabled": writes.busy || undefined,
|
|
195
|
-
|
|
373
|
+
"aria-disabled": !editable || writes.busy || undefined,
|
|
374
|
+
"aria-describedby": [
|
|
375
|
+
lockId,
|
|
376
|
+
choiceId,
|
|
377
|
+
saved ? `${id}-saved` : undefined
|
|
378
|
+
].filter(Boolean).join(' ') || undefined,
|
|
379
|
+
"aria-errormessage": message ? `${id}-error` : undefined,
|
|
380
|
+
error: message,
|
|
196
381
|
onChange: (event)=>{
|
|
197
|
-
|
|
198
|
-
|
|
382
|
+
if (!editable || writes.busy) return;
|
|
383
|
+
const draft = event.target.value;
|
|
384
|
+
setEdit(draft === arm.label ? null : {
|
|
385
|
+
base: edit && !edit.submitted ? edit.base : arm.label,
|
|
386
|
+
draft,
|
|
387
|
+
submitted: false
|
|
388
|
+
});
|
|
199
389
|
setInvalid(false);
|
|
200
390
|
setError(undefined);
|
|
201
391
|
setSaved(false);
|
|
202
392
|
},
|
|
203
393
|
onBlur: ()=>void commit(),
|
|
204
394
|
onKeyDown: (event)=>{
|
|
205
|
-
if (event.key === 'Enter') {
|
|
395
|
+
if (event.key === 'Enter' && !event.nativeEvent.isComposing) {
|
|
206
396
|
event.preventDefault();
|
|
207
397
|
void commit();
|
|
208
398
|
}
|
|
209
399
|
if (event.key === 'Escape') {
|
|
210
400
|
event.preventDefault();
|
|
211
|
-
|
|
212
|
-
if (pending.current) pending.current.cancelled = true;
|
|
213
|
-
draft.current = arm.label;
|
|
214
|
-
setName(arm.label);
|
|
215
|
-
setInvalid(false);
|
|
216
|
-
setError(undefined);
|
|
217
|
-
setSaved(false);
|
|
401
|
+
discard();
|
|
218
402
|
}
|
|
219
403
|
}
|
|
220
404
|
}),
|
|
221
|
-
|
|
405
|
+
/*#__PURE__*/ _jsx("span", {
|
|
406
|
+
id: `${id}-saved`,
|
|
222
407
|
role: "status",
|
|
223
|
-
className: "xp-ui-help",
|
|
224
|
-
children: C.saved
|
|
408
|
+
className: "xp-ui-help xp-slot-version-saved",
|
|
409
|
+
children: saved ? C.saved : ''
|
|
410
|
+
}),
|
|
411
|
+
choiceId && !writes.busy ? /*#__PURE__*/ _jsx(SavedValueChanged, {
|
|
412
|
+
id: choiceId,
|
|
413
|
+
value: arm.label,
|
|
414
|
+
reason: conflict ? C.nameChanged : error,
|
|
415
|
+
conflict: conflict,
|
|
416
|
+
announce: announcement,
|
|
417
|
+
onDiscard: discard,
|
|
418
|
+
onKeep: editable && !writes.busy ? ()=>{
|
|
419
|
+
void commit(true);
|
|
420
|
+
} : undefined
|
|
225
421
|
}) : null
|
|
226
422
|
]
|
|
227
423
|
});
|
|
@@ -287,11 +483,14 @@ export function RemoveVersion({ arm, writes, count, shared, onRemove, onClose })
|
|
|
287
483
|
})
|
|
288
484
|
});
|
|
289
485
|
}
|
|
290
|
-
|
|
486
|
+
const shareBase = (arms)=>arms.map((arm)=>`${arm.key}:${arm.weight}`).join(',');
|
|
487
|
+
export function VersionWeights({ experiment, writes, edits, setEdits, groupId, splitIntent, editable = true, showSplit = editable, beforeSplit, beforeActions, renderRow }) {
|
|
291
488
|
const id = useId();
|
|
292
|
-
const
|
|
489
|
+
const lockId = useContext(VersionLockContext);
|
|
293
490
|
const [errors, setErrors] = useState({});
|
|
294
491
|
const armKeys = experiment.arms.map((arm)=>arm.key).join(',');
|
|
492
|
+
const base = shareBase(experiment.arms);
|
|
493
|
+
const [announcement, announce] = useDraftAnnouncement();
|
|
295
494
|
useEffect(()=>{
|
|
296
495
|
const keys = new Set(armKeys.split(','));
|
|
297
496
|
setErrors((current)=>Object.fromEntries(Object.entries(current).filter(([key])=>keys.has(key))));
|
|
@@ -299,18 +498,27 @@ export function VersionWeights({ experiment, writes, edits, setEdits, groupId, s
|
|
|
299
498
|
armKeys
|
|
300
499
|
]);
|
|
301
500
|
const clearErrors = (keys)=>setErrors((current)=>Object.fromEntries(Object.entries(current).filter(([key])=>!keys.includes(key))));
|
|
302
|
-
const invalidKeys = new Set(Object.entries(edits).filter(([,
|
|
303
|
-
const apply = (arms, key)=>balanceWeight(arms, key, Number(edits[key]));
|
|
501
|
+
const invalidKeys = new Set(Object.entries(edits).filter(([, edit])=>edit.value.trim() === '' || !Number.isInteger(Number(edit.value)) || Number(edit.value) < 0 || Number(edit.value) > 100).map(([key])=>key));
|
|
502
|
+
const apply = (arms, key)=>balanceWeight(arms, key, Number(edits[key]?.value));
|
|
304
503
|
const keys = Object.keys(edits);
|
|
305
504
|
const clearDraft = (key)=>setEdits((current)=>Object.fromEntries(Object.entries(current).filter(([candidate])=>candidate !== key)));
|
|
306
|
-
const live = withSlotsFor(keys.length === 1 && !invalidKeys.has(keys[0]) && !errors[keys[0]] ? apply(experiment.arms, keys[0]) : experiment.arms, 'block');
|
|
505
|
+
const live = withSlotsFor(keys.length === 1 && !invalidKeys.has(keys[0]) && !errors[keys[0]] && edits[keys[0]]?.base === base && editable ? apply(experiment.arms, keys[0]) : experiment.arms, 'block');
|
|
307
506
|
const issues = checkArms(live, 'block');
|
|
308
|
-
async function commit(key) {
|
|
309
|
-
|
|
507
|
+
async function commit(key, confirmed = false) {
|
|
508
|
+
const edit = edits[key];
|
|
509
|
+
if (writes.busy || !edit || invalidKeys.has(key)) return;
|
|
510
|
+
if (!editable || !confirmed && edit.base !== base) {
|
|
511
|
+
announce();
|
|
512
|
+
return;
|
|
513
|
+
}
|
|
310
514
|
clearErrors([
|
|
311
515
|
key
|
|
312
516
|
]);
|
|
313
|
-
const
|
|
517
|
+
const expected = confirmed ? base : edit.base;
|
|
518
|
+
const saved = await writes.write((arms)=>{
|
|
519
|
+
if (shareBase(arms) !== expected) throw new ArmWriteError(C.shareChanged);
|
|
520
|
+
return setVersionTraffic(arms, key, Number(edit.value));
|
|
521
|
+
}, {
|
|
314
522
|
onError: (message)=>setErrors((current)=>({
|
|
315
523
|
...current,
|
|
316
524
|
[key]: message
|
|
@@ -324,6 +532,11 @@ export function VersionWeights({ experiment, writes, edits, setEdits, groupId, s
|
|
|
324
532
|
/*#__PURE__*/ _jsx("div", {
|
|
325
533
|
className: "xp-slot-weight-inputs",
|
|
326
534
|
children: experiment.arms.map((arm)=>{
|
|
535
|
+
const edit = edits[arm.key];
|
|
536
|
+
const conflict = !!edit && edit.base !== base;
|
|
537
|
+
const choiceId = edit && (conflict || !editable) ? `${id}-${arm.key}-new-value` : undefined;
|
|
538
|
+
const error = !choiceId ? invalidKeys.has(arm.key) ? C.invalidShare : errors[arm.key] : undefined;
|
|
539
|
+
const errorId = error ? `${id}-${arm.key}-error` : undefined;
|
|
327
540
|
const input = /*#__PURE__*/ _jsx(NumberInput, {
|
|
328
541
|
id: `${id}-${arm.key}`,
|
|
329
542
|
label: C.traffic,
|
|
@@ -331,18 +544,29 @@ export function VersionWeights({ experiment, writes, edits, setEdits, groupId, s
|
|
|
331
544
|
min: 0,
|
|
332
545
|
max: 100,
|
|
333
546
|
step: 1,
|
|
334
|
-
value:
|
|
547
|
+
value: edit?.value ?? live.find((current)=>current.key === arm.key)?.weight ?? '',
|
|
335
548
|
readOnly: !editable || writes.busy,
|
|
336
|
-
"aria-disabled": writes.busy || undefined,
|
|
337
|
-
|
|
549
|
+
"aria-disabled": !editable || writes.busy || undefined,
|
|
550
|
+
"aria-describedby": [
|
|
551
|
+
lockId,
|
|
552
|
+
choiceId
|
|
553
|
+
].filter(Boolean).join(' ') || undefined,
|
|
554
|
+
"aria-errormessage": errorId,
|
|
555
|
+
error: error,
|
|
338
556
|
onChange: (event)=>{
|
|
557
|
+
if (!editable || writes.busy) return;
|
|
339
558
|
clearErrors([
|
|
340
559
|
arm.key
|
|
341
560
|
]);
|
|
342
561
|
const value = event.target.value;
|
|
343
|
-
|
|
562
|
+
if (!conflict && value === String(arm.weight)) clearDraft(arm.key);
|
|
563
|
+
else setEdits((current)=>({
|
|
344
564
|
...current,
|
|
345
|
-
[arm.key]:
|
|
565
|
+
[arm.key]: {
|
|
566
|
+
value,
|
|
567
|
+
base: current[arm.key]?.base ?? base,
|
|
568
|
+
label: C.weight(arm.label)
|
|
569
|
+
}
|
|
346
570
|
}));
|
|
347
571
|
},
|
|
348
572
|
onBlur: (event)=>{
|
|
@@ -363,43 +587,81 @@ export function VersionWeights({ experiment, writes, edits, setEdits, groupId, s
|
|
|
363
587
|
}
|
|
364
588
|
}
|
|
365
589
|
});
|
|
590
|
+
const notice = choiceId && !writes.busy ? /*#__PURE__*/ _jsx(SavedValueChanged, {
|
|
591
|
+
id: choiceId,
|
|
592
|
+
value: `${arm.weight}%`,
|
|
593
|
+
reason: conflict ? C.shareChanged : errors[arm.key],
|
|
594
|
+
conflict: conflict,
|
|
595
|
+
announce: announcement,
|
|
596
|
+
onDiscard: ()=>clearDraft(arm.key),
|
|
597
|
+
onKeep: editable && !invalidKeys.has(arm.key) ? ()=>{
|
|
598
|
+
void commit(arm.key, true);
|
|
599
|
+
} : undefined
|
|
600
|
+
}) : null;
|
|
366
601
|
return /*#__PURE__*/ _jsx("div", {
|
|
367
|
-
|
|
602
|
+
className: "xp-slot-version-item",
|
|
603
|
+
children: renderRow ? renderRow(arm, /*#__PURE__*/ _jsxs(_Fragment, {
|
|
604
|
+
children: [
|
|
605
|
+
/*#__PURE__*/ _jsxs("div", {
|
|
606
|
+
className: "xp-slot-version-traffic",
|
|
607
|
+
children: [
|
|
608
|
+
input,
|
|
609
|
+
/*#__PURE__*/ _jsx("span", {
|
|
610
|
+
className: "xp-slot-percent",
|
|
611
|
+
"aria-hidden": "true",
|
|
612
|
+
children: C.percent
|
|
613
|
+
})
|
|
614
|
+
]
|
|
615
|
+
}),
|
|
616
|
+
notice
|
|
617
|
+
]
|
|
618
|
+
})) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
619
|
+
children: [
|
|
620
|
+
input,
|
|
621
|
+
notice
|
|
622
|
+
]
|
|
623
|
+
})
|
|
368
624
|
}, arm.key);
|
|
369
625
|
})
|
|
370
626
|
}),
|
|
371
|
-
|
|
627
|
+
keys.length && !invalidKeys.size ? issues.map((issue, i)=>/*#__PURE__*/ _jsx("p", {
|
|
372
628
|
role: "alert",
|
|
373
629
|
className: "xp-ui-error",
|
|
374
630
|
children: issueMessage(issue, totalWeight(live))
|
|
375
631
|
}, i)) : null,
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
632
|
+
beforeActions,
|
|
633
|
+
beforeSplit || showSplit ? /*#__PURE__*/ _jsxs("div", {
|
|
634
|
+
className: "xp-slot-version-actions",
|
|
635
|
+
children: [
|
|
636
|
+
beforeSplit,
|
|
637
|
+
showSplit ? /*#__PURE__*/ _jsx("div", {
|
|
638
|
+
"data-xp-split": groupId,
|
|
639
|
+
onPointerDownCapture: ()=>{
|
|
640
|
+
// Pointer intent reaches the destination before the source iframe loses focus.
|
|
641
|
+
if (!editable) return;
|
|
642
|
+
splitIntent.current = true;
|
|
643
|
+
setTimeout(()=>{
|
|
644
|
+
splitIntent.current = false;
|
|
645
|
+
}, 0);
|
|
646
|
+
},
|
|
647
|
+
children: /*#__PURE__*/ _jsx(Button, {
|
|
648
|
+
size: "sm",
|
|
649
|
+
"aria-describedby": lockId,
|
|
650
|
+
"aria-disabled": !editable || writes.busy || undefined,
|
|
651
|
+
onClick: async ()=>{
|
|
652
|
+
if (!editable || writes.busy) return;
|
|
653
|
+
const saved = await writes.write(splitEvenly, {
|
|
654
|
+
errorKey: 'split'
|
|
655
|
+
});
|
|
656
|
+
if (saved) {
|
|
657
|
+
setEdits(()=>({}));
|
|
658
|
+
setErrors({});
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
children: C.split
|
|
662
|
+
})
|
|
663
|
+
}) : null
|
|
664
|
+
]
|
|
403
665
|
}) : null
|
|
404
666
|
]
|
|
405
667
|
});
|
|
@@ -94,7 +94,7 @@ export async function readExperiment(url, signal) {
|
|
|
94
94
|
if (!response.ok) {
|
|
95
95
|
const codes = Array.isArray(body?.errors) ? body.errors : [];
|
|
96
96
|
const stale = response.status === 409 && codes.some((error)=>error?.code === 'stale-edit');
|
|
97
|
-
if (
|
|
97
|
+
if (response.status === 409 || response.status === 403) {
|
|
98
98
|
try {
|
|
99
99
|
publish(await readExperiment(`${url}?depth=0`));
|
|
100
100
|
} catch {}
|
|
@@ -33,11 +33,9 @@ const mounted = new Map();
|
|
|
33
33
|
const revision = revisions.get(key) ?? 0;
|
|
34
34
|
entry.promise = load(controller.signal).then((doc)=>{
|
|
35
35
|
if ((revisions.get(key) ?? 0) !== revision) return cache.get(key)?.doc ?? doc;
|
|
36
|
-
|
|
37
|
-
return doc;
|
|
36
|
+
return controller.signal.aborted ? doc : publishExperiment(testId, doc);
|
|
38
37
|
}, (error)=>{
|
|
39
38
|
if ((revisions.get(key) ?? 0) !== revision && cache.get(key)?.doc) return cache.get(key).doc;
|
|
40
|
-
if (!controller.signal.aborted && (revisions.get(key) ?? 0) === revision) setArms(testId, undefined);
|
|
41
39
|
throw error;
|
|
42
40
|
}).finally(()=>{
|
|
43
41
|
if (pending.get(key) === entry) pending.delete(key);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ComponentData } from '@puckeditor/core';
|
|
2
|
+
type PasteArgs = {
|
|
3
|
+
block: ComponentData;
|
|
4
|
+
destination: {
|
|
5
|
+
ancestors: readonly {
|
|
6
|
+
type: string;
|
|
7
|
+
}[];
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function canPasteExperiment({ block, destination }: PasteArgs): true | string;
|
|
11
|
+
export declare const experimentClipboard: {
|
|
12
|
+
blockClipboard: {
|
|
13
|
+
canPaste: typeof canPasteExperiment;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
export {};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { nestedTests } from '../nestedTests.js';
|
|
2
|
+
import { editorCopy } from './copy.js';
|
|
3
|
+
export function canPasteExperiment({ block, destination }) {
|
|
4
|
+
const ancestors = destination.ancestors.map((ancestor)=>({
|
|
5
|
+
type: ancestor.type,
|
|
6
|
+
props: {}
|
|
7
|
+
}));
|
|
8
|
+
if (nestedTests(block, {
|
|
9
|
+
includeHidden: true,
|
|
10
|
+
ancestors
|
|
11
|
+
}).length) return editorCopy.nestedPaste;
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
// Spread into the component config so older Puck typings and hosts accept the
|
|
15
|
+
// extra key. payload-puck 0.12.1 invokes it; 0.12.0 simply ignores it.
|
|
16
|
+
export const experimentClipboard = {
|
|
17
|
+
blockClipboard: {
|
|
18
|
+
canPaste: canPasteExperiment
|
|
19
|
+
}
|
|
20
|
+
};
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export declare const editorCopy: {
|
|
2
|
+
readonly nested: (outer?: string, inner?: string) => string;
|
|
3
|
+
readonly nestedHidden: (outer?: string) => string;
|
|
4
|
+
readonly nestedPaste: "A test can't go inside another test's version.";
|
|
2
5
|
readonly hidden: "This block is hidden, so visitors won't see this test here.";
|
|
3
6
|
readonly hiddenOn: (sizes: string) => string;
|
|
4
7
|
readonly retrySetup: "Retry";
|
|
@@ -21,7 +24,8 @@ export declare const editorCopy: {
|
|
|
21
24
|
readonly draft: (label: string) => string;
|
|
22
25
|
readonly running: "Changing this content mid-test mixes two versions in one result";
|
|
23
26
|
readonly decided: (winner: string) => string;
|
|
24
|
-
readonly archived:
|
|
27
|
+
readonly archived: (winner: string) => string;
|
|
28
|
+
readonly archivedOriginal: (original: string, discarded: boolean) => string;
|
|
25
29
|
readonly copy: (label?: string) => string;
|
|
26
30
|
readonly copyEmpty: (label?: string) => string;
|
|
27
31
|
readonly enterName: "Enter a name to create the test.";
|
|
@@ -50,6 +54,7 @@ export declare const editorCopy: {
|
|
|
50
54
|
readonly deleteContentHelp: (label: string, count: number) => string;
|
|
51
55
|
readonly draftOnly: "Only draft tests can add this version. Use a different test to include it.";
|
|
52
56
|
readonly outsideTest: (label: string) => string;
|
|
57
|
+
readonly showVersion: (label: string) => string;
|
|
53
58
|
readonly tabs: "Test versions";
|
|
54
59
|
readonly add: "Add variant";
|
|
55
60
|
readonly testGroup: "Test";
|
|
@@ -59,6 +64,7 @@ export declare const editorCopy: {
|
|
|
59
64
|
readonly createAnother: "Create a test";
|
|
60
65
|
readonly readOnlyVersions: "You don't have permission to change this test's versions.";
|
|
61
66
|
readonly traffic: "Traffic (%)";
|
|
67
|
+
readonly percent: "%";
|
|
62
68
|
readonly saved: "Saved";
|
|
63
69
|
readonly removeVersion: "Remove version";
|
|
64
70
|
readonly emptyLabel: "Enter a name for this version.";
|
|
@@ -70,6 +76,7 @@ export declare const editorCopy: {
|
|
|
70
76
|
readonly removed: "Save the page to finish removing this version's content.";
|
|
71
77
|
readonly removeUncleared: "The version was removed from the test, but its content couldn't be cleared here. Delete it from the outline, then save the page.";
|
|
72
78
|
readonly lockedGeneric: "This test's versions can't change. View the test page for details.";
|
|
79
|
+
readonly holdoutContent: "Holdout visitors see the Original.";
|
|
73
80
|
readonly holdoutPeople: (label: string, count: string) => string;
|
|
74
81
|
readonly weight: (label: string) => string;
|
|
75
82
|
readonly invalidShare: "Use a whole number from 0 to 100.";
|
|
@@ -79,7 +86,10 @@ export declare const editorCopy: {
|
|
|
79
86
|
readonly decided: "This test has a decision, so its versions can't change. View the results on the test page.";
|
|
80
87
|
readonly archived: "This test is archived, so its versions can't change. View the results on the test page.";
|
|
81
88
|
};
|
|
82
|
-
readonly staleEdit: "
|
|
89
|
+
readonly staleEdit: "This test changed. Check the saved settings and try again.";
|
|
90
|
+
readonly nameChanged: "This version name changed while you were editing.";
|
|
91
|
+
readonly versionName: (label: string) => string;
|
|
92
|
+
readonly shareChanged: "The saved shares changed while you were editing.";
|
|
83
93
|
readonly writeError: "Couldn't complete this change. Try again.";
|
|
84
94
|
readonly writeNetwork: "Couldn't reach the server. Check your connection and try again.";
|
|
85
95
|
readonly writeUnreadable: "Couldn't read the server's response. Reload and try again.";
|