@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
|
@@ -10,11 +10,21 @@ import { createApi } from '../../testSurface/api.js';
|
|
|
10
10
|
import { useOnTestReturn } from '../../testSurface/useOnTestReturn.js';
|
|
11
11
|
import { noMatchesLine, SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
12
12
|
import { Banner, EmptyState, StatusChip } from '../../ui/Feedback.js';
|
|
13
|
+
import { useDateFormatter } from '../../testSurface/format/useDateFormatter.js';
|
|
13
14
|
import { Button } from '../../ui/Button.js';
|
|
14
15
|
import { SearchInput } from '../../ui/Inputs.js';
|
|
15
16
|
import { SurfaceShell } from './SurfaceShell.js';
|
|
16
17
|
import { sanitizeReadinessDetail } from '../../sanitizeReadinessDetail.js';
|
|
17
18
|
import { groupTests, homeCard } from './home.model.js';
|
|
19
|
+
import { availableActions } from '../../testSurface/actions/actions.model.js';
|
|
20
|
+
import { LifecycleDialog } from '../../testSurface/actions/LifecycleAction.js';
|
|
21
|
+
import { useXpStepNav } from './useXpStepNav.js';
|
|
22
|
+
import { TestRowMenu } from './TestRowMenu.js';
|
|
23
|
+
import { useTestDocument } from '../../testSurface/surface/useTestDocument.js';
|
|
24
|
+
import { ConfirmDialog } from '../../ui/Dialog.js';
|
|
25
|
+
import { ACTIONS_COPY } from '../../testSurface/copy/actions.js';
|
|
26
|
+
import { API_MESSAGES } from '../../testSurface/copy/common.js';
|
|
27
|
+
import { READINESS_COPY } from '../../testSurface/copy/readiness.js';
|
|
18
28
|
const HOME_FIELDS = [
|
|
19
29
|
'name',
|
|
20
30
|
'kind',
|
|
@@ -25,13 +35,21 @@ const HOME_FIELDS = [
|
|
|
25
35
|
'decision',
|
|
26
36
|
'unitType',
|
|
27
37
|
'flagPoint',
|
|
28
|
-
'updatedAt'
|
|
38
|
+
'updatedAt',
|
|
39
|
+
'phase',
|
|
40
|
+
'allocation',
|
|
41
|
+
'startedAt'
|
|
29
42
|
];
|
|
30
43
|
// Typecheck fails if HomeTest gains a field the list request does not select (Payload always returns id).
|
|
31
44
|
const homeFieldsComplete = true;
|
|
32
45
|
void homeFieldsComplete;
|
|
33
46
|
const HOME_SELECT = HOME_FIELDS.map((field)=>`select[${field}]=true`).join('&');
|
|
34
|
-
export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = false, crumbs, flagPoints }) {
|
|
47
|
+
export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = false, canReadResults = true, crumbs, flagPoints }) {
|
|
48
|
+
useXpStepNav([
|
|
49
|
+
{
|
|
50
|
+
label: SURFACE_COPY.title
|
|
51
|
+
}
|
|
52
|
+
]);
|
|
35
53
|
const api = useMemo(()=>createApi(apiRoute), [
|
|
36
54
|
apiRoute
|
|
37
55
|
]);
|
|
@@ -44,14 +62,34 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
44
62
|
const [notice, setNotice] = useState();
|
|
45
63
|
const noticeRef = useRef(null);
|
|
46
64
|
const deletedIds = useRef(new Set());
|
|
47
|
-
const
|
|
65
|
+
const openDialogId = useRef(undefined);
|
|
66
|
+
const [selection, setSelection] = useState();
|
|
48
67
|
const [dialogTest, setDialogTest] = useState();
|
|
49
68
|
const refreshDeferred = useRef(false);
|
|
69
|
+
const returnToRow = useRef(null);
|
|
70
|
+
const actionList = useRef(null);
|
|
50
71
|
useLayoutEffect(()=>{
|
|
51
72
|
if (notice) noticeRef.current?.focus();
|
|
52
73
|
}, [
|
|
53
74
|
notice
|
|
54
75
|
]);
|
|
76
|
+
useEffect(()=>{
|
|
77
|
+
const previous = returnToRow.current;
|
|
78
|
+
const list = actionList.current;
|
|
79
|
+
const doc = noticeRef.current?.ownerDocument;
|
|
80
|
+
if (!previous || !doc || state.loading || openDialogId.current !== undefined) return;
|
|
81
|
+
if (previous.trigger?.isConnected) return;
|
|
82
|
+
returnToRow.current = null;
|
|
83
|
+
if (doc.activeElement !== doc.body && !doc.activeElement?.hasAttribute('data-dialog-focus-fallback')) return;
|
|
84
|
+
const row = [
|
|
85
|
+
...list?.querySelectorAll('[data-test-row]') ?? []
|
|
86
|
+
].find((item)=>item.dataset.testRow === previous.id);
|
|
87
|
+
const archived = row?.closest('details:not([open])');
|
|
88
|
+
const target = archived?.querySelector('summary') ?? row?.querySelector('.xp-tests-row-menu-trigger') ?? row?.querySelector('.xp-tests-row-action');
|
|
89
|
+
(target ?? doc.getElementById('xp-tests-search'))?.focus();
|
|
90
|
+
}, [
|
|
91
|
+
state
|
|
92
|
+
]);
|
|
55
93
|
useEffect(()=>{
|
|
56
94
|
const url = new URL(window.location.href);
|
|
57
95
|
const deleted = url.searchParams.get('deleted');
|
|
@@ -73,12 +111,12 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
73
111
|
function settle(next) {
|
|
74
112
|
if (!active) return;
|
|
75
113
|
// A new group can remount a row. Let its open dialog finish before replacing the list.
|
|
76
|
-
if (
|
|
114
|
+
if (openDialogId.current === undefined) {
|
|
77
115
|
setState(next);
|
|
78
116
|
return;
|
|
79
117
|
}
|
|
80
118
|
refreshDeferred.current = true;
|
|
81
|
-
if (!next.loading && !next.error) setDialogTest(next.tests.find((test)=>String(test.id) ===
|
|
119
|
+
if (!next.loading && !next.error) setDialogTest(next.tests.find((test)=>String(test.id) === openDialogId.current));
|
|
82
120
|
}
|
|
83
121
|
async function load() {
|
|
84
122
|
try {
|
|
@@ -90,8 +128,8 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
90
128
|
if (!response.ok) throw new Error('list');
|
|
91
129
|
const docs = response.docs.sort((a, b)=>(Date.parse(b.updatedAt ?? '') || 0) - (Date.parse(a.updatedAt ?? '') || 0));
|
|
92
130
|
if (!active) return;
|
|
93
|
-
const summary = await api.summary(docs.map((doc)=>doc.id));
|
|
94
|
-
const summaries = summary
|
|
131
|
+
const summary = canReadResults ? await api.summary(docs.map((doc)=>doc.id)) : undefined;
|
|
132
|
+
const summaries = summary?.ok ? summary.data ?? {} : {};
|
|
95
133
|
const ids = [
|
|
96
134
|
...new Set(docs.flatMap((doc)=>{
|
|
97
135
|
const item = summaries[doc.id];
|
|
@@ -125,7 +163,7 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
125
163
|
tests: docs.filter((doc)=>!deletedIds.current.has(String(doc.id))),
|
|
126
164
|
goalNames,
|
|
127
165
|
summaries,
|
|
128
|
-
summaryError:
|
|
166
|
+
summaryError: summary?.ok === false
|
|
129
167
|
});
|
|
130
168
|
} catch {
|
|
131
169
|
settle({
|
|
@@ -143,12 +181,25 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
143
181
|
api,
|
|
144
182
|
apiRoute,
|
|
145
183
|
attempt,
|
|
146
|
-
canManage
|
|
184
|
+
canManage,
|
|
185
|
+
canReadResults
|
|
147
186
|
]);
|
|
148
|
-
function
|
|
149
|
-
|
|
187
|
+
function showDialog(row, action) {
|
|
188
|
+
openDialogId.current = String(row.id);
|
|
189
|
+
returnToRow.current = {
|
|
190
|
+
id: String(row.id),
|
|
191
|
+
trigger: actionList.current?.ownerDocument.activeElement ?? null
|
|
192
|
+
};
|
|
193
|
+
setSelection({
|
|
194
|
+
row,
|
|
195
|
+
action
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
function closeDialog() {
|
|
199
|
+
openDialogId.current = undefined;
|
|
200
|
+
setSelection(undefined);
|
|
150
201
|
setDialogTest(undefined);
|
|
151
|
-
if (
|
|
202
|
+
if (refreshDeferred.current) {
|
|
152
203
|
refreshDeferred.current = false;
|
|
153
204
|
reload();
|
|
154
205
|
}
|
|
@@ -176,6 +227,17 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
176
227
|
}),
|
|
177
228
|
children: SURFACE_COPY.newTest
|
|
178
229
|
});
|
|
230
|
+
const actionSurface = {
|
|
231
|
+
adminRoute,
|
|
232
|
+
apiRoute,
|
|
233
|
+
contentLocale,
|
|
234
|
+
canManage,
|
|
235
|
+
canReadResults,
|
|
236
|
+
isAdmin: false,
|
|
237
|
+
flagPoints: flagPoints ?? [],
|
|
238
|
+
attributeKeys: {},
|
|
239
|
+
metricSources: []
|
|
240
|
+
};
|
|
179
241
|
return /*#__PURE__*/ _jsxs(SurfaceShell, {
|
|
180
242
|
adminRoute: adminRoute,
|
|
181
243
|
crumbs: crumbs,
|
|
@@ -240,31 +302,51 @@ export function TestsHome({ adminRoute, apiRoute, contentLocale, canManage = fal
|
|
|
240
302
|
action: retry,
|
|
241
303
|
children: SURFACE_COPY.summaryError
|
|
242
304
|
}) : null,
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
children:
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
clear: ()=>setSearch('')
|
|
305
|
+
/*#__PURE__*/ _jsx("div", {
|
|
306
|
+
ref: actionList,
|
|
307
|
+
children: state.tests.length === 0 ? /*#__PURE__*/ _jsx(EmptyState, {
|
|
308
|
+
action: newTest,
|
|
309
|
+
children: SURFACE_COPY.empty
|
|
310
|
+
}) : /*#__PURE__*/ _jsx(TestGroups, {
|
|
311
|
+
tests: state.tests,
|
|
312
|
+
summaries: state.summaries,
|
|
313
|
+
goalNames: state.goalNames,
|
|
314
|
+
adminRoute: adminRoute,
|
|
315
|
+
canManage: canManage,
|
|
316
|
+
canReadResults: canReadResults,
|
|
317
|
+
onSelect: showDialog,
|
|
318
|
+
flagPoints: flagPoints,
|
|
319
|
+
search: search,
|
|
320
|
+
clear: ()=>setSearch('')
|
|
321
|
+
})
|
|
261
322
|
})
|
|
262
323
|
]
|
|
263
|
-
})
|
|
324
|
+
}),
|
|
325
|
+
selection?.action.id === 'delete' ? /*#__PURE__*/ _jsx(DeleteTest, {
|
|
326
|
+
fromMenu: true,
|
|
327
|
+
test: dialogTest ?? selection.row,
|
|
328
|
+
canManage: canManage,
|
|
329
|
+
apiRoute: apiRoute,
|
|
330
|
+
contentLocale: contentLocale,
|
|
331
|
+
onDeleted: (outcome)=>handleDeleted(selection.row.id, outcome),
|
|
332
|
+
onDialogChange: (open)=>{
|
|
333
|
+
if (!open) closeDialog();
|
|
334
|
+
},
|
|
335
|
+
onStatusChanged: reload
|
|
336
|
+
}) : selection ? /*#__PURE__*/ _jsx(ListLifecycleDialog, {
|
|
337
|
+
selection: selection,
|
|
338
|
+
surface: actionSurface,
|
|
339
|
+
onClose: ()=>{
|
|
340
|
+
closeDialog();
|
|
341
|
+
reload();
|
|
342
|
+
}
|
|
343
|
+
}) : null
|
|
264
344
|
]
|
|
265
345
|
});
|
|
266
346
|
}
|
|
267
|
-
function TestGroups({ tests,
|
|
347
|
+
function TestGroups({ tests, summaries, goalNames, adminRoute, canManage, canReadResults, onSelect, flagPoints, search, clear }) {
|
|
348
|
+
const formatDate = useDateFormatter();
|
|
349
|
+
const now = Date.now();
|
|
268
350
|
const groups = groupTests(tests, summaries, search);
|
|
269
351
|
if (!groups.some((group)=>group.tests.length)) return /*#__PURE__*/ _jsxs("div", {
|
|
270
352
|
className: "xp-tests-no-matches",
|
|
@@ -286,9 +368,28 @@ function TestGroups({ tests, dialogTest, summaries, goalNames, adminRoute, apiRo
|
|
|
286
368
|
const rows = /*#__PURE__*/ _jsx("div", {
|
|
287
369
|
className: "xp-tests-list",
|
|
288
370
|
children: group.tests.map((test)=>{
|
|
289
|
-
const
|
|
371
|
+
const summary = summaries[test.id];
|
|
372
|
+
const card = homeCard(test, summary, adminRoute, {
|
|
373
|
+
formatDate,
|
|
374
|
+
now,
|
|
375
|
+
flagPoints,
|
|
376
|
+
goalNames,
|
|
377
|
+
canReadResults
|
|
378
|
+
});
|
|
379
|
+
const ready = test.status === 'draft' && summary?.ready === true;
|
|
380
|
+
const actions = availableActions({
|
|
381
|
+
...test,
|
|
382
|
+
canManage,
|
|
383
|
+
canReadResults
|
|
384
|
+
});
|
|
385
|
+
const primary = ready ? actions.find((action)=>action.id === 'start') : undefined;
|
|
386
|
+
const menu = actions.filter((action)=>action.id !== 'start' || test.status === 'stopped').map((action)=>action.id === 'start' && summary?.ready === false ? {
|
|
387
|
+
...action,
|
|
388
|
+
unavailable: card.line
|
|
389
|
+
} : action);
|
|
290
390
|
return /*#__PURE__*/ _jsxs("article", {
|
|
291
391
|
className: "xp-tests-row",
|
|
392
|
+
"data-test-row": String(test.id),
|
|
292
393
|
children: [
|
|
293
394
|
/*#__PURE__*/ _jsxs("div", {
|
|
294
395
|
className: "xp-tests-row-main",
|
|
@@ -307,7 +408,7 @@ function TestGroups({ tests, dialogTest, summaries, goalNames, adminRoute, apiRo
|
|
|
307
408
|
/*#__PURE__*/ _jsx("span", {
|
|
308
409
|
title: card.pill.tooltip,
|
|
309
410
|
children: /*#__PURE__*/ _jsx(StatusChip, {
|
|
310
|
-
status: test.status
|
|
411
|
+
status: ready ? 'ready' : test.status
|
|
311
412
|
})
|
|
312
413
|
})
|
|
313
414
|
]
|
|
@@ -327,23 +428,28 @@ function TestGroups({ tests, dialogTest, summaries, goalNames, adminRoute, apiRo
|
|
|
327
428
|
]
|
|
328
429
|
}),
|
|
329
430
|
/*#__PURE__*/ _jsxs("div", {
|
|
330
|
-
className: "xp-ui-button-group",
|
|
431
|
+
className: "xp-ui-button-group xp-tests-row-actions",
|
|
331
432
|
children: [
|
|
332
|
-
/*#__PURE__*/ _jsx(
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
/*#__PURE__*/ _jsx(Button, {
|
|
433
|
+
primary ? /*#__PURE__*/ _jsx(Button, {
|
|
434
|
+
className: "xp-tests-row-action",
|
|
435
|
+
variant: "primary",
|
|
436
|
+
size: "sm",
|
|
437
|
+
onClick: (event)=>{
|
|
438
|
+
event.currentTarget.focus();
|
|
439
|
+
onSelect(test, primary);
|
|
440
|
+
},
|
|
441
|
+
children: primary.label
|
|
442
|
+
}) : /*#__PURE__*/ _jsx(Button, {
|
|
342
443
|
className: "xp-tests-row-action",
|
|
343
444
|
size: "sm",
|
|
344
445
|
href: card.href,
|
|
345
446
|
children: card.action
|
|
346
|
-
})
|
|
447
|
+
}),
|
|
448
|
+
menu.length ? /*#__PURE__*/ _jsx(TestRowMenu, {
|
|
449
|
+
name: test.name,
|
|
450
|
+
actions: menu,
|
|
451
|
+
onSelect: (action)=>onSelect(test, action)
|
|
452
|
+
}) : null
|
|
347
453
|
]
|
|
348
454
|
})
|
|
349
455
|
]
|
|
@@ -362,10 +468,11 @@ function TestGroups({ tests, dialogTest, summaries, goalNames, adminRoute, apiRo
|
|
|
362
468
|
})
|
|
363
469
|
]
|
|
364
470
|
});
|
|
365
|
-
return
|
|
471
|
+
return group.key === 'archived' ? /*#__PURE__*/ _jsxs("details", {
|
|
366
472
|
className: "xp-tests-group",
|
|
367
473
|
children: [
|
|
368
474
|
/*#__PURE__*/ _jsx("summary", {
|
|
475
|
+
tabIndex: 0,
|
|
369
476
|
children: /*#__PURE__*/ _jsxs("h2", {
|
|
370
477
|
className: "xp-tests-group-head",
|
|
371
478
|
children: [
|
|
@@ -394,3 +501,35 @@ function TestGroups({ tests, dialogTest, summaries, goalNames, adminRoute, apiRo
|
|
|
394
501
|
})
|
|
395
502
|
});
|
|
396
503
|
}
|
|
504
|
+
function ListLifecycleDialog({ selection: { row, action }, surface, onClose }) {
|
|
505
|
+
const test = useTestDocument(row.id, {
|
|
506
|
+
apiRoute: surface.apiRoute,
|
|
507
|
+
contentLocale: surface.contentLocale
|
|
508
|
+
});
|
|
509
|
+
const doc = test.doc;
|
|
510
|
+
const [opened, setOpened] = useState(false);
|
|
511
|
+
const canOpen = !!doc && doc.status === row.status && (row.phase === undefined || doc.phase === row.phase) && availableActions({
|
|
512
|
+
...doc,
|
|
513
|
+
decision: doc.decision,
|
|
514
|
+
canManage: surface.canManage,
|
|
515
|
+
canReadResults: surface.canReadResults
|
|
516
|
+
}).some((item)=>item.id === action.id && !item.unavailable);
|
|
517
|
+
if (!opened && canOpen) setOpened(true);
|
|
518
|
+
if (opened) return /*#__PURE__*/ _jsx(LifecycleDialog, {
|
|
519
|
+
action: action,
|
|
520
|
+
test: test,
|
|
521
|
+
surface: surface,
|
|
522
|
+
onClose: onClose
|
|
523
|
+
});
|
|
524
|
+
const checking = test.loadState === 'loading';
|
|
525
|
+
return /*#__PURE__*/ _jsx(ConfirmDialog, {
|
|
526
|
+
title: action.confirm.title,
|
|
527
|
+
cancelLabel: ACTIONS_COPY.cancel,
|
|
528
|
+
onClose: onClose,
|
|
529
|
+
error: checking ? undefined : test.preflightRead?.message ?? (doc ? API_MESSAGES.roundChanged : API_MESSAGES.unreadable),
|
|
530
|
+
children: checking ? /*#__PURE__*/ _jsx("p", {
|
|
531
|
+
role: "status",
|
|
532
|
+
children: READINESS_COPY.checking
|
|
533
|
+
}) : null
|
|
534
|
+
});
|
|
535
|
+
}
|
|
@@ -52,6 +52,7 @@ function SurfacePage(props) {
|
|
|
52
52
|
apiRoute: props.apiRoute,
|
|
53
53
|
contentLocale: props.contentLocale,
|
|
54
54
|
canManage: props.canManage,
|
|
55
|
+
canReadResults: props.canReadResults,
|
|
55
56
|
flagPoints: props.flagPoints,
|
|
56
57
|
crumbs: crumbs
|
|
57
58
|
});
|
|
@@ -79,7 +80,7 @@ function SurfacePage(props) {
|
|
|
79
80
|
title: title,
|
|
80
81
|
children: props.route === 'new' ? /*#__PURE__*/ _jsx(NewTest, {
|
|
81
82
|
surface: surface,
|
|
82
|
-
|
|
83
|
+
blockPageCollections: props.blockPageCollections
|
|
83
84
|
}) : props.id === undefined ? null : /*#__PURE__*/ _jsx(ResultsRoute, {
|
|
84
85
|
id: props.id,
|
|
85
86
|
surface: surface,
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useRef, useState } from 'react';
|
|
4
|
+
import { ConfirmDialog } from '../../../ui/Dialog.js';
|
|
5
|
+
import { actionTitle } from '../../../testSurface/copy/actions.js';
|
|
6
|
+
import { GOALS_COPY as C } from '../../copy/goals.js';
|
|
7
|
+
import { deleteGoal } from './data.js';
|
|
8
|
+
export function DeleteGoalDialog({ goal, apiRoute, onClose, onDeleted }) {
|
|
9
|
+
const [busy, setBusy] = useState(false);
|
|
10
|
+
const [error, setError] = useState();
|
|
11
|
+
const inFlight = useRef(false);
|
|
12
|
+
async function remove() {
|
|
13
|
+
if (inFlight.current) return;
|
|
14
|
+
inFlight.current = true;
|
|
15
|
+
setBusy(true);
|
|
16
|
+
setError(undefined);
|
|
17
|
+
try {
|
|
18
|
+
await deleteGoal(apiRoute, goal.id);
|
|
19
|
+
onDeleted();
|
|
20
|
+
} catch (cause) {
|
|
21
|
+
setError(cause instanceof Error ? cause.message : C.deleteError);
|
|
22
|
+
inFlight.current = false;
|
|
23
|
+
setBusy(false);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return /*#__PURE__*/ _jsx(ConfirmDialog, {
|
|
27
|
+
open: true,
|
|
28
|
+
title: actionTitle(C.confirmDelete, goal.name),
|
|
29
|
+
onClose: onClose,
|
|
30
|
+
cancelLabel: C.cancel,
|
|
31
|
+
busy: busy,
|
|
32
|
+
busyLabel: C.deleting,
|
|
33
|
+
description: C.deleteBody,
|
|
34
|
+
error: error,
|
|
35
|
+
confirm: {
|
|
36
|
+
label: C.confirmDelete,
|
|
37
|
+
destructive: true,
|
|
38
|
+
disabled: busy,
|
|
39
|
+
onClick: remove
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|