@delmaredigital/payload-experiments 0.4.0-rc.7 → 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 +9 -15
- 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 +7 -6
- 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 +12 -10
- 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 +224 -52
- 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 +99 -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 +98 -66
- 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 +2 -2
- package/dist/collections/experiments/armInvariants.js +8 -5
- package/dist/collections/experiments/config.js +8 -3
- package/dist/collections/experiments/deleteGuard.js +2 -2
- package/dist/collections/experiments/lockHook.js +21 -2
- package/dist/collections/experiments/pickSlug.js +2 -0
- package/dist/collections/metrics.js +12 -5
- package/dist/collections/metricsGuards.js +2 -0
- package/dist/collections/serialize.js +8 -6
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/db/adapter.d.ts +9 -1
- package/dist/db/adapter.js +77 -1
- package/dist/db/delete.d.ts +1 -1
- package/dist/db/delete.js +2 -4
- package/dist/db/events.d.ts +9 -0
- package/dist/db/events.js +42 -8
- package/dist/db/executor.d.ts +7 -1
- package/dist/db/executor.js +7 -3
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/results.d.ts +5 -1
- package/dist/db/results.js +21 -5
- package/dist/db/snapshots.d.ts +2 -0
- package/dist/endpoints/deleteImpact.js +2 -1
- 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/events.js +103 -39
- package/dist/endpoints/index.js +22 -8
- package/dist/endpoints/pages.js +245 -66
- package/dist/endpoints/placementStatus.js +8 -4
- package/dist/endpoints/results.d.ts +1 -1
- package/dist/endpoints/results.js +9 -2
- package/dist/endpoints/routeId.d.ts +2 -2
- package/dist/endpoints/routeId.js +11 -5
- package/dist/endpoints/summary.js +46 -12
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +41 -29
- package/dist/errors.d.ts +4 -0
- package/dist/errors.js +6 -0
- package/dist/events/request.d.ts +6 -2
- package/dist/events/request.js +35 -8
- package/dist/events/rows.d.ts +1 -1
- package/dist/events/rows.js +24 -8
- package/dist/events/writable.d.ts +9 -0
- package/dist/events/writable.js +13 -0
- package/dist/exports/index.d.ts +1 -1
- package/dist/exports/rsc.d.ts +1 -0
- package/dist/exports/rsc.js +1 -0
- package/dist/goals/fairness.js +2 -2
- 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/hostHook.js +6 -2
- package/dist/hooks/pageGuard.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/lib/fetchAllDocs.d.ts +1 -1
- package/dist/manifest/compile.js +8 -5
- package/dist/onInit.js +14 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +23 -2
- package/dist/plugin.js +56 -2
- package/dist/proxy/pageNavigation.d.ts +4 -0
- package/dist/proxy/pageNavigation.js +28 -0
- package/dist/proxy/resolve.js +52 -25
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
- package/dist/puck/editor/ConfigureTestDrawer.js +40 -29
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +376 -139
- package/dist/puck/editor/LeftoverVersions.js +17 -32
- package/dist/puck/editor/QuickTestActions.d.ts +6 -3
- package/dist/puck/editor/QuickTestActions.js +55 -33
- package/dist/puck/editor/ResultsReadout.d.ts +4 -1
- package/dist/puck/editor/ResultsReadout.js +28 -15
- package/dist/puck/editor/VersionBuilder.d.ts +17 -4
- package/dist/puck/editor/VersionBuilder.js +175 -112
- package/dist/puck/editor/armWrites.js +2 -2
- package/dist/puck/editor/armsCache.js +1 -3
- package/dist/puck/editor/copy.d.ts +14 -7
- package/dist/puck/editor/copy.js +26 -13
- package/dist/puck/editor/editor.chrome.css +10 -8
- package/dist/puck/editor/editor.css +15 -9
- package/dist/puck/editor/editor.model.d.ts +1 -0
- package/dist/puck/editor/placementsCache.d.ts +4 -0
- package/dist/puck/editor/usePageSaveReadiness.d.ts +6 -0
- package/dist/puck/editor/usePageSaveReadiness.js +31 -0
- 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/aggregate.d.ts +6 -3
- package/dist/results/aggregate.js +9 -9
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/health.d.ts +8 -0
- package/dist/results/health.js +28 -0
- package/dist/results/identityCredit.d.ts +1 -0
- package/dist/results/identityCredit.js +4 -1
- package/dist/results/verdict.d.ts +4 -4
- package/dist/results/verdict.js +15 -11
- package/dist/runtime/cookie.d.ts +10 -2
- package/dist/runtime/cookie.js +38 -6
- package/dist/runtime/cookieOptions.d.ts +6 -0
- package/dist/runtime/cookieOptions.js +14 -0
- package/dist/runtime/proxyRuntime.d.ts +1 -0
- package/dist/runtime/proxyRuntime.js +18 -8
- package/dist/runtime/signing.d.ts +1 -0
- package/dist/runtime/signing.js +5 -0
- package/dist/sanitizeReadinessDetail.d.ts +2 -2
- package/dist/sanitizeReadinessDetail.js +20 -2
- package/dist/server/getAssignments.js +11 -10
- package/dist/server/recordContentChange.d.ts +1 -1
- package/dist/server/recordContentChange.js +11 -2
- package/dist/server/resolveExperimentBlocks.js +2 -4
- package/dist/server/resolveExperimentData.js +2 -5
- package/dist/server/runResults.js +54 -15
- package/dist/server/startExperiment.d.ts +20 -0
- package/dist/server/startExperiment.js +70 -0
- package/dist/server/trackConversion.js +10 -13
- package/dist/testSurface/PreviewLinks.d.ts +2 -1
- package/dist/testSurface/PreviewLinks.js +3 -3
- package/dist/testSurface/actions/DecideDialog.d.ts +10 -4
- package/dist/testSurface/actions/DecideDialog.js +93 -63
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/testSurface/actions/MakeContentResult.d.ts +4 -3
- package/dist/testSurface/actions/MakeContentResult.js +10 -2
- 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 +9 -6
- package/dist/testSurface/api.js +43 -23
- package/dist/testSurface/copy/actions.d.ts +37 -14
- package/dist/testSurface/copy/actions.js +40 -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 +8 -6
- package/dist/testSurface/copy/common.js +8 -6
- package/dist/testSurface/copy/languages.d.ts +1 -0
- package/dist/testSurface/copy/languages.js +1 -0
- package/dist/testSurface/copy/metrics.d.ts +7 -0
- package/dist/testSurface/copy/metrics.js +9 -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 +20 -7
- package/dist/testSurface/copy/readiness.js +36 -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 +21 -12
- package/dist/testSurface/copy/results.js +24 -13
- 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 +36 -12
- package/dist/testSurface/copy/testPage.js +53 -16
- 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 +4 -0
- package/dist/testSurface/readPreflight.js +6 -0
- package/dist/testSurface/readinessRead.d.ts +3 -0
- package/dist/testSurface/readinessRead.js +4 -0
- 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 +3 -2
- package/dist/testSurface/results/VerdictHero.js +5 -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 +9 -4
- package/dist/testSurface/results/results.model.js +31 -23
- package/dist/testSurface/results/snapshot.d.ts +2 -0
- package/dist/testSurface/results/snapshot.js +3 -0
- package/dist/testSurface/surface/contracts.d.ts +13 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +3 -3
- package/dist/testSurface/surface/editorPlacement.js +2 -2
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +3 -3
- 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 +300 -197
- 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 +9 -5
- package/dist/testSurface/surface/readiness/ActionDialogs.js +241 -230
- package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
- package/dist/testSurface/surface/readiness/Banner.js +113 -141
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +8 -4
- package/dist/testSurface/surface/readiness/SaveStatus.js +23 -22
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +20 -6
- package/dist/testSurface/surface/readiness/readiness.model.js +168 -21
- package/dist/testSurface/surface/readiness/useTransition.d.ts +6 -4
- package/dist/testSurface/surface/readiness/useTransition.js +57 -14
- package/dist/testSurface/surface/results/ReleasePages.d.ts +6 -3
- package/dist/testSurface/surface/results/ReleasePages.js +42 -41
- package/dist/testSurface/surface/results/ResultsBody.d.ts +11 -4
- package/dist/testSurface/surface/results/ResultsBody.js +221 -118
- 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 +13 -8
- package/dist/testSurface/surface/results/useResults.js +3 -2
- package/dist/testSurface/surface/setting/parts.js +89 -46
- package/dist/testSurface/surface/setting/setting.css +2 -1
- package/dist/testSurface/surface/test/AdvancedSection.js +11 -4
- package/dist/testSurface/surface/test/DeleteTest.d.ts +10 -2
- package/dist/testSurface/surface/test/DeleteTest.js +173 -74
- package/dist/testSurface/surface/test/GoalSection.js +18 -14
- package/dist/testSurface/surface/test/LengthSection.js +24 -13
- package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
- package/dist/testSurface/surface/test/PageHoldout.js +11 -8
- 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 +82 -12
- package/dist/testSurface/surface/test/TestSurface.js +73 -37
- package/dist/testSurface/surface/test/VersionsSection.js +141 -91
- package/dist/testSurface/surface/test/fields.d.ts +32 -6
- package/dist/testSurface/surface/test/fields.js +166 -52
- package/dist/testSurface/surface/test/pageParts.js +27 -12
- package/dist/testSurface/surface/test/testPage.css +9 -2
- package/dist/testSurface/surface/test/testPage.model.d.ts +1 -0
- package/dist/testSurface/surface/test/testPage.model.js +6 -0
- package/dist/testSurface/surface/testDocument.model.d.ts +3 -0
- package/dist/testSurface/surface/testDocument.model.js +4 -1
- package/dist/testSurface/surface/useTestDocument.d.ts +21 -5
- package/dist/testSurface/surface/useTestDocument.js +472 -167
- 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 +8 -5
- package/dist/testSurface/useOnTestReturn.d.ts +2 -0
- package/dist/testSurface/useOnTestReturn.js +27 -0
- package/dist/testSurface/useReadinessPolling.js +3 -1
- package/dist/transitions/addMetric.d.ts +2 -5
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/allocate.d.ts +2 -2
- package/dist/transitions/allocate.js +3 -1
- package/dist/transitions/archive.d.ts +1 -1
- package/dist/transitions/archive.js +3 -2
- package/dist/transitions/checkStart.d.ts +1 -0
- package/dist/transitions/checkStart.js +17 -6
- package/dist/transitions/decide.d.ts +1 -1
- package/dist/transitions/decide.js +5 -3
- package/dist/transitions/deleteExperiment.d.ts +2 -2
- package/dist/transitions/deleteExperiment.js +17 -7
- package/dist/transitions/kernel.d.ts +4 -0
- package/dist/transitions/kernel.js +9 -4
- package/dist/transitions/makeContent.d.ts +2 -1
- package/dist/transitions/makeContent.js +12 -8
- package/dist/transitions/nestedPlacementNames.d.ts +2 -2
- package/dist/transitions/nestedPlacementNames.js +4 -5
- 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/phaseRecord.d.ts +2 -0
- package/dist/transitions/phaseRecord.js +5 -0
- package/dist/transitions/placementInteractions.d.ts +3 -3
- package/dist/transitions/placementInteractions.js +8 -7
- package/dist/transitions/placements.d.ts +2 -0
- package/dist/transitions/placements.js +5 -5
- package/dist/transitions/preflightData.d.ts +3 -2
- package/dist/transitions/preflightData.js +77 -43
- package/dist/transitions/releaseHoldout.d.ts +2 -1
- package/dist/transitions/releaseHoldout.js +3 -1
- package/dist/transitions/releasePages.d.ts +2 -1
- package/dist/transitions/releasePages.js +3 -1
- package/dist/transitions/resolveCaps.d.ts +2 -4
- package/dist/transitions/start.d.ts +7 -9
- package/dist/transitions/start.js +75 -39
- package/dist/transitions/startReads.d.ts +7 -0
- package/dist/transitions/startReads.js +28 -0
- package/dist/transitions/stop.d.ts +2 -1
- package/dist/transitions/stop.js +3 -2
- package/dist/types/armKey.d.ts +2 -0
- package/dist/types/armKey.js +1 -0
- package/dist/types/contracts.d.ts +17 -4
- package/dist/types/endpoints.d.ts +89 -17
- package/dist/types/endpoints.js +1 -1
- package/dist/types/runtime.d.ts +15 -9
- package/dist/types/snapshot.d.ts +2 -0
- package/dist/types/surface.d.ts +7 -9
- package/dist/ui/ChipsInput.d.ts +8 -1
- package/dist/ui/ChipsInput.js +17 -4
- 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
|
@@ -6,37 +6,52 @@ import { Select, Textarea, TextInput } from '../../ui/Inputs.js';
|
|
|
6
6
|
import { unsupportedContentCopy } from '../copy/readiness.js';
|
|
7
7
|
import { useApi } from '../useApi.js';
|
|
8
8
|
import { reloadPage } from '../reload.js';
|
|
9
|
-
import {
|
|
10
|
-
import { ACTIONS_COPY as C, decideCopy } from '../copy/actions.js';
|
|
9
|
+
import { Banner } from '../../ui/Banner.js';
|
|
10
|
+
import { ACTIONS_COPY as C, actionTitle, decideCopy } from '../copy/actions.js';
|
|
11
|
+
import { READINESS_COPY } from '../copy/readiness.js';
|
|
12
|
+
import { actionGroupLabel, isDestructiveAction } from './actions.model.js';
|
|
11
13
|
import { decideState } from './decide.model.js';
|
|
12
|
-
import {
|
|
13
|
-
|
|
14
|
+
import { ConfirmDialog } from '../../ui/Dialog.js';
|
|
15
|
+
import { notifyTestDocument } from '../surface/watchTestDocument.js';
|
|
16
|
+
export function DecideDialog({ id, name, phase, arms, results, checks = [], unavailable, pending, onClose, apiRoute, onSuccess, onRefusal }) {
|
|
14
17
|
const api = useApi(apiRoute);
|
|
15
|
-
const [snapshot, setSnapshot] = useState(null);
|
|
16
|
-
const [
|
|
18
|
+
const [snapshot, setSnapshot] = useState(results?.snapshot ?? null);
|
|
19
|
+
const [roundArms, setRoundArms] = useState();
|
|
20
|
+
const frozenArms = roundArms ?? arms;
|
|
21
|
+
const [chosen, setChosenArm] = useState();
|
|
22
|
+
const chosenArm = chosen === undefined ? snapshot?.verdict.recommendedArm ?? null : chosen;
|
|
17
23
|
const [note, setNote] = useState('');
|
|
18
24
|
const [typed, setTyped] = useState('');
|
|
19
|
-
const [loading, setLoading] = useState(
|
|
25
|
+
const [loading, setLoading] = useState(!results);
|
|
20
26
|
const [busy, setBusy] = useState(false);
|
|
21
27
|
const inFlight = useRef(false);
|
|
22
28
|
const refreshing = useRef(false);
|
|
23
29
|
const [error, setError] = useState(null);
|
|
24
30
|
const [loadFailed, setLoadFailed] = useState(false);
|
|
31
|
+
const accessRefused = !!error && [
|
|
32
|
+
401,
|
|
33
|
+
403,
|
|
34
|
+
404
|
|
35
|
+
].includes(error.status);
|
|
36
|
+
const statusRefused = accessRefused || error?.code === 'round-changed' || error?.code === 'invalid-status';
|
|
25
37
|
const state = decideState({
|
|
26
38
|
snapshot,
|
|
27
|
-
arms,
|
|
39
|
+
arms: frozenArms ?? [],
|
|
28
40
|
chosenArm,
|
|
29
41
|
note,
|
|
30
42
|
typed
|
|
31
43
|
});
|
|
32
44
|
useEffect(()=>{
|
|
45
|
+
if (results) return;
|
|
33
46
|
let current = true;
|
|
34
|
-
void api.results(id
|
|
47
|
+
void api.results(id, {
|
|
48
|
+
phase
|
|
49
|
+
}).then((result)=>{
|
|
35
50
|
if (!current) return;
|
|
36
51
|
if (result.ok) {
|
|
37
52
|
const next = result.data?.snapshot ?? null;
|
|
38
53
|
setSnapshot(next);
|
|
39
|
-
|
|
54
|
+
setRoundArms(result.data?.phases?.find((round)=>round.phase === phase && round.phaseKind === 'test')?.arms);
|
|
40
55
|
} else {
|
|
41
56
|
setError(result);
|
|
42
57
|
setLoadFailed(true);
|
|
@@ -48,17 +63,22 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute, onSucce
|
|
|
48
63
|
};
|
|
49
64
|
}, [
|
|
50
65
|
api,
|
|
51
|
-
id
|
|
66
|
+
id,
|
|
67
|
+
phase,
|
|
68
|
+
results
|
|
52
69
|
]);
|
|
53
70
|
async function refresh() {
|
|
54
71
|
if (refreshing.current) return;
|
|
55
72
|
refreshing.current = true;
|
|
56
73
|
setLoading(true);
|
|
57
|
-
const result = await api.results(id
|
|
74
|
+
const result = await api.results(id, {
|
|
75
|
+
phase
|
|
76
|
+
});
|
|
58
77
|
refreshing.current = false;
|
|
59
78
|
setLoading(false);
|
|
60
79
|
if (result.ok) {
|
|
61
80
|
setSnapshot(result.data?.snapshot ?? null);
|
|
81
|
+
setRoundArms(result.data?.phases?.find((round)=>round.phase === phase && round.phaseKind === 'test')?.arms);
|
|
62
82
|
setLoadFailed(false);
|
|
63
83
|
} else {
|
|
64
84
|
setSnapshot(null);
|
|
@@ -67,44 +87,75 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute, onSucce
|
|
|
67
87
|
}
|
|
68
88
|
}
|
|
69
89
|
async function submit() {
|
|
70
|
-
if (inFlight.current || loading || busy || !state.canSubmit || loadFailed) return;
|
|
90
|
+
if (unavailable || pending || statusRefused || inFlight.current || loading || busy || !state.canSubmit || loadFailed) return;
|
|
71
91
|
inFlight.current = true;
|
|
92
|
+
setChosenArm(chosenArm);
|
|
72
93
|
setBusy(true);
|
|
73
94
|
setError(null);
|
|
74
|
-
const result = await api.decide(id,
|
|
95
|
+
const result = await api.decide(id, {
|
|
96
|
+
...state.body,
|
|
97
|
+
phase
|
|
98
|
+
});
|
|
75
99
|
if (result.ok) {
|
|
76
100
|
if (onSuccess) onSuccess(result.data?.doc);
|
|
77
|
-
else
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
setError(result);
|
|
81
|
-
if (result.code === 'confirmation-required') {
|
|
82
|
-
setTyped('');
|
|
83
|
-
await refresh();
|
|
101
|
+
else {
|
|
102
|
+
notifyTestDocument(apiRoute, id);
|
|
103
|
+
reloadPage();
|
|
84
104
|
}
|
|
105
|
+
return;
|
|
85
106
|
}
|
|
107
|
+
setError(result);
|
|
108
|
+
if (result.code === 'confirmation-required') {
|
|
109
|
+
await refresh();
|
|
110
|
+
} else if (result.status === 409 || result.code === 'invalid-status') onRefusal?.();
|
|
86
111
|
inFlight.current = false;
|
|
87
112
|
setBusy(false);
|
|
88
113
|
}
|
|
89
|
-
const enabled = !busy && !loading && !loadFailed && state.canSubmit;
|
|
114
|
+
const enabled = !unavailable && !pending && !statusRefused && !busy && !loading && !loadFailed && state.canSubmit;
|
|
115
|
+
const noEvidence = !loading && !loadFailed && state.noEvidence;
|
|
116
|
+
const control = actionGroupLabel('control', frozenArms?.find((arm)=>arm.key === 'control')?.label);
|
|
90
117
|
const label = state.options.find((option)=>option.value === chosenArm)?.label;
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
title: C.decide,
|
|
118
|
+
const noteRequired = state.guarded && Boolean(label);
|
|
119
|
+
return /*#__PURE__*/ _jsxs(ConfirmDialog, {
|
|
120
|
+
title: name ? actionTitle(C.titleLead.decide, name) : C.decide,
|
|
121
|
+
description: C.decideBody,
|
|
96
122
|
onClose: ()=>{
|
|
97
|
-
|
|
123
|
+
onClose();
|
|
124
|
+
if (accessRefused) onRefusal?.();
|
|
98
125
|
},
|
|
126
|
+
busy: busy,
|
|
127
|
+
busyLabel: READINESS_COPY.changing,
|
|
128
|
+
cancelLabel: C.cancel,
|
|
129
|
+
error: error?.message ?? (unavailable ? C.decisionUnavailable : !loading && !frozenArms ? C.decideRoundMissing : null),
|
|
130
|
+
confirm: {
|
|
131
|
+
label: noEvidence ? C.decideAnyway : C.decide,
|
|
132
|
+
disabled: !enabled,
|
|
133
|
+
destructive: isDestructiveAction('decide'),
|
|
134
|
+
onClick: submit
|
|
135
|
+
},
|
|
136
|
+
secondaryAction: !unavailable && error?.retryable ? /*#__PURE__*/ _jsx(Button, {
|
|
137
|
+
disabled: busy || pending || loading || !loadFailed && !state.canSubmit,
|
|
138
|
+
onClick: ()=>{
|
|
139
|
+
if (loadFailed) {
|
|
140
|
+
setError(null);
|
|
141
|
+
void refresh();
|
|
142
|
+
} else void submit();
|
|
143
|
+
},
|
|
144
|
+
children: C.retry
|
|
145
|
+
}) : null,
|
|
99
146
|
children: [
|
|
100
147
|
loading ? /*#__PURE__*/ _jsx("p", {
|
|
101
148
|
role: "status",
|
|
102
149
|
children: C.loading
|
|
103
150
|
}) : null,
|
|
151
|
+
noEvidence ? /*#__PURE__*/ _jsx(Banner, {
|
|
152
|
+
tone: "warning",
|
|
153
|
+
children: C.noEvidence
|
|
154
|
+
}) : null,
|
|
104
155
|
/*#__PURE__*/ _jsxs(Select, {
|
|
105
156
|
id: "xp-winner",
|
|
106
157
|
name: "xp-winner",
|
|
107
|
-
label: C.
|
|
158
|
+
label: C.winningVersion,
|
|
108
159
|
value: chosenArm ?? '',
|
|
109
160
|
disabled: busy || loading,
|
|
110
161
|
required: true,
|
|
@@ -115,7 +166,7 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute, onSucce
|
|
|
115
166
|
children: [
|
|
116
167
|
/*#__PURE__*/ _jsx("option", {
|
|
117
168
|
value: "",
|
|
118
|
-
children:
|
|
169
|
+
children: C.chooseVersion
|
|
119
170
|
}),
|
|
120
171
|
state.options.map((option)=>/*#__PURE__*/ _jsx("option", {
|
|
121
172
|
value: option.value,
|
|
@@ -124,7 +175,7 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute, onSucce
|
|
|
124
175
|
]
|
|
125
176
|
}),
|
|
126
177
|
label ? /*#__PURE__*/ _jsx("p", {
|
|
127
|
-
children: decideCopy(label,
|
|
178
|
+
children: decideCopy(label, !!frozenArms?.some((group)=>group.key === 'holdout'), control, chosenArm === 'control')
|
|
128
179
|
}) : null,
|
|
129
180
|
checks.filter((check)=>check.code === 'make-content-unsupported' && check.warning).map((check)=>/*#__PURE__*/ _jsx("p", {
|
|
130
181
|
children: unsupportedContentCopy(typeof check.detail === 'string' ? check.detail : 'This page')
|
|
@@ -134,11 +185,14 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute, onSucce
|
|
|
134
185
|
}) : null,
|
|
135
186
|
/*#__PURE__*/ _jsx(Textarea, {
|
|
136
187
|
id: "xp-note",
|
|
137
|
-
label: C.note,
|
|
188
|
+
label: noteRequired ? C.requiredNote : C.note,
|
|
138
189
|
value: note,
|
|
139
|
-
required:
|
|
190
|
+
required: noteRequired,
|
|
140
191
|
readOnly: busy,
|
|
141
|
-
onChange: (event)=>
|
|
192
|
+
onChange: (event)=>{
|
|
193
|
+
if (chosenArm !== null) setChosenArm(chosenArm);
|
|
194
|
+
setNote(event.target.value);
|
|
195
|
+
}
|
|
142
196
|
}),
|
|
143
197
|
state.guarded && label ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
144
198
|
children: [
|
|
@@ -156,37 +210,13 @@ export function DecideDialog({ id, arms, checks = [], onClose, apiRoute, onSucce
|
|
|
156
210
|
label: C.confirmation,
|
|
157
211
|
value: typed,
|
|
158
212
|
readOnly: busy,
|
|
159
|
-
onChange: (event)=>
|
|
213
|
+
onChange: (event)=>{
|
|
214
|
+
setChosenArm(chosenArm);
|
|
215
|
+
setTyped(event.target.value);
|
|
216
|
+
}
|
|
160
217
|
})
|
|
161
218
|
]
|
|
162
|
-
}) : null
|
|
163
|
-
error ? /*#__PURE__*/ _jsx("p", {
|
|
164
|
-
role: "alert",
|
|
165
|
-
children: error.message
|
|
166
|
-
}) : null,
|
|
167
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
168
|
-
disabled: !enabled,
|
|
169
|
-
onClick: ()=>{
|
|
170
|
-
void submit();
|
|
171
|
-
},
|
|
172
|
-
children: C.decide
|
|
173
|
-
}),
|
|
174
|
-
error?.retryable ? /*#__PURE__*/ _jsx(Button, {
|
|
175
|
-
disabled: busy || loading || !loadFailed && !state.canSubmit,
|
|
176
|
-
onClick: ()=>{
|
|
177
|
-
if (loadFailed) {
|
|
178
|
-
setError(null);
|
|
179
|
-
void refresh();
|
|
180
|
-
} else void submit();
|
|
181
|
-
},
|
|
182
|
-
children: C.retry
|
|
183
|
-
}) : null,
|
|
184
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
185
|
-
"data-dialog-cancel": true,
|
|
186
|
-
disabled: busy,
|
|
187
|
-
onClick: onClose,
|
|
188
|
-
children: C.cancel
|
|
189
|
-
})
|
|
219
|
+
}) : null
|
|
190
220
|
]
|
|
191
221
|
});
|
|
192
222
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ActionTestApi, SurfaceProps } from '../surface/contracts.js';
|
|
2
|
+
import { type ExperimentAction } from './actions.model.js';
|
|
3
|
+
export declare function LifecycleButton({ action, reason, showReason, disabled, ariaDisabled, busy, onClick }: {
|
|
4
|
+
action: ExperimentAction;
|
|
5
|
+
reason?: string;
|
|
6
|
+
showReason?: boolean;
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
ariaDisabled?: boolean;
|
|
9
|
+
busy?: boolean;
|
|
10
|
+
onClick: () => void;
|
|
11
|
+
}): import("react").JSX.Element;
|
|
12
|
+
export declare function LifecycleDialog({ action, test, surface, onClose }: {
|
|
13
|
+
action: ExperimentAction;
|
|
14
|
+
test: ActionTestApi;
|
|
15
|
+
surface: SurfaceProps;
|
|
16
|
+
onClose: () => void;
|
|
17
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useId, useState } from 'react';
|
|
4
|
+
import { Button } from '../../ui/Button.js';
|
|
5
|
+
import { AddMetricAction, AllocateAction, ConfirmAction } from '../surface/readiness/ActionDialogs.js';
|
|
6
|
+
import { ReleasePagesDialog } from '../surface/results/ReleasePages.js';
|
|
7
|
+
import { actionGroupLabel, availableActions } from './actions.model.js';
|
|
8
|
+
import { DecideDialog } from './DecideDialog.js';
|
|
9
|
+
export function LifecycleButton({ action, reason, showReason = true, disabled, ariaDisabled, busy, onClick }) {
|
|
10
|
+
const id = useId();
|
|
11
|
+
const help = showReason ? reason ?? action.hint : action.hint;
|
|
12
|
+
return /*#__PURE__*/ _jsxs("span", {
|
|
13
|
+
className: "xp-lifecycle-action",
|
|
14
|
+
children: [
|
|
15
|
+
/*#__PURE__*/ _jsx(Button, {
|
|
16
|
+
variant: action.tone === 'danger' ? 'danger' : action.tone === 'primary' ? 'primary' : 'secondary',
|
|
17
|
+
busy: busy,
|
|
18
|
+
disabled: disabled || !!reason,
|
|
19
|
+
"aria-disabled": ariaDisabled || undefined,
|
|
20
|
+
"aria-describedby": help ? id : undefined,
|
|
21
|
+
title: !showReason ? reason : undefined,
|
|
22
|
+
onClick: (event)=>{
|
|
23
|
+
if (ariaDisabled) return;
|
|
24
|
+
event.currentTarget.focus();
|
|
25
|
+
onClick();
|
|
26
|
+
},
|
|
27
|
+
children: action.label
|
|
28
|
+
}),
|
|
29
|
+
help ? /*#__PURE__*/ _jsx("span", {
|
|
30
|
+
className: "xp-ui-help",
|
|
31
|
+
id: id,
|
|
32
|
+
children: help
|
|
33
|
+
}) : null
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
export function LifecycleDialog({ action, test, surface, onClose }) {
|
|
38
|
+
const [opened] = useState(test.doc);
|
|
39
|
+
const doc = test.doc ?? opened;
|
|
40
|
+
const decision = doc.decision;
|
|
41
|
+
const winner = actionGroupLabel(decision?.winnerArm ?? 'control', doc.arms.find((arm)=>arm.key === decision?.winnerArm)?.label);
|
|
42
|
+
const props = {
|
|
43
|
+
test,
|
|
44
|
+
surface,
|
|
45
|
+
onClose
|
|
46
|
+
};
|
|
47
|
+
const changed = !test.doc || doc.phase !== opened.phase || !availableActions({
|
|
48
|
+
...doc,
|
|
49
|
+
decision,
|
|
50
|
+
canManage: surface.canManage,
|
|
51
|
+
canReadResults: surface.canReadResults
|
|
52
|
+
}).some((item)=>item.id === action.id);
|
|
53
|
+
if (action.id === 'decide') return /*#__PURE__*/ _jsx(DecideDialog, {
|
|
54
|
+
name: opened.name,
|
|
55
|
+
id: opened.id,
|
|
56
|
+
phase: opened.phase,
|
|
57
|
+
checks: test.preflight?.checks,
|
|
58
|
+
apiRoute: surface.apiRoute,
|
|
59
|
+
pending: test.statusReadPending,
|
|
60
|
+
unavailable: changed,
|
|
61
|
+
onClose: onClose,
|
|
62
|
+
onRefusal: ()=>{
|
|
63
|
+
void test.reload();
|
|
64
|
+
},
|
|
65
|
+
onSuccess: (result)=>{
|
|
66
|
+
test.acceptTransition?.({
|
|
67
|
+
doc: result
|
|
68
|
+
});
|
|
69
|
+
onClose();
|
|
70
|
+
void test.reload();
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
if (action.id === 'release-pages') return /*#__PURE__*/ _jsx(ReleasePagesDialog, {
|
|
74
|
+
name: opened.name,
|
|
75
|
+
id: opened.id,
|
|
76
|
+
phase: opened.phase,
|
|
77
|
+
apiRoute: surface.apiRoute,
|
|
78
|
+
disabled: test.statusReadPending || changed,
|
|
79
|
+
onClose: onClose,
|
|
80
|
+
onRefusal: (status)=>{
|
|
81
|
+
if ([
|
|
82
|
+
401,
|
|
83
|
+
403,
|
|
84
|
+
404,
|
|
85
|
+
409,
|
|
86
|
+
422
|
|
87
|
+
].includes(status)) void test.reload();
|
|
88
|
+
},
|
|
89
|
+
onSuccess: (doc)=>{
|
|
90
|
+
test.acceptTransition?.({
|
|
91
|
+
doc
|
|
92
|
+
});
|
|
93
|
+
void test.reload();
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
if (action.id === 'allocate') return /*#__PURE__*/ _jsx(AllocateAction, {
|
|
97
|
+
...props
|
|
98
|
+
});
|
|
99
|
+
if (action.id === 'add-metric') return /*#__PURE__*/ _jsx(AddMetricAction, {
|
|
100
|
+
...props
|
|
101
|
+
});
|
|
102
|
+
return /*#__PURE__*/ _jsx(ConfirmAction, {
|
|
103
|
+
...props,
|
|
104
|
+
action: action,
|
|
105
|
+
winnerLabel: winner
|
|
106
|
+
});
|
|
107
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DocId } from '../../types/contracts.js';
|
|
2
|
-
import type { MakeContentResult as Result } from '../../types/endpoints.js';
|
|
3
|
-
import type { createApi } from '../api.js';
|
|
2
|
+
import type { DismissContentEntryResult, MakeContentResult as Result } from '../../types/endpoints.js';
|
|
3
|
+
import type { ApiResult, createApi } from '../api.js';
|
|
4
4
|
type Props = {
|
|
5
5
|
result: Result;
|
|
6
6
|
onRetry: () => void | Promise<void>;
|
|
@@ -12,6 +12,7 @@ type Props = {
|
|
|
12
12
|
onFinish?: () => void | Promise<void>;
|
|
13
13
|
onBusyChange?: (busy: boolean) => void;
|
|
14
14
|
onActionStart?: () => void;
|
|
15
|
+
onDocumentChange?: (result: ApiResult<DismissContentEntryResult>) => void | Promise<void>;
|
|
15
16
|
};
|
|
16
|
-
export declare function MakeContentResult({ result, onRetry, busy, id, api, canManage, isDecided, onFinish, onBusyChange, onActionStart }: Props): import("react").JSX.Element;
|
|
17
|
+
export declare function MakeContentResult({ result, onRetry, busy, id, api, canManage, isDecided, onFinish, onBusyChange, onActionStart, onDocumentChange }: Props): import("react").JSX.Element;
|
|
17
18
|
export {};
|
|
@@ -6,7 +6,7 @@ import { Button } from '../../ui/Button.js';
|
|
|
6
6
|
import { Banner } from '../../ui/Banner.js';
|
|
7
7
|
import { API_MESSAGES } from '../copy/common.js';
|
|
8
8
|
import { ACTIONS_COPY as C, contentReportCopy } from '../copy/actions.js';
|
|
9
|
-
export function MakeContentResult({ result, onRetry, busy = false, id, api, canManage = false, isDecided = false, onFinish, onBusyChange, onActionStart }) {
|
|
9
|
+
export function MakeContentResult({ result, onRetry, busy = false, id, api, canManage = false, isDecided = false, onFinish, onBusyChange, onActionStart, onDocumentChange }) {
|
|
10
10
|
const inFlight = useRef(false);
|
|
11
11
|
const container = useRef(null);
|
|
12
12
|
const focusTarget = useRef(null);
|
|
@@ -58,8 +58,16 @@ export function MakeContentResult({ result, onRetry, busy = false, id, api, canM
|
|
|
58
58
|
});
|
|
59
59
|
if (!response.ok) {
|
|
60
60
|
setError(response.message);
|
|
61
|
+
if ([
|
|
62
|
+
401,
|
|
63
|
+
403,
|
|
64
|
+
404,
|
|
65
|
+
409,
|
|
66
|
+
422
|
|
67
|
+
].includes(response.status)) await onDocumentChange?.(response);
|
|
61
68
|
return;
|
|
62
69
|
}
|
|
70
|
+
await onDocumentChange?.(response);
|
|
63
71
|
const decision = response.data?.doc.decision;
|
|
64
72
|
const updated = decision?.contentReport?.docs?.find((doc)=>doc.collection === entry.collection && String(doc.id) === String(entry.id));
|
|
65
73
|
if (!updated) {
|
|
@@ -137,7 +145,7 @@ export function MakeContentResult({ result, onRetry, busy = false, id, api, canM
|
|
|
137
145
|
}) : null,
|
|
138
146
|
editable && contentDone(docs) && onFinish ? /*#__PURE__*/ _jsx(Button, {
|
|
139
147
|
"data-finish-archiving": true,
|
|
140
|
-
variant: "
|
|
148
|
+
variant: "danger",
|
|
141
149
|
disabled: busy || pending,
|
|
142
150
|
onClick: ()=>{
|
|
143
151
|
void run(onFinish);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import type { ExperimentKind, Status } from '../../types/contracts.js';
|
|
2
2
|
import type { ArchiveBody, ContentReport } from '../../types/endpoints.js';
|
|
3
|
+
import { type PageReleaseDecision } from '../results/releasePages.model.js';
|
|
3
4
|
export type ActionGroup = {
|
|
4
5
|
key: string;
|
|
5
6
|
label?: string;
|
|
6
7
|
kind?: string;
|
|
7
8
|
};
|
|
8
9
|
export type { ContentReport } from '../../types/endpoints.js';
|
|
9
|
-
export type ActionDecision = {
|
|
10
|
-
winnerArm?: string | null;
|
|
10
|
+
export type ActionDecision = PageReleaseDecision & {
|
|
11
11
|
holdoutReleasedAt?: string | null;
|
|
12
12
|
contentReport?: ContentReport | null;
|
|
13
13
|
};
|
|
14
|
-
export type ActionId = 'start' | 'stop' | 'decide' | 'release-holdout' | 'make-content' | 'after-content' | 'archive' | 'discard' | 'hard-coded' | 'allocate' | 'add-metric';
|
|
14
|
+
export type ActionId = 'start' | 'stop' | 'decide' | 'release-holdout' | 'make-content' | 'after-content' | 'archive' | 'discard' | 'hard-coded' | 'allocate' | 'add-metric' | 'delete' | 'release-pages';
|
|
15
|
+
export declare function isDestructiveAction(id: ActionId): boolean;
|
|
15
16
|
export type ExperimentAction = {
|
|
16
17
|
id: ActionId;
|
|
17
18
|
label: string;
|
|
@@ -19,17 +20,24 @@ export type ExperimentAction = {
|
|
|
19
20
|
confirm: {
|
|
20
21
|
title: string;
|
|
21
22
|
body: string;
|
|
23
|
+
label?: string;
|
|
22
24
|
phrase?: {
|
|
23
25
|
action: 'discard' | 'hard-coded';
|
|
24
26
|
};
|
|
25
27
|
};
|
|
26
28
|
archive?: ArchiveBody;
|
|
29
|
+
hint?: string;
|
|
30
|
+
unavailable?: string;
|
|
27
31
|
};
|
|
28
32
|
export declare function actionGroupLabel(key: string, storedLabel?: string): string;
|
|
29
|
-
export declare function
|
|
33
|
+
export declare function canDeleteTest(status: string): status is "draft" | "archived";
|
|
34
|
+
export declare function availableActions({ name, status, kind, arms, allocation, decision, canManage, canReadResults }: {
|
|
35
|
+
name?: string;
|
|
30
36
|
status: Status;
|
|
31
37
|
kind: ExperimentKind;
|
|
32
|
-
arms
|
|
38
|
+
arms?: readonly ActionGroup[] | null;
|
|
39
|
+
allocation?: number;
|
|
33
40
|
decision?: ActionDecision | null;
|
|
34
41
|
canManage: boolean;
|
|
42
|
+
canReadResults?: boolean;
|
|
35
43
|
}): ExperimentAction[];
|
|
@@ -1,18 +1,46 @@
|
|
|
1
1
|
import { contentDone } from '../../contentDone.js';
|
|
2
2
|
import { armLabel } from '../labels.js';
|
|
3
|
-
import { ACTIONS_COPY as C, hardCodedLabel, makeContentCopy, releaseCopy } from '../copy/actions.js';
|
|
3
|
+
import { ACTIONS_COPY as C, actionTitle, archiveCopy, discardCopy, hardCodedLabel, makeContentCopy, releaseCopy, stopCopy } from '../copy/actions.js';
|
|
4
4
|
import { REVIEW_COPY } from '../copy/review.js';
|
|
5
|
+
import { READINESS_COPY } from '../copy/readiness.js';
|
|
6
|
+
import { DELETE_TEST } from '../copy/testPage.js';
|
|
7
|
+
import { RESULTS_COPY } from '../copy/results.js';
|
|
8
|
+
import { canReleasePages } from '../results/releasePages.model.js';
|
|
9
|
+
const destructiveActions = new Set([
|
|
10
|
+
'stop',
|
|
11
|
+
'decide',
|
|
12
|
+
'release-holdout',
|
|
13
|
+
'make-content',
|
|
14
|
+
'after-content',
|
|
15
|
+
'archive',
|
|
16
|
+
'discard',
|
|
17
|
+
'hard-coded',
|
|
18
|
+
'delete',
|
|
19
|
+
'release-pages'
|
|
20
|
+
]);
|
|
21
|
+
// Use destructive confirmation styling when an action permanently ends a round, ships or releases content, archives, or deletes.
|
|
22
|
+
export function isDestructiveAction(id) {
|
|
23
|
+
return destructiveActions.has(id);
|
|
24
|
+
}
|
|
5
25
|
export function actionGroupLabel(key, storedLabel) {
|
|
6
26
|
return storedLabel?.trim() || armLabel(key);
|
|
7
27
|
}
|
|
8
|
-
export function
|
|
28
|
+
export function canDeleteTest(status) {
|
|
29
|
+
return status === 'draft' || status === 'archived';
|
|
30
|
+
}
|
|
31
|
+
export function availableActions({ name, status, kind, arms = [], allocation, decision, canManage, canReadResults = canManage }) {
|
|
9
32
|
if (!canManage) return [];
|
|
10
|
-
const action = (id, label, body, tone = 'secondary', archive, phrase)=>
|
|
33
|
+
const action = (id, label, body, tone = 'secondary', archive, phrase)=>{
|
|
34
|
+
const confirmLabel = id === 'hard-coded' ? C.confirmPermanentWinner : label;
|
|
35
|
+
const titleKey = id === 'start' && status === 'stopped' ? 'restart' : id;
|
|
36
|
+
const titleLead = Object.hasOwn(C.titleLead, titleKey) ? C.titleLead[titleKey] : confirmLabel;
|
|
37
|
+
return {
|
|
11
38
|
id,
|
|
12
39
|
label,
|
|
13
40
|
tone,
|
|
14
41
|
confirm: {
|
|
15
|
-
title:
|
|
42
|
+
title: name ? actionTitle(titleLead, name) : confirmLabel,
|
|
43
|
+
label: confirmLabel,
|
|
16
44
|
body,
|
|
17
45
|
...phrase ? {
|
|
18
46
|
phrase: {
|
|
@@ -23,30 +51,52 @@ export function availableActions({ status, kind, arms, decision, canManage }) {
|
|
|
23
51
|
...archive ? {
|
|
24
52
|
archive
|
|
25
53
|
} : {}
|
|
26
|
-
}
|
|
54
|
+
};
|
|
55
|
+
};
|
|
27
56
|
const start = action('start', status === 'stopped' ? C.restart : C.start, status === 'stopped' ? C.restartBody : C.startBody, 'primary');
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
57
|
+
const control = actionGroupLabel('control', arms?.find((group)=>group.kind === 'control' || group.key === 'control')?.label);
|
|
58
|
+
const decide = canReadResults ? [
|
|
59
|
+
action('decide', C.decide, C.decideBody, 'primary')
|
|
60
|
+
] : [];
|
|
61
|
+
const remove = action('delete', DELETE_TEST.action, DELETE_TEST.consequences, 'danger');
|
|
62
|
+
if (canDeleteTest(status)) return status === 'draft' ? [
|
|
63
|
+
start,
|
|
64
|
+
remove
|
|
65
|
+
] : [
|
|
66
|
+
...canReleasePages({
|
|
67
|
+
status,
|
|
68
|
+
kind,
|
|
69
|
+
decision
|
|
70
|
+
}) ? [
|
|
71
|
+
action('release-pages', RESULTS_COPY.releasePages, RESULTS_COPY.releasePagesBody)
|
|
72
|
+
] : [],
|
|
73
|
+
remove
|
|
31
74
|
];
|
|
32
75
|
if (status === 'running') return [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
76
|
+
...decide,
|
|
77
|
+
action('add-metric', READINESS_COPY.addGoal, ''),
|
|
78
|
+
{
|
|
79
|
+
...action('allocate', READINESS_COPY.allocate, REVIEW_COPY.allocationBody),
|
|
80
|
+
unavailable: allocation !== undefined && allocation >= 100 ? READINESS_COPY.everyone : undefined
|
|
81
|
+
},
|
|
82
|
+
action('stop', C.stop, stopCopy(control), 'danger')
|
|
37
83
|
];
|
|
38
84
|
if (status === 'stopped') return [
|
|
39
85
|
start,
|
|
40
|
-
decide,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
86
|
+
...decide,
|
|
87
|
+
{
|
|
88
|
+
...action('archive', C.archive, archiveCopy(control), 'secondary', {
|
|
89
|
+
mode: 'stopped'
|
|
90
|
+
}),
|
|
91
|
+
hint: DELETE_TEST.archiveFirst
|
|
92
|
+
}
|
|
44
93
|
];
|
|
45
94
|
if (status !== 'decided') return [];
|
|
46
|
-
const
|
|
95
|
+
const groups = arms ?? [];
|
|
96
|
+
const winner = groups.find((group)=>group.key === decision?.winnerArm);
|
|
47
97
|
const label = actionGroupLabel(decision?.winnerArm ?? 'control', winner?.label);
|
|
48
|
-
const rolloutOpen =
|
|
49
|
-
|
|
98
|
+
const rolloutOpen = groups.some((group)=>group.key === 'holdout') && Boolean(decision?.winnerArm) && decision?.winnerArm !== 'control' && !decision?.holdoutReleasedAt;
|
|
99
|
+
const actions = [
|
|
50
100
|
...rolloutOpen ? [
|
|
51
101
|
action('release-holdout', C.release, releaseCopy(label))
|
|
52
102
|
] : [],
|
|
@@ -58,13 +108,16 @@ export function availableActions({ status, kind, arms, decision, canManage }) {
|
|
|
58
108
|
mode: 'after-content'
|
|
59
109
|
})
|
|
60
110
|
] : [],
|
|
61
|
-
action('discard', C.discard,
|
|
111
|
+
action('discard', C.discard, discardCopy(control), 'danger', {
|
|
62
112
|
mode: 'discard'
|
|
63
113
|
}, 'discard'),
|
|
64
|
-
...kind === 'code' ? [
|
|
65
|
-
action('hard-coded', hardCodedLabel(label),
|
|
114
|
+
...kind === 'code' && winner && winner.kind !== 'holdout' ? [
|
|
115
|
+
action('hard-coded', hardCodedLabel(label), C.hardCodedBody, 'primary', {
|
|
66
116
|
mode: 'hard-coded'
|
|
67
117
|
}, 'hard-coded')
|
|
68
118
|
] : []
|
|
69
119
|
];
|
|
120
|
+
const archiveOption = actions.find((item)=>item.id === 'after-content') ?? actions.find((item)=>item.archive || item.id === 'make-content');
|
|
121
|
+
if (archiveOption) archiveOption.hint = DELETE_TEST.archiveFirst;
|
|
122
|
+
return actions;
|
|
70
123
|
}
|
|
@@ -4,10 +4,13 @@ const percent = (value)=>String(Math.round(value * 10) / 10);
|
|
|
4
4
|
export function allocationSentence({ allocation, unitType, arms, layer, status }) {
|
|
5
5
|
const groups = arms.filter((group)=>group.kind !== 'holdout');
|
|
6
6
|
if (!groups.length || !Number.isFinite(allocation)) return '';
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const control = groups.find((group)=>group.kind === 'control' || group.key === 'control');
|
|
8
|
+
const labelOf = (group)=>group.label?.trim() || armLabel(group.key);
|
|
9
|
+
const controlLabel = control ? labelOf(control) : armLabel('control');
|
|
10
|
+
const equal = groups.length > 1 && groups.every((group)=>group.weight === groups[0].weight);
|
|
11
|
+
const shares = equal ? eachVersion(percent(allocation * groups[0].weight / 100)) : groups.map((group)=>groupShare(percent(allocation * group.weight / 100), labelOf(group))).join(', ');
|
|
9
12
|
const holdout = arms.find((group)=>group.kind === 'holdout');
|
|
10
|
-
let sentence = participation(percent(allocation), peopleLabel[unitType], shares) + (holdout ? holdoutClause(percent(holdout.weight)) : '') + (allocation < 100 ? holdout ? holdoutRemainder : uncounted : '');
|
|
13
|
+
let sentence = participation(percent(allocation), peopleLabel[unitType], shares) + (holdout ? holdoutClause(percent(holdout.weight), controlLabel) : '') + (allocation < 100 ? holdout ? holdoutRemainder(controlLabel) : uncounted(controlLabel) : '');
|
|
11
14
|
if ((holdout || layer || status === 'running') && !sentence.endsWith('.')) sentence += '.';
|
|
12
15
|
if (layer) sentence += layerSentence(layer.name, layer.used, layer.free);
|
|
13
16
|
return sentence;
|