@delmaredigital/payload-experiments 0.4.0-rc.9 → 0.4.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 +3 -7
- package/dist/admin/MetricSourceSelect.js +10 -3
- package/dist/admin/armSelect/armSelect.model.d.ts +1 -1
- package/dist/admin/blocks/BlockPanel.d.ts +1 -0
- package/dist/admin/blocks/BlockPanel.js +75 -29
- package/dist/admin/blocks/model.js +5 -4
- package/dist/admin/copy/blocks.d.ts +14 -11
- package/dist/admin/copy/blocks.js +33 -22
- package/dist/admin/copy/goals.d.ts +15 -8
- package/dist/admin/copy/goals.js +18 -8
- package/dist/admin/copy/newTest.d.ts +10 -7
- package/dist/admin/copy/newTest.js +14 -7
- package/dist/admin/copy/status.d.ts +1 -1
- package/dist/admin/copy/status.js +2 -1
- package/dist/admin/pageCollections.d.ts +1 -0
- package/dist/admin/pageCollections.js +3 -0
- package/dist/admin/placementStatus.model.js +5 -3
- package/dist/admin/status.model.d.ts +1 -0
- package/dist/admin/status.model.js +2 -1
- package/dist/admin/surface/ResultsRoute.js +4 -8
- package/dist/admin/surface/SurfaceShell.d.ts +4 -2
- package/dist/admin/surface/SurfaceShell.js +28 -3
- package/dist/admin/surface/TestRowMenu.d.ts +13 -0
- package/dist/admin/surface/TestRowMenu.js +163 -0
- package/dist/admin/surface/TestsHome.d.ts +4 -3
- package/dist/admin/surface/TestsHome.js +186 -47
- package/dist/admin/surface/TestsSurface.js +2 -1
- package/dist/admin/surface/goals/DeleteGoalDialog.d.ts +7 -0
- package/dist/admin/surface/goals/DeleteGoalDialog.js +42 -0
- package/dist/admin/surface/goals/GoalForm.d.ts +1 -0
- package/dist/admin/surface/goals/GoalForm.js +280 -198
- package/dist/admin/surface/goals/GoalsList.js +102 -33
- package/dist/admin/surface/goals/data.d.ts +2 -0
- package/dist/admin/surface/goals/data.js +9 -0
- package/dist/admin/surface/goals/goals.css +3 -2
- package/dist/admin/surface/goals/goals.model.d.ts +2 -2
- package/dist/admin/surface/goals/goals.model.js +7 -12
- package/dist/admin/surface/home.model.d.ts +15 -8
- package/dist/admin/surface/home.model.js +22 -18
- package/dist/admin/surface/newTest/NewTest.d.ts +3 -3
- package/dist/admin/surface/newTest/NewTest.js +156 -96
- package/dist/admin/surface/newTest/PageWizard.d.ts +4 -1
- package/dist/admin/surface/newTest/PageWizard.js +93 -68
- package/dist/admin/surface/newTest/newTest.css +28 -11
- package/dist/admin/surface/results/ResultsHeader.d.ts +1 -1
- package/dist/admin/surface/results/ResultsHeader.js +90 -63
- package/dist/admin/surface/surface.css +29 -0
- package/dist/admin/surface/test/TestPage.js +46 -38
- package/dist/admin/surface/useXpStepNav.d.ts +11 -0
- package/dist/admin/surface/useXpStepNav.js +14 -0
- package/dist/admin/views/TestsSurfaceClient.js +27 -3
- package/dist/admin/views/buildSurfaceProps.js +18 -66
- package/dist/arms/copy.d.ts +13 -3
- package/dist/arms/copy.js +5 -4
- package/dist/blocks/createExperimentBlock.js +1 -1
- package/dist/blocks/formState.js +1 -1
- package/dist/collections/experiments/armInvariants.js +8 -5
- package/dist/collections/metrics.js +12 -5
- package/dist/collections/serialize.js +3 -2
- package/dist/db/pageCopies.d.ts +5 -0
- package/dist/db/pageCopies.js +31 -0
- package/dist/db/snapshots.d.ts +1 -0
- package/dist/endpoints/duplicateOriginal.d.ts +38 -0
- package/dist/endpoints/duplicateOriginal.js +414 -0
- package/dist/endpoints/editorSurface.js +1 -1
- package/dist/endpoints/index.js +20 -0
- package/dist/endpoints/pages.js +245 -66
- package/dist/endpoints/placementStatus.js +1 -0
- package/dist/endpoints/results.js +3 -0
- package/dist/endpoints/testVersion.d.ts +2 -0
- package/dist/endpoints/testVersion.js +38 -0
- package/dist/endpoints/transitions.js +4 -5
- package/dist/exports/index.d.ts +1 -1
- package/dist/goals/picker/copy.js +1 -1
- package/dist/goals/sourceLabel.d.ts +2 -0
- package/dist/goals/sourceLabel.js +4 -0
- package/dist/hooks/trackPageCopies.d.ts +11 -0
- package/dist/hooks/trackPageCopies.js +7 -0
- package/dist/labels/arms.d.ts +3 -0
- package/dist/labels/arms.js +8 -0
- package/dist/options.d.ts +2 -0
- package/dist/options.js +18 -2
- package/dist/plugin.js +56 -2
- package/dist/puck/editor/ConfigureTestDrawer.d.ts +7 -7
- package/dist/puck/editor/ConfigureTestDrawer.js +36 -26
- package/dist/puck/editor/ExperimentSlotEditor.d.ts +2 -1
- package/dist/puck/editor/ExperimentSlotEditor.js +219 -106
- package/dist/puck/editor/LeftoverVersions.js +17 -32
- package/dist/puck/editor/QuickTestActions.d.ts +2 -2
- package/dist/puck/editor/QuickTestActions.js +44 -34
- package/dist/puck/editor/ResultsReadout.d.ts +3 -1
- package/dist/puck/editor/ResultsReadout.js +28 -16
- package/dist/puck/editor/VersionBuilder.d.ts +4 -2
- package/dist/puck/editor/VersionBuilder.js +42 -63
- package/dist/puck/editor/armWrites.js +1 -1
- package/dist/puck/editor/copy.d.ts +10 -6
- package/dist/puck/editor/copy.js +22 -12
- package/dist/puck/editor/editor.chrome.css +9 -8
- package/dist/puck/editor/editor.css +14 -9
- package/dist/puck/editor/placementsCache.d.ts +1 -1
- package/dist/puck/editor/placementsCache.js +9 -17
- package/dist/puck/editor/usePageSaveReadiness.d.ts +1 -4
- package/dist/puck/editor/usePageSaveReadiness.js +18 -21
- package/dist/puck/editor/usePlacementNotice.d.ts +2 -2
- package/dist/puck/editor/usePlacementNotice.js +4 -5
- package/dist/puck/nestedTestCopy.js +2 -2
- package/dist/puck/slotConfig.d.ts +1 -1
- package/dist/puck/slotConfig.js +1 -1
- package/dist/results/analyse.d.ts +2 -0
- package/dist/results/analyse.js +2 -2
- package/dist/results/verdict.d.ts +4 -4
- package/dist/results/verdict.js +13 -10
- package/dist/server/runResults.js +2 -1
- package/dist/testSurface/PreviewLinks.d.ts +2 -1
- package/dist/testSurface/PreviewLinks.js +3 -3
- package/dist/testSurface/actions/DecideDialog.d.ts +7 -4
- package/dist/testSurface/actions/DecideDialog.js +71 -59
- package/dist/testSurface/actions/LifecycleAction.d.ts +17 -0
- package/dist/testSurface/actions/LifecycleAction.js +107 -0
- package/dist/testSurface/actions/MakeContentResult.js +1 -1
- package/dist/testSurface/actions/actions.model.d.ts +13 -5
- package/dist/testSurface/actions/actions.model.js +75 -22
- package/dist/testSurface/actions/decide.model.d.ts +1 -0
- package/dist/testSurface/actions/decide.model.js +1 -0
- package/dist/testSurface/allocation.model.js +6 -3
- package/dist/testSurface/api.d.ts +4 -1
- package/dist/testSurface/api.js +22 -14
- package/dist/testSurface/copy/actions.d.ts +36 -14
- package/dist/testSurface/copy/actions.js +39 -17
- package/dist/testSurface/copy/advanced.d.ts +10 -0
- package/dist/testSurface/copy/advanced.js +10 -0
- package/dist/testSurface/copy/arms.d.ts +1 -1
- package/dist/testSurface/copy/arms.js +1 -1
- package/dist/testSurface/copy/audience.d.ts +4 -3
- package/dist/testSurface/copy/audience.js +5 -4
- package/dist/testSurface/copy/common.d.ts +6 -6
- package/dist/testSurface/copy/common.js +6 -6
- package/dist/testSurface/copy/metrics.d.ts +6 -0
- package/dist/testSurface/copy/metrics.js +8 -0
- package/dist/testSurface/copy/pages.d.ts +67 -7
- package/dist/testSurface/copy/pages.js +74 -7
- package/dist/testSurface/copy/readiness.d.ts +8 -6
- package/dist/testSurface/copy/readiness.js +19 -10
- package/dist/testSurface/copy/recommendation.d.ts +1 -22
- package/dist/testSurface/copy/recommendation.js +2 -22
- package/dist/testSurface/copy/results.d.ts +16 -10
- package/dist/testSurface/copy/results.js +19 -11
- package/dist/testSurface/copy/review.d.ts +13 -10
- package/dist/testSurface/copy/review.js +14 -10
- package/dist/testSurface/copy/setting.d.ts +1 -2
- package/dist/testSurface/copy/setting.js +1 -2
- package/dist/testSurface/copy/surface.d.ts +11 -2
- package/dist/testSurface/copy/surface.js +14 -11
- package/dist/testSurface/copy/testPage.d.ts +16 -10
- package/dist/testSurface/copy/testPage.js +24 -18
- package/dist/testSurface/format/date.d.ts +5 -2
- package/dist/testSurface/format/date.js +24 -8
- package/dist/testSurface/format/roundProgress.d.ts +6 -0
- package/dist/testSurface/format/roundProgress.js +15 -0
- package/dist/testSurface/format/useDateFormatter.d.ts +3 -0
- package/dist/testSurface/format/useDateFormatter.js +8 -0
- package/dist/testSurface/labels.d.ts +1 -2
- package/dist/testSurface/labels.js +2 -3
- package/dist/testSurface/lockedNotice.model.d.ts +2 -0
- package/dist/testSurface/lockedNotice.model.js +31 -0
- package/dist/testSurface/readPreflight.d.ts +0 -1
- package/dist/testSurface/readPreflight.js +0 -1
- package/dist/testSurface/results/CiChart.js +2 -1
- package/dist/testSurface/results/DataTable.d.ts +1 -1
- package/dist/testSurface/results/DataTable.js +4 -3
- package/dist/testSurface/results/VerdictHero.d.ts +1 -1
- package/dist/testSurface/results/legacy.d.ts +0 -5
- package/dist/testSurface/results/legacy.js +0 -14
- package/dist/testSurface/results/results.css +2 -2
- package/dist/testSurface/results/results.model.d.ts +8 -3
- package/dist/testSurface/results/results.model.js +25 -21
- package/dist/testSurface/results/snapshot.d.ts +2 -0
- package/dist/testSurface/results/snapshot.js +3 -0
- package/dist/testSurface/surface/contracts.d.ts +6 -1
- package/dist/testSurface/surface/editorPlacement.d.ts +1 -1
- package/dist/testSurface/surface/editorPlacement.js +1 -1
- package/dist/testSurface/surface/pageBlock/pageBlock.model.js +1 -1
- package/dist/testSurface/surface/pageBlock/parts.js +25 -12
- package/dist/testSurface/surface/pagePicker/CopyRoute.d.ts +8 -1
- package/dist/testSurface/surface/pagePicker/CopyRoute.js +243 -22
- package/dist/testSurface/surface/pagePicker/PageCombobox.d.ts +15 -4
- package/dist/testSurface/surface/pagePicker/PageCombobox.js +298 -209
- package/dist/testSurface/surface/pagePicker/pagePicker.css +73 -10
- package/dist/testSurface/surface/pagePicker/pagePicker.model.d.ts +5 -3
- package/dist/testSurface/surface/pagePicker/pagePicker.model.js +17 -2
- package/dist/testSurface/surface/readiness/ActionDialogs.d.ts +5 -3
- package/dist/testSurface/surface/readiness/ActionDialogs.js +213 -207
- package/dist/testSurface/surface/readiness/Banner.d.ts +5 -1
- package/dist/testSurface/surface/readiness/Banner.js +109 -148
- package/dist/testSurface/surface/readiness/SaveStatus.d.ts +5 -2
- package/dist/testSurface/surface/readiness/SaveStatus.js +8 -7
- package/dist/testSurface/surface/readiness/readiness.model.d.ts +14 -5
- package/dist/testSurface/surface/readiness/readiness.model.js +62 -12
- package/dist/testSurface/surface/readiness/useTransition.d.ts +3 -1
- package/dist/testSurface/surface/readiness/useTransition.js +49 -8
- package/dist/testSurface/surface/results/ReleasePages.d.ts +4 -3
- package/dist/testSurface/surface/results/ReleasePages.js +41 -41
- package/dist/testSurface/surface/results/ResultsBody.d.ts +7 -2
- package/dist/testSurface/surface/results/ResultsBody.js +170 -110
- package/dist/testSurface/surface/results/recommendation.model.d.ts +6 -9
- package/dist/testSurface/surface/results/recommendation.model.js +15 -59
- package/dist/testSurface/surface/results/useResults.d.ts +6 -2
- package/dist/testSurface/surface/setting/parts.js +31 -28
- package/dist/testSurface/surface/setting/setting.css +2 -1
- package/dist/testSurface/surface/test/AdvancedSection.js +10 -4
- package/dist/testSurface/surface/test/DeleteTest.d.ts +5 -1
- package/dist/testSurface/surface/test/DeleteTest.js +63 -55
- package/dist/testSurface/surface/test/GoalSection.js +11 -11
- package/dist/testSurface/surface/test/LengthSection.js +21 -13
- package/dist/testSurface/surface/test/PageHoldout.d.ts +1 -1
- package/dist/testSurface/surface/test/PageHoldout.js +7 -7
- package/dist/testSurface/surface/test/ReadinessBar.d.ts +2 -1
- package/dist/testSurface/surface/test/ReadinessBar.js +4 -10
- package/dist/testSurface/surface/test/Section.js +8 -0
- package/dist/testSurface/surface/test/TargetingSection.js +7 -2
- package/dist/testSurface/surface/test/TestSurface.js +17 -43
- package/dist/testSurface/surface/test/VersionsSection.js +93 -70
- package/dist/testSurface/surface/test/fields.d.ts +4 -3
- package/dist/testSurface/surface/test/fields.js +10 -16
- package/dist/testSurface/surface/test/pageParts.js +13 -7
- package/dist/testSurface/surface/test/testPage.css +9 -2
- package/dist/testSurface/surface/useTestDocument.d.ts +1 -3
- package/dist/testSurface/surface/useTestDocument.js +110 -52
- package/dist/testSurface/surface/watchTestDocument.d.ts +15 -0
- package/dist/testSurface/surface/watchTestDocument.js +181 -0
- package/dist/testSurface/surfaceUrls.d.ts +1 -0
- package/dist/testSurface/surfaceUrls.js +4 -0
- package/dist/testSurface/useApi.d.ts +3 -0
- package/dist/transitions/addMetric.d.ts +1 -1
- package/dist/transitions/addMetric.js +5 -1
- package/dist/transitions/kernel.d.ts +2 -0
- package/dist/transitions/kernel.js +1 -1
- package/dist/transitions/pageAddress.d.ts +6 -0
- package/dist/transitions/pageAddress.js +71 -0
- package/dist/transitions/pageVersions.d.ts +1 -1
- package/dist/transitions/preflightData.js +10 -2
- package/dist/transitions/start.d.ts +1 -1
- package/dist/transitions/start.js +8 -5
- package/dist/types/armKey.d.ts +2 -0
- package/dist/types/armKey.js +1 -0
- package/dist/types/contracts.d.ts +11 -1
- package/dist/types/endpoints.d.ts +38 -9
- package/dist/types/endpoints.js +1 -1
- package/dist/types/surface.d.ts +7 -9
- package/dist/ui/Dialog.d.ts +21 -2
- package/dist/ui/Dialog.js +101 -4
- package/dist/ui/Inputs.js +0 -1
- package/dist/ui/ui.css +5 -1
- package/package.json +2 -2
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { surfaceUrls } from '../../../testSurface/surfaceUrls.js';
|
|
4
|
-
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
5
5
|
import { useRouter } from 'next/navigation.js';
|
|
6
6
|
import { formatAdminURL } from 'payload/shared';
|
|
7
|
-
import { GOALS_COPY as C, goalDeleteLockedStart, goalInUse, goalShowAll } from '../../copy/goals.js';
|
|
8
|
-
import {
|
|
7
|
+
import { GOALS_COPY as C, goalDeleteLockedStart, goalInUse, goalShowAll, largestValues } from '../../copy/goals.js';
|
|
8
|
+
import { metricSourceOptions, sourceFor } from '../../../testSurface/metricSource.model.js';
|
|
9
9
|
import { validateCappingType, validateCappingValue } from '../../../collections/metricValidation.js';
|
|
10
10
|
import { CLICK_KEY } from '../../../goals/key.js';
|
|
11
|
-
import {
|
|
11
|
+
import { goalSourceLabel } from '../../../goals/sourceLabel.js';
|
|
12
12
|
import { goalSlug, goalUsage, goalUsageRows, visibleGoalUsage } from './goals.model.js';
|
|
13
13
|
import { GoalResponseError, goalPages, goalResponse } from './data.js';
|
|
14
14
|
import { SURFACE_COPY } from '../../../testSurface/copy/surface.js';
|
|
15
15
|
import { SurfaceShell } from '../SurfaceShell.js';
|
|
16
|
+
import { useXpStepNav } from '../useXpStepNav.js';
|
|
16
17
|
import { Button } from '../../../ui/Button.js';
|
|
17
|
-
import { TextInput, NumberInput
|
|
18
|
+
import { TextInput, NumberInput } from '../../../ui/Inputs.js';
|
|
19
|
+
import { Select } from '../../../ui/Select.js';
|
|
18
20
|
import { Card } from '../../../ui/Card.js';
|
|
19
|
-
import { Banner } from '../../../ui/Feedback.js';
|
|
20
|
-
import {
|
|
21
|
+
import { Banner, StatusChip } from '../../../ui/Feedback.js';
|
|
22
|
+
import { SaveStatus } from '../../../testSurface/surface/readiness/SaveStatus.js';
|
|
23
|
+
import { sameTestValue } from '../../../testSurface/surface/testDocument.model.js';
|
|
24
|
+
import { DeleteGoalDialog } from './DeleteGoalDialog.js';
|
|
25
|
+
import '../../../ui/ui.css';
|
|
21
26
|
import './goals.css';
|
|
22
27
|
const fieldNames = {
|
|
23
28
|
name: 'name',
|
|
@@ -41,11 +46,43 @@ const empty = ()=>({
|
|
|
41
46
|
capValue: '',
|
|
42
47
|
warningPercent: '5'
|
|
43
48
|
});
|
|
49
|
+
const HOURS_PER_DAY = 24;
|
|
50
|
+
function awaitingFixedAmount(draft) {
|
|
51
|
+
return draft.capType === 'absolute' && !draft.capValue.trim() && !draft.capValueEdited;
|
|
52
|
+
}
|
|
53
|
+
function goalBody(draft, lockedGoal) {
|
|
54
|
+
const click = draft.source.startsWith('click:');
|
|
55
|
+
const slug = lockedGoal?.slug ?? draft.slug;
|
|
56
|
+
return {
|
|
57
|
+
name: draft.name,
|
|
58
|
+
slug,
|
|
59
|
+
source: lockedGoal?.source ?? (click ? `click:${slug}` : draft.source),
|
|
60
|
+
direction: click ? 'increase' : draft.direction,
|
|
61
|
+
attributionWindowHours: draft.windowDays === undefined ? draft.attributionWindowHours : Number(draft.windowDays) * HOURS_PER_DAY,
|
|
62
|
+
minSampleSize: draft.minSampleSize,
|
|
63
|
+
capping: {
|
|
64
|
+
type: click ? null : draft.capType || null,
|
|
65
|
+
value: click || !draft.capValue.trim() ? null : Number(draft.capValue)
|
|
66
|
+
},
|
|
67
|
+
guardrailThreshold: (draft.warningPercent.trim() === '' ? 5 : Number(draft.warningPercent)) / 100
|
|
68
|
+
};
|
|
69
|
+
}
|
|
44
70
|
export function GoalForm({ surface, id, returnToTest }) {
|
|
45
71
|
const router = useRouter();
|
|
46
72
|
const base = surface.apiRoute.replace(/\/$/, '');
|
|
47
73
|
const [draft, setDraft] = useState(empty);
|
|
48
74
|
const [goal, setGoal] = useState();
|
|
75
|
+
useXpStepNav([
|
|
76
|
+
{
|
|
77
|
+
label: SURFACE_COPY.goals,
|
|
78
|
+
url: surfaceUrls.goals(surface.adminRoute, returnToTest ? {
|
|
79
|
+
return: returnToTest
|
|
80
|
+
} : undefined)
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: goal?.name ?? (id === undefined ? C.newGoal : C.goal)
|
|
84
|
+
}
|
|
85
|
+
]);
|
|
49
86
|
const [usageTests, setUsageTests] = useState([]);
|
|
50
87
|
const [showAllUsage, setShowAllUsage] = useState(false);
|
|
51
88
|
const [usedBy, setUsedBy] = useState(0);
|
|
@@ -55,11 +92,14 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
55
92
|
const [fieldErrors, setFieldErrors] = useState({});
|
|
56
93
|
const [seenFieldErrors, setSeenFieldErrors] = useState(fieldErrors);
|
|
57
94
|
const [advancedOpen, setAdvancedOpen] = useState(false);
|
|
58
|
-
const [
|
|
95
|
+
const [saving, setSaving] = useState('idle');
|
|
59
96
|
const [slugEdited, setSlugEdited] = useState(false);
|
|
60
97
|
const [attempt, setAttempt] = useState(0);
|
|
61
98
|
const inFlight = useRef(false);
|
|
99
|
+
const persisted = useRef(undefined);
|
|
100
|
+
const queued = useRef(undefined);
|
|
62
101
|
const [confirmDelete, setConfirmDelete] = useState(false);
|
|
102
|
+
const existing = id !== undefined;
|
|
63
103
|
const listUrl = surfaceUrls.goals(surface.adminRoute, returnToTest ? {
|
|
64
104
|
return: returnToTest
|
|
65
105
|
} : undefined);
|
|
@@ -86,14 +126,15 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
86
126
|
setUsageTests(tests);
|
|
87
127
|
setShowAllUsage(false);
|
|
88
128
|
setUsedBy(goalUsage(tests).get(loaded.id) ?? 0);
|
|
89
|
-
|
|
129
|
+
const loadedDraft = {
|
|
90
130
|
...empty(),
|
|
91
131
|
...loaded,
|
|
92
132
|
capType: loaded.capping?.type ?? (defaultCap ? 'percentile' : ''),
|
|
93
133
|
capValue: loaded.capping?.value == null ? defaultCap ? '0.99' : '' : String(loaded.capping.value),
|
|
94
134
|
warningPercent: String(Number(((loaded.guardrailThreshold ?? 0.05) * 100).toPrecision(12)))
|
|
95
|
-
}
|
|
96
|
-
|
|
135
|
+
};
|
|
136
|
+
persisted.current = loadedDraft;
|
|
137
|
+
setDraft(loadedDraft);
|
|
97
138
|
}
|
|
98
139
|
if (!controller.signal.aborted) setReady(true);
|
|
99
140
|
} catch (cause) {
|
|
@@ -104,7 +145,8 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
104
145
|
}, [
|
|
105
146
|
base,
|
|
106
147
|
id,
|
|
107
|
-
attempt
|
|
148
|
+
attempt,
|
|
149
|
+
surface.metricSources
|
|
108
150
|
]);
|
|
109
151
|
const source = sourceFor(draft.source, surface.metricSources);
|
|
110
152
|
const click = draft.source.startsWith('click:');
|
|
@@ -113,70 +155,130 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
113
155
|
setSeenFieldErrors(fieldErrors);
|
|
114
156
|
if (click && fieldErrors.slug || fieldErrors.capType || fieldErrors.capValue || fieldErrors.warningPercent) setAdvancedOpen(true);
|
|
115
157
|
}
|
|
116
|
-
const
|
|
117
|
-
const options =
|
|
158
|
+
const selectedSource = click ? 'click:' : draft.source;
|
|
159
|
+
const options = [
|
|
160
|
+
{
|
|
161
|
+
value: '',
|
|
162
|
+
label: C.chooseSource
|
|
163
|
+
},
|
|
164
|
+
...metricSourceOptions(surface.metricSources)
|
|
165
|
+
];
|
|
166
|
+
if (selectedSource && !source) options.push({
|
|
167
|
+
value: selectedSource,
|
|
168
|
+
label: goalSourceLabel(selectedSource)
|
|
169
|
+
});
|
|
170
|
+
const capChoice = draft.capType === 'percentile' ? draft.capValue : draft.capType;
|
|
171
|
+
const capOptions = source?.kind === 'revenue' ? [] : [
|
|
172
|
+
{
|
|
173
|
+
value: '',
|
|
174
|
+
label: C.noCap
|
|
175
|
+
}
|
|
176
|
+
];
|
|
177
|
+
capOptions.push(...[
|
|
178
|
+
'0.99',
|
|
179
|
+
'0.95'
|
|
180
|
+
].map((value)=>({
|
|
181
|
+
value,
|
|
182
|
+
label: largestValues(value)
|
|
183
|
+
})));
|
|
184
|
+
if (draft.capType === 'percentile' && capChoice && !capOptions.some((option)=>option.value === capChoice)) {
|
|
185
|
+
capOptions.push({
|
|
186
|
+
value: capChoice,
|
|
187
|
+
label: largestValues(capChoice)
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
capOptions.push({
|
|
191
|
+
value: 'absolute',
|
|
192
|
+
label: C.absolute
|
|
193
|
+
});
|
|
194
|
+
const hasUnsaved = !persisted.current || !sameTestValue(goalBody(persisted.current), goalBody(draft));
|
|
118
195
|
const set = (key, value)=>setDraft((current)=>({
|
|
119
196
|
...current,
|
|
120
197
|
[key]: value
|
|
121
198
|
}));
|
|
122
|
-
async function
|
|
123
|
-
if (
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
199
|
+
const submit = useCallback(async function save(draft) {
|
|
200
|
+
if (!ready || !surface.canManage || confirmDelete || existing && persisted.current === draft) return;
|
|
201
|
+
if (existing && awaitingFixedAmount(draft)) return;
|
|
202
|
+
if (inFlight.current) {
|
|
203
|
+
if (existing) queued.current = draft;
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const lockedGoal = usedBy ? goal : undefined;
|
|
207
|
+
const click = draft.source.startsWith('click:');
|
|
208
|
+
const body = goalBody(draft, lockedGoal);
|
|
209
|
+
const kind = sourceFor(draft.source, surface.metricSources)?.kind;
|
|
210
|
+
const typeError = validateCappingType(body.capping.type, body.capping.value, kind);
|
|
211
|
+
const valueError = validateCappingValue(body.capping.value, body.capping.type);
|
|
212
|
+
const days = draft.windowDays === undefined ? undefined : Number(draft.windowDays);
|
|
128
213
|
const errors = {
|
|
129
|
-
|
|
214
|
+
...!draft.name.trim() ? {
|
|
215
|
+
name: C.nameRequired
|
|
216
|
+
} : {},
|
|
217
|
+
...!draft.slug || (!existing || click) && !CLICK_KEY.test(draft.slug) ? {
|
|
130
218
|
slug: C.slugRule
|
|
131
219
|
} : {},
|
|
220
|
+
...!draft.source ? {
|
|
221
|
+
source: C.chooseSource
|
|
222
|
+
} : {},
|
|
223
|
+
...days !== undefined && (!Number.isInteger(days) || days < 1 || !Number.isFinite(days * HOURS_PER_DAY)) ? {
|
|
224
|
+
attributionWindowHours: C.windowError
|
|
225
|
+
} : {},
|
|
226
|
+
...draft.minSampleSize == null || !Number.isFinite(draft.minSampleSize) || draft.minSampleSize < 1 ? {
|
|
227
|
+
minSampleSize: C.minimumError
|
|
228
|
+
} : {},
|
|
132
229
|
...typeError !== true ? {
|
|
133
230
|
capType: typeError
|
|
134
231
|
} : {},
|
|
135
|
-
...valueError !== true ? {
|
|
136
|
-
capValue:
|
|
232
|
+
...valueError !== true ? draft.capType === 'absolute' ? {
|
|
233
|
+
capValue: C.fixedAmountError
|
|
234
|
+
} : {
|
|
235
|
+
capType: valueError
|
|
137
236
|
} : {},
|
|
138
|
-
...!Number.isFinite(
|
|
237
|
+
...!Number.isFinite(body.guardrailThreshold) || body.guardrailThreshold < 0 ? {
|
|
139
238
|
warningPercent: C.thresholdError
|
|
140
239
|
} : {}
|
|
141
240
|
};
|
|
142
241
|
setFieldErrors(errors);
|
|
143
|
-
if (Object.keys(errors).length) return;
|
|
144
|
-
inFlight.current = true;
|
|
145
|
-
setPending('save');
|
|
146
242
|
setError('');
|
|
243
|
+
if (Object.keys(errors).length) {
|
|
244
|
+
setSaving('error');
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
// Send only this editor's changes. Groups such as capping stay atomic.
|
|
248
|
+
const baseline = existing && persisted.current ? goalBody(persisted.current, lockedGoal) : undefined;
|
|
249
|
+
const patch = baseline ? Object.fromEntries(Object.entries(body).filter(([key, value])=>!sameTestValue(value, baseline[key]))) : body;
|
|
250
|
+
if (!Object.keys(patch).length) {
|
|
251
|
+
persisted.current = draft;
|
|
252
|
+
setSaving('saved');
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
inFlight.current = true;
|
|
256
|
+
setSaving('saving');
|
|
147
257
|
try {
|
|
148
|
-
// Use an explicit body: loaded metadata and presentation fields never go back to Payload.
|
|
149
|
-
const body = {
|
|
150
|
-
name: draft.name,
|
|
151
|
-
slug: usedBy && goal ? goal.slug : draft.slug,
|
|
152
|
-
source: usedBy && goal ? goal.source : click ? `click:${draft.slug}` : draft.source,
|
|
153
|
-
direction: click ? 'increase' : draft.direction,
|
|
154
|
-
attributionWindowHours: draft.attributionWindowHours,
|
|
155
|
-
minSampleSize: draft.minSampleSize,
|
|
156
|
-
capping: {
|
|
157
|
-
type: click ? null : draft.capType || null,
|
|
158
|
-
value: capValue
|
|
159
|
-
},
|
|
160
|
-
guardrailThreshold: warningPercent / 100
|
|
161
|
-
};
|
|
162
258
|
const response = await fetch(`${base}/xp-metrics${id === undefined ? '' : `/${encodeURIComponent(id)}`}`, {
|
|
163
|
-
method:
|
|
259
|
+
method: existing ? 'PATCH' : 'POST',
|
|
164
260
|
credentials: 'include',
|
|
165
261
|
headers: {
|
|
166
262
|
'Content-Type': 'application/json'
|
|
167
263
|
},
|
|
168
|
-
body: JSON.stringify(
|
|
264
|
+
body: JSON.stringify(patch)
|
|
169
265
|
});
|
|
170
266
|
const saved = await goalResponse(response, C.saveError, {
|
|
171
267
|
notFound: C.notFound
|
|
172
268
|
});
|
|
173
269
|
if (saved.doc?.id == null) throw new Error(C.saveError);
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
270
|
+
if (existing) {
|
|
271
|
+
persisted.current = draft;
|
|
272
|
+
setGoal(saved.doc);
|
|
273
|
+
setSaving('saved');
|
|
274
|
+
} else {
|
|
275
|
+
router.push(returnToTest ? formatAdminURL({
|
|
276
|
+
adminRoute: surface.adminRoute,
|
|
277
|
+
path: `/experiments/${encodeURIComponent(returnToTest)}?${new URLSearchParams({
|
|
278
|
+
goal: String(saved.doc.id)
|
|
279
|
+
})}`
|
|
280
|
+
}) : listUrl);
|
|
281
|
+
}
|
|
180
282
|
} catch (cause) {
|
|
181
283
|
setError(cause instanceof GoalResponseError ? cause.message : C.saveError);
|
|
182
284
|
if (cause instanceof GoalResponseError) setFieldErrors(Object.fromEntries(Object.entries(cause.fields).flatMap(([path, message])=>fieldNames[path] ? [
|
|
@@ -185,30 +287,32 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
185
287
|
path === 'slug' ? click ? C.duplicateSlug : C.duplicateSlugMain : message
|
|
186
288
|
]
|
|
187
289
|
] : [])));
|
|
290
|
+
setSaving('error');
|
|
291
|
+
} finally{
|
|
188
292
|
inFlight.current = false;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
if (inFlight.current || !confirmDelete || !ready || !surface.canManage || usedBy || id === undefined) return;
|
|
194
|
-
inFlight.current = true;
|
|
195
|
-
setPending('delete');
|
|
196
|
-
setError('');
|
|
197
|
-
setConfirmDelete(false);
|
|
198
|
-
try {
|
|
199
|
-
const response = await fetch(`${base}/xp-metrics/${encodeURIComponent(id)}`, {
|
|
200
|
-
method: 'DELETE',
|
|
201
|
-
credentials: 'include'
|
|
202
|
-
});
|
|
203
|
-
await goalResponse(response, C.deleteError, {
|
|
204
|
-
notFound: C.notFound
|
|
205
|
-
});
|
|
206
|
-
router.push(listUrl);
|
|
207
|
-
} catch (cause) {
|
|
208
|
-
setError(cause instanceof Error ? cause.message : C.deleteError);
|
|
209
|
-
inFlight.current = false;
|
|
210
|
-
setPending(null);
|
|
293
|
+
// Blur commits can outlive this screen, including edits made during a PATCH.
|
|
294
|
+
const next = queued.current;
|
|
295
|
+
queued.current = undefined;
|
|
296
|
+
if (next) await save(next);
|
|
211
297
|
}
|
|
298
|
+
}, [
|
|
299
|
+
base,
|
|
300
|
+
confirmDelete,
|
|
301
|
+
existing,
|
|
302
|
+
goal,
|
|
303
|
+
id,
|
|
304
|
+
listUrl,
|
|
305
|
+
ready,
|
|
306
|
+
returnToTest,
|
|
307
|
+
router,
|
|
308
|
+
surface.adminRoute,
|
|
309
|
+
surface.canManage,
|
|
310
|
+
surface.metricSources,
|
|
311
|
+
usedBy
|
|
312
|
+
]);
|
|
313
|
+
function select(next) {
|
|
314
|
+
setDraft(next);
|
|
315
|
+
if (existing) void submit(next);
|
|
212
316
|
}
|
|
213
317
|
const usage = goal ? goalUsageRows(usageTests, goal.id) : [];
|
|
214
318
|
const title = goal?.name ?? (id === undefined ? C.newGoal : C.goal);
|
|
@@ -248,9 +352,13 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
248
352
|
children: C.loading
|
|
249
353
|
}) : /*#__PURE__*/ _jsxs("form", {
|
|
250
354
|
className: "xp-goal-form",
|
|
355
|
+
noValidate: true,
|
|
356
|
+
onBlur: (event)=>{
|
|
357
|
+
if (existing && event.target instanceof HTMLInputElement) void submit(draft);
|
|
358
|
+
},
|
|
251
359
|
onSubmit: (event)=>{
|
|
252
360
|
event.preventDefault();
|
|
253
|
-
void submit();
|
|
361
|
+
void submit(draft);
|
|
254
362
|
},
|
|
255
363
|
children: [
|
|
256
364
|
usage.length ? /*#__PURE__*/ _jsxs(Card, {
|
|
@@ -270,12 +378,13 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
270
378
|
}),
|
|
271
379
|
children: test.name
|
|
272
380
|
}),
|
|
273
|
-
/*#__PURE__*/
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
381
|
+
/*#__PURE__*/ _jsx("span", {
|
|
382
|
+
className: "xp-goal-usage-roles",
|
|
383
|
+
children: test.roles.join(' · ')
|
|
384
|
+
}),
|
|
385
|
+
test.status ? /*#__PURE__*/ _jsx(StatusChip, {
|
|
386
|
+
status: test.status
|
|
387
|
+
}) : null
|
|
279
388
|
]
|
|
280
389
|
}, test.id))
|
|
281
390
|
}),
|
|
@@ -291,6 +400,11 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
291
400
|
}) : null,
|
|
292
401
|
error ? /*#__PURE__*/ _jsx(Banner, {
|
|
293
402
|
tone: "error",
|
|
403
|
+
action: existing && !Object.keys(fieldErrors).length ? /*#__PURE__*/ _jsx(Button, {
|
|
404
|
+
size: "sm",
|
|
405
|
+
onClick: ()=>void submit(draft),
|
|
406
|
+
children: C.retry
|
|
407
|
+
}) : undefined,
|
|
294
408
|
children: error
|
|
295
409
|
}) : null,
|
|
296
410
|
/*#__PURE__*/ _jsxs(Card, {
|
|
@@ -300,7 +414,7 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
300
414
|
children: C.fields
|
|
301
415
|
}),
|
|
302
416
|
/*#__PURE__*/ _jsxs("fieldset", {
|
|
303
|
-
disabled:
|
|
417
|
+
disabled: !existing && saving === 'saving' || !surface.canManage,
|
|
304
418
|
children: [
|
|
305
419
|
/*#__PURE__*/ _jsx(TextInput, {
|
|
306
420
|
id: "xp-goal-name",
|
|
@@ -313,13 +427,13 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
313
427
|
setDraft((current)=>({
|
|
314
428
|
...current,
|
|
315
429
|
name,
|
|
316
|
-
...!
|
|
317
|
-
slug:
|
|
430
|
+
...!existing && !slugEdited ? {
|
|
431
|
+
slug: goalSlug(name)
|
|
318
432
|
} : {}
|
|
319
433
|
}));
|
|
320
|
-
if (click && !
|
|
434
|
+
if (click && !existing && !slugEdited) setFieldErrors((current)=>({
|
|
321
435
|
...current,
|
|
322
|
-
slug:
|
|
436
|
+
slug: goalSlug(name) ? undefined : C.slugRule
|
|
323
437
|
}));
|
|
324
438
|
}
|
|
325
439
|
}),
|
|
@@ -338,56 +452,43 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
338
452
|
}
|
|
339
453
|
})
|
|
340
454
|
}) : null,
|
|
341
|
-
/*#__PURE__*/
|
|
455
|
+
/*#__PURE__*/ _jsx(Select, {
|
|
342
456
|
id: "xp-goal-source",
|
|
343
457
|
label: C.source,
|
|
344
458
|
required: true,
|
|
345
|
-
value:
|
|
459
|
+
value: selectedSource,
|
|
460
|
+
options: options,
|
|
346
461
|
disabled: usedBy > 0,
|
|
347
|
-
help: usedBy ? C.sourceLocked :
|
|
462
|
+
help: usedBy ? C.sourceLocked : undefined,
|
|
348
463
|
error: fieldErrors.source,
|
|
349
464
|
onChange: (event)=>{
|
|
350
465
|
const sourceId = event.currentTarget.value;
|
|
351
466
|
const revenue = sourceFor(sourceId, surface.metricSources)?.kind === 'revenue';
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
capValue: revenue ? '0.99' : ''
|
|
360
|
-
}));
|
|
361
|
-
if (sourceId === 'click:' && !slugEdited && !usedBy) setFieldErrors((current)=>({
|
|
467
|
+
select({
|
|
468
|
+
...draft,
|
|
469
|
+
source: sourceId,
|
|
470
|
+
capType: revenue ? 'percentile' : '',
|
|
471
|
+
capValue: revenue ? '0.99' : ''
|
|
472
|
+
});
|
|
473
|
+
if (sourceId === 'click:' && !existing && !slugEdited) setFieldErrors((current)=>({
|
|
362
474
|
...current,
|
|
363
|
-
slug:
|
|
475
|
+
slug: goalSlug(draft.name) ? undefined : C.slugRule
|
|
364
476
|
}));
|
|
365
477
|
else if (sourceId === 'click:' !== click) setFieldErrors((current)=>({
|
|
366
478
|
...current,
|
|
367
479
|
slug: undefined
|
|
368
480
|
}));
|
|
369
|
-
}
|
|
370
|
-
children: [
|
|
371
|
-
/*#__PURE__*/ _jsx("option", {
|
|
372
|
-
value: "",
|
|
373
|
-
children: C.chooseSource
|
|
374
|
-
}),
|
|
375
|
-
options.map((option)=>/*#__PURE__*/ _jsx("option", {
|
|
376
|
-
value: option.value,
|
|
377
|
-
children: option.value === 'click:' ? sourceFor(option.value, surface.metricSources)?.label : option.label
|
|
378
|
-
}, option.value)),
|
|
379
|
-
!click && draft.source && !options.some((option)=>option.value === draft.source) ? /*#__PURE__*/ _jsx("option", {
|
|
380
|
-
value: draft.source,
|
|
381
|
-
children: draft.source
|
|
382
|
-
}) : null
|
|
383
|
-
]
|
|
481
|
+
}
|
|
384
482
|
}),
|
|
385
483
|
!click ? /*#__PURE__*/ _jsxs(Select, {
|
|
386
484
|
id: "xp-goal-direction",
|
|
387
485
|
label: C.direction,
|
|
388
486
|
value: draft.direction,
|
|
389
487
|
error: fieldErrors.direction,
|
|
390
|
-
onChange: (event)=>
|
|
488
|
+
onChange: (event)=>select({
|
|
489
|
+
...draft,
|
|
490
|
+
direction: event.currentTarget.value === 'decrease' ? 'decrease' : 'increase'
|
|
491
|
+
}),
|
|
391
492
|
children: [
|
|
392
493
|
/*#__PURE__*/ _jsx("option", {
|
|
393
494
|
value: "increase",
|
|
@@ -404,10 +505,10 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
404
505
|
label: C.window,
|
|
405
506
|
required: true,
|
|
406
507
|
min: "1",
|
|
407
|
-
step: "
|
|
408
|
-
value: draft.
|
|
508
|
+
step: "1",
|
|
509
|
+
value: draft.windowDays ?? (draft.attributionWindowHours == null ? '' : draft.attributionWindowHours % HOURS_PER_DAY === 0 ? draft.attributionWindowHours / HOURS_PER_DAY : (draft.attributionWindowHours / HOURS_PER_DAY).toFixed(1)),
|
|
409
510
|
error: fieldErrors.attributionWindowHours,
|
|
410
|
-
onChange: (event)=>set('
|
|
511
|
+
onChange: (event)=>set('windowDays', event.currentTarget.value)
|
|
411
512
|
}),
|
|
412
513
|
/*#__PURE__*/ _jsx(NumberInput, {
|
|
413
514
|
id: "xp-goal-minimum",
|
|
@@ -445,50 +546,47 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
445
546
|
}
|
|
446
547
|
})
|
|
447
548
|
}) : /*#__PURE__*/ _jsxs("fieldset", {
|
|
549
|
+
"aria-labelledby": "xp-goal-capping-heading",
|
|
448
550
|
children: [
|
|
449
|
-
/*#__PURE__*/ _jsx("
|
|
551
|
+
/*#__PURE__*/ _jsx("h3", {
|
|
552
|
+
id: "xp-goal-capping-heading",
|
|
450
553
|
children: C.capping
|
|
451
554
|
}),
|
|
452
|
-
/*#__PURE__*/
|
|
555
|
+
/*#__PURE__*/ _jsx(Select, {
|
|
453
556
|
id: "xp-goal-cap-type",
|
|
454
557
|
label: C.capType,
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
558
|
+
value: capChoice,
|
|
559
|
+
options: capOptions,
|
|
560
|
+
disabled: !!source && source.kind !== 'revenue',
|
|
561
|
+
error: fieldErrors.capType ?? (draft.capType !== 'absolute' ? fieldErrors.capValue : undefined),
|
|
458
562
|
onChange: (event)=>{
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
children: C.noCap
|
|
470
|
-
}) : null,
|
|
471
|
-
/*#__PURE__*/ _jsx("option", {
|
|
472
|
-
value: "percentile",
|
|
473
|
-
children: C.percentile
|
|
474
|
-
}),
|
|
475
|
-
/*#__PURE__*/ _jsx("option", {
|
|
476
|
-
value: "absolute",
|
|
477
|
-
children: C.absolute
|
|
478
|
-
})
|
|
479
|
-
]
|
|
563
|
+
const value = event.currentTarget.value;
|
|
564
|
+
const next = {
|
|
565
|
+
...draft,
|
|
566
|
+
capType: value === '' || value === 'absolute' ? value : 'percentile',
|
|
567
|
+
capValue: value === 'absolute' ? '' : value,
|
|
568
|
+
capValueEdited: false
|
|
569
|
+
};
|
|
570
|
+
if (value === 'absolute') setDraft(next);
|
|
571
|
+
else select(next);
|
|
572
|
+
}
|
|
480
573
|
}),
|
|
481
|
-
/*#__PURE__*/ _jsx(NumberInput, {
|
|
574
|
+
draft.capType === 'absolute' ? /*#__PURE__*/ _jsx(NumberInput, {
|
|
482
575
|
id: "xp-goal-cap-value",
|
|
483
576
|
label: C.capValue,
|
|
484
577
|
step: "any",
|
|
485
578
|
min: "0",
|
|
486
|
-
disabled: !draft.capType,
|
|
487
579
|
value: draft.capValue,
|
|
488
|
-
error: fieldErrors.capValue,
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
580
|
+
error: existing && awaitingFixedAmount(draft) ? undefined : fieldErrors.capValue,
|
|
581
|
+
onChange: (event)=>{
|
|
582
|
+
const capValue = event.currentTarget.value;
|
|
583
|
+
setDraft((current)=>({
|
|
584
|
+
...current,
|
|
585
|
+
capValue,
|
|
586
|
+
capValueEdited: true
|
|
587
|
+
}));
|
|
588
|
+
}
|
|
589
|
+
}) : null
|
|
492
590
|
]
|
|
493
591
|
}),
|
|
494
592
|
/*#__PURE__*/ _jsx(NumberInput, {
|
|
@@ -510,29 +608,24 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
510
608
|
})
|
|
511
609
|
]
|
|
512
610
|
}),
|
|
513
|
-
/*#__PURE__*/
|
|
611
|
+
/*#__PURE__*/ _jsx("div", {
|
|
514
612
|
className: "xp-ui-button-group",
|
|
515
|
-
children:
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
"aria-describedby": usedBy ? 'xp-goal-used' : undefined,
|
|
532
|
-
onClick: ()=>setConfirmDelete(true),
|
|
533
|
-
children: pending === 'delete' ? C.deleting : C.remove
|
|
534
|
-
})
|
|
535
|
-
]
|
|
613
|
+
children: existing ? /*#__PURE__*/ _jsx(Button, {
|
|
614
|
+
variant: "danger",
|
|
615
|
+
disabled: saving === 'saving' || usedBy > 0 || !surface.canManage,
|
|
616
|
+
"aria-describedby": usedBy ? 'xp-goal-used' : undefined,
|
|
617
|
+
onClick: (event)=>{
|
|
618
|
+
event.currentTarget.focus();
|
|
619
|
+
setConfirmDelete(true);
|
|
620
|
+
},
|
|
621
|
+
children: C.remove
|
|
622
|
+
}) : /*#__PURE__*/ _jsx(Button, {
|
|
623
|
+
variant: "primary",
|
|
624
|
+
type: "submit",
|
|
625
|
+
disabled: saving === 'saving' || !surface.canManage,
|
|
626
|
+
busy: saving === 'saving',
|
|
627
|
+
children: saving === 'saving' ? C.saving : C.createGoal
|
|
628
|
+
})
|
|
536
629
|
}),
|
|
537
630
|
id !== undefined && usedBy ? /*#__PURE__*/ _jsxs("p", {
|
|
538
631
|
className: "xp-ui-help",
|
|
@@ -547,37 +640,26 @@ export function GoalForm({ surface, id, returnToTest }) {
|
|
|
547
640
|
]
|
|
548
641
|
}) : null
|
|
549
642
|
]
|
|
550
|
-
})
|
|
643
|
+
}),
|
|
644
|
+
existing && surface.canManage ? /*#__PURE__*/ _jsx("div", {
|
|
645
|
+
className: "xp-goal-save",
|
|
646
|
+
children: /*#__PURE__*/ _jsx(SaveStatus, {
|
|
647
|
+
save: {
|
|
648
|
+
saving,
|
|
649
|
+
hasUnsaved,
|
|
650
|
+
stale: false,
|
|
651
|
+
errors: {}
|
|
652
|
+
}
|
|
653
|
+
})
|
|
654
|
+
}) : null
|
|
551
655
|
]
|
|
552
656
|
}),
|
|
553
|
-
/*#__PURE__*/
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
title: C.deleteTitle,
|
|
657
|
+
confirmDelete && goal ? /*#__PURE__*/ _jsx(DeleteGoalDialog, {
|
|
658
|
+
goal: goal,
|
|
659
|
+
apiRoute: base,
|
|
557
660
|
onClose: ()=>setConfirmDelete(false),
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
children: C.deleteBody
|
|
561
|
-
}),
|
|
562
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
563
|
-
className: "xp-ui-button-group",
|
|
564
|
-
children: [
|
|
565
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
566
|
-
variant: "quiet",
|
|
567
|
-
"data-dialog-cancel": true,
|
|
568
|
-
onClick: ()=>setConfirmDelete(false),
|
|
569
|
-
children: C.cancel
|
|
570
|
-
}),
|
|
571
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
572
|
-
variant: "danger",
|
|
573
|
-
disabled: pending !== null,
|
|
574
|
-
onClick: ()=>void remove(),
|
|
575
|
-
children: C.confirmDelete
|
|
576
|
-
})
|
|
577
|
-
]
|
|
578
|
-
})
|
|
579
|
-
]
|
|
580
|
-
})
|
|
661
|
+
onDeleted: ()=>router.push(listUrl)
|
|
662
|
+
}) : null
|
|
581
663
|
]
|
|
582
664
|
})
|
|
583
665
|
});
|