@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
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { Button } from '../../../ui/Button.js';
|
|
4
4
|
import { useId, useState } from 'react';
|
|
5
5
|
import { ChipsInput } from '../../../ui/ChipsInput.js';
|
|
6
6
|
import { AUDIENCE_COPY } from '../../copy/audience.js';
|
|
7
7
|
import { coerceValue, emptyListHint, humaniseAttribute, opLabel, opsFor, readListValue, readTargetingRules, valueInput } from '../../targeting/targeting.model.js';
|
|
8
8
|
import { TEST_PAGE as C, NUMBER_COMPARISONS } from '../../copy/testPage.js';
|
|
9
|
-
import { CheckboxList, FieldErrors, reasonFor, save, SelectEdit, TextEdit } from './fields.js';
|
|
9
|
+
import { CheckboxList, FieldErrors, ReadOnly, reasonFor, save, SavedValueChanged, SelectEdit, TextEdit, useDraftAnnouncement, useFieldDraft } from './fields.js';
|
|
10
10
|
import { Section } from './Section.js';
|
|
11
11
|
export function TargetingSection({ test, surface }) {
|
|
12
12
|
const id = useId();
|
|
@@ -59,12 +59,20 @@ export function TargetingSection({ test, surface }) {
|
|
|
59
59
|
...partial
|
|
60
60
|
} : row));
|
|
61
61
|
const hint = emptyListHint(rule.op, rule.value);
|
|
62
|
+
const draftKey = JSON.stringify([
|
|
63
|
+
'targeting',
|
|
64
|
+
rowsRevision,
|
|
65
|
+
index,
|
|
66
|
+
rule.attribute,
|
|
67
|
+
rule.op,
|
|
68
|
+
rules.length
|
|
69
|
+
]);
|
|
62
70
|
const changeValue = (raw)=>{
|
|
63
71
|
const current = test.doc.targeting?.[index];
|
|
64
72
|
const schema = current && surface.attributeKeys[current.attribute];
|
|
65
|
-
if (!current || !schema) return;
|
|
73
|
+
if (!current || !schema) return false;
|
|
66
74
|
const value = coerceValue(schema.type, current.op, raw);
|
|
67
|
-
|
|
75
|
+
return value !== null && setRule({
|
|
68
76
|
value
|
|
69
77
|
});
|
|
70
78
|
};
|
|
@@ -125,15 +133,15 @@ export function TargetingSection({ test, surface }) {
|
|
|
125
133
|
])
|
|
126
134
|
] : values.filter((saved)=>saved !== value));
|
|
127
135
|
}
|
|
128
|
-
}) : input.kind === 'chips' ? /*#__PURE__*/ _jsx(
|
|
136
|
+
}) : input.kind === 'chips' ? /*#__PURE__*/ _jsx(TargetingChips, {
|
|
137
|
+
draftKey: draftKey,
|
|
138
|
+
test: test,
|
|
129
139
|
id: `${id}-${index}-value`,
|
|
130
|
-
label: C.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
onChange: changeValue
|
|
136
|
-
}, `${rule.attribute}-${rule.op}`) : input.kind === 'select' ? /*#__PURE__*/ _jsx(SelectEdit, {
|
|
140
|
+
label: C.targetingValue(humaniseAttribute(rule.attribute)),
|
|
141
|
+
values: readListValue(rule.value),
|
|
142
|
+
reason: reason,
|
|
143
|
+
onCommit: changeValue
|
|
144
|
+
}, draftKey) : input.kind === 'select' ? /*#__PURE__*/ _jsx(SelectEdit, {
|
|
137
145
|
label: C.value,
|
|
138
146
|
reason: reason,
|
|
139
147
|
value: String(rule.value),
|
|
@@ -155,6 +163,8 @@ export function TargetingSection({ test, surface }) {
|
|
|
155
163
|
],
|
|
156
164
|
onCommit: changeValue
|
|
157
165
|
}) : /*#__PURE__*/ _jsx(TextEdit, {
|
|
166
|
+
test: test,
|
|
167
|
+
draftKey: draftKey,
|
|
158
168
|
label: C.value,
|
|
159
169
|
reason: reason,
|
|
160
170
|
value: Array.isArray(rule.value) ? rule.value.join(', ') : String(rule.value),
|
|
@@ -210,3 +220,63 @@ export function TargetingSection({ test, surface }) {
|
|
|
210
220
|
]
|
|
211
221
|
});
|
|
212
222
|
}
|
|
223
|
+
function TargetingChips({ test, draftKey, id, label, values, reason, onCommit }) {
|
|
224
|
+
const saved = values.join(', ');
|
|
225
|
+
const draft = useFieldDraft(test, draftKey, label, '', saved);
|
|
226
|
+
const [announcement, announce] = useDraftAnnouncement();
|
|
227
|
+
const choice = draft.dirty && !draft.saving && (draft.conflict || draft.retry || reason);
|
|
228
|
+
const locked = Boolean(reason || test.stale || draft.saving);
|
|
229
|
+
const commit = (text, confirmed = false)=>{
|
|
230
|
+
if (locked || choice && !confirmed) {
|
|
231
|
+
announce();
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const next = [
|
|
235
|
+
...new Set([
|
|
236
|
+
...values,
|
|
237
|
+
...text.split(',').map((value)=>value.trim()).filter(Boolean)
|
|
238
|
+
])
|
|
239
|
+
];
|
|
240
|
+
if (next.length === values.length) {
|
|
241
|
+
draft.discard();
|
|
242
|
+
return;
|
|
243
|
+
}
|
|
244
|
+
if (text !== draft.value || !draft.dirty) draft.change(text);
|
|
245
|
+
draft.submit(()=>onCommit(next));
|
|
246
|
+
};
|
|
247
|
+
if (reason && !draft.dirty) return /*#__PURE__*/ _jsx(ReadOnly, {
|
|
248
|
+
label: C.value,
|
|
249
|
+
value: values.join(', ')
|
|
250
|
+
});
|
|
251
|
+
const choiceId = choice ? `${id}-new-value` : undefined;
|
|
252
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
253
|
+
children: [
|
|
254
|
+
/*#__PURE__*/ _jsx(ChipsInput, {
|
|
255
|
+
id: id,
|
|
256
|
+
label: C.value,
|
|
257
|
+
value: values,
|
|
258
|
+
disabled: locked,
|
|
259
|
+
description: reason ? undefined : AUDIENCE_COPY.listDescription,
|
|
260
|
+
placeholder: AUDIENCE_COPY.listPlaceholder,
|
|
261
|
+
onChange: onCommit,
|
|
262
|
+
draft: {
|
|
263
|
+
value: draft.dirty ? draft.value : '',
|
|
264
|
+
change: draft.change,
|
|
265
|
+
submit: commit,
|
|
266
|
+
discard: draft.discard,
|
|
267
|
+
describedBy: choiceId
|
|
268
|
+
}
|
|
269
|
+
}),
|
|
270
|
+
choiceId ? /*#__PURE__*/ _jsx(SavedValueChanged, {
|
|
271
|
+
id: choiceId,
|
|
272
|
+
value: saved,
|
|
273
|
+
reason: reason,
|
|
274
|
+
showReason: false,
|
|
275
|
+
conflict: draft.conflict,
|
|
276
|
+
announce: announcement,
|
|
277
|
+
onKeep: !locked ? ()=>commit(draft.value, true) : undefined,
|
|
278
|
+
onDiscard: draft.discard
|
|
279
|
+
}) : null
|
|
280
|
+
]
|
|
281
|
+
});
|
|
282
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
4
|
-
import { surfaceUrls } from '../../surfaceUrls.js';
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { DeleteTestAction } from './DeleteTest.js';
|
|
5
4
|
import { useEffect, useState, useRef } from 'react';
|
|
6
5
|
import { useTestDocument } from '../useTestDocument.js';
|
|
7
6
|
import { API_MESSAGES } from '../../copy/common.js';
|
|
@@ -31,19 +30,10 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
31
30
|
const documentState = useTestDocument(id, {
|
|
32
31
|
apiRoute: surface.apiRoute,
|
|
33
32
|
contentLocale: surface.contentLocale,
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
...onDocument ? {
|
|
39
|
-
onDocument
|
|
40
|
-
} : {},
|
|
41
|
-
...onPreflight ? {
|
|
42
|
-
onPreflight
|
|
43
|
-
} : {},
|
|
44
|
-
...requestPreflight ? {
|
|
45
|
-
requestPreflight
|
|
46
|
-
} : {}
|
|
33
|
+
enabled: surface.canManage,
|
|
34
|
+
onDocument,
|
|
35
|
+
onPreflight,
|
|
36
|
+
requestPreflight
|
|
47
37
|
});
|
|
48
38
|
const [placementRead, setPlacementRead] = useState();
|
|
49
39
|
const placementKey = JSON.stringify([
|
|
@@ -73,6 +63,14 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
73
63
|
surface.contentLocale
|
|
74
64
|
]);
|
|
75
65
|
const currentRead = documentState.loadState === 'ready' && placementRead?.key === placementKey ? placementRead : undefined;
|
|
66
|
+
const answer = currentRead?.pending ? undefined : currentRead?.read;
|
|
67
|
+
const { syncDocument } = documentState;
|
|
68
|
+
useEffect(()=>{
|
|
69
|
+
syncDocument?.(answer);
|
|
70
|
+
}, [
|
|
71
|
+
answer,
|
|
72
|
+
syncDocument
|
|
73
|
+
]);
|
|
76
74
|
const preflight = currentRead ? currentRead.preflight ?? (currentRead.pending && !currentRead.error ? documentState.preflight : null) : documentState.preflight;
|
|
77
75
|
const sharedDocument = currentRead ? {
|
|
78
76
|
...documentState,
|
|
@@ -88,7 +86,11 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
88
86
|
value: preflight.placements
|
|
89
87
|
};
|
|
90
88
|
const placements = !placementFailed && !sharedDocument.preflightError && lastPlacements.current?.key === placementKey ? lastPlacements.current.value : undefined;
|
|
91
|
-
const
|
|
89
|
+
const editorDocument = embedded ? currentPuckDocument(window.location.pathname, surface.adminRoute, placements) : undefined;
|
|
90
|
+
const editorPage = editorDocument ? {
|
|
91
|
+
...editorDocument,
|
|
92
|
+
versionContent: surface.editorPage?.versionContent
|
|
93
|
+
} : surface.editorPage;
|
|
92
94
|
const message = editorPlacementMessage(placements, editorPage, documentState.doc?.status);
|
|
93
95
|
surface = {
|
|
94
96
|
...surface,
|
|
@@ -117,6 +119,23 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
117
119
|
children
|
|
118
120
|
}) : children;
|
|
119
121
|
};
|
|
122
|
+
const detachedEdits = (test.detachedDrafts ?? []).map((key)=>{
|
|
123
|
+
const draft = test.fieldDrafts?.[key];
|
|
124
|
+
return draft && !draft.saving ? /*#__PURE__*/ _jsxs(Banner, {
|
|
125
|
+
tone: "warning",
|
|
126
|
+
action: /*#__PURE__*/ _jsx(Button, {
|
|
127
|
+
onClick: ()=>test.trackDraft(key, null),
|
|
128
|
+
children: C.discardEdit
|
|
129
|
+
}),
|
|
130
|
+
children: [
|
|
131
|
+
C.detachedEdit(draft.label),
|
|
132
|
+
" ",
|
|
133
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
134
|
+
children: draft.value || C.emptyValue
|
|
135
|
+
})
|
|
136
|
+
]
|
|
137
|
+
}, key) : null;
|
|
138
|
+
});
|
|
120
139
|
// Results readers have no permission to load the manager-only test/preflight.
|
|
121
140
|
if (!surface.canManage) return frame(/*#__PURE__*/ _jsx(ResultsBody, {
|
|
122
141
|
id: id,
|
|
@@ -126,6 +145,20 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
126
145
|
className: "xp-test-page",
|
|
127
146
|
role: test.loadState === 'error' ? 'alert' : 'status',
|
|
128
147
|
children: [
|
|
148
|
+
Object.entries(test.fieldDrafts ?? {}).map(([key, draft])=>/*#__PURE__*/ _jsxs(Banner, {
|
|
149
|
+
tone: "warning",
|
|
150
|
+
action: /*#__PURE__*/ _jsx(Button, {
|
|
151
|
+
onClick: ()=>test.trackDraft(key, null),
|
|
152
|
+
children: C.discardEdit
|
|
153
|
+
}),
|
|
154
|
+
children: [
|
|
155
|
+
C.detachedEdit(draft.label),
|
|
156
|
+
" ",
|
|
157
|
+
/*#__PURE__*/ _jsx("strong", {
|
|
158
|
+
children: draft.value || C.emptyValue
|
|
159
|
+
})
|
|
160
|
+
]
|
|
161
|
+
}, key)),
|
|
129
162
|
/*#__PURE__*/ _jsx("p", {
|
|
130
163
|
children: test.preflightRead?.kind === 'signed-out' ? API_MESSAGES.unauthenticated : test.loadState === 'forbidden' ? C.forbidden : test.loadState === 'missing' ? C.missing : test.loadState === 'error' ? C.error : C.loading
|
|
131
164
|
}),
|
|
@@ -155,14 +188,25 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
155
188
|
/*#__PURE__*/ _jsxs("div", {
|
|
156
189
|
className: "xp-test-content",
|
|
157
190
|
children: [
|
|
158
|
-
test.errors._section ? /*#__PURE__*/
|
|
191
|
+
test.errors._section ? /*#__PURE__*/ _jsxs(Banner, {
|
|
159
192
|
tone: "error",
|
|
160
193
|
action: /*#__PURE__*/ _jsx(Button, {
|
|
161
|
-
onClick: ()=>void test.reload(
|
|
194
|
+
onClick: ()=>void test.reload({
|
|
195
|
+
discardDrafts: true
|
|
196
|
+
}),
|
|
162
197
|
children: C.reload
|
|
163
198
|
}),
|
|
164
|
-
children:
|
|
199
|
+
children: [
|
|
200
|
+
test.errors._section,
|
|
201
|
+
test.stale ? null : /*#__PURE__*/ _jsxs(_Fragment, {
|
|
202
|
+
children: [
|
|
203
|
+
" ",
|
|
204
|
+
C.reloadAfterError
|
|
205
|
+
]
|
|
206
|
+
})
|
|
207
|
+
]
|
|
165
208
|
}) : null,
|
|
209
|
+
detachedEdits,
|
|
166
210
|
/*#__PURE__*/ _jsxs(Section, {
|
|
167
211
|
surface: surface,
|
|
168
212
|
test: test,
|
|
@@ -197,35 +241,27 @@ export function TestSurface({ id, surface, onTitleChange, renderFrame, embedded
|
|
|
197
241
|
/*#__PURE__*/ _jsx(AdvancedSection, {
|
|
198
242
|
...props
|
|
199
243
|
}),
|
|
200
|
-
!embedded ? /*#__PURE__*/ _jsx(
|
|
201
|
-
|
|
202
|
-
test: test.doc,
|
|
203
|
-
canManage: surface.canManage,
|
|
204
|
-
apiRoute: surface.apiRoute,
|
|
205
|
-
contentLocale: surface.contentLocale,
|
|
206
|
-
onDeleted: (outcome)=>{
|
|
207
|
-
window.location.assign(surfaceUrls.home(surface.adminRoute, {
|
|
208
|
-
deleted: outcome
|
|
209
|
-
}));
|
|
210
|
-
}
|
|
211
|
-
})
|
|
244
|
+
!embedded ? /*#__PURE__*/ _jsx(DeleteTestAction, {
|
|
245
|
+
...props
|
|
212
246
|
}) : null,
|
|
213
247
|
embedded && surface.canReadResults && test.doc.status !== 'draft' ? /*#__PURE__*/ _jsx(ResultsBody, {
|
|
248
|
+
documentVersion: `${test.doc.phase}/${test.doc.status}`,
|
|
249
|
+
liveDocument: test.doc,
|
|
250
|
+
statusReadPending: test.statusReadPending,
|
|
214
251
|
id: id,
|
|
215
252
|
surface: surface,
|
|
216
|
-
onChanged: (
|
|
217
|
-
test.acceptTransition?.(
|
|
218
|
-
doc
|
|
219
|
-
});
|
|
253
|
+
onChanged: (transition)=>{
|
|
254
|
+
if (transition) test.acceptTransition?.(transition);
|
|
220
255
|
void test.reload();
|
|
221
256
|
}
|
|
222
|
-
}
|
|
257
|
+
}) : null
|
|
223
258
|
]
|
|
224
259
|
})
|
|
225
260
|
]
|
|
226
261
|
}),
|
|
227
262
|
/*#__PURE__*/ _jsx(ReadinessBar, {
|
|
228
263
|
...props,
|
|
264
|
+
embedded: embedded,
|
|
229
265
|
onHeightChange: setBarHeight
|
|
230
266
|
})
|
|
231
267
|
]
|