@delmaredigital/payload-experiments 0.4.1 → 0.5.1
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/blocks/placementLocale.d.ts +14 -0
- package/dist/blocks/placementLocale.js +80 -13
- package/dist/blocks/placementPublication.d.ts +14 -0
- package/dist/blocks/placementPublication.js +24 -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 +2 -1
- package/dist/db/adapter.js +17 -4
- package/dist/db/appends.d.ts +2 -1
- package/dist/db/appends.js +3 -2
- package/dist/db/bulkPlacementRemoval.d.ts +5 -0
- package/dist/db/bulkPlacementRemoval.js +7 -2
- 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/pageBindings.d.ts +2 -2
- package/dist/db/pageBindings.js +3 -3
- 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.d.ts +6 -1
- package/dist/db/placements.js +27 -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/duplicateOriginal.d.ts +1 -0
- 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.d.ts +1 -1
- package/dist/hooks/blockRemovalRule.js +12 -8
- package/dist/hooks/pageGuard.d.ts +7 -1
- package/dist/hooks/pageGuard.js +177 -4
- package/dist/hooks/puckNestedTests.d.ts +1 -1
- package/dist/hooks/puckNestedTests.js +3 -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 -6
- 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/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +42 -20
- 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 +40 -13
- 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.d.ts +7 -2
- package/dist/transitions/placementInteractions.js +9 -7
- package/dist/transitions/placements.d.ts +4 -3
- package/dist/transitions/placements.js +28 -14
- 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 +139 -56
- 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
|
@@ -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 {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { COHORT_EDITOR } from '../../copy/cohorts.js';
|
|
3
4
|
import { theme } from '../../theme.js';
|
|
4
5
|
import { useEffect, useId, useRef, useState } from 'react';
|
|
5
6
|
import { Button } from '../../../ui/Button.js';
|
|
@@ -27,6 +28,8 @@ import { recommendation } from './recommendation.model.js';
|
|
|
27
28
|
import { useResults } from './useResults.js';
|
|
28
29
|
import { DecideDialog } from '../../actions/DecideDialog.js';
|
|
29
30
|
import { Banner } from '../../../ui/Banner.js';
|
|
31
|
+
import { displayStatus } from '../../labels.js';
|
|
32
|
+
import { useScheduleClock } from '../../format/useScheduleClock.js';
|
|
30
33
|
import { availableActions } from '../../actions/actions.model.js';
|
|
31
34
|
import { PagesReleased, ReleasePagesDialog } from './ReleasePages.js';
|
|
32
35
|
import { usePlacementLabels } from '../../placements/usePlacementLabels.js';
|
|
@@ -46,7 +49,10 @@ export function ResultsBody({ id, surface, onRecomputed, renderPage, onChanged,
|
|
|
46
49
|
}
|
|
47
50
|
function ResultsContent({ id, surface, onRecomputed, renderPage, onChanged, documentVersion, liveDocument, statusReadPending }) {
|
|
48
51
|
const formatDate = useDateFormatter();
|
|
49
|
-
const results = useResults(id, surface,
|
|
52
|
+
const results = useResults(id, surface, {
|
|
53
|
+
documentVersion,
|
|
54
|
+
documentPhase: liveDocument?.phase
|
|
55
|
+
});
|
|
50
56
|
const { api, doc, round, phases, state, data } = results;
|
|
51
57
|
const managerDoc = liveDocument ?? doc;
|
|
52
58
|
const manage = surface.canManage && surface.canReadResults;
|
|
@@ -114,16 +120,28 @@ function ResultsContent({ id, surface, onRecomputed, renderPage, onChanged, docu
|
|
|
114
120
|
});
|
|
115
121
|
const latestPhase = phases.find((phase)=>phase.phase === newestRound);
|
|
116
122
|
const decision = data?.decision ?? doc?.decision;
|
|
117
|
-
const status = managerDoc?.status ?? (data?.decision ? 'decided' : latestPhase?.phaseKind === 'test' && latestPhase.endedAt === null ? 'running' : 'stopped');
|
|
123
|
+
const status = managerDoc?.status ?? data?.experiment?.status ?? (data?.decision ? 'decided' : latestPhase?.phaseKind === 'test' && latestPhase.endedAt === null ? 'running' : 'stopped');
|
|
124
|
+
const startedAt = liveDocument?.startedAt ?? latestPhase?.startedAt;
|
|
125
|
+
const now = useScheduleClock([
|
|
126
|
+
{
|
|
127
|
+
status,
|
|
128
|
+
startedAt,
|
|
129
|
+
schedule: liveDocument?.schedule ?? latestPhase?.schedule
|
|
130
|
+
}
|
|
131
|
+
], surface.timeZone);
|
|
132
|
+
const currentStatus = displayStatus({
|
|
133
|
+
status,
|
|
134
|
+
startedAt
|
|
135
|
+
}, now);
|
|
118
136
|
// ADM-06b: an older round never inherits the live test's running status.
|
|
119
|
-
const lineStatus = !statusReadPending &&
|
|
137
|
+
const lineStatus = !statusReadPending && currentStatus === 'running' && round === newestRound ? 'running' : 'stopped';
|
|
120
138
|
const isDecidedTestRound = status === 'decided' && phase?.phaseKind === 'test' && decision?.phase === round;
|
|
121
139
|
const showingDecision = isDecidedTestRound && Boolean(data?.decisionSnapshot);
|
|
122
140
|
const shown = showingDecision ? data.decisionSnapshot : snapshot;
|
|
123
141
|
const winner = phase?.arms.find((arm)=>arm.key === decision?.winnerArm)?.label ?? armLabel(decision?.winnerArm ?? 'control');
|
|
124
142
|
const control = phase?.arms.find((arm)=>arm.kind === 'control') ?? phases.find((item)=>item.phase === decision?.phase)?.arms.find((arm)=>arm.kind === 'control');
|
|
125
143
|
const planned = phase?.plannedDurationDays ?? (phase?.phaseKind === 'test' && lineStatus === 'running' ? managerDoc?.analysis?.plannedDurationDays : undefined);
|
|
126
|
-
const progress = roundProgress(phase?.startedAt ?? shown?.window.from, planned, lineStatus === 'running' ?
|
|
144
|
+
const progress = roundProgress(phase?.startedAt ?? shown?.window.from, planned, lineStatus === 'running' || status === 'paused' && round === newestRound ? now : Date.parse(shown?.window.to ?? ''), undefined, phase);
|
|
127
145
|
const planLine = shown && lineStatus === 'running' ? runningPlanLine(shown, progress, formatDate) : null;
|
|
128
146
|
const card = shown ? verdictCard({
|
|
129
147
|
snapshot: shown,
|
|
@@ -149,12 +167,12 @@ function ResultsContent({ id, surface, onRecomputed, renderPage, onChanged, docu
|
|
|
149
167
|
placementLabels
|
|
150
168
|
};
|
|
151
169
|
// A late browser-activity warning can reach the same round after a decision.
|
|
152
|
-
const
|
|
153
|
-
const qualitySnapshot = shown &&
|
|
170
|
+
const lateHealth = showingDecision && snapshot && shown && snapshot.phase === shown.phase ? snapshot.health?.filter((item)=>(item.code === 'rapid-browser-events' || item.code === 'paused-share' || item.code === 'schedule-population') && !shown.health?.some((existing)=>item.code === existing.code)) ?? [] : [];
|
|
171
|
+
const qualitySnapshot = shown && lateHealth.length ? {
|
|
154
172
|
...shown,
|
|
155
173
|
health: [
|
|
156
174
|
...shown.health ?? [],
|
|
157
|
-
|
|
175
|
+
...lateHealth
|
|
158
176
|
]
|
|
159
177
|
} : shown;
|
|
160
178
|
const qualityItems = phase && qualitySnapshot ? dataQuality(qualitySnapshot, context) : [];
|
|
@@ -163,6 +181,8 @@ function ResultsContent({ id, surface, onRecomputed, renderPage, onChanged, docu
|
|
|
163
181
|
const lifecycle = managerDoc || data ? availableActions({
|
|
164
182
|
...managerDoc,
|
|
165
183
|
status,
|
|
184
|
+
startedAt,
|
|
185
|
+
now,
|
|
166
186
|
kind: managerDoc?.kind ?? 'block',
|
|
167
187
|
decision: managerDoc?.decision,
|
|
168
188
|
canManage: surface.canManage,
|
|
@@ -214,7 +234,7 @@ function ResultsContent({ id, surface, onRecomputed, renderPage, onChanged, docu
|
|
|
214
234
|
children: TEST_PAGE.editOnPage
|
|
215
235
|
}) : null;
|
|
216
236
|
// A decided round displays the frozen snapshot used for the decision.
|
|
217
|
-
const refresh = manage && !showingDecision ? /*#__PURE__*/ _jsxs("div", {
|
|
237
|
+
const refresh = manage && !showingDecision && currentStatus !== 'scheduled' ? /*#__PURE__*/ _jsxs("div", {
|
|
218
238
|
className: "xp-results-refresh",
|
|
219
239
|
children: [
|
|
220
240
|
/*#__PURE__*/ _jsx(Button, {
|
|
@@ -271,6 +291,20 @@ function ResultsContent({ id, surface, onRecomputed, renderPage, onChanged, docu
|
|
|
271
291
|
]
|
|
272
292
|
})
|
|
273
293
|
});
|
|
294
|
+
const participation = phase?.cohortSummaries?.length ? /*#__PURE__*/ _jsxs("section", {
|
|
295
|
+
"aria-label": COHORT_EDITOR.whoTookPart,
|
|
296
|
+
className: "xp-results-block",
|
|
297
|
+
children: [
|
|
298
|
+
/*#__PURE__*/ _jsx("h2", {
|
|
299
|
+
children: COHORT_EDITOR.whoTookPart
|
|
300
|
+
}),
|
|
301
|
+
/*#__PURE__*/ _jsx("ul", {
|
|
302
|
+
children: phase.cohortSummaries.map((line, index)=>/*#__PURE__*/ _jsx("li", {
|
|
303
|
+
children: line
|
|
304
|
+
}, index))
|
|
305
|
+
})
|
|
306
|
+
]
|
|
307
|
+
}) : null;
|
|
274
308
|
const leader = shown?.verdict.recommendedArm;
|
|
275
309
|
const leadingComparison = shown?.metrics.find((metric)=>metric.role === 'primary')?.comparisons.find((item)=>item.arm === leader);
|
|
276
310
|
const chance = shown?.method === 'bayesian' && ![
|
|
@@ -346,6 +380,7 @@ function ResultsContent({ id, surface, onRecomputed, renderPage, onChanged, docu
|
|
|
346
380
|
browserWritablePrimary: primary?.browserWritable || primary?.clickGoal,
|
|
347
381
|
sinceShipping: rolloutLine(shown, phase, phases, decision ?? undefined)
|
|
348
382
|
}),
|
|
383
|
+
participation,
|
|
349
384
|
primary?.clickGoal ? /*#__PURE__*/ _jsx("p", {
|
|
350
385
|
children: C.clickPrimary
|
|
351
386
|
}) : null,
|
|
@@ -414,6 +449,7 @@ function ResultsContent({ id, surface, onRecomputed, renderPage, onChanged, docu
|
|
|
414
449
|
}) : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
415
450
|
children: [
|
|
416
451
|
meta,
|
|
452
|
+
participation,
|
|
417
453
|
state === 'empty' || state === 'ready' ? /*#__PURE__*/ _jsx("p", {
|
|
418
454
|
children: C.empty
|
|
419
455
|
}) : null
|
|
@@ -29,7 +29,10 @@ export declare function useResults(id: DocId, { apiRoute, canReadResults, canMan
|
|
|
29
29
|
apiRoute: string;
|
|
30
30
|
canReadResults: boolean;
|
|
31
31
|
canManage?: boolean;
|
|
32
|
-
}, documentVersion?:
|
|
32
|
+
}, { documentVersion, documentPhase }?: {
|
|
33
|
+
documentVersion?: string;
|
|
34
|
+
documentPhase?: number;
|
|
35
|
+
}): {
|
|
33
36
|
api: {
|
|
34
37
|
findTestIdBySlug: (slug: string) => Promise<Extract<ApiResult<DocId>, {
|
|
35
38
|
ok: false;
|
|
@@ -48,6 +51,13 @@ export declare function useResults(id: DocId, { apiRoute, canReadResults, canMan
|
|
|
48
51
|
page?: number;
|
|
49
52
|
mode?: "block";
|
|
50
53
|
}, signal?: AbortSignal) => Promise<ApiResult<import("../../../types/endpoints.js").PagesResult>>;
|
|
54
|
+
cohortSources: (q: string, exclude: DocId, signal?: AbortSignal) => Promise<ApiResult<import("../../../types/endpoints.js").CohortSourcesResult>>;
|
|
55
|
+
buildCohorts: (id: DocId) => Promise<ApiResult<{
|
|
56
|
+
cohorts: Array<{
|
|
57
|
+
key: string;
|
|
58
|
+
members: number;
|
|
59
|
+
}>;
|
|
60
|
+
}>>;
|
|
51
61
|
previewPageCopy: (id: DocId, arm: string, signal?: AbortSignal) => Promise<ApiResult<import("../../../types/endpoints.js").CopyPagePlan>>;
|
|
52
62
|
makePageCopy: (id: DocId, arm: string, plan: import("../../../types/endpoints.js").CopyPagePlan) => Promise<ApiResult<import("../../../types/endpoints.js").CopyPageResult>>;
|
|
53
63
|
placementStatus: (body: import("../../../types/endpoints.js").PlacementStatusBody) => Promise<ApiResult<import("../../../types/endpoints.js").PlacementStatusResult>>;
|
|
@@ -65,6 +75,10 @@ export declare function useResults(id: DocId, { apiRoute, canReadResults, canMan
|
|
|
65
75
|
fallback?: string;
|
|
66
76
|
}) => Promise<ApiResult<import("../../../types/endpoints.js").AddMetricResult>>;
|
|
67
77
|
stop: (id: DocId, phase?: number) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
78
|
+
pause: (id: DocId, body: import("../../../types/endpoints.js").PauseBody) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
79
|
+
resume: (id: DocId, phase?: number) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
80
|
+
reschedule: (id: DocId, body: import("../../../types/endpoints.js").RescheduleBody) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
81
|
+
cancelSchedule: (id: DocId, phase?: number) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
68
82
|
decide: (id: DocId, body: import("../../../types/endpoints.js").DecideBody) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
69
83
|
releaseHoldout: (id: DocId, phase?: number) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
70
84
|
releasePages: (id: DocId, phase?: number) => Promise<ApiResult<import("../../../types/endpoints.js").TransitionSuccess>>;
|
|
@@ -88,6 +102,7 @@ export declare function useResults(id: DocId, { apiRoute, canReadResults, canMan
|
|
|
88
102
|
recompute: (id: DocId) => Promise<ApiResult<{
|
|
89
103
|
snapshotId: string;
|
|
90
104
|
}>>;
|
|
105
|
+
pausedBy: (signal: AbortSignal) => Promise<ApiResult<Record<string, import("../../../types/endpoints.js").PauseAttribution>>>;
|
|
91
106
|
summary: (ids: readonly DocId[]) => Promise<ApiResult<import("../../../types/endpoints.js").SummaryResponse>>;
|
|
92
107
|
};
|
|
93
108
|
state: ResultsLoadState;
|
|
@@ -32,7 +32,7 @@ async function read(url, signal) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
export function useResults(id, { apiRoute, canReadResults, canManage = true }, documentVersion) {
|
|
35
|
+
export function useResults(id, { apiRoute, canReadResults, canManage = true }, { documentVersion, documentPhase } = {}) {
|
|
36
36
|
const base = apiRoute.replace(/\/$/, '');
|
|
37
37
|
const key = JSON.stringify([
|
|
38
38
|
base,
|
|
@@ -47,7 +47,14 @@ export function useResults(id, { apiRoute, canReadResults, canManage = true }, d
|
|
|
47
47
|
key,
|
|
48
48
|
round: null
|
|
49
49
|
});
|
|
50
|
-
const
|
|
50
|
+
const selected = selection.key === key ? selection.round : null;
|
|
51
|
+
// Cancel schedule moves the current phase backwards and deletes the unopened round.
|
|
52
|
+
const removed = selected !== null && documentPhase !== undefined && selection.documentPhase !== undefined && selected <= selection.documentPhase && selected > documentPhase;
|
|
53
|
+
if (removed) setSelection({
|
|
54
|
+
key,
|
|
55
|
+
round: null
|
|
56
|
+
});
|
|
57
|
+
const round = removed ? null : selected;
|
|
51
58
|
const [refresh, setRefresh] = useState(0);
|
|
52
59
|
const [view, setView] = useState({
|
|
53
60
|
key,
|
|
@@ -129,7 +136,8 @@ export function useResults(id, { apiRoute, canReadResults, canManage = true }, d
|
|
|
129
136
|
});
|
|
130
137
|
setSelection({
|
|
131
138
|
key,
|
|
132
|
-
round: initial
|
|
139
|
+
round: initial,
|
|
140
|
+
documentPhase
|
|
133
141
|
});
|
|
134
142
|
return;
|
|
135
143
|
}
|
|
@@ -153,7 +161,8 @@ export function useResults(id, { apiRoute, canReadResults, canManage = true }, d
|
|
|
153
161
|
canManage,
|
|
154
162
|
round,
|
|
155
163
|
refresh,
|
|
156
|
-
documentVersion
|
|
164
|
+
documentVersion,
|
|
165
|
+
documentPhase
|
|
157
166
|
]);
|
|
158
167
|
const current = view.key === key;
|
|
159
168
|
const matching = current && (round === null || view.round === round);
|
|
@@ -172,12 +181,14 @@ export function useResults(id, { apiRoute, canReadResults, canManage = true }, d
|
|
|
172
181
|
error: matching ? view.error : undefined,
|
|
173
182
|
setRound: (next)=>setSelection({
|
|
174
183
|
key,
|
|
175
|
-
round: next
|
|
184
|
+
round: next,
|
|
185
|
+
documentPhase
|
|
176
186
|
}),
|
|
177
187
|
reload: ()=>{
|
|
178
188
|
setSelection({
|
|
179
189
|
key,
|
|
180
|
-
round: selectedRound
|
|
190
|
+
round: selectedRound,
|
|
191
|
+
documentPhase
|
|
181
192
|
});
|
|
182
193
|
setRefresh((value)=>value + 1);
|
|
183
194
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CohortRule } from '../../../cohorts/rule.js';
|
|
2
|
+
import type { CohortSourceOption } from '../../../types/endpoints.js';
|
|
3
|
+
import type { SectionProps } from '../contracts.js';
|
|
4
|
+
import '../pagePicker/pagePicker.css';
|
|
5
|
+
export declare const EMPTY_COHORT_RULE: CohortRule;
|
|
6
|
+
export declare function CohortRuleEditor({ test, surface, index, pending, draftId, saved, sourceFor, onSource, onSave, onRemove, onDiscard }: SectionProps & {
|
|
7
|
+
index: number;
|
|
8
|
+
pending?: boolean;
|
|
9
|
+
draftId: string;
|
|
10
|
+
saved: CohortRule;
|
|
11
|
+
sourceFor: (id: string) => CohortSourceOption | undefined;
|
|
12
|
+
onSource: (source: CohortSourceOption) => void;
|
|
13
|
+
onSave: (rule: CohortRule) => boolean;
|
|
14
|
+
onRemove: () => void;
|
|
15
|
+
onDiscard?: () => void;
|
|
16
|
+
}): import("react").JSX.Element;
|