@delmaredigital/payload-experiments 0.4.0-rc.4 → 0.4.0-rc.5
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/surface/ResultsRoute.js +2 -10
- package/dist/admin/surface/newTest/PageWizard.js +10 -12
- package/dist/admin/surface/results/ResultsHeader.js +15 -8
- package/dist/goals/fairness.d.ts +1 -1
- package/dist/goals/fairness.js +1 -1
- package/dist/puck/editor/ConfigureTestDrawer.js +2 -2
- package/dist/puck/editor/CreateExperimentDrawer.js +4 -0
- package/dist/puck/editor/EditorControls.d.ts +1 -1
- package/dist/puck/editor/EditorControls.js +1 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +425 -80
- package/dist/puck/editor/LeftoverVersions.d.ts +13 -0
- package/dist/puck/editor/LeftoverVersions.js +115 -0
- package/dist/puck/editor/PlacementNotice.d.ts +8 -0
- package/dist/puck/editor/PlacementNotice.js +22 -0
- package/dist/puck/editor/QuickTestActions.d.ts +3 -0
- package/dist/puck/editor/QuickTestActions.js +50 -0
- package/dist/puck/editor/ResultsReadout.js +5 -0
- package/dist/puck/editor/VersionBuilder.d.ts +20 -6
- package/dist/puck/editor/VersionBuilder.js +78 -48
- package/dist/puck/editor/armWrites.d.ts +3 -1
- package/dist/puck/editor/armWrites.js +2 -1
- package/dist/puck/editor/cloneSlot.d.ts +2 -0
- package/dist/puck/editor/cloneSlot.js +7 -0
- package/dist/puck/editor/copy.d.ts +24 -3
- package/dist/puck/editor/copy.js +24 -3
- package/dist/puck/editor/editor.chrome.css +11 -0
- package/dist/puck/editor/editor.css +29 -0
- package/dist/puck/editor/experimentOutlinePlugin.js +96 -28
- package/dist/puck/editor/outlineVersion.d.ts +5 -0
- package/dist/puck/editor/outlineVersion.js +36 -0
- package/dist/puck/editor/placementsCache.d.ts +33 -2
- package/dist/puck/editor/placementsCache.js +208 -33
- package/dist/puck/editor/sidebar.d.ts +12 -0
- package/dist/puck/editor/sidebar.js +77 -0
- package/dist/puck/editor/usePlacementNotice.d.ts +3 -0
- package/dist/puck/editor/usePlacementNotice.js +14 -0
- package/dist/testSurface/api.js +1 -1
- package/dist/testSurface/copy/common.d.ts +1 -1
- package/dist/testSurface/copy/common.js +3 -1
- package/dist/testSurface/copy/readiness.d.ts +17 -1
- package/dist/testSurface/copy/readiness.js +22 -1
- package/dist/testSurface/copy/testPage.d.ts +1 -0
- package/dist/testSurface/copy/testPage.js +1 -0
- package/dist/testSurface/readPreflight.d.ts +9 -0
- package/dist/testSurface/readPreflight.js +38 -0
- package/dist/testSurface/readinessRead.d.ts +50 -0
- package/dist/testSurface/readinessRead.js +46 -0
- package/dist/testSurface/surface/contracts.d.ts +6 -2
- package/dist/testSurface/surface/editorPlacement.d.ts +21 -0
- package/dist/testSurface/surface/editorPlacement.js +60 -0
- package/dist/testSurface/surface/pageBlock/parts.js +13 -3
- package/dist/testSurface/surface/readiness/ActionDialogs.js +37 -7
- package/dist/testSurface/surface/readiness/Banner.d.ts +1 -4
- package/dist/testSurface/surface/readiness/Banner.js +106 -68
- package/dist/testSurface/surface/readiness/BlockerList.d.ts +11 -0
- package/dist/testSurface/surface/readiness/BlockerList.js +31 -0
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +6 -2
- package/dist/testSurface/surface/readiness/SaveStatus.js +35 -22
- package/dist/testSurface/surface/readiness/parts.js +0 -2
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +13 -0
- package/dist/testSurface/surface/readiness/readiness.model.js +51 -36
- package/dist/testSurface/surface/readiness/useTransition.d.ts +5 -2
- package/dist/testSurface/surface/readiness/useTransition.js +69 -7
- package/dist/testSurface/surface/test/AdvancedSection.js +1 -0
- package/dist/testSurface/surface/test/GoalSection.js +1 -0
- package/dist/testSurface/surface/test/LengthSection.d.ts +1 -1
- package/dist/testSurface/surface/test/LengthSection.js +2 -1
- package/dist/testSurface/surface/test/Rail.js +7 -4
- package/dist/testSurface/surface/test/ReadinessBar.js +1 -2
- package/dist/testSurface/surface/test/Section.d.ts +3 -1
- package/dist/testSurface/surface/test/Section.js +38 -6
- package/dist/testSurface/surface/test/TargetingSection.js +5 -0
- package/dist/testSurface/surface/test/TestSurface.d.ts +2 -1
- package/dist/testSurface/surface/test/TestSurface.js +68 -7
- package/dist/testSurface/surface/test/VersionsSection.js +1 -0
- package/dist/testSurface/surface/test/testPage.css +12 -0
- package/dist/testSurface/surface/useTestDocument.d.ts +5 -2
- package/dist/testSurface/surface/useTestDocument.js +61 -46
- package/dist/testSurface/useReadinessPolling.d.ts +3 -0
- package/dist/testSurface/useReadinessPolling.js +24 -0
- package/dist/transitions/preflightData.js +1 -1
- package/dist/ui/Card.d.ts +2 -1
- package/dist/ui/Card.js +4 -4
- package/dist/ui/Tabs.d.ts +2 -1
- package/dist/ui/Tabs.js +19 -6
- package/dist/ui/ui.css +18 -0
- package/package.json +1 -1
|
@@ -1,30 +1,44 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { createPortal } from 'react-dom';
|
|
3
4
|
import { createUsePuck, useGetPuck } from '@puckeditor/core';
|
|
4
5
|
import { useEffect, useRef, useState } from 'react';
|
|
6
|
+
import { defaultArms } from '../../arms/model.js';
|
|
7
|
+
import { readExperiment } from './armWrites.js';
|
|
8
|
+
import { publishOutlineVersion } from './outlineVersion.js';
|
|
9
|
+
import { LeftoverVersions } from './LeftoverVersions.js';
|
|
5
10
|
import { Button } from '../../ui/Button.js';
|
|
6
11
|
import { StatusChip } from '../../ui/StatusChip.js';
|
|
7
12
|
import { Banner } from '../../ui/Banner.js';
|
|
8
13
|
import { Tabs } from '../../ui/Tabs.js';
|
|
9
14
|
import { Dialog } from '../../ui/Dialog.js';
|
|
10
15
|
import { accentVariables, deriveAccent, validateAccent } from '../../ui/accent.js';
|
|
11
|
-
import {
|
|
16
|
+
import { ExperimentPicker } from '../ExperimentPicker.js';
|
|
17
|
+
import { TestSidebarField, useSidebarTargets } from './sidebar.js';
|
|
18
|
+
import { readPreflight } from '../../testSurface/readPreflight.js';
|
|
19
|
+
import { classifyReadinessRead } from '../../testSurface/readinessRead.js';
|
|
20
|
+
import { useReadinessPolling } from '../../testSurface/useReadinessPolling.js';
|
|
21
|
+
import { PlacementNotice } from './PlacementNotice.js';
|
|
22
|
+
import { QuickTestActions } from './QuickTestActions.js';
|
|
23
|
+
import { BlockerList } from '../../testSurface/surface/readiness/BlockerList.js';
|
|
12
24
|
import { resolvePuckRoutes } from '../routes.js';
|
|
13
25
|
import { PuckHostProvider, usePuckRoutes } from '../hostContext.js';
|
|
14
26
|
import { pickerCopy, slotLabels } from '../copy.js';
|
|
15
27
|
import { experimentSlotDefaultProps, experimentSlotFields, experimentSlotLabel } from '../slotConfig.js';
|
|
16
28
|
import { armsFromBlock, bannerFor, currentPuckDocument, isSharedTest, tabsFor } from './editor.model.js';
|
|
17
|
-
import { cloneSlot } from './cloneSlot.js';
|
|
29
|
+
import { cloneSlot, countSlotBlocks } from './cloneSlot.js';
|
|
18
30
|
import { openCreateExperimentDrawer } from './CreateExperimentDrawer.js';
|
|
19
31
|
import { editorCopy } from './copy.js';
|
|
20
32
|
import { acquireArms, loadArms, publishExperiment, useArms } from './armsCache.js';
|
|
21
33
|
import { AddVariant, RemoveVersion, VersionActions, VersionWeights, useArmWrites } from './VersionBuilder.js';
|
|
22
34
|
import { ResultsReadout } from './ResultsReadout.js';
|
|
23
35
|
import { EditorControls } from './EditorControls.js';
|
|
24
|
-
import { acquirePlacements, invalidatePlacements, refreshPlacements } from './placementsCache.js';
|
|
36
|
+
import { acquirePlacements, subscribePlacements, cachedPreflight, cachedReadinessRead, placementsPending, placementsBlocking, placementReadError, invalidatePlacements, refreshPlacements, focusPlacements } from './placementsCache.js';
|
|
37
|
+
import { sidebarReadinessBlockers, editorPlacementMessage } from '../../testSurface/surface/editorPlacement.js';
|
|
25
38
|
import { localPlacements } from './localPlacements.js';
|
|
39
|
+
import { usePlacementNotice } from './usePlacementNotice.js';
|
|
26
40
|
import { useEditorSurface } from './editorSurface.js';
|
|
27
|
-
import {
|
|
41
|
+
import { ConfigureTestControl } from './ConfigureTestDrawer.js';
|
|
28
42
|
import './editor.css';
|
|
29
43
|
const usePuckSelector = createUsePuck();
|
|
30
44
|
class TestReadError extends Error {
|
|
@@ -44,9 +58,11 @@ function isExperiment(value) {
|
|
|
44
58
|
}
|
|
45
59
|
function EditorRender(props) {
|
|
46
60
|
const getPuck = useGetPuck();
|
|
61
|
+
const sidebar = useSidebarTargets(props.id);
|
|
47
62
|
const { admin, api } = usePuckRoutes();
|
|
48
63
|
const access = useEditorSurface(api);
|
|
49
64
|
const root = useRef(null);
|
|
65
|
+
const [readAttempt, setReadAttempt] = useState(0);
|
|
50
66
|
const [mode, setMode] = useState('light');
|
|
51
67
|
useEffect(()=>{
|
|
52
68
|
const node = root.current;
|
|
@@ -86,7 +102,19 @@ function EditorRender(props) {
|
|
|
86
102
|
}, []);
|
|
87
103
|
const isCurrentBinding = ()=>binding.current.live && binding.current.key === bindingKey;
|
|
88
104
|
const knownArms = useArms(experimentId);
|
|
105
|
+
const [preflight, setPreflight] = useState();
|
|
106
|
+
const [placements, setPlacements] = useState();
|
|
89
107
|
const [loaded, setLoaded] = useState();
|
|
108
|
+
const [documentPending, setDocumentPending] = useState(false);
|
|
109
|
+
const documentFailures = useRef({
|
|
110
|
+
key: bindingKey,
|
|
111
|
+
failures: 0
|
|
112
|
+
});
|
|
113
|
+
if (documentFailures.current.key !== bindingKey) documentFailures.current = {
|
|
114
|
+
key: bindingKey,
|
|
115
|
+
failures: 0
|
|
116
|
+
};
|
|
117
|
+
useReadinessPolling(loaded?.id === experimentId ? loaded?.read : undefined, ()=>setReadAttempt((value)=>value + 1), true, documentPending);
|
|
90
118
|
const [active, setActive] = useState();
|
|
91
119
|
const [openMenu, setOpenMenu] = useState(null);
|
|
92
120
|
const [clearError, setClearError] = useState(null);
|
|
@@ -99,11 +127,13 @@ function EditorRender(props) {
|
|
|
99
127
|
const [removing, setRemoving] = useState(null);
|
|
100
128
|
const pageTitle = usePuckSelector((state)=>typeof state.appState.data.root.props?.title === 'string' ? state.appState.data.root.props.title : '');
|
|
101
129
|
// Selection only changes the chrome's appearance; actions always resolve this block by id.
|
|
130
|
+
const dragging = usePuckSelector((state)=>state.appState.ui?.isDragging ?? false);
|
|
102
131
|
const isSelected = usePuckSelector((state)=>state.selectedItem?.props.id === props.id);
|
|
103
132
|
const originalEmpty = usePuckSelector((state)=>{
|
|
104
133
|
const content = state.getItemById(props.id)?.props.control;
|
|
105
134
|
return !Array.isArray(content) || content.length === 0;
|
|
106
135
|
});
|
|
136
|
+
const testVersions = (knownArms?.arms.length ? knownArms.arms : undefined) ?? (loaded?.id === experimentId ? loaded?.doc?.arms.map((arm)=>arm.key) : undefined);
|
|
107
137
|
const orphanSlots = usePuckSelector((state)=>{
|
|
108
138
|
const item = state.getItemById(props.id);
|
|
109
139
|
return [
|
|
@@ -112,7 +142,7 @@ function EditorRender(props) {
|
|
|
112
142
|
'variantC'
|
|
113
143
|
].filter((slot)=>{
|
|
114
144
|
const content = item?.props[slot];
|
|
115
|
-
return
|
|
145
|
+
return testVersions && !testVersions.includes(slot) && Array.isArray(content) && content.length > 0;
|
|
116
146
|
}).join(',');
|
|
117
147
|
}).split(',').filter(Boolean);
|
|
118
148
|
useEffect(()=>{
|
|
@@ -123,18 +153,20 @@ function EditorRender(props) {
|
|
|
123
153
|
const releaseArms = acquireArms(experimentId);
|
|
124
154
|
async function load() {
|
|
125
155
|
const revision = ++request;
|
|
156
|
+
setDocumentPending(true);
|
|
126
157
|
try {
|
|
127
158
|
const doc = await loadArms(experimentId, async (signal)=>{
|
|
128
|
-
const response = await fetch(`${api}/xp-experiments/${encodeURIComponent(experimentId)}?depth=0`, {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
159
|
+
const { response, body } = await readPreflight((boundedSignal)=>fetch(`${api}/xp-experiments/${encodeURIComponent(experimentId)}?depth=0`, {
|
|
160
|
+
credentials: 'include',
|
|
161
|
+
signal: boundedSignal
|
|
162
|
+
}), signal);
|
|
132
163
|
if (!response.ok) throw new TestReadError(response.status);
|
|
133
|
-
const doc =
|
|
164
|
+
const doc = body;
|
|
134
165
|
if (!isExperiment(doc)) throw new Error('document');
|
|
135
166
|
return doc;
|
|
136
167
|
}, controller.signal);
|
|
137
168
|
if (current && revision === request) {
|
|
169
|
+
documentFailures.current.failures = 0;
|
|
138
170
|
setLoaded((value)=>({
|
|
139
171
|
id: experimentId,
|
|
140
172
|
doc,
|
|
@@ -143,16 +175,23 @@ function EditorRender(props) {
|
|
|
143
175
|
}
|
|
144
176
|
} catch (cause) {
|
|
145
177
|
if (current && revision === request) {
|
|
146
|
-
const
|
|
147
|
-
|
|
178
|
+
const read = classifyReadinessRead(cause instanceof TestReadError ? cause.status : 0, undefined, ++documentFailures.current.failures, {
|
|
179
|
+
kind: 'document',
|
|
180
|
+
surface: 'editor'
|
|
181
|
+
});
|
|
182
|
+
const forbidden = read.loadState === 'forbidden';
|
|
183
|
+
const missing = read.loadState === 'missing';
|
|
148
184
|
setLoaded((value)=>({
|
|
149
185
|
id: experimentId,
|
|
186
|
+
read,
|
|
150
187
|
forbidden,
|
|
151
188
|
missing,
|
|
152
189
|
error: !forbidden && !missing,
|
|
153
190
|
shared: value?.id === experimentId ? value?.shared : undefined
|
|
154
191
|
}));
|
|
155
192
|
}
|
|
193
|
+
} finally{
|
|
194
|
+
if (current && revision === request) setDocumentPending(false);
|
|
156
195
|
}
|
|
157
196
|
}
|
|
158
197
|
void load();
|
|
@@ -169,25 +208,46 @@ function EditorRender(props) {
|
|
|
169
208
|
};
|
|
170
209
|
}, [
|
|
171
210
|
experimentId,
|
|
172
|
-
api
|
|
211
|
+
api,
|
|
212
|
+
readAttempt
|
|
173
213
|
]);
|
|
174
214
|
const cachedExperiment = loaded?.id === experimentId && !loaded?.forbidden && !loaded?.missing ? knownArms?.doc : undefined;
|
|
175
215
|
const status = cachedExperiment?.status ?? (loaded?.id === experimentId ? loaded?.doc?.status : undefined);
|
|
176
216
|
useEffect(()=>{
|
|
177
|
-
if (experimentId === undefined || !status) return;
|
|
178
|
-
|
|
217
|
+
if (experimentId === undefined || !status || !access.surface?.canManage) return;
|
|
218
|
+
const release = acquirePlacements(api, experimentId, (placements)=>{
|
|
219
|
+
// Retain guidance only while revalidating; failures must show their own message.
|
|
220
|
+
setPlacements((current)=>placements === undefined && placementsPending(api, experimentId) && current?.id === experimentId ? current : {
|
|
221
|
+
id: experimentId,
|
|
222
|
+
value: placements
|
|
223
|
+
});
|
|
224
|
+
setPreflight({
|
|
225
|
+
id: experimentId,
|
|
226
|
+
value: cachedPreflight(api, experimentId),
|
|
227
|
+
pending: placementsPending(api, experimentId),
|
|
228
|
+
blocking: placementsBlocking(api, experimentId)
|
|
229
|
+
});
|
|
179
230
|
const shared = placements === undefined ? undefined : isSharedTest(placements, currentPuckDocument(window.location.pathname, admin, placements));
|
|
180
231
|
setLoaded((value)=>({
|
|
181
232
|
...value?.id === experimentId ? value : {},
|
|
182
233
|
id: experimentId,
|
|
183
|
-
shared
|
|
234
|
+
shared: shared ?? (value?.id === experimentId ? value.shared : undefined)
|
|
184
235
|
}));
|
|
185
|
-
}
|
|
236
|
+
});
|
|
237
|
+
const focus = ()=>{
|
|
238
|
+
void focusPlacements(api, experimentId);
|
|
239
|
+
};
|
|
240
|
+
window.addEventListener('focus', focus);
|
|
241
|
+
return ()=>{
|
|
242
|
+
release();
|
|
243
|
+
window.removeEventListener('focus', focus);
|
|
244
|
+
};
|
|
186
245
|
}, [
|
|
187
246
|
api,
|
|
188
247
|
admin,
|
|
189
248
|
experimentId,
|
|
190
|
-
status
|
|
249
|
+
status,
|
|
250
|
+
access.surface?.canManage
|
|
191
251
|
]);
|
|
192
252
|
const locallyShared = usePuckSelector((state)=>experimentId !== undefined && (localPlacements(state.appState.data, state.config).get(String(experimentId))?.size ?? 0) > 1);
|
|
193
253
|
const result = experimentId === undefined || loaded?.id !== experimentId ? undefined : loaded;
|
|
@@ -206,6 +266,15 @@ function EditorRender(props) {
|
|
|
206
266
|
removed,
|
|
207
267
|
bindingKey
|
|
208
268
|
]);
|
|
269
|
+
const splitIntent = useRef(false);
|
|
270
|
+
const [weightEdits, setWeightEdits] = useState({});
|
|
271
|
+
useEffect(()=>{
|
|
272
|
+
setWeightEdits({});
|
|
273
|
+
splitIntent.current = false;
|
|
274
|
+
}, [
|
|
275
|
+
bindingKey,
|
|
276
|
+
status
|
|
277
|
+
]);
|
|
209
278
|
const writes = useArmWrites(`${api}/xp-experiments/${encodeURIComponent(String(experimentId))}`, (doc)=>{
|
|
210
279
|
publishExperiment(experimentId, doc);
|
|
211
280
|
if (isCurrentBinding()) setLoaded((value)=>({
|
|
@@ -213,7 +282,10 @@ function EditorRender(props) {
|
|
|
213
282
|
doc,
|
|
214
283
|
shared: value?.id === experimentId ? value?.shared : undefined
|
|
215
284
|
}));
|
|
216
|
-
}, isCurrentBinding, ()=>setClearError(null))
|
|
285
|
+
}, isCurrentBinding, ()=>setClearError(null), ()=>{
|
|
286
|
+
if (isCurrentBinding()) setWeightEdits({});
|
|
287
|
+
invalidatePlacements(api, experimentId);
|
|
288
|
+
});
|
|
217
289
|
// The slot arrays belong to the page; reading the test is unnecessary to edit them.
|
|
218
290
|
const pageSlots = usePuckSelector((state)=>[
|
|
219
291
|
'control',
|
|
@@ -234,18 +306,32 @@ function EditorRender(props) {
|
|
|
234
306
|
slots: new Set()
|
|
235
307
|
};
|
|
236
308
|
for (const slot of pageSlots.split(','))observedSlots.current.slots.add(slot);
|
|
237
|
-
const tabs = unavailable ? [
|
|
309
|
+
const tabs = unavailable || !experiment ? [
|
|
238
310
|
...observedSlots.current.slots
|
|
239
311
|
].sort((a, b)=>a.localeCompare(b)).map((slot)=>({
|
|
240
312
|
slot: slot,
|
|
241
313
|
label: slotLabels[slot]
|
|
242
|
-
})) :
|
|
314
|
+
})) : [
|
|
315
|
+
...tabsFor(experiment),
|
|
316
|
+
...orphanSlots.map((slot)=>({
|
|
317
|
+
slot,
|
|
318
|
+
label: editorCopy.outsideTest(slotLabels[slot])
|
|
319
|
+
}))
|
|
320
|
+
];
|
|
243
321
|
const activeSlot = active && active.id === experimentId ? active.slot : undefined;
|
|
244
322
|
const slot = tabs.find((tab)=>tab.slot === activeSlot)?.slot ?? tabs[0]?.slot ?? 'control';
|
|
245
323
|
const slotEmpty = usePuckSelector((state)=>{
|
|
246
324
|
const content = state.getItemById(props.id)?.props[slot];
|
|
247
325
|
return !Array.isArray(content) || content.length === 0;
|
|
248
326
|
});
|
|
327
|
+
useEffect(()=>{
|
|
328
|
+
publishOutlineVersion(getPuck, props.id, slot);
|
|
329
|
+
return ()=>publishOutlineVersion(getPuck, props.id);
|
|
330
|
+
}, [
|
|
331
|
+
getPuck,
|
|
332
|
+
props.id,
|
|
333
|
+
slot
|
|
334
|
+
]);
|
|
249
335
|
const Slot = props[slot];
|
|
250
336
|
const winnerKey = experiment?.decision?.winnerArm;
|
|
251
337
|
const winner = tabs.find((tab)=>tab.slot === winnerKey)?.label;
|
|
@@ -297,6 +383,18 @@ function EditorRender(props) {
|
|
|
297
383
|
return;
|
|
298
384
|
}
|
|
299
385
|
setClearError(null);
|
|
386
|
+
if (countSlotBlocks(item.props[slot]) === 0) {
|
|
387
|
+
setRemoved((current)=>({
|
|
388
|
+
key: bindingKey,
|
|
389
|
+
revision: (current?.revision ?? 0) + 1,
|
|
390
|
+
contentRemoved: false
|
|
391
|
+
}));
|
|
392
|
+
setActive({
|
|
393
|
+
id: experimentId,
|
|
394
|
+
slot: 'control'
|
|
395
|
+
});
|
|
396
|
+
return;
|
|
397
|
+
}
|
|
300
398
|
dispatch({
|
|
301
399
|
type: 'replace',
|
|
302
400
|
destinationIndex: selector.index,
|
|
@@ -311,7 +409,8 @@ function EditorRender(props) {
|
|
|
311
409
|
});
|
|
312
410
|
setRemoved((current)=>({
|
|
313
411
|
key: bindingKey,
|
|
314
|
-
revision: (current?.revision ?? 0) + 1
|
|
412
|
+
revision: (current?.revision ?? 0) + 1,
|
|
413
|
+
contentRemoved: true
|
|
315
414
|
}));
|
|
316
415
|
setActive({
|
|
317
416
|
id: experimentId,
|
|
@@ -341,6 +440,11 @@ function EditorRender(props) {
|
|
|
341
440
|
}
|
|
342
441
|
async function newTestArms() {
|
|
343
442
|
if (!isCurrentBinding()) throw new Error('binding');
|
|
443
|
+
const item = getPuck().getItemById(props.id);
|
|
444
|
+
if (!item) throw new Error('binding');
|
|
445
|
+
if (experimentId === undefined) return armsFromBlock({
|
|
446
|
+
arms: defaultArms('block')
|
|
447
|
+
}, item.props);
|
|
344
448
|
// Another placement can rename or add a version while this dialog is open.
|
|
345
449
|
const response = await fetch(`${api}/xp-experiments/${encodeURIComponent(String(experimentId))}?depth=0`, {
|
|
346
450
|
credentials: 'include',
|
|
@@ -348,9 +452,9 @@ function EditorRender(props) {
|
|
|
348
452
|
});
|
|
349
453
|
if (!response.ok) throw new Error('load');
|
|
350
454
|
const doc = await response.json();
|
|
351
|
-
const
|
|
352
|
-
if (!isCurrentBinding() || !isExperiment(doc) || !
|
|
353
|
-
return armsFromBlock(doc,
|
|
455
|
+
const latest = getPuck().getItemById(props.id);
|
|
456
|
+
if (!isCurrentBinding() || !isExperiment(doc) || !latest) throw new Error('binding');
|
|
457
|
+
return armsFromBlock(doc, latest.props);
|
|
354
458
|
}
|
|
355
459
|
function createFromBlock() {
|
|
356
460
|
if (!root.current) return;
|
|
@@ -359,7 +463,7 @@ function EditorRender(props) {
|
|
|
359
463
|
api
|
|
360
464
|
}, {
|
|
361
465
|
initialName: pageTitle,
|
|
362
|
-
arms:
|
|
466
|
+
arms: newTestArms,
|
|
363
467
|
label: experimentId === undefined ? editorCopy.createLabel : editorCopy.newTest,
|
|
364
468
|
onCreate: bind
|
|
365
469
|
});
|
|
@@ -372,6 +476,7 @@ function EditorRender(props) {
|
|
|
372
476
|
detachBusy.current = true;
|
|
373
477
|
setCheckingDetach(true);
|
|
374
478
|
setClearError(null);
|
|
479
|
+
let releasePlacements;
|
|
375
480
|
try {
|
|
376
481
|
const response = await fetch(`${api}/xp-experiments/${encodeURIComponent(String(experimentId))}?depth=0`, {
|
|
377
482
|
credentials: 'include',
|
|
@@ -391,6 +496,8 @@ function EditorRender(props) {
|
|
|
391
496
|
setDetaching(null);
|
|
392
497
|
return;
|
|
393
498
|
}
|
|
499
|
+
// A status change replaces the display subscription; keep the explicit running check alive.
|
|
500
|
+
if (isExperiment(current) && current.status === 'running') releasePlacements = subscribePlacements(api, experimentId, ()=>{});
|
|
394
501
|
if (isExperiment(current)) publishExperiment(experimentId, current);
|
|
395
502
|
if (isExperiment(current) && current.status === 'running') {
|
|
396
503
|
const placements = await refreshPlacements(api, experimentId);
|
|
@@ -428,20 +535,271 @@ function EditorRender(props) {
|
|
|
428
535
|
setDetaching(null);
|
|
429
536
|
}
|
|
430
537
|
} finally{
|
|
538
|
+
releasePlacements?.();
|
|
431
539
|
detachBusy.current = false;
|
|
432
540
|
setCheckingDetach(false);
|
|
433
541
|
}
|
|
434
542
|
}
|
|
543
|
+
const placementMessage = editorPlacementMessage(placements && placements.id === experimentId ? placements.value : undefined, currentPuckDocument(window.location.pathname, admin, placements && placements.id === experimentId ? placements.value : undefined), experiment?.status);
|
|
435
544
|
const newTestButton = experimentId !== undefined && canManage ? /*#__PURE__*/ _jsx(Button, {
|
|
436
545
|
disabled: !experiment,
|
|
437
546
|
onClick: createFromBlock,
|
|
438
547
|
children: editorCopy.newTest
|
|
439
548
|
}) : null;
|
|
549
|
+
const currentPreflight = preflight && preflight.id === experimentId && Array.isArray(preflight.value?.checks) ? preflight.value : null;
|
|
550
|
+
const editorPage = currentPuckDocument(window.location.pathname, admin, placements?.value);
|
|
551
|
+
const surface = access.surface ? {
|
|
552
|
+
...access.surface,
|
|
553
|
+
editorPage,
|
|
554
|
+
apiRoute: api,
|
|
555
|
+
adminRoute: admin,
|
|
556
|
+
editorPlacementMessage: placementMessage
|
|
557
|
+
} : undefined;
|
|
558
|
+
const quickTest = {
|
|
559
|
+
doc: experiment ? {
|
|
560
|
+
...experiment,
|
|
561
|
+
id: experimentId,
|
|
562
|
+
kind: 'block'
|
|
563
|
+
} : null,
|
|
564
|
+
preflight: currentPreflight,
|
|
565
|
+
preflightRead: experimentId === undefined ? undefined : cachedReadinessRead(api, experimentId),
|
|
566
|
+
preflightError: !currentPreflight ? placementReadError(api, experimentId) ?? null : null,
|
|
567
|
+
preflightPending: documentPending || !preflight || preflight.id !== experimentId || preflight.pending,
|
|
568
|
+
hasUnsaved: writes.busy || Object.keys(weightEdits).length > 0,
|
|
569
|
+
saving: writes.busy ? 'saving' : 'idle',
|
|
570
|
+
stale: false,
|
|
571
|
+
errors: {},
|
|
572
|
+
chosenPages: {},
|
|
573
|
+
loadState: 'ready',
|
|
574
|
+
stage: ()=>{},
|
|
575
|
+
commit: async ()=>{},
|
|
576
|
+
choosePage: async ()=>{},
|
|
577
|
+
refreshPreflight: async (supersede)=>{
|
|
578
|
+
if (experimentId !== undefined) {
|
|
579
|
+
if (supersede) invalidatePlacements(api, experimentId);
|
|
580
|
+
await refreshPlacements(api, experimentId);
|
|
581
|
+
}
|
|
582
|
+
},
|
|
583
|
+
reload: async ()=>{
|
|
584
|
+
if (experimentId === undefined) return;
|
|
585
|
+
// A transition may succeed without a readable response body; recover its document too.
|
|
586
|
+
publishExperiment(experimentId, await readExperiment(`${api}/xp-experiments/${encodeURIComponent(experimentId)}?depth=0`));
|
|
587
|
+
invalidatePlacements(api, experimentId);
|
|
588
|
+
await refreshPlacements(api, experimentId);
|
|
589
|
+
},
|
|
590
|
+
acceptTransition: (result)=>{
|
|
591
|
+
const doc = result?.doc;
|
|
592
|
+
if (doc && experimentId !== undefined) publishExperiment(experimentId, doc);
|
|
593
|
+
}
|
|
594
|
+
};
|
|
595
|
+
const placementNotice = quickTest.preflightRead?.message ?? placementMessage;
|
|
596
|
+
usePlacementNotice(api, experimentId, canManage ? placementNotice : undefined);
|
|
597
|
+
const placementNoticeView = /*#__PURE__*/ _jsx(PlacementNotice, {
|
|
598
|
+
read: quickTest.preflightRead,
|
|
599
|
+
message: placementMessage,
|
|
600
|
+
running: experiment?.status === 'running',
|
|
601
|
+
onRetry: ()=>{
|
|
602
|
+
if (experimentId !== undefined) void refreshPlacements(api, experimentId);
|
|
603
|
+
}
|
|
604
|
+
});
|
|
605
|
+
const sidebarBlockers = surface ? sidebarReadinessBlockers(quickTest, surface) : [];
|
|
606
|
+
const leftoverControls = experiment && orphanSlots.length ? /*#__PURE__*/ _jsx(LeftoverVersions, {
|
|
607
|
+
slots: orphanSlots,
|
|
608
|
+
experiment: experiment,
|
|
609
|
+
writes: writes,
|
|
610
|
+
canManage: canManage,
|
|
611
|
+
countBlocks: (slot)=>countSlotBlocks(getPuck().getItemById(props.id)?.props[slot]),
|
|
612
|
+
onDelete: removeContent,
|
|
613
|
+
onSelect: (slot)=>{
|
|
614
|
+
if (isCurrentBinding()) setActive({
|
|
615
|
+
id: experimentId,
|
|
616
|
+
slot
|
|
617
|
+
});
|
|
618
|
+
}
|
|
619
|
+
}) : null;
|
|
620
|
+
const documentRead = result?.read ? classifyReadinessRead(result.read.status, undefined, documentFailures.current.failures, {
|
|
621
|
+
kind: 'document',
|
|
622
|
+
surface: 'editor',
|
|
623
|
+
resultsOnly
|
|
624
|
+
}) : undefined;
|
|
625
|
+
const accessNotice = documentRead ? documentRead.retry ? /*#__PURE__*/ _jsx(Banner, {
|
|
626
|
+
tone: "error",
|
|
627
|
+
action: /*#__PURE__*/ _jsx(Button, {
|
|
628
|
+
onClick: ()=>setReadAttempt((value)=>value + 1),
|
|
629
|
+
children: editorCopy.retrySetup
|
|
630
|
+
}),
|
|
631
|
+
children: documentRead.message
|
|
632
|
+
}) : /*#__PURE__*/ _jsx("p", {
|
|
633
|
+
className: "xp-ui-help",
|
|
634
|
+
children: documentRead.message
|
|
635
|
+
}) : !access.surface && !access.error ? /*#__PURE__*/ _jsx("p", {
|
|
636
|
+
className: "xp-ui-help",
|
|
637
|
+
role: "status",
|
|
638
|
+
children: editorCopy.loading
|
|
639
|
+
}) : access.error === 'unavailable' ? /*#__PURE__*/ _jsxs("p", {
|
|
640
|
+
className: "xp-ui-help",
|
|
641
|
+
children: [
|
|
642
|
+
editorCopy.controlsUnavailable,
|
|
643
|
+
" ",
|
|
644
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
645
|
+
onClick: access.retry,
|
|
646
|
+
children: editorCopy.retrySetup
|
|
647
|
+
})
|
|
648
|
+
]
|
|
649
|
+
}) : experimentId === undefined && resultsOnly ? /*#__PURE__*/ _jsx("p", {
|
|
650
|
+
className: "xp-ui-help",
|
|
651
|
+
children: editorCopy.setupForbidden
|
|
652
|
+
}) : experimentId === undefined && noAccess ? /*#__PURE__*/ _jsx("p", {
|
|
653
|
+
className: "xp-ui-help",
|
|
654
|
+
children: pickerCopy.forbiddenUnbound
|
|
655
|
+
}) : experimentId !== undefined && (noAccess || unavailable || resultsOnly) ? /*#__PURE__*/ _jsx("p", {
|
|
656
|
+
className: "xp-ui-help",
|
|
657
|
+
children: resultsOnly ? pickerCopy.resultsOnly : pickerCopy.forbidden
|
|
658
|
+
}) : /*#__PURE__*/ _jsx(Banner, {
|
|
659
|
+
tone: experiment?.status === 'running' ? 'warning' : 'info',
|
|
660
|
+
children: experimentId === undefined ? bannerFor() : experiment ? bannerFor(experiment.status, winner) : editorCopy.loading
|
|
661
|
+
});
|
|
662
|
+
const removeDialog = removing?.key === bindingKey ? /*#__PURE__*/ _jsx(RemoveVersion, {
|
|
663
|
+
count: countSlotBlocks(getPuck().getItemById(props.id)?.props[removing.arm.key]),
|
|
664
|
+
shared: locallyShared ? true : result?.shared,
|
|
665
|
+
arm: removing.arm,
|
|
666
|
+
writes: writes,
|
|
667
|
+
onRemove: removeContent,
|
|
668
|
+
onClose: ()=>setRemoving(null)
|
|
669
|
+
}) : null;
|
|
440
670
|
return /*#__PURE__*/ _jsxs("section", {
|
|
441
671
|
ref: root,
|
|
442
672
|
className: "xp-slot-root xp-slot-editor",
|
|
443
673
|
style: props.accent ? accentVariables(props.accent[mode]) : undefined,
|
|
444
674
|
children: [
|
|
675
|
+
sidebar ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
676
|
+
children: [
|
|
677
|
+
/*#__PURE__*/ createPortal(/*#__PURE__*/ _jsx("div", {
|
|
678
|
+
onClick: (event)=>event.stopPropagation(),
|
|
679
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
680
|
+
children: /*#__PURE__*/ _jsxs("section", {
|
|
681
|
+
"aria-label": editorCopy.testGroup,
|
|
682
|
+
children: [
|
|
683
|
+
/*#__PURE__*/ _jsx("h4", {
|
|
684
|
+
children: editorCopy.testGroup
|
|
685
|
+
}),
|
|
686
|
+
access.surface?.canManage ? /*#__PURE__*/ _jsx(ExperimentPicker, {
|
|
687
|
+
value: props.experiment ?? null,
|
|
688
|
+
onChange: sidebar.onChange
|
|
689
|
+
}) : null,
|
|
690
|
+
experiment ? /*#__PURE__*/ _jsx(StatusChip, {
|
|
691
|
+
status: experiment.status
|
|
692
|
+
}) : experimentId === undefined ? /*#__PURE__*/ _jsx("span", {
|
|
693
|
+
className: "xp-ui-status",
|
|
694
|
+
children: editorCopy.notSetUp
|
|
695
|
+
}) : null,
|
|
696
|
+
accessNotice,
|
|
697
|
+
canManage ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
698
|
+
children: [
|
|
699
|
+
placementNoticeView,
|
|
700
|
+
experiment?.status === 'draft' || experiment?.status === 'stopped' ? /*#__PURE__*/ _jsx(BlockerList, {
|
|
701
|
+
steps: sidebarBlockers
|
|
702
|
+
}) : null
|
|
703
|
+
]
|
|
704
|
+
}) : null
|
|
705
|
+
]
|
|
706
|
+
})
|
|
707
|
+
}), sidebar.test),
|
|
708
|
+
/*#__PURE__*/ createPortal(/*#__PURE__*/ _jsxs("div", {
|
|
709
|
+
onClick: (event)=>event.stopPropagation(),
|
|
710
|
+
onKeyDown: (event)=>event.stopPropagation(),
|
|
711
|
+
children: [
|
|
712
|
+
experiment && canManage ? /*#__PURE__*/ _jsxs("section", {
|
|
713
|
+
"aria-label": editorCopy.versionsGroup,
|
|
714
|
+
children: [
|
|
715
|
+
/*#__PURE__*/ _jsx("h4", {
|
|
716
|
+
children: editorCopy.versionsGroup
|
|
717
|
+
}),
|
|
718
|
+
/*#__PURE__*/ _jsx(VersionWeights, {
|
|
719
|
+
edits: weightEdits,
|
|
720
|
+
setEdits: setWeightEdits,
|
|
721
|
+
groupId: props.id,
|
|
722
|
+
splitIntent: splitIntent,
|
|
723
|
+
experiment: experiment,
|
|
724
|
+
writes: writes,
|
|
725
|
+
editable: editable,
|
|
726
|
+
beforeSplit: /*#__PURE__*/ _jsxs(_Fragment, {
|
|
727
|
+
children: [
|
|
728
|
+
leftoverControls,
|
|
729
|
+
editable ? /*#__PURE__*/ _jsx(AddVariant, {
|
|
730
|
+
experiment: experiment,
|
|
731
|
+
writes: writes,
|
|
732
|
+
onSelect: (slot)=>{
|
|
733
|
+
if (isCurrentBinding()) setActive({
|
|
734
|
+
id: experimentId,
|
|
735
|
+
slot
|
|
736
|
+
});
|
|
737
|
+
}
|
|
738
|
+
}) : null
|
|
739
|
+
]
|
|
740
|
+
}),
|
|
741
|
+
actions: (arm)=>/*#__PURE__*/ _jsxs(_Fragment, {
|
|
742
|
+
children: [
|
|
743
|
+
/*#__PURE__*/ _jsx(VersionActions, {
|
|
744
|
+
arm: arm,
|
|
745
|
+
writes: writes,
|
|
746
|
+
editable: editable,
|
|
747
|
+
running: experiment.status === 'running',
|
|
748
|
+
open: openMenu === `sidebar-${arm.key}`,
|
|
749
|
+
onOpenChange: (open)=>setOpenMenu(open ? `sidebar-${arm.key}` : null),
|
|
750
|
+
canCopy: !originalEmpty,
|
|
751
|
+
onCopy: requestCopy,
|
|
752
|
+
onRequestRemove: ()=>setRemoving({
|
|
753
|
+
key: bindingKey,
|
|
754
|
+
arm
|
|
755
|
+
})
|
|
756
|
+
}),
|
|
757
|
+
editable && arm.kind !== 'control' ? /*#__PURE__*/ _jsx(Button, {
|
|
758
|
+
disabled: writes.busy,
|
|
759
|
+
onClick: ()=>setRemoving({
|
|
760
|
+
key: bindingKey,
|
|
761
|
+
arm
|
|
762
|
+
}),
|
|
763
|
+
children: editorCopy.remove
|
|
764
|
+
}) : null
|
|
765
|
+
]
|
|
766
|
+
})
|
|
767
|
+
})
|
|
768
|
+
]
|
|
769
|
+
}) : null,
|
|
770
|
+
/*#__PURE__*/ _jsxs("section", {
|
|
771
|
+
"aria-label": editorCopy.actionsGroup,
|
|
772
|
+
children: [
|
|
773
|
+
/*#__PURE__*/ _jsx("h4", {
|
|
774
|
+
children: editorCopy.actionsGroup
|
|
775
|
+
}),
|
|
776
|
+
experimentId !== undefined && access.surface && !result?.missing && !noAccess && (!unavailable || resultsOnly) ? /*#__PURE__*/ _jsx(ConfigureTestControl, {
|
|
777
|
+
id: experimentId,
|
|
778
|
+
routes: {
|
|
779
|
+
admin,
|
|
780
|
+
api
|
|
781
|
+
}
|
|
782
|
+
}) : null,
|
|
783
|
+
canManage && experiment && surface ? /*#__PURE__*/ _jsx(QuickTestActions, {
|
|
784
|
+
test: quickTest,
|
|
785
|
+
surface: surface
|
|
786
|
+
}, `${experimentId}/${experiment.status}`) : null,
|
|
787
|
+
experimentId === undefined && canManage ? /*#__PURE__*/ _jsx(Button, {
|
|
788
|
+
variant: "primary",
|
|
789
|
+
onClick: createFromBlock,
|
|
790
|
+
children: editorCopy.createLabel
|
|
791
|
+
}) : null,
|
|
792
|
+
writes.error ? /*#__PURE__*/ _jsx("p", {
|
|
793
|
+
role: "alert",
|
|
794
|
+
children: writes.error
|
|
795
|
+
}) : null
|
|
796
|
+
]
|
|
797
|
+
}),
|
|
798
|
+
removeDialog
|
|
799
|
+
]
|
|
800
|
+
}), sidebar.controls)
|
|
801
|
+
]
|
|
802
|
+
}) : null,
|
|
445
803
|
/*#__PURE__*/ _jsxs(EditorControls, {
|
|
446
804
|
className: "xp-slot-chrome",
|
|
447
805
|
selected: isSelected,
|
|
@@ -470,45 +828,23 @@ function EditorRender(props) {
|
|
|
470
828
|
}) : null
|
|
471
829
|
]
|
|
472
830
|
}),
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
children: pickerCopy.unavailable
|
|
476
|
-
}) : !access.surface && !access.error ? /*#__PURE__*/ _jsx("p", {
|
|
477
|
-
className: "xp-ui-help",
|
|
478
|
-
role: "status",
|
|
479
|
-
children: editorCopy.loading
|
|
480
|
-
}) : access.error === 'unavailable' ? /*#__PURE__*/ _jsxs("p", {
|
|
481
|
-
className: "xp-ui-help",
|
|
482
|
-
children: [
|
|
483
|
-
editorCopy.controlsUnavailable,
|
|
484
|
-
" ",
|
|
485
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
486
|
-
onClick: access.retry,
|
|
487
|
-
children: editorCopy.retrySetup
|
|
488
|
-
})
|
|
489
|
-
]
|
|
490
|
-
}) : experimentId === undefined && resultsOnly ? /*#__PURE__*/ _jsx("p", {
|
|
491
|
-
className: "xp-ui-help",
|
|
492
|
-
children: editorCopy.setupForbidden
|
|
493
|
-
}) : experimentId === undefined && noAccess ? /*#__PURE__*/ _jsx("p", {
|
|
494
|
-
className: "xp-ui-help",
|
|
495
|
-
children: pickerCopy.forbiddenUnbound
|
|
496
|
-
}) : experimentId !== undefined && (noAccess || unavailable || resultsOnly) ? /*#__PURE__*/ _jsx("p", {
|
|
497
|
-
className: "xp-ui-help",
|
|
498
|
-
children: resultsOnly ? pickerCopy.resultsOnly : pickerCopy.forbidden
|
|
499
|
-
}) : /*#__PURE__*/ _jsx(Banner, {
|
|
500
|
-
tone: result?.error ? 'error' : experiment?.status === 'running' ? 'warning' : 'info',
|
|
501
|
-
children: experimentId === undefined ? bannerFor() : result?.error ? editorCopy.loadError : experiment ? bannerFor(experiment.status, winner) : editorCopy.loading
|
|
502
|
-
}),
|
|
503
|
-
orphanSlots.map((slot)=>/*#__PURE__*/ _jsx(Banner, {
|
|
504
|
-
tone: "warning",
|
|
505
|
-
children: editorCopy.orphan(slotLabels[slot])
|
|
506
|
-
}, slot)),
|
|
831
|
+
accessNotice,
|
|
832
|
+
leftoverControls,
|
|
507
833
|
shared ? /*#__PURE__*/ _jsx(Banner, {
|
|
508
834
|
tone: "info",
|
|
509
835
|
action: newTestButton,
|
|
510
836
|
children: editorCopy.sharedTest
|
|
511
837
|
}) : null,
|
|
838
|
+
canManage ? placementNoticeView : null,
|
|
839
|
+
experimentId !== undefined && canManage && !experiment && !result?.error ? /*#__PURE__*/ _jsx("p", {
|
|
840
|
+
className: "xp-ui-help",
|
|
841
|
+
children: editorCopy.loadingBeforeNew
|
|
842
|
+
}) : null,
|
|
843
|
+
checkingDetach ? /*#__PURE__*/ _jsx("p", {
|
|
844
|
+
role: "status",
|
|
845
|
+
className: "xp-ui-help",
|
|
846
|
+
children: editorCopy.checkingRemoval
|
|
847
|
+
}) : null,
|
|
512
848
|
/*#__PURE__*/ _jsxs("div", {
|
|
513
849
|
className: "xp-ui-button-group",
|
|
514
850
|
children: [
|
|
@@ -551,9 +887,18 @@ function EditorRender(props) {
|
|
|
551
887
|
children: editorCopy.locked[experiment.status]
|
|
552
888
|
}) : null,
|
|
553
889
|
experiment && editable ? /*#__PURE__*/ _jsx(VersionWeights, {
|
|
890
|
+
edits: weightEdits,
|
|
891
|
+
setEdits: setWeightEdits,
|
|
892
|
+
groupId: props.id,
|
|
893
|
+
splitIntent: splitIntent,
|
|
554
894
|
experiment: experiment,
|
|
555
895
|
writes: writes
|
|
556
896
|
}, `weights-${experimentId}`) : null,
|
|
897
|
+
writes.busy ? /*#__PURE__*/ _jsx("p", {
|
|
898
|
+
role: "status",
|
|
899
|
+
className: "xp-ui-help",
|
|
900
|
+
children: editorCopy.savingVersions
|
|
901
|
+
}) : null,
|
|
557
902
|
writes.error ? /*#__PURE__*/ _jsx("p", {
|
|
558
903
|
role: "alert",
|
|
559
904
|
className: "xp-ui-error",
|
|
@@ -564,7 +909,7 @@ function EditorRender(props) {
|
|
|
564
909
|
className: "xp-ui-error",
|
|
565
910
|
children: clearError.message
|
|
566
911
|
}) : null,
|
|
567
|
-
removed?.key === bindingKey ? /*#__PURE__*/ _jsx("p", {
|
|
912
|
+
removed?.key === bindingKey && removed.contentRemoved ? /*#__PURE__*/ _jsx("p", {
|
|
568
913
|
className: "xp-ui-help",
|
|
569
914
|
children: editorCopy.removed
|
|
570
915
|
}) : null,
|
|
@@ -573,12 +918,7 @@ function EditorRender(props) {
|
|
|
573
918
|
api: api,
|
|
574
919
|
experiment: experiment
|
|
575
920
|
}, `results-${experimentId}`) : null,
|
|
576
|
-
|
|
577
|
-
arm: removing.arm,
|
|
578
|
-
writes: writes,
|
|
579
|
-
onRemove: removeContent,
|
|
580
|
-
onClose: ()=>setRemoving(null)
|
|
581
|
-
}) : null,
|
|
921
|
+
!sidebar ? removeDialog : null,
|
|
582
922
|
detaching === bindingKey && canDetach ? /*#__PURE__*/ _jsx(Dialog, {
|
|
583
923
|
open: true,
|
|
584
924
|
title: editorCopy.detachTitle,
|
|
@@ -634,6 +974,7 @@ function EditorRender(props) {
|
|
|
634
974
|
]
|
|
635
975
|
}),
|
|
636
976
|
/*#__PURE__*/ _jsx(Tabs, {
|
|
977
|
+
disabled: dragging,
|
|
637
978
|
label: editorCopy.tabs,
|
|
638
979
|
value: slot,
|
|
639
980
|
renderHeader: (children)=>/*#__PURE__*/ _jsx(EditorControls, {
|
|
@@ -650,10 +991,11 @@ function EditorRender(props) {
|
|
|
650
991
|
items: tabs.map((tab)=>({
|
|
651
992
|
id: tab.slot,
|
|
652
993
|
label: tab.label,
|
|
653
|
-
actions: experiment ? /*#__PURE__*/ _jsx(VersionActions, {
|
|
994
|
+
actions: experiment?.arms.some((arm)=>arm.key === tab.slot) ? /*#__PURE__*/ _jsx(VersionActions, {
|
|
654
995
|
arm: experiment.arms.find((arm)=>arm.key === tab.slot),
|
|
655
996
|
writes: writes,
|
|
656
997
|
editable: editable,
|
|
998
|
+
running: experiment.status === 'running',
|
|
657
999
|
open: openMenu === tab.slot,
|
|
658
1000
|
onOpenChange: (open)=>setOpenMenu(open ? tab.slot : null),
|
|
659
1001
|
canCopy: !originalEmpty,
|
|
@@ -688,17 +1030,20 @@ export function createExperimentSlotEditor({ routes: inputRoutes, accent } = {})
|
|
|
688
1030
|
label: experimentSlotLabel,
|
|
689
1031
|
fields: {
|
|
690
1032
|
...experimentSlotFields,
|
|
691
|
-
experiment:
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
routes: routes
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
1033
|
+
experiment: {
|
|
1034
|
+
type: 'custom',
|
|
1035
|
+
label: pickerCopy.label,
|
|
1036
|
+
render: ({ value, onChange })=>/*#__PURE__*/ _jsx(PuckHostProvider, {
|
|
1037
|
+
routes: routes,
|
|
1038
|
+
children: /*#__PURE__*/ _jsx(TestSidebarField, {
|
|
1039
|
+
onChange: (next)=>{
|
|
1040
|
+
if (value) invalidatePlacements(routes.api, value.id);
|
|
1041
|
+
if (next) invalidatePlacements(routes.api, next.id);
|
|
1042
|
+
onChange(next);
|
|
1043
|
+
}
|
|
1044
|
+
})
|
|
1045
|
+
})
|
|
1046
|
+
}
|
|
702
1047
|
},
|
|
703
1048
|
defaultProps: experimentSlotDefaultProps,
|
|
704
1049
|
render: (props)=>/*#__PURE__*/ _jsx(PuckHostProvider, {
|