@delmaredigital/payload-experiments 0.4.0-rc.9 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -8
- package/dist/admin/MetricSourceSelect.js +10 -3
- package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +75 -29
- package/dist/admin/blocks/model.js +5 -4
- package/dist/admin/copy/blocks.d.ts +14 -11
- package/dist/admin/copy/blocks.js +33 -22
- package/dist/admin/copy/goals.d.ts +15 -8
- package/dist/admin/copy/goals.js +18 -8
- package/dist/admin/copy/newTest.d.ts +10 -7
- package/dist/admin/copy/newTest.js +14 -7
- package/dist/admin/copy/status.d.ts +1 -1
- package/dist/admin/copy/status.js +2 -1
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/placementStatus.model.js +5 -3
- package/dist/admin/status.model.d.ts +1 -0
- package/dist/admin/status.model.js +2 -1
- package/dist/admin/surface/ResultsRoute.js +4 -8
- package/dist/admin/surface/SurfaceShell.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +28 -3
- package/dist/admin/surface/TestRowMenu.d.ts +13 -0
- package/dist/admin/surface/TestRowMenu.js +163 -0
- package/dist/admin/surface/TestsHome.d.ts +4 -3
- package/dist/admin/surface/TestsHome.js +186 -47
- package/dist/admin/surface/TestsSurface.js +2 -1
- package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
- package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
- package/dist/admin/surface/goals/GoalForm.js +280 -198
- package/dist/admin/surface/goals/GoalsList.js +102 -33
- package/dist/admin/surface/goals/data.d.ts +2 -0
- package/dist/admin/surface/goals/data.js +9 -0
- package/dist/admin/surface/goals/goals.css +3 -2
- package/dist/admin/surface/goals/goals.model.d.ts +2 -2
- package/dist/admin/surface/goals/goals.model.js +7 -12
- package/dist/admin/surface/home.model.d.ts +15 -8
- package/dist/admin/surface/home.model.js +22 -18
- package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
- package/dist/admin/surface/newTest/NewTest.js +156 -96
- package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
- package/dist/admin/surface/newTest/PageWizard.js +93 -68
- package/dist/admin/surface/newTest/newTest.css +28 -11
- package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
- package/dist/admin/surface/results/ResultsHeader.js +90 -63
- package/dist/admin/surface/surface.css +29 -0
- package/dist/admin/surface/test/TestPage.js +46 -38
- package/dist/admin/surface/useXpStepNav.d.ts +11 -0
- package/dist/admin/surface/useXpStepNav.js +14 -0
- package/dist/admin/views/TestsSurfaceClient.js +27 -3
- package/dist/admin/views/buildSurfaceProps.js +18 -66
- package/dist/arms/copy.d.ts +13 -3
- package/dist/arms/copy.js +5 -4
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +1 -1
- package/dist/collections/experiments/armInvariants.js +8 -5
- package/dist/collections/metrics.js +12 -5
- package/dist/collections/serialize.js +3 -2
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +414 -0
- package/dist/endpoints/editorSurface.js +1 -1
- package/dist/endpoints/index.js +20 -0
- package/dist/endpoints/pages.js +245 -66
- package/dist/endpoints/placementStatus.js +1 -0
- package/dist/endpoints/results.js +3 -0
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +4 -5
- package/dist/exports/index.d.ts +1 -1
- package/dist/goals/picker/copy.js +1 -1
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/labels/arms.d.ts +3 -0
- package/dist/labels/arms.js +8 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +18 -2
- package/dist/plugin.js +56 -2
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
- package/dist/puck/editor/ConfigureTestDrawer.js +36 -26
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +219 -106
- package/dist/puck/editor/LeftoverVersions.js +17 -32
- package/dist/puck/editor/QuickTestActions.d.ts +2 -2
- package/dist/puck/editor/QuickTestActions.js +44 -34
- package/dist/puck/editor/ResultsReadout.d.ts +3 -1
- package/dist/puck/editor/ResultsReadout.js +28 -16
- package/dist/puck/editor/VersionBuilder.d.ts +4 -2
- package/dist/puck/editor/VersionBuilder.js +42 -63
- package/dist/puck/editor/armWrites.js +1 -1
- package/dist/puck/editor/copy.d.ts +10 -6
- package/dist/puck/editor/copy.js +22 -12
- package/dist/puck/editor/editor.chrome.css +9 -8
- package/dist/puck/editor/editor.css +14 -9
- package/dist/puck/editor/placementsCache.d.ts +1 -1
- package/dist/puck/editor/placementsCache.js +9 -17
- package/dist/puck/editor/usePageSaveReadiness.d.ts +1 -4
- package/dist/puck/editor/usePageSaveReadiness.js +18 -21
- package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
- package/dist/puck/editor/usePlacementNotice.js +4 -5
- package/dist/puck/nestedTestCopy.js +2 -2
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +1 -1
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/verdict.d.ts +4 -4
- package/dist/results/verdict.js +13 -10
- package/dist/server/runResults.js +2 -1
- package/dist/testSurface/PreviewLinks.d.ts +2 -1
- package/dist/testSurface/PreviewLinks.js +3 -3
- package/dist/testSurface/actions/DecideDialog.d.ts +7 -4
- package/dist/testSurface/actions/DecideDialog.js +71 -59
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/testSurface/actions/MakeContentResult.js +1 -1
- package/dist/testSurface/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +75 -22
- package/dist/testSurface/actions/decide.model.d.ts +1 -0
- package/dist/testSurface/actions/decide.model.js +1 -0
- package/dist/testSurface/allocation.model.js +6 -3
- package/dist/testSurface/api.d.ts +4 -1
- package/dist/testSurface/api.js +22 -14
- package/dist/testSurface/copy/actions.d.ts +36 -14
- package/dist/testSurface/copy/actions.js +39 -17
- package/dist/testSurface/copy/advanced.d.ts +10 -0
- package/dist/testSurface/copy/advanced.js +10 -0
- package/dist/testSurface/copy/arms.d.ts +1 -1
- package/dist/testSurface/copy/arms.js +1 -1
- package/dist/testSurface/copy/audience.d.ts +4 -3
- package/dist/testSurface/copy/audience.js +5 -4
- package/dist/testSurface/copy/common.d.ts +6 -6
- package/dist/testSurface/copy/common.js +6 -6
- package/dist/testSurface/copy/metrics.d.ts +6 -0
- package/dist/testSurface/copy/metrics.js +8 -0
- package/dist/testSurface/copy/pages.d.ts +67 -7
- package/dist/testSurface/copy/pages.js +74 -7
- package/dist/testSurface/copy/readiness.d.ts +8 -6
- package/dist/testSurface/copy/readiness.js +19 -10
- package/dist/testSurface/copy/recommendation.d.ts +1 -22
- package/dist/testSurface/copy/recommendation.js +2 -22
- package/dist/testSurface/copy/results.d.ts +16 -10
- package/dist/testSurface/copy/results.js +19 -11
- package/dist/testSurface/copy/review.d.ts +13 -10
- package/dist/testSurface/copy/review.js +14 -10
- package/dist/testSurface/copy/setting.d.ts +1 -2
- package/dist/testSurface/copy/setting.js +1 -2
- package/dist/testSurface/copy/surface.d.ts +11 -2
- package/dist/testSurface/copy/surface.js +14 -11
- package/dist/testSurface/copy/testPage.d.ts +16 -10
- package/dist/testSurface/copy/testPage.js +24 -18
- package/dist/testSurface/format/date.d.ts +5 -2
- package/dist/testSurface/format/date.js +24 -8
- package/dist/testSurface/format/roundProgress.d.ts +6 -0
- package/dist/testSurface/format/roundProgress.js +15 -0
- package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
- package/dist/testSurface/format/useDateFormatter.js +8 -0
- package/dist/testSurface/labels.d.ts +1 -2
- package/dist/testSurface/labels.js +2 -3
- package/dist/testSurface/lockedNotice.model.d.ts +2 -0
- package/dist/testSurface/lockedNotice.model.js +31 -0
- package/dist/testSurface/readPreflight.d.ts +0 -1
- package/dist/testSurface/readPreflight.js +0 -1
- package/dist/testSurface/results/CiChart.js +2 -1
- package/dist/testSurface/results/DataTable.d.ts +1 -1
- package/dist/testSurface/results/DataTable.js +4 -3
- package/dist/testSurface/results/VerdictHero.d.ts +1 -1
- package/dist/testSurface/results/legacy.d.ts +0 -5
- package/dist/testSurface/results/legacy.js +0 -14
- package/dist/testSurface/results/results.css +2 -2
- package/dist/testSurface/results/results.model.d.ts +8 -3
- package/dist/testSurface/results/results.model.js +25 -21
- package/dist/testSurface/results/snapshot.d.ts +2 -0
- package/dist/testSurface/results/snapshot.js +3 -0
- package/dist/testSurface/surface/contracts.d.ts +6 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +1 -1
- package/dist/testSurface/surface/editorPlacement.js +1 -1
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +1 -1
- package/dist/testSurface/surface/pageBlock/parts.js +25 -12
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +298 -209
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
- package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
- package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +5 -3
- package/dist/testSurface/surface/readiness/ActionDialogs.js +213 -207
- package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
- package/dist/testSurface/surface/readiness/Banner.js +109 -148
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +5 -2
- package/dist/testSurface/surface/readiness/SaveStatus.js +8 -7
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +14 -5
- package/dist/testSurface/surface/readiness/readiness.model.js +62 -12
- package/dist/testSurface/surface/readiness/useTransition.d.ts +3 -1
- package/dist/testSurface/surface/readiness/useTransition.js +49 -8
- package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -3
- package/dist/testSurface/surface/results/ReleasePages.js +41 -41
- package/dist/testSurface/surface/results/ResultsBody.d.ts +7 -2
- package/dist/testSurface/surface/results/ResultsBody.js +170 -110
- package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
- package/dist/testSurface/surface/results/recommendation.model.js +15 -59
- package/dist/testSurface/surface/results/useResults.d.ts +6 -2
- package/dist/testSurface/surface/setting/parts.js +31 -28
- package/dist/testSurface/surface/setting/setting.css +2 -1
- package/dist/testSurface/surface/test/AdvancedSection.js +10 -4
- package/dist/testSurface/surface/test/DeleteTest.d.ts +5 -1
- package/dist/testSurface/surface/test/DeleteTest.js +63 -55
- package/dist/testSurface/surface/test/GoalSection.js +11 -11
- package/dist/testSurface/surface/test/LengthSection.js +21 -13
- package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
- package/dist/testSurface/surface/test/PageHoldout.js +7 -7
- package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
- package/dist/testSurface/surface/test/Section.js +8 -0
- package/dist/testSurface/surface/test/TargetingSection.js +7 -2
- package/dist/testSurface/surface/test/TestSurface.js +17 -43
- package/dist/testSurface/surface/test/VersionsSection.js +93 -70
- package/dist/testSurface/surface/test/fields.d.ts +4 -3
- package/dist/testSurface/surface/test/fields.js +10 -16
- package/dist/testSurface/surface/test/pageParts.js +13 -7
- package/dist/testSurface/surface/test/testPage.css +9 -2
- package/dist/testSurface/surface/useTestDocument.d.ts +1 -3
- package/dist/testSurface/surface/useTestDocument.js +110 -52
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +1 -0
- package/dist/testSurface/surfaceUrls.js +4 -0
- package/dist/testSurface/useApi.d.ts +3 -0
- package/dist/transitions/addMetric.d.ts +1 -1
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/kernel.d.ts +2 -0
- package/dist/transitions/kernel.js +1 -1
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.d.ts +1 -1
- package/dist/transitions/preflightData.js +10 -2
- package/dist/transitions/start.d.ts +1 -1
- package/dist/transitions/start.js +8 -5
- package/dist/types/armKey.d.ts +2 -0
- package/dist/types/armKey.js +1 -0
- package/dist/types/contracts.d.ts +11 -1
- package/dist/types/endpoints.d.ts +38 -9
- package/dist/types/endpoints.js +1 -1
- package/dist/types/surface.d.ts +7 -9
- package/dist/ui/Dialog.d.ts +21 -2
- package/dist/ui/Dialog.js +101 -4
- package/dist/ui/Inputs.js +0 -1
- package/dist/ui/ui.css +5 -1
- package/package.json +2 -2
|
@@ -4,34 +4,48 @@ import { canStartTest, readyToStart } from '../../readinessRead.js';
|
|
|
4
4
|
import { DocsResponseError, fetchAllDocs } from '../../../lib/fetchAllDocs.js';
|
|
5
5
|
import { usePlacementLabels, placementDetailKey } from '../../placements/usePlacementLabels.js';
|
|
6
6
|
import { placementUncheckedCopy } from '../../copy/readiness.js';
|
|
7
|
-
import { useEffect, useState } from 'react';
|
|
8
|
-
import { Button } from '../../../ui/Button.js';
|
|
7
|
+
import { useEffect, useId, useState } from 'react';
|
|
9
8
|
import { TextInput, Select } from '../../../ui/Inputs.js';
|
|
10
|
-
import {
|
|
9
|
+
import { ConfirmDialog } from '../../../ui/Dialog.js';
|
|
10
|
+
import { isDestructiveAction } from '../../actions/actions.model.js';
|
|
11
11
|
import { MakeContentResult } from '../../actions/MakeContentResult.js';
|
|
12
12
|
import { expectedConfirm, matchesConfirm } from '../../../transitions/confirmPhrases.js';
|
|
13
|
-
import { ACTIONS_COPY as A, addMetricWarningCopy } from '../../copy/actions.js';
|
|
13
|
+
import { ACTIONS_COPY as A, actionTitle, addMetricWarningCopy } from '../../copy/actions.js';
|
|
14
14
|
import { REVIEW_COPY as R } from '../../copy/review.js';
|
|
15
15
|
import { READINESS_COPY as C } from '../../copy/readiness.js';
|
|
16
16
|
import { API_MESSAGES, refusalMessage } from '../../copy/common.js';
|
|
17
17
|
import { createApi } from '../../api.js';
|
|
18
|
-
import { blockingSteps, pageReadinessContext } from './readiness.model.js';
|
|
18
|
+
import { blockingSteps, pageReadinessContext, readinessCaveats } from './readiness.model.js';
|
|
19
19
|
import { actionWaitMessage } from './SaveStatus.js';
|
|
20
|
+
import { surfaceUrls } from '../../surfaceUrls.js';
|
|
21
|
+
import { Button } from '../../../ui/Button.js';
|
|
20
22
|
import { useTransition } from './useTransition.js';
|
|
21
|
-
|
|
23
|
+
export function dialogTitle(label, test) {
|
|
24
|
+
return test.doc?.name ? actionTitle(label, test.doc.name) : label;
|
|
25
|
+
}
|
|
26
|
+
/** Prop-driven ConfirmDialog adapter: same model/copy, section reload instead of a page reload. */ export function ConfirmAction({ test, surface, action, winnerLabel, onClose, onSuccess }) {
|
|
22
27
|
const api = createApi(surface.apiRoute);
|
|
23
28
|
const [openedPhase] = useState(test.doc?.phase);
|
|
29
|
+
const [openedStatus] = useState(test.doc?.status);
|
|
30
|
+
const confirmationId = useId();
|
|
24
31
|
const [typed, setTyped] = useState('');
|
|
25
32
|
const [content, setContent] = useState(null);
|
|
26
33
|
const [reportBusy, setReportBusy] = useState(false);
|
|
27
|
-
const transition = useTransition(test,
|
|
34
|
+
const transition = useTransition(test, ()=>{
|
|
35
|
+
onClose();
|
|
36
|
+
onSuccess?.();
|
|
37
|
+
}, surface, true);
|
|
38
|
+
const changed = test.doc?.phase !== openedPhase || test.doc?.status !== openedStatus;
|
|
28
39
|
const wait = action.id === 'start' ? actionWaitMessage(test) : undefined;
|
|
29
40
|
const phrase = action.confirm.phrase ? expectedConfirm(action.confirm.phrase.action, winnerLabel) : null;
|
|
30
41
|
const ready = action.id !== 'start' || !transition.checking && canStartTest(test, surface.editorPlacementMessage);
|
|
31
|
-
const
|
|
42
|
+
const blocker = action.id === 'start' && !readyToStart(test, surface.editorPlacementMessage) ? test.preflightError ?? (test.doc ? blockingSteps(test.preflight, pageReadinessContext(test.doc, test.preflight, surface))[0]?.sentence : undefined) ?? C.checking : undefined;
|
|
43
|
+
const startMessage = wait ?? blocker;
|
|
44
|
+
const enabled = surface.canManage && !changed && ready && !test.statusReadPending && !transition.busy && !transition.reloadRequired && !wait && (!phrase || matchesConfirm(phrase, typed));
|
|
32
45
|
async function submit(finish = false) {
|
|
33
46
|
if (!enabled || !test.doc) return;
|
|
34
|
-
const { id
|
|
47
|
+
const { id } = test.doc;
|
|
48
|
+
const phase = openedPhase;
|
|
35
49
|
await transition.run(finish ? 'archive' : action.id === 'start' && test.doc.status === 'stopped' ? 'restart' : action.id, async ()=>{
|
|
36
50
|
if (finish) return api.archive(id, {
|
|
37
51
|
mode: 'after-content',
|
|
@@ -53,6 +67,7 @@ import { useTransition } from './useTransition.js';
|
|
|
53
67
|
return result;
|
|
54
68
|
}
|
|
55
69
|
if (result.ok) {
|
|
70
|
+
test.acceptTransition?.(undefined);
|
|
56
71
|
await test.reload();
|
|
57
72
|
return {
|
|
58
73
|
ok: false,
|
|
@@ -69,13 +84,39 @@ import { useTransition } from './useTransition.js';
|
|
|
69
84
|
function close() {
|
|
70
85
|
if (transition.busy || reportBusy) return;
|
|
71
86
|
onClose();
|
|
87
|
+
transition.refreshAfterDismissal();
|
|
72
88
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
89
|
+
const label = action.confirm.label ?? action.label;
|
|
90
|
+
const caveats = action.id === 'start' ? readinessCaveats(test, surface.adminRoute) : [];
|
|
91
|
+
const description = caveats.length ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
92
|
+
children: [
|
|
93
|
+
/*#__PURE__*/ _jsx("p", {
|
|
94
|
+
children: action.confirm.body
|
|
95
|
+
}),
|
|
96
|
+
/*#__PURE__*/ _jsx("ul", {
|
|
97
|
+
children: caveats.map(({ key, sentence, href })=>/*#__PURE__*/ _jsx("li", {
|
|
98
|
+
children: href && !transition.busy ? /*#__PURE__*/ _jsx("a", {
|
|
99
|
+
href: href,
|
|
100
|
+
children: sentence
|
|
101
|
+
}) : sentence
|
|
102
|
+
}, key))
|
|
103
|
+
})
|
|
104
|
+
]
|
|
105
|
+
}) : action.confirm.body;
|
|
106
|
+
return /*#__PURE__*/ _jsxs(ConfirmDialog, {
|
|
107
|
+
title: action.confirm.title === label ? dialogTitle(label, test) : action.confirm.title,
|
|
78
108
|
onClose: close,
|
|
109
|
+
description: content ? undefined : description,
|
|
110
|
+
busy: transition.busy || reportBusy,
|
|
111
|
+
busyLabel: C.changing,
|
|
112
|
+
cancelLabel: content ? A.done : A.cancel,
|
|
113
|
+
error: transition.error ?? (changed && !transition.busy && !content ? A.actionChanged : null),
|
|
114
|
+
confirm: content ? undefined : {
|
|
115
|
+
label,
|
|
116
|
+
disabled: !enabled,
|
|
117
|
+
destructive: isDestructiveAction(action.id),
|
|
118
|
+
onClick: ()=>submit()
|
|
119
|
+
},
|
|
79
120
|
children: [
|
|
80
121
|
content ? /*#__PURE__*/ _jsx(MakeContentResult, {
|
|
81
122
|
result: content,
|
|
@@ -92,60 +133,31 @@ import { useTransition } from './useTransition.js';
|
|
|
92
133
|
if (result.ok) test.acceptTransition?.(result.data);
|
|
93
134
|
await test.reload();
|
|
94
135
|
}
|
|
95
|
-
}) : /*#__PURE__*/
|
|
96
|
-
children:
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
onChange: (event)=>setTyped(event.target.value)
|
|
117
|
-
})
|
|
118
|
-
]
|
|
119
|
-
}) : null
|
|
120
|
-
]
|
|
136
|
+
}) : /*#__PURE__*/ _jsx(_Fragment, {
|
|
137
|
+
children: phrase ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
138
|
+
children: [
|
|
139
|
+
/*#__PURE__*/ _jsxs("p", {
|
|
140
|
+
children: [
|
|
141
|
+
A.typePhrase,
|
|
142
|
+
" ",
|
|
143
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
144
|
+
children: phrase
|
|
145
|
+
})
|
|
146
|
+
]
|
|
147
|
+
}),
|
|
148
|
+
/*#__PURE__*/ _jsx(TextInput, {
|
|
149
|
+
id: confirmationId,
|
|
150
|
+
label: A.confirmation,
|
|
151
|
+
value: typed,
|
|
152
|
+
readOnly: transition.busy,
|
|
153
|
+
onChange: (event)=>setTyped(event.target.value)
|
|
154
|
+
})
|
|
155
|
+
]
|
|
156
|
+
}) : null
|
|
121
157
|
}),
|
|
122
|
-
transition.
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}) : null,
|
|
126
|
-
transition.error ? /*#__PURE__*/ _jsx("p", {
|
|
127
|
-
role: "alert",
|
|
128
|
-
children: transition.error
|
|
129
|
-
}) : null,
|
|
130
|
-
!content && wait ? /*#__PURE__*/ _jsx("p", {
|
|
131
|
-
children: wait
|
|
132
|
-
}) : !content && action.id === 'start' && !readyToStart(test, surface.editorPlacementMessage) ? /*#__PURE__*/ _jsx("p", {
|
|
133
|
-
children: test.preflightError ? test.preflightError : test.doc ? blockingSteps(test.preflight, pageReadinessContext(test.doc, test.preflight, surface))[0]?.sentence ?? C.checking : C.checking
|
|
134
|
-
}) : null,
|
|
135
|
-
!content ? /*#__PURE__*/ _jsx(Button, {
|
|
136
|
-
busy: transition.busy,
|
|
137
|
-
disabled: !enabled,
|
|
138
|
-
onClick: ()=>{
|
|
139
|
-
void submit();
|
|
140
|
-
},
|
|
141
|
-
children: action.label
|
|
142
|
-
}) : null,
|
|
143
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
144
|
-
"data-dialog-cancel": true,
|
|
145
|
-
disabled: transition.busy || reportBusy,
|
|
146
|
-
onClick: close,
|
|
147
|
-
children: content ? A.done : A.cancel
|
|
148
|
-
})
|
|
158
|
+
!content && startMessage && startMessage !== transition.error ? /*#__PURE__*/ _jsx("p", {
|
|
159
|
+
children: startMessage
|
|
160
|
+
}) : null
|
|
149
161
|
]
|
|
150
162
|
});
|
|
151
163
|
}
|
|
@@ -153,21 +165,35 @@ import { useTransition } from './useTransition.js';
|
|
|
153
165
|
const current = test.doc?.allocation ?? 100;
|
|
154
166
|
const [openedPhase] = useState(test.doc?.phase);
|
|
155
167
|
const [value, setValue] = useState(String(Math.min(100, current + 1)));
|
|
156
|
-
const transition = useTransition(test, onClose, surface);
|
|
168
|
+
const transition = useTransition(test, onClose, surface, true);
|
|
157
169
|
const allocation = Number(value);
|
|
158
170
|
const valid = value.trim() !== '' && Number.isInteger(allocation) && allocation > current && allocation <= 100;
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
171
|
+
const changed = test.doc?.status !== 'running' || test.doc?.phase !== openedPhase;
|
|
172
|
+
const disabled = transition.busy || test.statusReadPending || changed || transition.reloadRequired;
|
|
173
|
+
return /*#__PURE__*/ _jsxs(ConfirmDialog, {
|
|
174
|
+
title: dialogTitle(A.titleLead.allocate, test),
|
|
175
|
+
description: R.allocationBody,
|
|
164
176
|
onClose: ()=>{
|
|
165
|
-
|
|
177
|
+
onClose();
|
|
178
|
+
transition.refreshAfterDismissal();
|
|
179
|
+
},
|
|
180
|
+
busy: transition.busy,
|
|
181
|
+
busyLabel: C.changing,
|
|
182
|
+
cancelLabel: A.cancel,
|
|
183
|
+
error: transition.error ?? (changed && !transition.busy ? A.actionChanged : null),
|
|
184
|
+
confirm: {
|
|
185
|
+
label: C.allocate,
|
|
186
|
+
disabled: disabled || !valid,
|
|
187
|
+
onClick: ()=>{
|
|
188
|
+
if (valid && test.doc) return transition.run('allocate', ()=>createApi(surface.apiRoute).allocate(test.doc.id, {
|
|
189
|
+
allocation,
|
|
190
|
+
phase: openedPhase
|
|
191
|
+
}, {
|
|
192
|
+
notFound: API_MESSAGES.roundChanged
|
|
193
|
+
}));
|
|
194
|
+
}
|
|
166
195
|
},
|
|
167
196
|
children: [
|
|
168
|
-
/*#__PURE__*/ _jsx("p", {
|
|
169
|
-
children: R.allocationBody
|
|
170
|
-
}),
|
|
171
197
|
/*#__PURE__*/ _jsxs("label", {
|
|
172
198
|
children: [
|
|
173
199
|
C.participation,
|
|
@@ -184,38 +210,12 @@ import { useTransition } from './useTransition.js';
|
|
|
184
210
|
}),
|
|
185
211
|
!valid ? /*#__PURE__*/ _jsx("p", {
|
|
186
212
|
children: R.allocationInvalid
|
|
187
|
-
}) : null
|
|
188
|
-
transition.busy ? /*#__PURE__*/ _jsx("p", {
|
|
189
|
-
role: "status",
|
|
190
|
-
children: C.changing
|
|
191
|
-
}) : null,
|
|
192
|
-
transition.error ? /*#__PURE__*/ _jsx("p", {
|
|
193
|
-
role: "alert",
|
|
194
|
-
children: transition.error
|
|
195
|
-
}) : null,
|
|
196
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
197
|
-
busy: transition.busy,
|
|
198
|
-
disabled: disabled || !valid,
|
|
199
|
-
onClick: ()=>{
|
|
200
|
-
// Not-found can also mean the experiment is missing; use round copy for the missing phase record.
|
|
201
|
-
if (valid && test.doc) void transition.run('allocate', ()=>createApi(surface.apiRoute).allocate(test.doc.id, {
|
|
202
|
-
allocation,
|
|
203
|
-
phase: openedPhase
|
|
204
|
-
}, {
|
|
205
|
-
notFound: API_MESSAGES.roundChanged
|
|
206
|
-
}));
|
|
207
|
-
},
|
|
208
|
-
children: C.allocate
|
|
209
|
-
}),
|
|
210
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
211
|
-
disabled: transition.busy,
|
|
212
|
-
onClick: onClose,
|
|
213
|
-
children: A.cancel
|
|
214
|
-
})
|
|
213
|
+
}) : null
|
|
215
214
|
]
|
|
216
215
|
});
|
|
217
216
|
}
|
|
218
|
-
/** AddMetricDialog adapter; the
|
|
217
|
+
/** AddMetricDialog adapter; the current round’s main goal is fixed. */ export function AddMetricAction({ test, surface, onClose }) {
|
|
218
|
+
const [openedPhase] = useState(test.doc?.phase);
|
|
219
219
|
const [metrics, setMetrics] = useState([]);
|
|
220
220
|
const [loading, setLoading] = useState(true);
|
|
221
221
|
const [loadError, setLoadError] = useState(null);
|
|
@@ -227,7 +227,7 @@ import { useTransition } from './useTransition.js';
|
|
|
227
227
|
...surface
|
|
228
228
|
});
|
|
229
229
|
const [role, setRole] = useState('secondary');
|
|
230
|
-
const transition = useTransition(test, onClose, surface);
|
|
230
|
+
const transition = useTransition(test, onClose, surface, true);
|
|
231
231
|
useEffect(()=>{
|
|
232
232
|
const controller = new AbortController();
|
|
233
233
|
void (async ()=>{
|
|
@@ -254,113 +254,119 @@ import { useTransition } from './useTransition.js';
|
|
|
254
254
|
...test.doc?.metrics?.guardrails ?? []
|
|
255
255
|
].filter((id)=>id != null).map(String));
|
|
256
256
|
const available = metrics.filter((item)=>!attached.has(String(item.id)));
|
|
257
|
+
const empty = !loading && !loadError && !available.length;
|
|
257
258
|
const selected = available.find((item)=>String(item.id) === metric);
|
|
258
|
-
const
|
|
259
|
+
const changed = test.doc?.status !== 'running' || test.doc?.phase !== openedPhase;
|
|
260
|
+
const disabled = transition.busy || test.statusReadPending || changed || transition.reloadRequired && transition.error !== API_MESSAGES.goalNotFound;
|
|
259
261
|
function close() {
|
|
260
262
|
if (transition.busy) return;
|
|
261
263
|
onClose();
|
|
264
|
+
transition.refreshAfterDismissal();
|
|
262
265
|
}
|
|
263
|
-
return /*#__PURE__*/
|
|
264
|
-
open: true,
|
|
265
|
-
dismissible: !transition.busy,
|
|
266
|
+
return /*#__PURE__*/ _jsx(ConfirmDialog, {
|
|
266
267
|
title: C.addGoal,
|
|
268
|
+
description: warnings || empty ? undefined : C.addMetric,
|
|
267
269
|
onClose: close,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
270
|
+
busy: transition.busy,
|
|
271
|
+
busyLabel: C.changing,
|
|
272
|
+
cancelLabel: warnings ? A.done : A.cancel,
|
|
273
|
+
error: warnings ? undefined : loadError ?? transition.error ?? (changed ? A.actionChanged : null),
|
|
274
|
+
confirm: warnings || empty ? undefined : {
|
|
275
|
+
label: C.addGoal,
|
|
276
|
+
disabled: disabled || loading || !!loadError || !selected,
|
|
277
|
+
onClick: ()=>{
|
|
278
|
+
// Goal and phase lookups share not-found; prefer the more likely missing goal without reading server text.
|
|
279
|
+
if (selected && test.doc) return transition.run('add-metric', async ()=>{
|
|
280
|
+
const result = await createApi(surface.apiRoute).addMetric(test.doc.id, {
|
|
281
|
+
metric: selected.id,
|
|
282
|
+
role,
|
|
283
|
+
phase: openedPhase
|
|
284
|
+
}, {
|
|
285
|
+
notFound: API_MESSAGES.goalNotFound
|
|
286
|
+
});
|
|
287
|
+
if (result.ok) {
|
|
288
|
+
if (result.data?.warnings?.length) setWarnings(result.data.warnings);
|
|
289
|
+
else onClose();
|
|
290
|
+
}
|
|
291
|
+
return result;
|
|
292
|
+
}, {
|
|
293
|
+
closeOnSuccess: false
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
},
|
|
297
|
+
children: warnings ? warnings.map((warning, index)=>{
|
|
298
|
+
const placement = warning.code === 'placement-unchecked' ? placementLabels.get(placementDetailKey(warning.detail)) : undefined;
|
|
299
|
+
return /*#__PURE__*/ _jsx("p", {
|
|
300
|
+
children: placement ? placement.href ? /*#__PURE__*/ _jsx("a", {
|
|
301
|
+
href: placement.href,
|
|
302
|
+
children: placementUncheckedCopy(placement.title)
|
|
303
|
+
}) : placementUncheckedCopy(placement.title) : addMetricWarningCopy(warning)
|
|
304
|
+
}, index);
|
|
305
|
+
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
306
|
+
children: [
|
|
307
|
+
loading ? /*#__PURE__*/ _jsx("p", {
|
|
308
|
+
role: "status",
|
|
309
|
+
children: R.loadingMetrics
|
|
310
|
+
}) : null,
|
|
311
|
+
empty ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
312
|
+
children: [
|
|
313
|
+
/*#__PURE__*/ _jsx("p", {
|
|
314
|
+
children: metrics.length ? R.allMetricsAttached : R.noMetrics
|
|
315
|
+
}),
|
|
316
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
317
|
+
href: surfaceUrls.newGoal(surface.adminRoute, {
|
|
318
|
+
return: test.doc ? String(test.doc.id) : undefined
|
|
313
319
|
}),
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
320
|
+
children: R.createGoal
|
|
321
|
+
})
|
|
322
|
+
]
|
|
323
|
+
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
324
|
+
children: [
|
|
325
|
+
/*#__PURE__*/ _jsxs(Select, {
|
|
326
|
+
id: "xp-add-goal-metric",
|
|
327
|
+
label: R.metric,
|
|
328
|
+
value: metric,
|
|
329
|
+
disabled: disabled || loading,
|
|
330
|
+
onChange: (event)=>setMetric(event.target.value),
|
|
331
|
+
children: [
|
|
332
|
+
/*#__PURE__*/ _jsx("option", {
|
|
333
|
+
value: "",
|
|
334
|
+
children: R.chooseMetric
|
|
335
|
+
}),
|
|
336
|
+
available.map((item)=>/*#__PURE__*/ _jsx("option", {
|
|
337
|
+
value: String(item.id),
|
|
338
|
+
children: item.name
|
|
339
|
+
}, item.id))
|
|
340
|
+
]
|
|
341
|
+
}),
|
|
342
|
+
/*#__PURE__*/ _jsxs(Select, {
|
|
343
|
+
id: "xp-add-goal-role",
|
|
344
|
+
label: R.role,
|
|
345
|
+
value: role,
|
|
346
|
+
disabled: disabled,
|
|
347
|
+
onChange: (event)=>setRole(event.target.value),
|
|
348
|
+
children: [
|
|
349
|
+
/*#__PURE__*/ _jsx("option", {
|
|
350
|
+
value: "primary",
|
|
351
|
+
disabled: true,
|
|
352
|
+
children: R.primary
|
|
353
|
+
}),
|
|
354
|
+
/*#__PURE__*/ _jsx("option", {
|
|
355
|
+
value: "secondary",
|
|
356
|
+
children: R.supporting
|
|
357
|
+
}),
|
|
358
|
+
/*#__PURE__*/ _jsx("option", {
|
|
359
|
+
value: "guardrail",
|
|
360
|
+
children: R.guardrail
|
|
361
|
+
})
|
|
362
|
+
]
|
|
363
|
+
})
|
|
364
|
+
]
|
|
365
|
+
}),
|
|
366
|
+
!loading && !loadError && available.length > 0 && !selected ? /*#__PURE__*/ _jsx("p", {
|
|
367
|
+
children: C.chooseGoalToAdd
|
|
368
|
+
}) : null
|
|
369
|
+
]
|
|
370
|
+
})
|
|
365
371
|
});
|
|
366
372
|
}
|
|
@@ -1,2 +1,6 @@
|
|
|
1
|
+
import { type Ref } from 'react';
|
|
1
2
|
import type { SectionProps } from '../contracts.js';
|
|
2
|
-
export declare function ReadinessContent({ test, surface, resultsVersion }: SectionProps
|
|
3
|
+
export declare function ReadinessContent({ test, surface, resultsVersion, embedded, barRef }: SectionProps & {
|
|
4
|
+
embedded?: boolean;
|
|
5
|
+
barRef?: Ref<HTMLDivElement>;
|
|
6
|
+
}): import("react").JSX.Element;
|