@delmaredigital/payload-experiments 0.5.1 → 0.5.3
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/dist/admin/PlacementStatus.js +5 -3
- package/dist/admin/paths.d.ts +0 -4
- package/dist/admin/paths.js +0 -4
- package/dist/admin/theme.css +0 -2
- package/dist/blocks/placementPublication.d.ts +4 -0
- package/dist/blocks/placementPublication.js +7 -0
- package/dist/db/pageContent.d.ts +2 -0
- package/dist/db/pageContent.js +35 -17
- package/dist/endpoints/pages.js +32 -15
- package/dist/endpoints/placementStatus.js +52 -8
- package/dist/exports/adminClient.d.ts +0 -2
- package/dist/exports/adminClient.js +0 -2
- package/dist/exports/adminRsc.d.ts +0 -2
- package/dist/exports/adminRsc.js +0 -2
- package/dist/puck/editor/editor.css +0 -6
- package/dist/testSurface/api.js +1 -1
- package/dist/testSurface/copy/surface.d.ts +0 -3
- package/dist/testSurface/copy/surface.js +0 -3
- package/dist/transitions/pageAddress.js +42 -4
- package/dist/types/endpoints.d.ts +2 -0
- package/package.json +1 -1
- package/dist/admin/TestsDashboardCards.d.ts +0 -4
- package/dist/admin/TestsDashboardCards.js +0 -48
- package/dist/admin/TestsNavLink.d.ts +0 -6
- package/dist/admin/TestsNavLink.js +0 -68
- package/dist/admin/dashboard.css +0 -35
- package/dist/admin/views/CollectionListRedirect.d.ts +0 -3
- package/dist/admin/views/CollectionListRedirect.js +0 -8
- package/dist/admin/views/TestsNavLinkServer.d.ts +0 -3
- package/dist/admin/views/TestsNavLinkServer.js +0 -43
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { useConfig, useDocumentInfo } from '@payloadcms/ui';
|
|
3
|
+
import { useConfig, useDocumentInfo, useLocale } from '@payloadcms/ui';
|
|
4
4
|
import { useEffect, useMemo, useState } from 'react';
|
|
5
5
|
import { formatAdminURL } from 'payload/shared';
|
|
6
6
|
import { createApi } from '../testSurface/api.js';
|
|
@@ -8,8 +8,10 @@ import { pageStatusCopy } from './placementStatus.model.js';
|
|
|
8
8
|
/** Manage-only endpoint: access-filtered editors see no status or error text. */ export function PlacementStatus(_props) {
|
|
9
9
|
const { id, collectionSlug } = useDocumentInfo();
|
|
10
10
|
const { config } = useConfig();
|
|
11
|
-
const
|
|
12
|
-
|
|
11
|
+
const locale = useLocale()?.code;
|
|
12
|
+
const api = useMemo(()=>createApi(config.routes.api, locale), [
|
|
13
|
+
config.routes.api,
|
|
14
|
+
locale
|
|
13
15
|
]);
|
|
14
16
|
const [tests, setTests] = useState([]);
|
|
15
17
|
useEffect(()=>{
|
package/dist/admin/paths.d.ts
CHANGED
|
@@ -2,12 +2,8 @@ export declare const XP_METRIC_SOURCE_SELECT = "@delmaredigital/payload-experime
|
|
|
2
2
|
export declare const XP_LAYER_USAGE = "@delmaredigital/payload-experiments/admin/client#LayerUsage";
|
|
3
3
|
export declare const XP_ARM_SELECT = "@delmaredigital/payload-experiments/admin/client#ArmSelectField";
|
|
4
4
|
export declare const XP_TESTS_VIEW = "@delmaredigital/payload-experiments/admin/rsc#ExperimentsRootView";
|
|
5
|
-
export declare const XP_TESTS_LIST_REDIRECT = "@delmaredigital/payload-experiments/admin/rsc#CollectionListRedirect";
|
|
6
5
|
export declare const XP_TEST_EDIT_REDIRECT = "@delmaredigital/payload-experiments/admin/rsc#CollectionEditRedirect";
|
|
7
|
-
export declare const XP_TESTS_NAV_LINK = "@delmaredigital/payload-experiments/admin/rsc#TestsNavLinkServer";
|
|
8
|
-
export declare const XP_TESTS_NAV_CLIENT = "@delmaredigital/payload-experiments/admin/client#TestsNavLink";
|
|
9
6
|
export declare const XP_TESTS_SURFACE = "@delmaredigital/payload-experiments/admin/client#TestsSurface";
|
|
10
|
-
export declare const XP_TESTS_DASHBOARD_CARDS = "@delmaredigital/payload-experiments/admin/client#TestsDashboardCards";
|
|
11
7
|
export declare const XP_PLACEMENT_STATUS = "@delmaredigital/payload-experiments/admin/client#PlacementStatus";
|
|
12
8
|
export declare const XP_TEST_BLOCK = "@delmaredigital/payload-experiments/admin/client#TestBlockField";
|
|
13
9
|
export declare const XP_BLOCK_STATUS = "@delmaredigital/payload-experiments/admin/client#BlockStatusField";
|
package/dist/admin/paths.js
CHANGED
|
@@ -2,12 +2,8 @@ export const XP_METRIC_SOURCE_SELECT = '@delmaredigital/payload-experiments/admi
|
|
|
2
2
|
export const XP_LAYER_USAGE = '@delmaredigital/payload-experiments/admin/client#LayerUsage';
|
|
3
3
|
export const XP_ARM_SELECT = '@delmaredigital/payload-experiments/admin/client#ArmSelectField';
|
|
4
4
|
export const XP_TESTS_VIEW = '@delmaredigital/payload-experiments/admin/rsc#ExperimentsRootView';
|
|
5
|
-
export const XP_TESTS_LIST_REDIRECT = '@delmaredigital/payload-experiments/admin/rsc#CollectionListRedirect';
|
|
6
5
|
export const XP_TEST_EDIT_REDIRECT = '@delmaredigital/payload-experiments/admin/rsc#CollectionEditRedirect';
|
|
7
|
-
export const XP_TESTS_NAV_LINK = '@delmaredigital/payload-experiments/admin/rsc#TestsNavLinkServer';
|
|
8
|
-
export const XP_TESTS_NAV_CLIENT = '@delmaredigital/payload-experiments/admin/client#TestsNavLink';
|
|
9
6
|
export const XP_TESTS_SURFACE = '@delmaredigital/payload-experiments/admin/client#TestsSurface';
|
|
10
|
-
export const XP_TESTS_DASHBOARD_CARDS = '@delmaredigital/payload-experiments/admin/client#TestsDashboardCards';
|
|
11
7
|
export const XP_PLACEMENT_STATUS = '@delmaredigital/payload-experiments/admin/client#PlacementStatus';
|
|
12
8
|
export const XP_TEST_BLOCK = '@delmaredigital/payload-experiments/admin/client#TestBlockField';
|
|
13
9
|
export const XP_BLOCK_STATUS = '@delmaredigital/payload-experiments/admin/client#BlockStatusField';
|
package/dist/admin/theme.css
CHANGED
|
@@ -87,8 +87,6 @@
|
|
|
87
87
|
--xp-error-text: var(--xp-error);
|
|
88
88
|
--xp-radius: var(--xp-radius-control);
|
|
89
89
|
--xp-radius-large: var(--xp-radius-card);
|
|
90
|
-
--xp-dash-card-gap: 12px;
|
|
91
|
-
--xp-dash-card-gap-small: 8px;
|
|
92
90
|
--xp-font-body: var(--xp-font);
|
|
93
91
|
--xp-font-size-small: 13px;
|
|
94
92
|
--xp-font-size-body: 15px;
|
|
@@ -12,3 +12,7 @@ export declare function isPublicationStatus(value: unknown): value is Publicatio
|
|
|
12
12
|
export declare function allLocalesStatus(req: PayloadRequest, flags: PublicationFlags | undefined, status: unknown, operation: 'create' | 'update'): PublicationStatus | undefined;
|
|
13
13
|
export declare function publicationStatusInLocale(doc: Record<string, unknown> | null | undefined, locale: string): PublicationStatus | undefined;
|
|
14
14
|
export declare function publishedInLocale(doc: Record<string, unknown> | null | undefined, locale: string): boolean;
|
|
15
|
+
/** The locale of a single-document read. All-locale callers can choose an explicit view. */
|
|
16
|
+
export declare function publicationLocale(req: PayloadRequest): string | undefined;
|
|
17
|
+
/** Local API reads can already have projected the status to the selected locale. */
|
|
18
|
+
export declare function pagePublicationStatus(doc: Record<string, unknown> | null | undefined, locale?: string): PublicationStatus | undefined;
|
|
@@ -22,3 +22,10 @@ export function publicationStatusInLocale(doc, locale) {
|
|
|
22
22
|
export function publishedInLocale(doc, locale) {
|
|
23
23
|
return publicationStatusInLocale(doc, locale) === 'published';
|
|
24
24
|
}
|
|
25
|
+
/** The locale of a single-document read. All-locale callers can choose an explicit view. */ export function publicationLocale(req) {
|
|
26
|
+
return req.locale && req.locale !== 'all' ? req.locale : req.payload.config.localization ? req.payload.config.localization.defaultLocale : undefined;
|
|
27
|
+
}
|
|
28
|
+
/** Local API reads can already have projected the status to the selected locale. */ export function pagePublicationStatus(doc, locale) {
|
|
29
|
+
const status = doc?._status;
|
|
30
|
+
return isPublicationStatus(status) ? status : locale ? publicationStatusInLocale(doc, locale) : undefined;
|
|
31
|
+
}
|
package/dist/db/pageContent.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ import type { DocId } from '../types/contracts.js';
|
|
|
4
4
|
export declare function pageVersionContent(req: PayloadRequest, collection: string, id: DocId): Promise<(Record<string, unknown> & {
|
|
5
5
|
id: DocId;
|
|
6
6
|
}) | null>;
|
|
7
|
+
/** Path selection only, after checking access to the page. Version content is not needed. */
|
|
8
|
+
export declare function hasPublishedPageVersion(req: PayloadRequest, collection: string, id: DocId, locale?: string): Promise<boolean>;
|
|
7
9
|
/** §7.8: status computes a page's published (or never-published draft) path. */
|
|
8
10
|
export declare function statusPageContent(req: PayloadRequest, collection: string, id: DocId): Promise<(Record<string, unknown> & {
|
|
9
11
|
id: DocId;
|
package/dist/db/pageContent.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { pagePublicationStatus, publicationLocale, usesLocalizedPublication } from '../blocks/placementPublication.js';
|
|
1
2
|
/** §7.8: version-identical compares published content raw (ids stripped). */ export async function pageVersionContent(req, collection, id) {
|
|
2
3
|
return req.payload.db.findOne({
|
|
3
4
|
collection,
|
|
@@ -11,25 +12,16 @@
|
|
|
11
12
|
overrideAccess: true
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
|
-
/**
|
|
15
|
-
const doc = await req.payload.db.findOne({
|
|
16
|
-
collection,
|
|
17
|
-
req,
|
|
18
|
-
where: {
|
|
19
|
-
id: {
|
|
20
|
-
equals: id
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
// Adapter read: status computes a page's published (or never-published draft) path.
|
|
24
|
-
overrideAccess: true
|
|
25
|
-
});
|
|
26
|
-
if (!doc || doc._status !== 'draft') return doc;
|
|
27
|
-
// A formerly published but currently unpublished page still uses its stored main-row path.
|
|
15
|
+
/** Path selection only, after checking access to the page. Version content is not needed. */ export async function hasPublishedPageVersion(req, collection, id, locale) {
|
|
28
16
|
const published = await req.payload.db.findVersions({
|
|
29
17
|
collection,
|
|
30
18
|
req,
|
|
19
|
+
locale,
|
|
31
20
|
limit: 1,
|
|
32
21
|
pagination: false,
|
|
22
|
+
select: {
|
|
23
|
+
id: true
|
|
24
|
+
},
|
|
33
25
|
where: {
|
|
34
26
|
and: [
|
|
35
27
|
{
|
|
@@ -47,14 +39,36 @@
|
|
|
47
39
|
// Adapter read: status computes a page's published (or never-published draft) path.
|
|
48
40
|
overrideAccess: true
|
|
49
41
|
});
|
|
50
|
-
|
|
42
|
+
return published.docs.length > 0;
|
|
43
|
+
}
|
|
44
|
+
/** §7.8: status computes a page's published (or never-published draft) path. */ export async function statusPageContent(req, collection, id) {
|
|
45
|
+
const locale = usesLocalizedPublication(req, collection) ? publicationLocale(req) : undefined;
|
|
46
|
+
const doc = await req.payload.db.findOne({
|
|
47
|
+
collection,
|
|
48
|
+
req,
|
|
49
|
+
locale,
|
|
50
|
+
where: {
|
|
51
|
+
id: {
|
|
52
|
+
equals: id
|
|
53
|
+
}
|
|
54
|
+
},
|
|
55
|
+
// Adapter read: status computes a page's published (or never-published draft) path.
|
|
56
|
+
overrideAccess: true
|
|
57
|
+
});
|
|
58
|
+
if (!doc || (locale ? pagePublicationStatus(doc, locale) === 'published' : doc._status !== 'draft')) return doc;
|
|
59
|
+
// A formerly published locale keeps its main row. A sibling's publication history is independent.
|
|
60
|
+
if (await hasPublishedPageVersion(req, collection, id, locale)) return doc;
|
|
51
61
|
// §7.8: status computes a page's published (or never-published draft) path.
|
|
52
62
|
const latest = await req.payload.db.findVersions({
|
|
53
63
|
collection,
|
|
54
64
|
req,
|
|
55
65
|
limit: 1,
|
|
56
66
|
pagination: false,
|
|
57
|
-
|
|
67
|
+
locale,
|
|
68
|
+
sort: locale ? [
|
|
69
|
+
'-updatedAt',
|
|
70
|
+
'-id'
|
|
71
|
+
] : '-updatedAt',
|
|
58
72
|
where: {
|
|
59
73
|
and: [
|
|
60
74
|
{
|
|
@@ -62,7 +76,11 @@
|
|
|
62
76
|
equals: id
|
|
63
77
|
}
|
|
64
78
|
},
|
|
65
|
-
{
|
|
79
|
+
locale ? {
|
|
80
|
+
'version._status': {
|
|
81
|
+
equals: 'draft'
|
|
82
|
+
}
|
|
83
|
+
} : {
|
|
66
84
|
latest: {
|
|
67
85
|
equals: true
|
|
68
86
|
}
|
package/dist/endpoints/pages.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { flattenTopLevelFields, formatAdminURL } from 'payload/shared';
|
|
2
2
|
import { placementReader } from '../blocks/placementLocale.js';
|
|
3
|
+
import { pagePublicationStatus, publicationLocale, usesLocalizedPublication } from '../blocks/placementPublication.js';
|
|
4
|
+
import { hasPublishedPageVersion } from '../db/pageContent.js';
|
|
3
5
|
import { findDraftPageByPath, PAGE_ADDRESS_FIELDS } from '../transitions/pageAddress.js';
|
|
4
6
|
import { normalisePath } from '../runtime/normalisePath.js';
|
|
5
7
|
import { blockPageSlugs, hasPuckEditor } from '../options.js';
|
|
@@ -40,6 +42,7 @@ export async function handlePages(req, { options }) {
|
|
|
40
42
|
const title = config?.admin.useAsTitle;
|
|
41
43
|
const titleField = title && title !== 'id' ? title : fields.some((field)=>field.name === 'title') ? 'title' : title ?? 'id';
|
|
42
44
|
const drafts = Boolean(config?.versions && config.versions.drafts);
|
|
45
|
+
const locale = usesLocalizedPublication(req, slug, config) ? publicationLocale(req) : undefined;
|
|
43
46
|
if (path !== null && collection) {
|
|
44
47
|
const found = await collection.findByPath(path, req);
|
|
45
48
|
const main = found ? await req.payload.findByID({
|
|
@@ -55,8 +58,9 @@ export async function handlePages(req, { options }) {
|
|
|
55
58
|
docs: [],
|
|
56
59
|
hasNextPage: false
|
|
57
60
|
});
|
|
58
|
-
const published = !drafts || main
|
|
59
|
-
const
|
|
61
|
+
const published = !drafts || pagePublicationStatus(main, locale) === 'published';
|
|
62
|
+
const useMain = published || Boolean(locale && (!found || await hasPublishedPageVersion(req, slug, main.id, locale)));
|
|
63
|
+
const row = useMain ? main : await req.payload.findByID({
|
|
60
64
|
collection: slug,
|
|
61
65
|
id: main.id,
|
|
62
66
|
req,
|
|
@@ -204,11 +208,12 @@ export async function handlePages(req, { options }) {
|
|
|
204
208
|
// Host callbacks can inspect arbitrary fields. Only picker metadata leaves this endpoint.
|
|
205
209
|
select: hasDocCallbacks ? undefined : metadata
|
|
206
210
|
});
|
|
207
|
-
const
|
|
208
|
-
const
|
|
211
|
+
const localizedPaths = Boolean(locale && collection && !blockMode);
|
|
212
|
+
const draftIds = readDrafts ? result.docs.filter((doc)=>localizedPaths || pagePublicationStatus(doc, locale) === 'draft').map((doc)=>doc.id) : [];
|
|
213
|
+
const mainById = new Map();
|
|
209
214
|
if (draftIds.length) {
|
|
210
|
-
// Read
|
|
211
|
-
//
|
|
215
|
+
// Read the matching main rows in one bounded query. Localized drafts can
|
|
216
|
+
// carry a sibling's publication state, so only main confirms what is live.
|
|
212
217
|
const live = await req.payload.find({
|
|
213
218
|
collection: slug,
|
|
214
219
|
req,
|
|
@@ -219,27 +224,39 @@ export async function handlePages(req, { options }) {
|
|
|
219
224
|
id: {
|
|
220
225
|
in: draftIds
|
|
221
226
|
},
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
227
|
+
...!localizedPaths ? {
|
|
228
|
+
_status: {
|
|
229
|
+
equals: 'published'
|
|
230
|
+
}
|
|
231
|
+
} : {}
|
|
225
232
|
},
|
|
226
233
|
limit: PAGE_SIZE,
|
|
227
234
|
select: !blockMode && collection ? undefined : {
|
|
228
235
|
_status: true
|
|
229
236
|
}
|
|
230
237
|
});
|
|
231
|
-
|
|
238
|
+
await Promise.all(live.docs.map(async (doc)=>{
|
|
239
|
+
const published = pagePublicationStatus(doc, locale) === 'published';
|
|
240
|
+
if (!published && !localizedPaths) return;
|
|
241
|
+
const usePath = published || await hasPublishedPageVersion(req, slug, doc.id, locale);
|
|
242
|
+
mainById.set(String(doc.id), {
|
|
243
|
+
doc,
|
|
244
|
+
published,
|
|
245
|
+
usePath
|
|
246
|
+
});
|
|
247
|
+
}));
|
|
232
248
|
}
|
|
233
249
|
const docs = result.docs.flatMap((row)=>{
|
|
234
250
|
const placement = reader.read(row, input);
|
|
235
251
|
const doc = placement.doc;
|
|
236
|
-
const
|
|
237
|
-
const
|
|
238
|
-
const
|
|
252
|
+
const main = mainById.get(String(row.id));
|
|
253
|
+
const versionPublished = pagePublicationStatus(row, locale) === 'published';
|
|
254
|
+
const published = !drafts || (main?.published ?? versionPublished);
|
|
255
|
+
const pathDoc = !blockMode && main?.usePath ? reader.read(main.doc, input).doc : doc;
|
|
239
256
|
const rawPath = collection?.pathOf(pathDoc) ?? null;
|
|
240
257
|
const storedAddress = blockMode ? addressFields.reduce((value, field)=>value ?? textValue(pathDoc[field]), undefined) : undefined;
|
|
241
258
|
const address = rawPath ?? storedAddress;
|
|
242
|
-
const draftAddress = !blockMode &&
|
|
259
|
+
const draftAddress = !blockMode && main?.usePath ? collection?.pathOf(doc) : null;
|
|
243
260
|
const updatedAt = textValue(doc.updatedAt);
|
|
244
261
|
const title = doc[titleField];
|
|
245
262
|
const item = {
|
|
@@ -248,7 +265,7 @@ export async function handlePages(req, { options }) {
|
|
|
248
265
|
path: rawPath,
|
|
249
266
|
pathKey: rawPath === null ? null : normalisePath(rawPath),
|
|
250
267
|
published,
|
|
251
|
-
status:
|
|
268
|
+
status: main?.published && (!localizedPaths || !versionPublished || draftAddress !== rawPath) ? 'changed' : published ? 'published' : 'draft',
|
|
252
269
|
...address ? {
|
|
253
270
|
address
|
|
254
271
|
} : {},
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { placementReader } from '../blocks/placementLocale.js';
|
|
1
|
+
import { localeRequest, placementReader } from '../blocks/placementLocale.js';
|
|
2
|
+
import { isPublicationStatus, publicationLocale, usesLocalizedPublication } from '../blocks/placementPublication.js';
|
|
2
3
|
import { readBody } from './readBody.js';
|
|
3
4
|
import { safeError } from '../log.js';
|
|
4
5
|
import { statusPageContent } from '../db/pageContent.js';
|
|
@@ -18,6 +19,7 @@ const error = (status, code, message)=>Response.json({
|
|
|
18
19
|
const object = (v)=>!!v && typeof v === 'object' && !Array.isArray(v);
|
|
19
20
|
const id = (v)=>typeof v === 'string' && !!v.trim() || typeof v === 'number' && Number.isSafeInteger(v);
|
|
20
21
|
export async function handlePlacementStatus(req, { options }) {
|
|
22
|
+
const fallbackLocale = req.fallbackLocale;
|
|
21
23
|
let value;
|
|
22
24
|
try {
|
|
23
25
|
value = await readBody(req);
|
|
@@ -161,22 +163,64 @@ export async function handlePlacementStatus(req, { options }) {
|
|
|
161
163
|
collection,
|
|
162
164
|
id,
|
|
163
165
|
req,
|
|
166
|
+
fallbackLocale,
|
|
164
167
|
overrideAccess: false,
|
|
165
168
|
depth: 0,
|
|
166
169
|
draft: false
|
|
167
170
|
});
|
|
168
171
|
const registration = options.pages?.collections.find((entry)=>entry.slug === collection);
|
|
169
|
-
const
|
|
170
|
-
const
|
|
171
|
-
const
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
const reader = placementReader(req, collection, options);
|
|
173
|
+
const localizedStatus = usesLocalizedPublication(req, collection);
|
|
174
|
+
const readPath = async (viewReq)=>{
|
|
175
|
+
if (!registration) return null;
|
|
176
|
+
const raw = await statusPageContent(viewReq, collection, id);
|
|
177
|
+
const input = localizedStatus && isPublicationStatus(raw?._status) ? 'localized' : 'all-locales';
|
|
178
|
+
const view = {
|
|
179
|
+
locale: viewReq.locale ?? '',
|
|
180
|
+
fallbackLocale: viewReq.fallbackLocale ?? false
|
|
181
|
+
};
|
|
182
|
+
const doc = reader.read(raw, input, view).doc;
|
|
183
|
+
return doc ? registration.pathOf(doc) : null;
|
|
184
|
+
};
|
|
185
|
+
let pathsByLocale;
|
|
186
|
+
if (registration && localizedStatus && req.locale === 'all') {
|
|
187
|
+
const paths = await Promise.all(reader.documentViews.map(async (view)=>{
|
|
188
|
+
const viewReq = localeRequest(req, {
|
|
189
|
+
...view,
|
|
190
|
+
fallbackLocale: fallbackLocale ?? view.fallbackLocale
|
|
191
|
+
});
|
|
192
|
+
const readable = await req.payload.findByID({
|
|
193
|
+
collection,
|
|
194
|
+
id,
|
|
195
|
+
req: viewReq,
|
|
196
|
+
fallbackLocale: viewReq.fallbackLocale,
|
|
197
|
+
overrideAccess: false,
|
|
198
|
+
depth: 0,
|
|
199
|
+
draft: false,
|
|
200
|
+
disableErrors: true
|
|
201
|
+
});
|
|
202
|
+
return [
|
|
203
|
+
view.locale,
|
|
204
|
+
readable ? await readPath(viewReq) : null
|
|
205
|
+
];
|
|
206
|
+
}));
|
|
207
|
+
pathsByLocale = Object.fromEntries(paths);
|
|
208
|
+
}
|
|
209
|
+
const path = pathsByLocale ? pathsByLocale[publicationLocale(req) ?? ''] ?? null : await readPath(req);
|
|
210
|
+
const pathKeys = new Set((pathsByLocale ? Object.values(pathsByLocale) : [
|
|
211
|
+
path
|
|
212
|
+
]).flatMap((path)=>path === null ? [] : [
|
|
213
|
+
normalisePath(path)
|
|
214
|
+
]));
|
|
174
215
|
const status = {
|
|
175
216
|
path,
|
|
217
|
+
...pathsByLocale ? {
|
|
218
|
+
pathsByLocale
|
|
219
|
+
} : {},
|
|
176
220
|
tests: []
|
|
177
221
|
};
|
|
178
222
|
for (const test of tests){
|
|
179
|
-
if (test.kind !== 'page' ||
|
|
223
|
+
if (test.kind !== 'page' || !pathKeys.size || test.decision?.pagesReleasedAt || test.decision?.discardedAt || test.status === 'archived' && !test.decision?.winnerArm) continue;
|
|
180
224
|
const round = rounds.get(test.slug);
|
|
181
225
|
if (!collections.has(test.slug)) collections.set(test.slug, await resolvePageCollection(req, options, {
|
|
182
226
|
...test,
|
|
@@ -184,7 +228,7 @@ export async function handlePlacementStatus(req, { options }) {
|
|
|
184
228
|
}));
|
|
185
229
|
const testCollection = collections.get(test.slug);
|
|
186
230
|
if (testCollection?.slug !== collection) continue;
|
|
187
|
-
const arm = round.arms.find((arm)=>arm.kind !== 'holdout' && arm.pageTarget && normalisePath(arm.pageTarget)
|
|
231
|
+
const arm = round.arms.find((arm)=>arm.kind !== 'holdout' && arm.pageTarget && pathKeys.has(normalisePath(arm.pageTarget)));
|
|
188
232
|
if (!arm) continue;
|
|
189
233
|
const winner = round.arms.find((arm)=>arm.key === test.decision?.winnerArm);
|
|
190
234
|
const original = round.arms.find((arm)=>arm.kind === 'control');
|
|
@@ -2,9 +2,7 @@ export { XP_IF_UPDATED_AT_HEADER } from '../constants.js';
|
|
|
2
2
|
export { LayerUsage } from '../admin/LayerUsage.js';
|
|
3
3
|
export { MetricSourceSelect } from '../admin/MetricSourceSelect.js';
|
|
4
4
|
export { ArmSelectField } from '../admin/armSelect/ArmSelectField.js';
|
|
5
|
-
export { TestsNavLink } from '../admin/TestsNavLink.js';
|
|
6
5
|
export { TestsSurface } from '../admin/views/TestsSurfaceClient.js';
|
|
7
|
-
export { TestsDashboardCards } from '../admin/TestsDashboardCards.js';
|
|
8
6
|
export { PlacementStatus } from '../admin/PlacementStatus.js';
|
|
9
7
|
export { wrapExperimentBlock, syncExperimentSlots, copyOriginalIntoVersion, unwrapExperimentBlock, findRegisteredBlocksField } from '../blocks/formState.js';
|
|
10
8
|
export { TestBlockField } from '../admin/blocks/TestBlockField.js';
|
|
@@ -3,9 +3,7 @@ export { XP_IF_UPDATED_AT_HEADER } from '../constants.js';
|
|
|
3
3
|
export { LayerUsage } from '../admin/LayerUsage.js';
|
|
4
4
|
export { MetricSourceSelect } from '../admin/MetricSourceSelect.js';
|
|
5
5
|
export { ArmSelectField } from '../admin/armSelect/ArmSelectField.js';
|
|
6
|
-
export { TestsNavLink } from '../admin/TestsNavLink.js';
|
|
7
6
|
export { TestsSurface } from '../admin/views/TestsSurfaceClient.js';
|
|
8
|
-
export { TestsDashboardCards } from '../admin/TestsDashboardCards.js';
|
|
9
7
|
export { PlacementStatus } from '../admin/PlacementStatus.js';
|
|
10
8
|
export { wrapExperimentBlock, syncExperimentSlots, copyOriginalIntoVersion, unwrapExperimentBlock, findRegisteredBlocksField } from '../blocks/formState.js';
|
|
11
9
|
export { TestBlockField } from '../admin/blocks/TestBlockField.js';
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export { ExperimentsRootView } from '../admin/views/ExperimentsRootView.js';
|
|
2
|
-
export { CollectionListRedirect } from '../admin/views/CollectionListRedirect.js';
|
|
3
2
|
export { CollectionEditRedirect } from '../admin/views/CollectionEditRedirect.js';
|
|
4
|
-
export { TestsNavLinkServer } from '../admin/views/TestsNavLinkServer.js';
|
|
5
3
|
export { TestsCollectionListView } from '../admin/views/TestsCollectionListView.js';
|
|
6
4
|
export { GoalsCollectionListView } from '../admin/views/GoalsCollectionListView.js';
|
|
7
5
|
export { GoalEditRedirect } from '../admin/views/GoalEditRedirect.js';
|
package/dist/exports/adminRsc.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
export { ExperimentsRootView } from '../admin/views/ExperimentsRootView.js';
|
|
2
|
-
export { CollectionListRedirect } from '../admin/views/CollectionListRedirect.js';
|
|
3
2
|
export { CollectionEditRedirect } from '../admin/views/CollectionEditRedirect.js';
|
|
4
|
-
export { TestsNavLinkServer } from '../admin/views/TestsNavLinkServer.js';
|
|
5
3
|
export { TestsCollectionListView } from '../admin/views/TestsCollectionListView.js';
|
|
6
4
|
export { GoalsCollectionListView } from '../admin/views/GoalsCollectionListView.js';
|
|
7
5
|
export { GoalEditRedirect } from '../admin/views/GoalEditRedirect.js';
|
|
@@ -78,8 +78,6 @@
|
|
|
78
78
|
--xp-error-text: #a63030;
|
|
79
79
|
--xp-radius: 8px;
|
|
80
80
|
--xp-radius-large: 12px;
|
|
81
|
-
--xp-dash-card-gap: 12px;
|
|
82
|
-
--xp-dash-card-gap-small: 8px;
|
|
83
81
|
--xp-font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
84
82
|
--xp-font-size-small: 13px;
|
|
85
83
|
--xp-font-size-body: 15px;
|
|
@@ -165,8 +163,6 @@
|
|
|
165
163
|
--xp-error-text: #f09494;
|
|
166
164
|
--xp-radius: 8px;
|
|
167
165
|
--xp-radius-large: 12px;
|
|
168
|
-
--xp-dash-card-gap: 12px;
|
|
169
|
-
--xp-dash-card-gap-small: 8px;
|
|
170
166
|
--xp-font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
171
167
|
--xp-font-size-small: 13px;
|
|
172
168
|
--xp-font-size-body: 15px;
|
|
@@ -251,8 +247,6 @@
|
|
|
251
247
|
--xp-error-text: #a63030;
|
|
252
248
|
--xp-radius: 8px;
|
|
253
249
|
--xp-radius-large: 12px;
|
|
254
|
-
--xp-dash-card-gap: 12px;
|
|
255
|
-
--xp-dash-card-gap-small: 8px;
|
|
256
250
|
--xp-font-body: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
|
|
257
251
|
--xp-font-size-small: 13px;
|
|
258
252
|
--xp-font-size-body: 15px;
|
package/dist/testSurface/api.js
CHANGED
|
@@ -119,7 +119,7 @@ export function createApi(apiBase, contentLocale) {
|
|
|
119
119
|
...plan,
|
|
120
120
|
arm
|
|
121
121
|
}, undefined, undefined, plan.updatedAt),
|
|
122
|
-
placementStatus: (body)=>request(()
|
|
122
|
+
placementStatus: (body)=>request(()=>contentLocaleURL(`${apiBase.replace(/\/$/, '')}/xp/placements/status`, contentLocale), 'POST', body),
|
|
123
123
|
start: (id, phase)=>post(id, 'start', phase === undefined ? undefined : {
|
|
124
124
|
phase
|
|
125
125
|
}, {
|
|
@@ -6,9 +6,6 @@ export declare const SURFACE_COPY: {
|
|
|
6
6
|
readonly goals: "Goals";
|
|
7
7
|
readonly search: "Search tests";
|
|
8
8
|
readonly navAllTests: "All tests";
|
|
9
|
-
readonly navGoals: "Goals";
|
|
10
|
-
readonly dashShowTests: "Show all tests";
|
|
11
|
-
readonly dashShowGoals: "Show all goals";
|
|
12
9
|
readonly backToAdmin: "Back to admin";
|
|
13
10
|
readonly notInstalled: "The Tests screen isn't installed yet. Run `payload generate:importmap` and reload.";
|
|
14
11
|
readonly noAccess: "You don't have access to tests.";
|
|
@@ -7,9 +7,6 @@ export const SURFACE_COPY = {
|
|
|
7
7
|
goals: 'Goals',
|
|
8
8
|
search: 'Search tests',
|
|
9
9
|
navAllTests: 'All tests',
|
|
10
|
-
navGoals: 'Goals',
|
|
11
|
-
dashShowTests: 'Show all tests',
|
|
12
|
-
dashShowGoals: 'Show all goals',
|
|
13
10
|
backToAdmin: 'Back to admin',
|
|
14
11
|
notInstalled: "The Tests screen isn't installed yet. Run `payload generate:importmap` and reload.",
|
|
15
12
|
noAccess: "You don't have access to tests.",
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { flattenTopLevelFields } from 'payload/shared';
|
|
2
2
|
import { placementReader } from '../blocks/placementLocale.js';
|
|
3
|
+
import { pagePublicationStatus, publicationLocale, usesLocalizedPublication } from '../blocks/placementPublication.js';
|
|
4
|
+
import { hasPublishedPageVersion } from '../db/pageContent.js';
|
|
3
5
|
import { normalisePath } from '../runtime/normalisePath.js';
|
|
4
6
|
export const PAGE_ADDRESS_FIELDS = [
|
|
5
7
|
'path',
|
|
@@ -40,15 +42,18 @@ export const PAGE_ADDRESS_FIELDS = [
|
|
|
40
42
|
] : [];
|
|
41
43
|
});
|
|
42
44
|
if (!filters.length) return undefined;
|
|
45
|
+
const locale = usesLocalizedPublication(req, entry.slug, config) ? publicationLocale(req) : undefined;
|
|
43
46
|
const result = await req.payload.find({
|
|
44
47
|
collection: entry.slug,
|
|
45
48
|
req,
|
|
46
49
|
overrideAccess: false,
|
|
47
50
|
depth: 0,
|
|
48
|
-
draft:
|
|
51
|
+
draft: Boolean(locale),
|
|
49
52
|
pagination: false,
|
|
50
53
|
limit: 20,
|
|
51
|
-
where: {
|
|
54
|
+
where: locale ? {
|
|
55
|
+
or: filters
|
|
56
|
+
} : {
|
|
52
57
|
and: [
|
|
53
58
|
{
|
|
54
59
|
_status: {
|
|
@@ -63,9 +68,42 @@ export const PAGE_ADDRESS_FIELDS = [
|
|
|
63
68
|
});
|
|
64
69
|
const reader = placementReader(req, entry.slug);
|
|
65
70
|
const input = req.locale === 'all' ? 'all-locales' : 'localized';
|
|
66
|
-
const
|
|
71
|
+
const matchesPath = (row)=>{
|
|
67
72
|
const address = entry.pathOf(reader.read(row, input).doc);
|
|
68
73
|
return address !== null && normalisePath(address) === key;
|
|
69
|
-
}
|
|
74
|
+
};
|
|
75
|
+
const candidates = result.docs.filter(matchesPath);
|
|
76
|
+
if (locale) {
|
|
77
|
+
const main = await req.payload.find({
|
|
78
|
+
collection: entry.slug,
|
|
79
|
+
req,
|
|
80
|
+
overrideAccess: false,
|
|
81
|
+
depth: 0,
|
|
82
|
+
draft: false,
|
|
83
|
+
pagination: false,
|
|
84
|
+
limit: 40,
|
|
85
|
+
where: {
|
|
86
|
+
or: [
|
|
87
|
+
...filters,
|
|
88
|
+
{
|
|
89
|
+
id: {
|
|
90
|
+
in: candidates.map((row)=>row.id)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
const draftById = new Map(candidates.map((row)=>[
|
|
97
|
+
String(row.id),
|
|
98
|
+
row
|
|
99
|
+
]));
|
|
100
|
+
const eligible = await Promise.all(main.docs.map(async (row)=>{
|
|
101
|
+
if (pagePublicationStatus(row, locale) === 'published') return undefined;
|
|
102
|
+
if (await hasPublishedPageVersion(req, entry.slug, row.id, locale)) return matchesPath(row) ? row : undefined;
|
|
103
|
+
return draftById.get(String(row.id));
|
|
104
|
+
}));
|
|
105
|
+
const matched = eligible.filter((row)=>row !== undefined);
|
|
106
|
+
return matched.length === 1 ? matched[0] : undefined;
|
|
107
|
+
}
|
|
70
108
|
return candidates.length === 1 ? candidates[0] : undefined;
|
|
71
109
|
}
|
|
@@ -362,6 +362,8 @@ export type PageTestStatus = {
|
|
|
362
362
|
export type PlacementStatusResult = {
|
|
363
363
|
docs: Record<string, {
|
|
364
364
|
path: string | null;
|
|
365
|
+
/** With locale=all on a collection with localized status, path is the default locale's entry. */
|
|
366
|
+
pathsByLocale?: Record<string, string | null>;
|
|
365
367
|
tests: PageTestStatus[];
|
|
366
368
|
}>;
|
|
367
369
|
slugs: Record<string, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@delmaredigital/payload-experiments",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.3",
|
|
4
4
|
"description": "No-code A/B testing for Payload CMS and Next.js: block, page and flag experiments with holdouts, layers, exposure logging and honest statistics inside the admin — no vendor",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
-
import { surfaceUrls } from '../testSurface/surfaceUrls.js';
|
|
4
|
-
import './theme.css';
|
|
5
|
-
import './dashboard.css';
|
|
6
|
-
import { Card, useAuth, useConfig } from '@payloadcms/ui';
|
|
7
|
-
import { SURFACE_COPY } from '../testSurface/copy/surface.js';
|
|
8
|
-
/** @deprecated Retained for existing import maps until 0.5.0. */ export function TestsDashboardCards() {
|
|
9
|
-
const { config } = useConfig();
|
|
10
|
-
const { permissions } = useAuth();
|
|
11
|
-
const testPermissions = permissions?.collections?.['xp-experiments'];
|
|
12
|
-
const canManage = testPermissions?.update === true;
|
|
13
|
-
if (!canManage) return null;
|
|
14
|
-
return /*#__PURE__*/ _jsxs("section", {
|
|
15
|
-
className: "xp-dash-group",
|
|
16
|
-
"aria-labelledby": "xp-dash-title",
|
|
17
|
-
children: [
|
|
18
|
-
/*#__PURE__*/ _jsx("h2", {
|
|
19
|
-
className: "xp-dash-label",
|
|
20
|
-
id: "xp-dash-title",
|
|
21
|
-
children: SURFACE_COPY.title
|
|
22
|
-
}),
|
|
23
|
-
/*#__PURE__*/ _jsxs("ul", {
|
|
24
|
-
className: "xp-dash-card-list",
|
|
25
|
-
children: [
|
|
26
|
-
/*#__PURE__*/ _jsx("li", {
|
|
27
|
-
children: /*#__PURE__*/ _jsx(Card, {
|
|
28
|
-
title: SURFACE_COPY.navAllTests,
|
|
29
|
-
titleAs: "h3",
|
|
30
|
-
buttonAriaLabel: SURFACE_COPY.dashShowTests,
|
|
31
|
-
href: surfaceUrls.home(config.routes.admin),
|
|
32
|
-
id: "card-xp-tests"
|
|
33
|
-
})
|
|
34
|
-
}),
|
|
35
|
-
/*#__PURE__*/ _jsx("li", {
|
|
36
|
-
children: /*#__PURE__*/ _jsx(Card, {
|
|
37
|
-
title: SURFACE_COPY.navGoals,
|
|
38
|
-
titleAs: "h3",
|
|
39
|
-
buttonAriaLabel: SURFACE_COPY.dashShowGoals,
|
|
40
|
-
href: surfaceUrls.goals(config.routes.admin),
|
|
41
|
-
id: "card-xp-goals"
|
|
42
|
-
})
|
|
43
|
-
})
|
|
44
|
-
]
|
|
45
|
-
})
|
|
46
|
-
]
|
|
47
|
-
});
|
|
48
|
-
}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
-
import { surfaceUrls } from '../testSurface/surfaceUrls.js';
|
|
4
|
-
import './theme.css';
|
|
5
|
-
import { Link, NavGroup, useAuth, useConfig } from '@payloadcms/ui';
|
|
6
|
-
import { usePathname } from 'next/navigation.js';
|
|
7
|
-
import { SURFACE_COPY } from '../testSurface/copy/surface.js';
|
|
8
|
-
/** @deprecated Retained for existing import maps until 0.5.0. */ function TestsNav({ isOpen = true }) {
|
|
9
|
-
const { config } = useConfig();
|
|
10
|
-
const { permissions } = useAuth();
|
|
11
|
-
const pathname = usePathname();
|
|
12
|
-
const href = surfaceUrls.home(config.routes.admin);
|
|
13
|
-
const goalsHref = surfaceUrls.goals(config.routes.admin);
|
|
14
|
-
const base = href.replace(/\/$/, '');
|
|
15
|
-
const goalsBase = goalsHref.replace(/\/$/, '');
|
|
16
|
-
const goalsActive = pathname === goalsBase || Boolean(pathname?.startsWith(`${goalsBase}/`));
|
|
17
|
-
const testsActive = !goalsActive && (pathname === base || Boolean(pathname?.startsWith(`${base}/`)));
|
|
18
|
-
const testPermissions = permissions?.collections?.['xp-experiments'];
|
|
19
|
-
const canManage = testPermissions?.update === true;
|
|
20
|
-
if (!canManage) return null;
|
|
21
|
-
const entries = [
|
|
22
|
-
{
|
|
23
|
-
id: 'nav-xp-tests',
|
|
24
|
-
href,
|
|
25
|
-
label: SURFACE_COPY.navAllTests,
|
|
26
|
-
active: testsActive
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
id: 'nav-xp-goals',
|
|
30
|
-
href: goalsHref,
|
|
31
|
-
label: SURFACE_COPY.navGoals,
|
|
32
|
-
active: goalsActive
|
|
33
|
-
}
|
|
34
|
-
];
|
|
35
|
-
return /*#__PURE__*/ _jsx(NavGroup, {
|
|
36
|
-
label: SURFACE_COPY.title,
|
|
37
|
-
isOpen: isOpen,
|
|
38
|
-
children: entries.map((entry)=>{
|
|
39
|
-
const props = {
|
|
40
|
-
className: 'nav__link',
|
|
41
|
-
id: entry.id,
|
|
42
|
-
'aria-current': entry.active ? 'page' : undefined
|
|
43
|
-
};
|
|
44
|
-
const content = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
45
|
-
children: [
|
|
46
|
-
entry.active ? /*#__PURE__*/ _jsx("div", {
|
|
47
|
-
className: "nav__link-indicator"
|
|
48
|
-
}) : null,
|
|
49
|
-
/*#__PURE__*/ _jsx("span", {
|
|
50
|
-
className: "nav__link-label",
|
|
51
|
-
children: entry.label
|
|
52
|
-
})
|
|
53
|
-
]
|
|
54
|
-
});
|
|
55
|
-
return pathname === entry.href ? /*#__PURE__*/ _jsx("div", {
|
|
56
|
-
...props,
|
|
57
|
-
children: content
|
|
58
|
-
}, entry.id) : /*#__PURE__*/ _jsx(Link, {
|
|
59
|
-
...props,
|
|
60
|
-
href: entry.href,
|
|
61
|
-
prefetch: false,
|
|
62
|
-
children: content
|
|
63
|
-
}, entry.id);
|
|
64
|
-
})
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
// Preserve the existing import-map key.
|
|
68
|
-
export { TestsNav as TestsNavLink };
|
package/dist/admin/dashboard.css
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
.xp-dash-group {
|
|
2
|
-
display: flex;
|
|
3
|
-
flex-direction: column;
|
|
4
|
-
gap: var(--xp-space-4);
|
|
5
|
-
margin-bottom: var(--xp-space-4);
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
.xp-dash-label { margin: 0; }
|
|
9
|
-
|
|
10
|
-
.xp-dash-card-list {
|
|
11
|
-
padding: 0;
|
|
12
|
-
margin: 0;
|
|
13
|
-
list-style: none;
|
|
14
|
-
display: grid;
|
|
15
|
-
grid-template-columns: repeat(5, 1fr);
|
|
16
|
-
gap: var(--xp-dash-card-gap);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
.xp-dash-card-list .card { height: 100%; }
|
|
20
|
-
|
|
21
|
-
@media (max-width: 1440px) {
|
|
22
|
-
.xp-dash-card-list { grid-template-columns: repeat(4, 1fr); }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
@media (max-width: 1024px) {
|
|
26
|
-
.xp-dash-card-list { grid-template-columns: repeat(2, 1fr); }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
@media (max-width: 768px) {
|
|
30
|
-
.xp-dash-card-list { gap: var(--xp-dash-card-gap-small); }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
@media (max-width: 400px) {
|
|
34
|
-
.xp-dash-card-list { grid-template-columns: repeat(1, 1fr); }
|
|
35
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { formatAdminURL } from 'payload/shared';
|
|
2
|
-
import { redirect } from 'next/navigation.js';
|
|
3
|
-
/** @deprecated Retained for existing import maps until 0.5.0. */ export function CollectionListRedirect({ payload }) {
|
|
4
|
-
redirect(formatAdminURL({
|
|
5
|
-
adminRoute: payload.config.routes.admin,
|
|
6
|
-
path: '/experiments'
|
|
7
|
-
}));
|
|
8
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { ServerProps } from 'payload';
|
|
2
|
-
/** @deprecated Retained for existing import maps until 0.5.0. */
|
|
3
|
-
export declare function TestsNavLinkServer({ payload, user, permissions }: Pick<ServerProps, 'payload' | 'user' | 'permissions'>): Promise<string | number | bigint | boolean | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | Iterable<import("react").ReactNode> | null | undefined>;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { RenderServerComponent } from '@payloadcms/ui/elements/RenderServerComponent';
|
|
2
|
-
import { SURFACE_COPY } from '../../testSurface/copy/surface.js';
|
|
3
|
-
import { XP_TESTS_NAV_CLIENT } from '../paths.js';
|
|
4
|
-
/** @deprecated Retained for existing import maps until 0.5.0. */ export async function TestsNavLinkServer({ payload, user, permissions }) {
|
|
5
|
-
const testPermissions = permissions?.collections?.['xp-experiments'];
|
|
6
|
-
if (!user?.collection || testPermissions?.update !== true) return null;
|
|
7
|
-
const result = await payload.find({
|
|
8
|
-
collection: 'payload-preferences',
|
|
9
|
-
where: {
|
|
10
|
-
and: [
|
|
11
|
-
{
|
|
12
|
-
key: {
|
|
13
|
-
equals: 'nav'
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
'user.relationTo': {
|
|
18
|
-
equals: user.collection
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
'user.value': {
|
|
23
|
-
equals: user.id
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
limit: 1,
|
|
29
|
-
pagination: false,
|
|
30
|
-
depth: 0,
|
|
31
|
-
user,
|
|
32
|
-
overrideAccess: false
|
|
33
|
-
});
|
|
34
|
-
const value = result.docs[0]?.value;
|
|
35
|
-
// Resolve the CSS-bearing client boundary through Payload's public import map.
|
|
36
|
-
return RenderServerComponent({
|
|
37
|
-
Component: XP_TESTS_NAV_CLIENT,
|
|
38
|
-
importMap: payload.importMap,
|
|
39
|
-
clientProps: {
|
|
40
|
-
isOpen: value?.groups?.[SURFACE_COPY.title]?.open ?? true
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|