@delmaredigital/payload-experiments 0.4.1 → 0.5.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 +9 -5
- package/dist/admin/blocks/model.js +2 -0
- package/dist/admin/copy/blocks.d.ts +1 -0
- package/dist/admin/copy/blocks.js +1 -0
- package/dist/admin/copy/status.d.ts +3 -0
- package/dist/admin/copy/status.js +3 -0
- package/dist/admin/placementStatus.model.js +3 -0
- package/dist/admin/status.model.d.ts +3 -2
- package/dist/admin/status.model.js +9 -3
- package/dist/admin/surface/ResultsRoute.js +2 -1
- package/dist/admin/surface/TestsHome.d.ts +2 -1
- package/dist/admin/surface/TestsHome.js +31 -11
- package/dist/admin/surface/TestsSurface.js +4 -0
- package/dist/admin/surface/home.model.d.ts +11 -6
- package/dist/admin/surface/home.model.js +19 -8
- package/dist/admin/surface/newTest/PageWizard.js +13 -3
- package/dist/admin/surface/results/ResultsHeader.js +43 -9
- package/dist/admin/surface/test/TestPage.js +11 -1
- package/dist/admin/useLayerUsage.d.ts +1 -1
- package/dist/admin/views/buildSurfaceProps.js +3 -0
- package/dist/cohorts/build.d.ts +35 -0
- package/dist/cohorts/build.js +134 -0
- package/dist/cohorts/key.d.ts +12 -0
- package/dist/cohorts/key.js +15 -0
- package/dist/cohorts/maintenance.d.ts +10 -0
- package/dist/cohorts/maintenance.js +70 -0
- package/dist/cohorts/readiness.d.ts +30 -0
- package/dist/cohorts/readiness.js +54 -0
- package/dist/cohorts/readinessData.d.ts +29 -0
- package/dist/cohorts/readinessData.js +123 -0
- package/dist/cohorts/rule.d.ts +33 -0
- package/dist/cohorts/rule.js +50 -0
- package/dist/collections/cohortMembers.d.ts +4 -0
- package/dist/collections/cohortMembers.js +95 -0
- package/dist/collections/experiments/config.js +157 -7
- package/dist/collections/experiments/editability.js +10 -6
- package/dist/collections/experiments/lockHook.js +39 -20
- package/dist/collections/index.js +4 -1
- package/dist/collections/phases.js +4 -1
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/db/adapter.d.ts +1 -1
- package/dist/db/adapter.js +14 -4
- package/dist/db/appends.js +1 -1
- package/dist/db/cohortMembership.d.ts +11 -0
- package/dist/db/cohortMembership.js +31 -0
- package/dist/db/cohortPool.d.ts +9 -0
- package/dist/db/cohortPool.js +53 -0
- package/dist/db/cohortTransactions.d.ts +3 -0
- package/dist/db/cohortTransactions.js +52 -0
- package/dist/db/cohorts.d.ts +72 -0
- package/dist/db/cohorts.js +280 -0
- package/dist/db/erase.d.ts +2 -0
- package/dist/db/erase.js +21 -2
- package/dist/db/events.d.ts +2 -0
- package/dist/db/events.js +8 -0
- package/dist/db/executor.d.ts +2 -0
- package/dist/db/executor.js +8 -0
- package/dist/db/locks.d.ts +7 -0
- package/dist/db/locks.js +13 -1
- package/dist/db/names.d.ts +95 -1
- package/dist/db/names.js +95 -1
- package/dist/db/occupancy.d.ts +21 -0
- package/dist/db/occupancy.js +46 -0
- package/dist/db/pageOccupancy.d.ts +4 -4
- package/dist/db/pageOccupancy.js +13 -10
- package/dist/db/pgExecutor.d.ts +4 -0
- package/dist/db/pgExecutor.js +1 -1
- package/dist/db/placements.js +1 -1
- package/dist/db/results.d.ts +5 -2
- package/dist/db/results.js +32 -5
- package/dist/db/slices.d.ts +9 -2
- package/dist/db/slices.js +15 -8
- package/dist/db/snapshots.d.ts +16 -1
- package/dist/db/snapshots.js +27 -2
- package/dist/db/sql.d.ts +2 -2
- package/dist/db/sql.js +1 -2
- package/dist/endpoints/cohortSources.d.ts +16 -0
- package/dist/endpoints/cohortSources.js +335 -0
- package/dist/endpoints/contentLocale.d.ts +1 -1
- package/dist/endpoints/events.js +82 -18
- package/dist/endpoints/index.js +45 -1
- package/dist/endpoints/pausedBy.d.ts +14 -0
- package/dist/endpoints/pausedBy.js +94 -0
- package/dist/endpoints/preflight.js +4 -1
- package/dist/endpoints/previewToken.js +2 -0
- package/dist/endpoints/results.d.ts +2 -2
- package/dist/endpoints/results.js +111 -3
- package/dist/endpoints/routeId.d.ts +2 -1
- package/dist/endpoints/routeId.js +6 -2
- package/dist/endpoints/summary.js +24 -1
- package/dist/endpoints/transitions.d.ts +7 -0
- package/dist/endpoints/transitions.js +50 -1
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +5 -3
- package/dist/exports/index.d.ts +2 -0
- package/dist/exports/index.js +1 -0
- package/dist/exports/runtimeProxy.d.ts +1 -0
- package/dist/exports/runtimeProxy.js +1 -0
- package/dist/hooks/blockRemovalRule.js +7 -4
- package/dist/hooks/pageGuard.js +1 -1
- package/dist/labels/status.d.ts +15 -0
- package/dist/labels/status.js +12 -0
- package/dist/manifest/compile.d.ts +15 -4
- package/dist/manifest/compile.js +91 -3
- package/dist/onInit.js +4 -1
- package/dist/options.d.ts +1 -0
- package/dist/options.js +10 -0
- package/dist/proxy/consentFallback.d.ts +1 -1
- package/dist/proxy/consentFallback.js +4 -4
- package/dist/proxy/control.d.ts +1 -1
- package/dist/proxy/control.js +2 -2
- package/dist/proxy/pageRewrite.d.ts +1 -1
- package/dist/proxy/pageRewrite.js +3 -2
- package/dist/proxy/resolve.js +76 -17
- package/dist/puck/ExperimentPicker.js +2 -1
- package/dist/puck/copy.d.ts +6 -5
- package/dist/puck/copy.js +3 -7
- package/dist/puck/editor/ExperimentSlotEditor.js +16 -5
- package/dist/puck/editor/QuickTestActions.js +7 -1
- package/dist/puck/editor/armWrites.js +6 -1
- package/dist/puck/editor/copy.d.ts +3 -0
- package/dist/puck/editor/copy.js +3 -0
- package/dist/puck/editor/editor.css +2 -1
- package/dist/puck/editor/editor.model.d.ts +2 -1
- package/dist/puck/editor/editor.model.js +2 -0
- package/dist/puck/editor/placementsCache.d.ts +1 -1
- package/dist/puck/editor/placementsCache.js +6 -3
- package/dist/results/analyse.d.ts +3 -1
- package/dist/results/analyse.js +20 -3
- package/dist/results/health.d.ts +11 -0
- package/dist/results/health.js +38 -0
- package/dist/results/power.d.ts +1 -1
- package/dist/results/power.js +1 -1
- package/dist/results/snapshot.d.ts +8 -2
- package/dist/results/snapshot.js +23 -1
- package/dist/results/unitValues.d.ts +48 -0
- package/dist/results/unitValues.js +166 -0
- package/dist/runtime/assign.d.ts +7 -3
- package/dist/runtime/assign.js +12 -4
- package/dist/runtime/cohortCookie.d.ts +15 -0
- package/dist/runtime/cohortCookie.js +72 -0
- package/dist/runtime/cohortLookup.d.ts +9 -0
- package/dist/runtime/cohortLookup.js +25 -0
- package/dist/runtime/eligibility.d.ts +11 -5
- package/dist/runtime/eligibility.js +33 -7
- package/dist/runtime/header.d.ts +1 -0
- package/dist/runtime/header.js +1 -1
- package/dist/runtime/proxyRuntime.js +5 -1
- package/dist/runtime/targeting.d.ts +3 -2
- package/dist/runtime/targeting.js +2 -1
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +41 -4
- package/dist/schedule/activeTime.d.ts +28 -0
- package/dist/schedule/activeTime.js +322 -0
- package/dist/schedule/ranges.d.ts +13 -0
- package/dist/schedule/ranges.js +11 -0
- package/dist/schedule/roundTime.d.ts +10 -0
- package/dist/schedule/roundTime.js +45 -0
- package/dist/schedule/types.d.ts +29 -0
- package/dist/schedule/types.js +1 -0
- package/dist/server/cohortLookup.d.ts +3 -0
- package/dist/server/cohortLookup.js +7 -0
- package/dist/server/eraseUser.d.ts +1 -0
- package/dist/server/getAssignments.js +63 -40
- package/dist/server/previewDraft.d.ts +1 -1
- package/dist/server/previewDraft.js +3 -2
- package/dist/server/recordExposures.js +4 -2
- package/dist/server/runResults.js +97 -150
- package/dist/testSurface/actions/LifecycleAction.d.ts +2 -1
- package/dist/testSurface/actions/LifecycleAction.js +15 -5
- package/dist/testSurface/actions/actions.model.d.ts +13 -2
- package/dist/testSurface/actions/actions.model.js +38 -5
- package/dist/testSurface/api.d.ts +13 -1
- package/dist/testSurface/api.js +19 -0
- package/dist/testSurface/copy/actions.d.ts +13 -0
- package/dist/testSurface/copy/actions.js +13 -0
- package/dist/testSurface/copy/cohorts.d.ts +68 -0
- package/dist/testSurface/copy/cohorts.js +81 -0
- package/dist/testSurface/copy/common.d.ts +2 -3
- package/dist/testSurface/copy/common.js +4 -4
- package/dist/testSurface/copy/inputs.d.ts +3 -0
- package/dist/testSurface/copy/inputs.js +3 -0
- package/dist/testSurface/copy/readiness.d.ts +20 -6
- package/dist/testSurface/copy/readiness.js +42 -9
- package/dist/testSurface/copy/results.d.ts +1 -0
- package/dist/testSurface/copy/results.js +1 -0
- package/dist/testSurface/copy/schedule.d.ts +58 -0
- package/dist/testSurface/copy/schedule.js +150 -0
- package/dist/testSurface/copy/surface.d.ts +2 -0
- package/dist/testSurface/copy/surface.js +2 -0
- package/dist/testSurface/copy/testPage.d.ts +12 -2
- package/dist/testSurface/copy/testPage.js +17 -2
- package/dist/testSurface/format/roundProgress.d.ts +13 -1
- package/dist/testSurface/format/roundProgress.js +34 -5
- package/dist/testSurface/format/scheduleStatus.d.ts +34 -0
- package/dist/testSurface/format/scheduleStatus.js +93 -0
- package/dist/testSurface/format/useScheduleClock.d.ts +3 -0
- package/dist/testSurface/format/useScheduleClock.js +20 -0
- package/dist/testSurface/labels.d.ts +4 -9
- package/dist/testSurface/labels.js +2 -7
- package/dist/testSurface/lockedNotice.model.d.ts +2 -2
- package/dist/testSurface/lockedNotice.model.js +16 -3
- package/dist/testSurface/readPreflight.d.ts +3 -0
- package/dist/testSurface/readPreflight.js +14 -0
- package/dist/testSurface/readinessRead.d.ts +2 -2
- package/dist/testSurface/results/DataQualityPanel.js +7 -7
- package/dist/testSurface/results/results.model.d.ts +1 -1
- package/dist/testSurface/results/results.model.js +34 -6
- package/dist/testSurface/review/cohortEstimate.d.ts +11 -0
- package/dist/testSurface/review/cohortEstimate.js +32 -0
- package/dist/testSurface/surface/contracts.d.ts +2 -1
- package/dist/testSurface/surface/contracts.js +1 -0
- package/dist/testSurface/surface/editorPlacement.d.ts +1 -0
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +3 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.js +121 -32
- package/dist/testSurface/surface/readiness/Banner.js +29 -11
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -2
- package/dist/testSurface/surface/readiness/readiness.model.js +35 -5
- package/dist/testSurface/surface/readiness/useTransition.js +17 -5
- package/dist/testSurface/surface/results/ResultsBody.js +44 -8
- package/dist/testSurface/surface/results/useResults.d.ts +16 -1
- package/dist/testSurface/surface/results/useResults.js +17 -6
- package/dist/testSurface/surface/test/CohortRuleEditor.d.ts +16 -0
- package/dist/testSurface/surface/test/CohortRuleEditor.js +492 -0
- package/dist/testSurface/surface/test/LengthSection.js +26 -6
- package/dist/testSurface/surface/test/ScheduleDateInput.d.ts +4 -0
- package/dist/testSurface/surface/test/ScheduleDateInput.js +15 -0
- package/dist/testSurface/surface/test/ScheduleSection.d.ts +2 -0
- package/dist/testSurface/surface/test/ScheduleSection.js +322 -0
- package/dist/testSurface/surface/test/Section.js +1 -1
- package/dist/testSurface/surface/test/TargetingSection.js +306 -182
- package/dist/testSurface/surface/test/TestSurface.js +9 -0
- package/dist/testSurface/surface/test/fields.d.ts +2 -1
- package/dist/testSurface/surface/test/fields.js +3 -3
- package/dist/testSurface/surface/test/jumpToSection.d.ts +1 -1
- package/dist/testSurface/surface/test/jumpToSection.js +4 -4
- package/dist/testSurface/surface/test/testPage.css +26 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +12 -1
- package/dist/testSurface/surface/testDocument.model.js +2 -1
- package/dist/testSurface/surface/useTestDocument.js +11 -4
- package/dist/testSurface/targeting/targeting.model.d.ts +2 -1
- package/dist/testSurface/targeting/targeting.model.js +1 -1
- package/dist/testSurface/useApi.d.ts +12 -0
- package/dist/transitions/addMetric.js +5 -2
- package/dist/transitions/allocate.js +6 -1
- package/dist/transitions/assertNoOverlap.d.ts +9 -0
- package/dist/transitions/assertNoOverlap.js +24 -0
- package/dist/transitions/buildCohorts.d.ts +10 -0
- package/dist/transitions/buildCohorts.js +68 -0
- package/dist/transitions/cancelSchedule.d.ts +4 -0
- package/dist/transitions/cancelSchedule.js +42 -0
- package/dist/transitions/checkStart.d.ts +17 -3
- package/dist/transitions/checkStart.js +20 -7
- package/dist/transitions/decide.js +35 -11
- package/dist/transitions/kernel.d.ts +3 -1
- package/dist/transitions/kernel.js +5 -2
- package/dist/transitions/pause.d.ts +4 -0
- package/dist/transitions/pause.js +35 -0
- package/dist/transitions/phaseRecord.d.ts +19 -2
- package/dist/transitions/phaseRecord.js +50 -11
- package/dist/transitions/placementInteractions.js +1 -1
- package/dist/transitions/preflightData.d.ts +11 -3
- package/dist/transitions/preflightData.js +134 -81
- package/dist/transitions/reschedule.d.ts +4 -0
- package/dist/transitions/reschedule.js +58 -0
- package/dist/transitions/resume.d.ts +4 -0
- package/dist/transitions/resume.js +32 -0
- package/dist/transitions/scheduledRound.d.ts +18 -0
- package/dist/transitions/scheduledRound.js +42 -0
- package/dist/transitions/start.d.ts +4 -0
- package/dist/transitions/start.js +136 -55
- package/dist/transitions/startReads.d.ts +14 -0
- package/dist/transitions/startReads.js +27 -0
- package/dist/transitions/stop.d.ts +10 -0
- package/dist/transitions/stop.js +35 -22
- package/dist/types/admin.d.ts +1 -1
- package/dist/types/contracts.d.ts +7 -1
- package/dist/types/endpoints.d.ts +72 -3
- package/dist/types/manifest.d.ts +9 -0
- package/dist/types/runtime.d.ts +5 -0
- package/dist/types/snapshot.d.ts +10 -0
- package/dist/types/status.d.ts +1 -0
- package/dist/types/status.js +1 -0
- package/dist/types/surface.d.ts +1 -0
- package/dist/ui/Feedback.d.ts +9 -6
- package/dist/ui/Feedback.js +10 -9
- package/dist/ui/SelectControl.js +1 -1
- package/dist/ui/ui.css +2 -1
- package/package.json +2 -2
|
@@ -3,9 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
|
|
|
3
3
|
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
|
-
import { placementUncheckedCopy } from '../../copy/readiness.js';
|
|
6
|
+
import { placementUncheckedCopy, scheduleOccupancyCopy } from '../../copy/readiness.js';
|
|
7
7
|
import { useEffect, useId, useState } from 'react';
|
|
8
|
-
import { TextInput, Select } from '../../../ui/Inputs.js';
|
|
8
|
+
import { TextInput, Select, Textarea } from '../../../ui/Inputs.js';
|
|
9
9
|
import { ConfirmDialog } from '../../../ui/Dialog.js';
|
|
10
10
|
import { isDestructiveAction } from '../../actions/actions.model.js';
|
|
11
11
|
import { MakeContentResult } from '../../actions/MakeContentResult.js';
|
|
@@ -20,33 +20,60 @@ import { actionWaitMessage } from './SaveStatus.js';
|
|
|
20
20
|
import { surfaceUrls } from '../../surfaceUrls.js';
|
|
21
21
|
import { Button } from '../../../ui/Button.js';
|
|
22
22
|
import { useTransition } from './useTransition.js';
|
|
23
|
+
import { formatLocalDateTime, isValidTimeZone, parseLocalDateTime } from '../../../schedule/activeTime.js';
|
|
24
|
+
import { COHORT_EDITOR } from '../../copy/cohorts.js';
|
|
25
|
+
import { readCohortRule } from '../../../cohorts/rule.js';
|
|
26
|
+
import { audienceReview, cohortSize } from '../../review/cohortEstimate.js';
|
|
27
|
+
import { SCHEDULE_COPY } from '../../copy/schedule.js';
|
|
28
|
+
import { ScheduleDateInput } from '../test/ScheduleDateInput.js';
|
|
23
29
|
export function dialogTitle(label, test) {
|
|
24
30
|
return test.doc?.name ? actionTitle(label, test.doc.name) : label;
|
|
25
31
|
}
|
|
26
|
-
/** Prop-driven ConfirmDialog adapter: same model/copy, section reload instead of a page reload. */
|
|
32
|
+
/** Prop-driven ConfirmDialog adapter: same model/copy, section reload instead of a page reload. */ const PAUSE_REASON_LIMIT = 500;
|
|
33
|
+
export function ConfirmAction({ test, surface, action, winnerLabel, onClose, onSuccess, unavailable, now = Date.now() }) {
|
|
27
34
|
const api = createApi(surface.apiRoute);
|
|
28
35
|
const [openedPhase] = useState(test.doc?.phase);
|
|
29
36
|
const [openedStatus] = useState(test.doc?.status);
|
|
30
37
|
const confirmationId = useId();
|
|
31
38
|
const [typed, setTyped] = useState('');
|
|
39
|
+
const [pauseReason, setPauseReason] = useState('');
|
|
40
|
+
const configuredZone = test.doc?.schedule?.timeZone || surface.timeZone || test.preflight?.scheduleTimeZone;
|
|
41
|
+
const zone = configuredZone && isValidTimeZone(configuredZone) ? configuredZone : 'UTC';
|
|
42
|
+
const [originalEnd] = useState(test.doc?.schedule?.endAt ?? null);
|
|
43
|
+
const [endAt, setEndAt] = useState(()=>formatLocalDateTime(originalEnd, zone));
|
|
44
|
+
const endInstant = endAt === formatLocalDateTime(originalEnd, zone) ? originalEnd : endAt ? parseLocalDateTime(endAt, zone) : null;
|
|
45
|
+
const endError = action.id !== 'reschedule' || !endAt ? undefined : !endInstant ? SCHEDULE_COPY.invalidTime : Date.parse(endInstant) <= Math.max(now, Date.parse(test.doc?.startedAt ?? '') || 0) ? scheduleOccupancyCopy.reschedulePast : undefined;
|
|
32
46
|
const [content, setContent] = useState(null);
|
|
33
47
|
const [reportBusy, setReportBusy] = useState(false);
|
|
34
48
|
const transition = useTransition(test, ()=>{
|
|
35
49
|
onClose();
|
|
36
50
|
onSuccess?.();
|
|
37
51
|
}, surface, true);
|
|
38
|
-
const changed = test.doc?.phase !== openedPhase || test.doc?.status !== openedStatus;
|
|
39
|
-
const
|
|
52
|
+
const changed = unavailable || test.doc?.phase !== openedPhase || test.doc?.status !== openedStatus || action.id === 'reschedule' && (test.doc?.schedule?.endAt ?? null) !== originalEnd;
|
|
53
|
+
const buildAction = action.id === 'build-cohorts';
|
|
54
|
+
const wait = action.id === 'start' || buildAction ? actionWaitMessage(test) : undefined;
|
|
55
|
+
const [building, setBuilding] = useState(false);
|
|
56
|
+
const [recoverAudience, setRecoverAudience] = useState(false);
|
|
57
|
+
const review = action.id === 'start' && test.doc ? audienceReview((test.doc.targeting ?? []).flatMap((row)=>{
|
|
58
|
+
const rule = readCohortRule(row);
|
|
59
|
+
return rule ? [
|
|
60
|
+
{
|
|
61
|
+
include: rule.include,
|
|
62
|
+
size: cohortSize(rule, test.preflight?.cohortSources?.find((source)=>String(source.id) === rule.experiment))
|
|
63
|
+
}
|
|
64
|
+
] : [];
|
|
65
|
+
}), test.doc.analysis?.minExposuresPerArm ?? 200, test.doc.arms.filter((arm)=>arm.kind !== 'holdout').length) : undefined;
|
|
40
66
|
const phrase = action.confirm.phrase ? expectedConfirm(action.confirm.phrase.action, winnerLabel) : null;
|
|
41
67
|
const ready = action.id !== 'start' || !transition.checking && canStartTest(test, surface.editorPlacementMessage);
|
|
42
68
|
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
69
|
const startMessage = wait ?? blocker;
|
|
44
|
-
const enabled = surface.canManage && !changed && ready && !test.statusReadPending && !transition.busy && !transition.reloadRequired && !wait && (!phrase || matchesConfirm(phrase, typed));
|
|
70
|
+
const enabled = surface.canManage && !changed && ready && !test.statusReadPending && !transition.busy && !transition.reloadRequired && !recoverAudience && !wait && !endError && (!phrase || matchesConfirm(phrase, typed));
|
|
45
71
|
async function submit(finish = false) {
|
|
46
72
|
if (!enabled || !test.doc) return;
|
|
47
73
|
const { id } = test.doc;
|
|
48
74
|
const phase = openedPhase;
|
|
49
75
|
await transition.run(finish ? 'archive' : action.id === 'start' && test.doc.status === 'stopped' ? 'restart' : action.id, async ()=>{
|
|
76
|
+
if (action.id === 'build-cohorts') return api.buildCohorts(id);
|
|
50
77
|
if (finish) return api.archive(id, {
|
|
51
78
|
mode: 'after-content',
|
|
52
79
|
phase
|
|
@@ -58,8 +85,22 @@ export function dialogTitle(label, test) {
|
|
|
58
85
|
confirmation: typed.trim()
|
|
59
86
|
} : {}
|
|
60
87
|
});
|
|
61
|
-
if (action.id === 'start')
|
|
88
|
+
if (action.id === 'start') {
|
|
89
|
+
const result = await api.start(id, openedPhase);
|
|
90
|
+
if (!result.ok && result.code === 'cohort-build-timeout') setRecoverAudience(true);
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
62
93
|
if (action.id === 'stop') return api.stop(id, openedPhase);
|
|
94
|
+
if (action.id === 'pause') return api.pause(id, {
|
|
95
|
+
phase,
|
|
96
|
+
reason: pauseReason.trim() || undefined
|
|
97
|
+
});
|
|
98
|
+
if (action.id === 'resume') return api.resume(id, phase);
|
|
99
|
+
if (action.id === 'cancel-schedule') return api.cancelSchedule(id, phase);
|
|
100
|
+
if (action.id === 'reschedule') return api.reschedule(id, {
|
|
101
|
+
phase,
|
|
102
|
+
endAt: endInstant
|
|
103
|
+
});
|
|
63
104
|
if (action.id === 'release-holdout') return api.releaseHoldout(id, phase);
|
|
64
105
|
const result = await api.makeContent(id, phase);
|
|
65
106
|
if (result.ok && result.data) {
|
|
@@ -81,17 +122,34 @@ export function dialogTitle(label, test) {
|
|
|
81
122
|
closeOnSuccess: finish || action.id !== 'make-content'
|
|
82
123
|
});
|
|
83
124
|
}
|
|
125
|
+
async function buildAudience() {
|
|
126
|
+
if (!test.doc || changed || wait || !surface.canManage || transition.busy) return;
|
|
127
|
+
setBuilding(true);
|
|
128
|
+
const id = test.doc.id;
|
|
129
|
+
try {
|
|
130
|
+
await transition.run('build-cohorts', async ()=>{
|
|
131
|
+
const result = await api.buildCohorts(id);
|
|
132
|
+
if (result.ok) setRecoverAudience(false);
|
|
133
|
+
return result;
|
|
134
|
+
}, {
|
|
135
|
+
closeOnSuccess: false
|
|
136
|
+
});
|
|
137
|
+
} finally{
|
|
138
|
+
setBuilding(false);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
84
141
|
function close() {
|
|
85
142
|
if (transition.busy || reportBusy) return;
|
|
86
143
|
onClose();
|
|
87
144
|
transition.refreshAfterDismissal();
|
|
88
145
|
}
|
|
89
146
|
const label = action.confirm.label ?? action.label;
|
|
147
|
+
const body = action.id === 'resume' && Date.parse(test.doc?.schedule?.endAt ?? '') <= now ? A.resumeEndedBody : action.confirm.body;
|
|
90
148
|
const caveats = action.id === 'start' ? readinessCaveats(test, surface.adminRoute) : [];
|
|
91
149
|
const description = caveats.length ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
92
150
|
children: [
|
|
93
151
|
/*#__PURE__*/ _jsx("p", {
|
|
94
|
-
children:
|
|
152
|
+
children: body
|
|
95
153
|
}),
|
|
96
154
|
/*#__PURE__*/ _jsx("ul", {
|
|
97
155
|
children: caveats.map(({ key, sentence, href })=>/*#__PURE__*/ _jsx("li", {
|
|
@@ -102,14 +160,19 @@ export function dialogTitle(label, test) {
|
|
|
102
160
|
}, key))
|
|
103
161
|
})
|
|
104
162
|
]
|
|
105
|
-
}) :
|
|
163
|
+
}) : body;
|
|
106
164
|
return /*#__PURE__*/ _jsxs(ConfirmDialog, {
|
|
107
165
|
title: action.confirm.title === label ? dialogTitle(label, test) : action.confirm.title,
|
|
108
166
|
onClose: close,
|
|
109
167
|
description: content ? undefined : description,
|
|
110
168
|
busy: transition.busy || reportBusy,
|
|
111
|
-
busyLabel: C.changing,
|
|
169
|
+
busyLabel: buildAction || building ? COHORT_EDITOR.progress : C.changing,
|
|
112
170
|
cancelLabel: content ? A.done : A.cancel,
|
|
171
|
+
secondaryAction: recoverAudience ? /*#__PURE__*/ _jsx(Button, {
|
|
172
|
+
disabled: !!wait || changed || transition.busy,
|
|
173
|
+
onClick: ()=>void buildAudience(),
|
|
174
|
+
children: COHORT_EDITOR.build
|
|
175
|
+
}) : undefined,
|
|
113
176
|
error: transition.error ?? (changed && !transition.busy && !content ? A.actionChanged : null),
|
|
114
177
|
confirm: content ? undefined : {
|
|
115
178
|
label,
|
|
@@ -133,28 +196,54 @@ export function dialogTitle(label, test) {
|
|
|
133
196
|
if (result.ok) test.acceptTransition?.(result.data);
|
|
134
197
|
await test.reload();
|
|
135
198
|
}
|
|
136
|
-
}) : /*#__PURE__*/
|
|
137
|
-
children:
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
199
|
+
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
200
|
+
children: [
|
|
201
|
+
phrase ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
202
|
+
children: [
|
|
203
|
+
/*#__PURE__*/ _jsxs("p", {
|
|
204
|
+
children: [
|
|
205
|
+
A.typePhrase,
|
|
206
|
+
" ",
|
|
207
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
208
|
+
children: phrase
|
|
209
|
+
})
|
|
210
|
+
]
|
|
211
|
+
}),
|
|
212
|
+
/*#__PURE__*/ _jsx(TextInput, {
|
|
213
|
+
id: confirmationId,
|
|
214
|
+
label: A.confirmation,
|
|
215
|
+
value: typed,
|
|
216
|
+
readOnly: transition.busy,
|
|
217
|
+
onChange: (event)=>setTyped(event.target.value)
|
|
218
|
+
})
|
|
219
|
+
]
|
|
220
|
+
}) : null,
|
|
221
|
+
action.id === 'pause' ? /*#__PURE__*/ _jsx(Textarea, {
|
|
222
|
+
id: confirmationId,
|
|
223
|
+
label: A.pauseReason,
|
|
224
|
+
value: pauseReason,
|
|
225
|
+
maxLength: PAUSE_REASON_LIMIT,
|
|
226
|
+
help: A.pauseCount(pauseReason.length, PAUSE_REASON_LIMIT),
|
|
227
|
+
readOnly: transition.busy,
|
|
228
|
+
onChange: (event)=>setPauseReason(event.target.value.slice(0, PAUSE_REASON_LIMIT))
|
|
229
|
+
}) : null,
|
|
230
|
+
action.id === 'reschedule' ? /*#__PURE__*/ _jsx(ScheduleDateInput, {
|
|
231
|
+
label: SCHEDULE_COPY.end,
|
|
232
|
+
timeZone: zone,
|
|
233
|
+
value: endAt,
|
|
234
|
+
error: endError,
|
|
235
|
+
readOnly: transition.busy,
|
|
236
|
+
onChange: (event)=>setEndAt(event.target.value)
|
|
237
|
+
}) : null
|
|
238
|
+
]
|
|
157
239
|
}),
|
|
240
|
+
review?.lines.map((line, index)=>/*#__PURE__*/ _jsx("p", {
|
|
241
|
+
children: line
|
|
242
|
+
}, index)),
|
|
243
|
+
review?.warning ? /*#__PURE__*/ _jsx("p", {
|
|
244
|
+
className: "xp-ui-help",
|
|
245
|
+
children: review.warning
|
|
246
|
+
}) : null,
|
|
158
247
|
!content && startMessage && startMessage !== transition.error ? /*#__PURE__*/ _jsx("p", {
|
|
159
248
|
children: startMessage
|
|
160
249
|
}) : null
|
|
@@ -256,7 +345,7 @@ export function dialogTitle(label, test) {
|
|
|
256
345
|
const available = metrics.filter((item)=>!attached.has(String(item.id)));
|
|
257
346
|
const empty = !loading && !loadError && !available.length;
|
|
258
347
|
const selected = available.find((item)=>String(item.id) === metric);
|
|
259
|
-
const changed = test.doc?.status !== 'running' || test.doc?.phase !== openedPhase;
|
|
348
|
+
const changed = test.doc?.status !== 'running' && test.doc?.status !== 'paused' || test.doc?.phase !== openedPhase;
|
|
260
349
|
const disabled = transition.busy || test.statusReadPending || changed || transition.reloadRequired && transition.error !== API_MESSAGES.goalNotFound;
|
|
261
350
|
function close() {
|
|
262
351
|
if (transition.busy) return;
|
|
@@ -5,12 +5,14 @@ import { useEffect, useState } from 'react';
|
|
|
5
5
|
import { Button } from '../../../ui/Button.js';
|
|
6
6
|
import { actionWaitMessage, SaveStatus, saveStatusMessage } from './SaveStatus.js';
|
|
7
7
|
import { jumpToSection } from '../test/jumpToSection.js';
|
|
8
|
-
import { actionGroupLabel, availableActions } from '../../actions/actions.model.js';
|
|
8
|
+
import { actionGroupLabel, availableActions, buildAudienceAction } from '../../actions/actions.model.js';
|
|
9
9
|
import { createApi } from '../../api.js';
|
|
10
10
|
import { TEST_PAGE } from '../../copy/testPage.js';
|
|
11
11
|
import { READINESS_COPY as C, decidedCopy, fixFieldsNext, runningCopy, stoppedCopy } from '../../copy/readiness.js';
|
|
12
|
+
import { useScheduleClock } from '../../format/useScheduleClock.js';
|
|
13
|
+
import { scheduleStatus } from '../../format/scheduleStatus.js';
|
|
12
14
|
import { useDateFormatter } from '../../format/useDateFormatter.js';
|
|
13
|
-
import {
|
|
15
|
+
import { testProgress, displayDate, blockingSteps, pageReadinessContext, errorSection, readinessCaveats } from './readiness.model.js';
|
|
14
16
|
import { LifecycleButton, LifecycleDialog } from '../../actions/LifecycleAction.js';
|
|
15
17
|
import { preflightPlacementLabel } from '../../placements/placementLabels.js';
|
|
16
18
|
import { BlockerList } from './BlockerList.js';
|
|
@@ -19,19 +21,24 @@ export function ReadinessContent({ test, surface, resultsVersion, embedded = fal
|
|
|
19
21
|
const [selected, setSelected] = useState(null);
|
|
20
22
|
const [audience, setAudience] = useState();
|
|
21
23
|
const doc = test.doc;
|
|
22
|
-
const
|
|
24
|
+
const summary = audience?.phase === doc.phase ? audience?.summary : undefined;
|
|
25
|
+
const now = useScheduleClock([
|
|
26
|
+
doc
|
|
27
|
+
], surface.timeZone);
|
|
28
|
+
const schedule = scheduleStatus(doc, now, test.preflight?.timing ?? summary?.timing, surface.timeZone, test.preflight?.pauseAttribution);
|
|
29
|
+
const progress = schedule.status === 'running' ? testProgress(doc, now, summary?.timing) : null;
|
|
23
30
|
useEffect(()=>{
|
|
24
31
|
let active = true;
|
|
25
32
|
// Refreshes retain the last count for this round while loading.
|
|
26
|
-
if (surface.canReadResults &&
|
|
33
|
+
if (surface.canReadResults && (schedule.status === 'running' || schedule.status === 'paused')) {
|
|
27
34
|
void Promise.resolve().then(()=>active ? createApi(surface.apiRoute).summary([
|
|
28
35
|
doc.id
|
|
29
36
|
]) : undefined).then((result)=>{
|
|
30
37
|
if (!result?.ok) return;
|
|
31
|
-
const
|
|
32
|
-
if (active &&
|
|
38
|
+
const next = result.data?.[doc.id];
|
|
39
|
+
if (active && next && Number.isFinite(next.exposures)) setAudience({
|
|
33
40
|
phase: doc.phase,
|
|
34
|
-
|
|
41
|
+
summary: next
|
|
35
42
|
});
|
|
36
43
|
}).catch(()=>{});
|
|
37
44
|
}
|
|
@@ -40,7 +47,7 @@ export function ReadinessContent({ test, surface, resultsVersion, embedded = fal
|
|
|
40
47
|
};
|
|
41
48
|
}, [
|
|
42
49
|
doc.id,
|
|
43
|
-
|
|
50
|
+
schedule.status,
|
|
44
51
|
doc.phase,
|
|
45
52
|
surface.apiRoute,
|
|
46
53
|
surface.canReadResults,
|
|
@@ -93,13 +100,15 @@ export function ReadinessContent({ test, surface, resultsVersion, embedded = fal
|
|
|
93
100
|
const actions = availableActions({
|
|
94
101
|
...doc,
|
|
95
102
|
decision,
|
|
103
|
+
now,
|
|
104
|
+
timeZone: surface.timeZone,
|
|
96
105
|
canManage: surface.canManage,
|
|
97
106
|
canReadResults: surface.canReadResults
|
|
98
107
|
}).filter((action)=>action.id !== 'delete' && (!embedded || ![
|
|
99
108
|
'decide',
|
|
100
109
|
'release-pages'
|
|
101
110
|
].includes(action.id)));
|
|
102
|
-
const sentence = test.statusReadPending ? C.checking : setup ? ready && !blockers.length ? C.ready : null :
|
|
111
|
+
const sentence = test.statusReadPending ? C.checking : setup ? ready && !blockers.length ? C.ready : null : progress ? runningCopy(displayDate(doc.startedAt, formatDate), summary?.exposures ?? null, progress.daysToGo, progress.weekendsToGo) : doc.status === 'decided' ? decidedCopy(displayDate(doc.decidedAt, formatDate), winner) : doc.status === 'archived' ? C.archived : null;
|
|
103
112
|
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
104
113
|
children: [
|
|
105
114
|
/*#__PURE__*/ _jsx("div", {
|
|
@@ -143,15 +152,19 @@ export function ReadinessContent({ test, surface, resultsVersion, embedded = fal
|
|
|
143
152
|
role: "status",
|
|
144
153
|
children: sentence
|
|
145
154
|
}) : null,
|
|
155
|
+
!test.statusReadPending && embedded && schedule.line ? /*#__PURE__*/ _jsx("p", {
|
|
156
|
+
role: "status",
|
|
157
|
+
children: schedule.line
|
|
158
|
+
}) : null,
|
|
146
159
|
setup ? /*#__PURE__*/ _jsx(BlockerList, {
|
|
147
160
|
steps: blockers,
|
|
148
161
|
renderSentence: (_, index)=>{
|
|
149
162
|
const step = blockers[index];
|
|
150
163
|
return step.section === 'header' ? step.sentence : /*#__PURE__*/ _jsx("a", {
|
|
151
|
-
href: `#section-${step.section}`,
|
|
164
|
+
href: step.rule === undefined ? `#section-${step.section}` : `#xp-targeting-${step.rule}`,
|
|
152
165
|
onClick: (event)=>{
|
|
153
166
|
event.preventDefault();
|
|
154
|
-
if (step.section !== 'header') jumpToSection(step.section, step.arm);
|
|
167
|
+
if (step.section !== 'header') jumpToSection(step.section, step.arm, step.rule, event.currentTarget.ownerDocument);
|
|
155
168
|
},
|
|
156
169
|
children: step.sentence
|
|
157
170
|
});
|
|
@@ -170,6 +183,11 @@ export function ReadinessContent({ test, surface, resultsVersion, embedded = fal
|
|
|
170
183
|
},
|
|
171
184
|
children: C.refresh
|
|
172
185
|
}) : null,
|
|
186
|
+
setup && surface.canManage && readinessBlockers.some((step)=>step.code === 'cohort-build-timeout') ? /*#__PURE__*/ _jsx(LifecycleButton, {
|
|
187
|
+
action: buildAudienceAction,
|
|
188
|
+
disabled: !!wait || test.statusReadPending || test.preflightPending,
|
|
189
|
+
onClick: ()=>setSelected(buildAudienceAction)
|
|
190
|
+
}) : null,
|
|
173
191
|
actions.map((item)=>{
|
|
174
192
|
if (test.statusReadPending) return null;
|
|
175
193
|
const reason = item.id === 'start' ? startReason : item.unavailable;
|
|
@@ -4,7 +4,7 @@ import type { TestDocument } from '../testDocument.model.js';
|
|
|
4
4
|
import type { DateFormatter } from '../../format/date.js';
|
|
5
5
|
import type { ActionTestApi, SurfaceProps } from '../contracts.js';
|
|
6
6
|
import { type SectionId } from '../contracts.js';
|
|
7
|
-
export type ReadinessContext = Pick<TestDocument, 'arms' | 'unitType' | 'flagPoint'> & {
|
|
7
|
+
export type ReadinessContext = Pick<TestDocument, 'arms' | 'unitType' | 'flagPoint' | 'targeting'> & {
|
|
8
8
|
editorPage?: SurfaceProps['editorPage'];
|
|
9
9
|
editorPlacementMessage?: string;
|
|
10
10
|
collectionLabel?: string;
|
|
@@ -29,6 +29,7 @@ type ReadinessCaveat = {
|
|
|
29
29
|
};
|
|
30
30
|
export declare function readinessCaveats({ doc, preflight, statusReadPending }: Pick<ActionTestApi, 'doc' | 'preflight' | 'statusReadPending'>, adminRoute: string): ReadinessCaveat[];
|
|
31
31
|
export declare function blockingSteps(preflight: PreflightResult | null, ctx: ReadinessContext): {
|
|
32
|
+
rule?: number | undefined;
|
|
32
33
|
arm?: import("../../../types/armKey.js").ArmKey | undefined;
|
|
33
34
|
section: "header" | SectionId;
|
|
34
35
|
sentence: string;
|
|
@@ -36,6 +37,7 @@ export declare function blockingSteps(preflight: PreflightResult | null, ctx: Re
|
|
|
36
37
|
}[];
|
|
37
38
|
export declare function nextStep(preflight: PreflightResult | null, ctx: ReadinessContext): {
|
|
38
39
|
nextStep?: string | undefined;
|
|
40
|
+
rule?: number | undefined;
|
|
39
41
|
arm?: import("../../../types/armKey.js").ArmKey | undefined;
|
|
40
42
|
section: "header" | SectionId;
|
|
41
43
|
sentence: string;
|
|
@@ -51,7 +53,23 @@ export declare function sectionDone(test: {
|
|
|
51
53
|
doc?: Pick<TestDocument, 'targeting'> | null;
|
|
52
54
|
}): Record<SectionId, boolean>;
|
|
53
55
|
export declare function displayDate(value: unknown, formatDate: DateFormatter): string | null;
|
|
54
|
-
export declare function
|
|
56
|
+
export declare function testProgress(doc: TestDocument, now: number, timing?: import('../../../types/endpoints.js').SummaryResponse[string]['timing']): {
|
|
57
|
+
day: number;
|
|
58
|
+
plannedDays: number | null;
|
|
59
|
+
daysToGo: number | null;
|
|
60
|
+
end: number | null;
|
|
61
|
+
timeZone: string;
|
|
62
|
+
daysPerWeekend: number | null;
|
|
63
|
+
weekendsToGo: number | null;
|
|
64
|
+
} | {
|
|
65
|
+
day: number | null;
|
|
66
|
+
plannedDays: number | null;
|
|
67
|
+
end: number | null;
|
|
68
|
+
daysToGo: number | null;
|
|
69
|
+
timeZone: undefined;
|
|
70
|
+
weekendsToGo: null;
|
|
71
|
+
daysPerWeekend: null;
|
|
72
|
+
};
|
|
55
73
|
export declare function pageReadinessContext(doc: TestDocument, preflight: PreflightResult | null, surface: SurfaceProps): ReadinessContext;
|
|
56
74
|
/** First affected row in arm order; shared by the wizard and the test-page jump. */
|
|
57
75
|
export declare function readinessArm(code: ReadinessCode, detail: unknown, ctx: ReadinessContext): import("../../../types/armKey.js").ArmKey | undefined;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isCohortRule } from '../../../cohorts/rule.js';
|
|
2
|
+
import { COHORT_COPY } from '../../copy/cohorts.js';
|
|
1
3
|
import { nestedTestCopy } from '../../../puck/nestedTestCopy.js';
|
|
2
4
|
import { SURFACE_COPY } from '../../copy/surface.js';
|
|
3
5
|
import { roundProgress } from '../../format/roundProgress.js';
|
|
@@ -7,6 +9,7 @@ import { PLACEMENT_LANGUAGES, placementLanguageSuffix } from '../../copy/languag
|
|
|
7
9
|
import { METRICS_COPY } from '../../copy/metrics.js';
|
|
8
10
|
import { preflightPlacementLabel } from '../../placements/placementLabels.js';
|
|
9
11
|
import { hasBrowserWritablePrimary } from '../../readinessRead.js';
|
|
12
|
+
import { occupancyMessage } from '../../copy/readiness.js';
|
|
10
13
|
import { normalisePath } from '../../../runtime/normalisePath.js';
|
|
11
14
|
import { testPageCollection } from '../pagePicker/pagePicker.model.js';
|
|
12
15
|
import { SECTION_ORDER } from '../contracts.js';
|
|
@@ -162,7 +165,7 @@ function emptyContentGuidance(detail, ctx) {
|
|
|
162
165
|
const parameter = typeof issue.field === 'string' ? point?.params[issue.field]?.label ?? issue.field : C.parameterFallback;
|
|
163
166
|
return parameterNext(parameter, group(issue.arm, ctx));
|
|
164
167
|
}),
|
|
165
|
-
'flag-point-busy': row('what', ()=>C.busy),
|
|
168
|
+
'flag-point-busy': row('what', (detail)=>occupancyMessage(object(detail).occupancy) ?? C.busy),
|
|
166
169
|
'flag-placement-missing': row('versions', (detail, ctx)=>{
|
|
167
170
|
if (typeof detail === 'string') return placementFailureCopy(detail);
|
|
168
171
|
const value = object(detail);
|
|
@@ -175,13 +178,13 @@ function emptyContentGuidance(detail, ctx) {
|
|
|
175
178
|
'unit-source-mismatch': row('win', (_, ctx)=>goalPeopleNext(ctx.unitType === 'user' ? 'signed-in users' : 'visitors')),
|
|
176
179
|
'no-planned-duration': row('length', ()=>C.noDuration),
|
|
177
180
|
'no-reach-per-day': row('length', ()=>C.noReach),
|
|
178
|
-
'layer-full': row('versions', ()=>C.full),
|
|
181
|
+
'layer-full': row('versions', (detail)=>occupancyMessage(object(detail).occupancy) ?? C.full),
|
|
179
182
|
'layer-unit-mismatch': row('header', ()=>C.differentPeople),
|
|
180
183
|
'page-in-use': {
|
|
181
184
|
...row('versions', (detail, ctx)=>{
|
|
182
185
|
const paths = object(detail).paths;
|
|
183
186
|
const path = text(Array.isArray(paths) ? paths[0] : undefined, 'this page');
|
|
184
|
-
return pageInUseCopy(path, pageArm(path, ctx)?.kind === 'variant', ctx.arms.find((arm)=>arm.kind === 'control')?.label);
|
|
187
|
+
return occupancyMessage(object(detail).occupancy) ?? pageInUseCopy(path, pageArm(path, ctx)?.kind === 'variant', ctx.arms.find((arm)=>arm.kind === 'control')?.label);
|
|
185
188
|
}),
|
|
186
189
|
nextStep: C.choosePages
|
|
187
190
|
},
|
|
@@ -219,6 +222,11 @@ function emptyContentGuidance(detail, ctx) {
|
|
|
219
222
|
...row('who', ()=>C.blockPathRule),
|
|
220
223
|
nextStep: C.removeRule
|
|
221
224
|
},
|
|
225
|
+
'cohort-source-invalid': row('who', ()=>COHORT_COPY.invalid),
|
|
226
|
+
'cohort-cycle': row('who', ()=>COHORT_COPY.cycle),
|
|
227
|
+
'cohort-source-open': row('who', ()=>COHORT_COPY.open),
|
|
228
|
+
'cohort-lookup-missing': row('who', ()=>COHORT_COPY.lookup),
|
|
229
|
+
'cohort-build-timeout': row('who', ()=>COHORT_COPY.timeout),
|
|
222
230
|
'invalid-targeting-rule': row('who', (detail)=>{
|
|
223
231
|
const attributes = object(detail).attributes;
|
|
224
232
|
return ruleNext(detailText(detail, Array.isArray(attributes) && attributes.length ? attributes.map(String).join(', ') : C.ruleFallback));
|
|
@@ -296,6 +304,9 @@ export function blockingSteps(preflight, ctx) {
|
|
|
296
304
|
if (check.ok || (mapping?.section ?? 'what') !== section) return [];
|
|
297
305
|
const sentence = mapping ? mapping.next(check.detail, ctx) : SURFACE_COPY.next;
|
|
298
306
|
const arm = readinessArm(check.code, check.detail, ctx);
|
|
307
|
+
const index = object(check.detail).rule;
|
|
308
|
+
const firstCohort = ctx.targeting?.findIndex(isCohortRule);
|
|
309
|
+
const rule = check.code.startsWith('cohort-') ? typeof index === 'number' && Number.isSafeInteger(index) && index >= 0 ? index : firstCohort : undefined;
|
|
299
310
|
return sentence ? [
|
|
300
311
|
{
|
|
301
312
|
section,
|
|
@@ -303,6 +314,9 @@ export function blockingSteps(preflight, ctx) {
|
|
|
303
314
|
code: check.code,
|
|
304
315
|
...arm ? {
|
|
305
316
|
arm
|
|
317
|
+
} : {},
|
|
318
|
+
...rule !== undefined && rule >= 0 ? {
|
|
319
|
+
rule
|
|
306
320
|
} : {}
|
|
307
321
|
}
|
|
308
322
|
] : [];
|
|
@@ -331,6 +345,7 @@ export function errorSection(path) {
|
|
|
331
345
|
if (/^metrics(\.|$)/.test(path)) return 'win';
|
|
332
346
|
if (/^(targeting)(\.|$)/.test(path)) return 'who';
|
|
333
347
|
if (/^analysis\.(plannedDurationDays|reachPerDay)(\.|$)/.test(path)) return 'length';
|
|
348
|
+
if (/^schedule(\.|$)/.test(path)) return 'schedule';
|
|
334
349
|
if (/^(analysis|exposurePolicy|layer)(\.|$)/.test(path)) return 'advanced';
|
|
335
350
|
}
|
|
336
351
|
export function sectionBlocked(test, section) {
|
|
@@ -347,8 +362,23 @@ export function displayDate(value, formatDate) {
|
|
|
347
362
|
if (typeof value !== 'string' || !Number.isFinite(Date.parse(value))) return null;
|
|
348
363
|
return formatDate(value);
|
|
349
364
|
}
|
|
350
|
-
export function
|
|
351
|
-
|
|
365
|
+
export function testProgress(doc, now, timing) {
|
|
366
|
+
const saved = doc.schedule;
|
|
367
|
+
const schedule = saved?.timeZone && (saved.startAt || saved.endAt || saved.windows?.length) ? {
|
|
368
|
+
startAt: saved.startAt ?? undefined,
|
|
369
|
+
endAt: saved.endAt ?? undefined,
|
|
370
|
+
timeZone: saved.timeZone,
|
|
371
|
+
windows: saved.windows ?? []
|
|
372
|
+
} : undefined;
|
|
373
|
+
const pauses = doc.status === 'paused' && doc.pausedAt ? [
|
|
374
|
+
{
|
|
375
|
+
from: doc.pausedAt
|
|
376
|
+
}
|
|
377
|
+
] : [];
|
|
378
|
+
return roundProgress(doc.startedAt, doc.analysis?.plannedDurationDays, now, undefined, timing && timing.phase === doc.phase ? timing : {
|
|
379
|
+
schedule,
|
|
380
|
+
pauses
|
|
381
|
+
});
|
|
352
382
|
}
|
|
353
383
|
function pageArm(path, ctx) {
|
|
354
384
|
return ctx.arms.find((arm)=>arm.pageTarget && normalisePath(arm.pageTarget) === normalisePath(path));
|
|
@@ -6,6 +6,7 @@ import { API_MESSAGES } from '../../copy/common.js';
|
|
|
6
6
|
const inFlight = useRef(false);
|
|
7
7
|
const [busyRound, setBusyRound] = useState();
|
|
8
8
|
const [checking, setChecking] = useState(false);
|
|
9
|
+
const [code, setCode] = useState();
|
|
9
10
|
const [error, setError] = useState(null);
|
|
10
11
|
const [reloadRequired, setReloadRequired] = useState(false);
|
|
11
12
|
const round = JSON.stringify([
|
|
@@ -30,7 +31,7 @@ import { API_MESSAGES } from '../../copy/common.js';
|
|
|
30
31
|
latestAnswer.current = answer;
|
|
31
32
|
// Dismissal mutates the lifetime once; a later ready answer cannot revive it.
|
|
32
33
|
useEffect(()=>{
|
|
33
|
-
if (!refusal.current) return;
|
|
34
|
+
if (!refusal.current || code === 'cohort-build-timeout') return;
|
|
34
35
|
if (refusal.current.status !== test.doc?.status) {
|
|
35
36
|
if (!keepRefusal) clearError();
|
|
36
37
|
return;
|
|
@@ -55,6 +56,7 @@ import { API_MESSAGES } from '../../copy/common.js';
|
|
|
55
56
|
}, [
|
|
56
57
|
answer,
|
|
57
58
|
checking,
|
|
59
|
+
code,
|
|
58
60
|
error,
|
|
59
61
|
keepRefusal,
|
|
60
62
|
test.preflightPending,
|
|
@@ -64,9 +66,10 @@ import { API_MESSAGES } from '../../copy/common.js';
|
|
|
64
66
|
function clearError() {
|
|
65
67
|
refusal.current = null;
|
|
66
68
|
setError(null);
|
|
69
|
+
setCode(undefined);
|
|
67
70
|
}
|
|
68
71
|
async function run(kind, request, { closeOnSuccess = true } = {}) {
|
|
69
|
-
if (inFlight.current || test.statusReadPending || (kind === 'start' || kind === 'restart') && (test.hasUnsaved || test.saving === 'saving')) return;
|
|
72
|
+
if (inFlight.current || test.statusReadPending || (kind === 'start' || kind === 'restart' || kind === 'build-cohorts') && (test.hasUnsaved || test.saving === 'saving')) return;
|
|
70
73
|
clearError();
|
|
71
74
|
inFlight.current = true;
|
|
72
75
|
setBusyRound(round);
|
|
@@ -75,8 +78,11 @@ import { API_MESSAGES } from '../../copy/common.js';
|
|
|
75
78
|
try {
|
|
76
79
|
const result = await request();
|
|
77
80
|
if (result.ok) {
|
|
78
|
-
test.
|
|
79
|
-
|
|
81
|
+
if (kind === 'build-cohorts') await test.refreshPreflight(true);
|
|
82
|
+
else {
|
|
83
|
+
test.acceptTransition?.(result.data);
|
|
84
|
+
await test.reload();
|
|
85
|
+
}
|
|
80
86
|
if (closeOnSuccess) onSuccess?.();
|
|
81
87
|
// Keep successful actions latched until the dialog or old status goes away.
|
|
82
88
|
if (closeOnSuccess && kind !== 'allocate') {
|
|
@@ -87,6 +93,7 @@ import { API_MESSAGES } from '../../copy/common.js';
|
|
|
87
93
|
}
|
|
88
94
|
}
|
|
89
95
|
} else {
|
|
96
|
+
setCode(result.code);
|
|
90
97
|
if (keepRefusal && [
|
|
91
98
|
401,
|
|
92
99
|
403,
|
|
@@ -99,7 +106,12 @@ import { API_MESSAGES } from '../../copy/common.js';
|
|
|
99
106
|
return;
|
|
100
107
|
}
|
|
101
108
|
refused = true;
|
|
102
|
-
readDocument = result.
|
|
109
|
+
readDocument = result.code !== 'cohort-build-timeout' && ([
|
|
110
|
+
409,
|
|
111
|
+
403,
|
|
112
|
+
401,
|
|
113
|
+
404
|
|
114
|
+
].includes(result.status) || result.code === 'invalid-status' || result.code === 'stale-draft');
|
|
103
115
|
setError(result.message);
|
|
104
116
|
}
|
|
105
117
|
} catch {
|