From 3ce156ede6d8218347ba8542e3681ce4f49c0298 Mon Sep 17 00:00:00 2001 From: akhrarovsaid Date: Fri, 20 Dec 2024 23:21:10 -0500 Subject: [PATCH 1/4] fix: ensure tab label and description are serializable --- packages/payload/src/fields/config/client.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/payload/src/fields/config/client.ts b/packages/payload/src/fields/config/client.ts index 3c905a50993..f24bdd58962 100644 --- a/packages/payload/src/fields/config/client.ts +++ b/packages/payload/src/fields/config/client.ts @@ -300,6 +300,12 @@ export const createClientField = ({ i18n, importMap, }) + } else if (key === 'label' || key === 'description') { + let content = tab[key] ? tab[key] : undefined + if (typeof content === 'function') { + content = content({ t: i18n.t }) + } + clientTab[key] = content } else { clientTab[key] = tab[key] } From 2dbf6c9700ec612fb546435b1b949651d4f7b118 Mon Sep 17 00:00:00 2001 From: akhrarovsaid Date: Sat, 21 Dec 2024 18:45:26 -0500 Subject: [PATCH 2/4] chore: simplify else if logic --- packages/payload/src/fields/config/client.ts | 15 ++++++++------- test/_community/collections/Media/index.ts | 15 ++++++++++++++- test/_community/collections/Posts/index.ts | 15 +++++++++++++++ test/_community/payload-types.ts | 6 ++++++ test/dev.ts | 2 +- tsconfig.base.json | 2 +- 6 files changed, 45 insertions(+), 10 deletions(-) diff --git a/packages/payload/src/fields/config/client.ts b/packages/payload/src/fields/config/client.ts index f24bdd58962..1640424ab14 100644 --- a/packages/payload/src/fields/config/client.ts +++ b/packages/payload/src/fields/config/client.ts @@ -292,6 +292,8 @@ export const createClientField = ({ continue } + const tabProp = tab[key] + if (key === 'fields') { clientTab.fields = createClientFields({ defaultIDType, @@ -300,14 +302,13 @@ export const createClientField = ({ i18n, importMap, }) - } else if (key === 'label' || key === 'description') { - let content = tab[key] ? tab[key] : undefined - if (typeof content === 'function') { - content = content({ t: i18n.t }) - } - clientTab[key] = content + } else if ( + (key === 'label' || key === 'description') && + typeof tabProp === 'function' + ) { + clientTab[key] = tabProp({ t: i18n.t }) } else { - clientTab[key] = tab[key] + clientTab[key] = tabProp } } field.tabs[i] = clientTab diff --git a/test/_community/collections/Media/index.ts b/test/_community/collections/Media/index.ts index bb5edd03493..40e05107c4e 100644 --- a/test/_community/collections/Media/index.ts +++ b/test/_community/collections/Media/index.ts @@ -8,7 +8,20 @@ export const MediaCollection: CollectionConfig = { create: () => true, read: () => true, }, - fields: [], + fields: [ + { + type: 'text', + name: 'alt', + }, + { + type: 'text', + name: 'canttouchthis', + defaultValue: 'nah nah nah nah', + admin: { + readOnly: true, + }, + }, + ], upload: { crop: true, focalPoint: true, diff --git a/test/_community/collections/Posts/index.ts b/test/_community/collections/Posts/index.ts index ffed2abbd1e..11841d7925e 100644 --- a/test/_community/collections/Posts/index.ts +++ b/test/_community/collections/Posts/index.ts @@ -12,6 +12,21 @@ export const PostsCollection: CollectionConfig = { name: 'title', type: 'text', }, + { + type: 'tabs', + tabs: [ + { + label: ({ t }) => t('authentication:account'), + description: ({ t }) => t('authentication:apiKey'), + fields: [ + { + type: 'text', + name: 'someText', + }, + ], + }, + ], + }, ], versions: { drafts: true, diff --git a/test/_community/payload-types.ts b/test/_community/payload-types.ts index fd6483846a1..ec19fb73bdf 100644 --- a/test/_community/payload-types.ts +++ b/test/_community/payload-types.ts @@ -70,6 +70,7 @@ export interface UserAuthOperations { export interface Post { id: string; title?: string | null; + someText?: string | null; updatedAt: string; createdAt: string; _status?: ('draft' | 'published') | null; @@ -80,6 +81,8 @@ export interface Post { */ export interface Media { id: string; + alt?: string | null; + canttouchthis?: string | null; updatedAt: string; createdAt: string; url?: string | null; @@ -202,6 +205,7 @@ export interface PayloadMigration { */ export interface PostsSelect { title?: T; + someText?: T; updatedAt?: T; createdAt?: T; _status?: T; @@ -211,6 +215,8 @@ export interface PostsSelect { * via the `definition` "media_select". */ export interface MediaSelect { + alt?: T; + canttouchthis?: T; updatedAt?: T; createdAt?: T; url?: T; diff --git a/test/dev.ts b/test/dev.ts index 3a0846b36d8..73da4e325e3 100644 --- a/test/dev.ts +++ b/test/dev.ts @@ -52,7 +52,7 @@ await beforeTest() const { rootDir, adminRoute } = getNextRootDir(testSuiteArg) -await safelyRunScriptFunction(runInit, 4000, testSuiteArg, true) +await safelyRunScriptFunction(runInit, 14000, testSuiteArg, true) if (shouldStartMemoryDB) { await startMemoryDB() diff --git a/tsconfig.base.json b/tsconfig.base.json index 0ea64097ce5..01f5644941b 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -28,7 +28,7 @@ } ], "paths": { - "@payload-config": ["./test/database/config.ts"], + "@payload-config": ["./test/_community/config.ts"], "@payloadcms/live-preview": ["./packages/live-preview/src"], "@payloadcms/live-preview-react": ["./packages/live-preview-react/src/index.ts"], "@payloadcms/live-preview-vue": ["./packages/live-preview-vue/src/index.ts"], From 6530f90377812eb85a93862aa10b3bcf4801e38c Mon Sep 17 00:00:00 2001 From: akhrarovsaid Date: Sat, 21 Dec 2024 19:01:47 -0500 Subject: [PATCH 3/4] chore: revert unnecessarily pushed files --- test/_community/collections/Media/index.ts | 15 +-------------- test/_community/collections/Posts/index.ts | 15 --------------- test/_community/payload-types.ts | 8 +------- test/dev.ts | 2 +- tsconfig.base.json | 2 +- 5 files changed, 4 insertions(+), 38 deletions(-) diff --git a/test/_community/collections/Media/index.ts b/test/_community/collections/Media/index.ts index 40e05107c4e..bb5edd03493 100644 --- a/test/_community/collections/Media/index.ts +++ b/test/_community/collections/Media/index.ts @@ -8,20 +8,7 @@ export const MediaCollection: CollectionConfig = { create: () => true, read: () => true, }, - fields: [ - { - type: 'text', - name: 'alt', - }, - { - type: 'text', - name: 'canttouchthis', - defaultValue: 'nah nah nah nah', - admin: { - readOnly: true, - }, - }, - ], + fields: [], upload: { crop: true, focalPoint: true, diff --git a/test/_community/collections/Posts/index.ts b/test/_community/collections/Posts/index.ts index 11841d7925e..ffed2abbd1e 100644 --- a/test/_community/collections/Posts/index.ts +++ b/test/_community/collections/Posts/index.ts @@ -12,21 +12,6 @@ export const PostsCollection: CollectionConfig = { name: 'title', type: 'text', }, - { - type: 'tabs', - tabs: [ - { - label: ({ t }) => t('authentication:account'), - description: ({ t }) => t('authentication:apiKey'), - fields: [ - { - type: 'text', - name: 'someText', - }, - ], - }, - ], - }, ], versions: { drafts: true, diff --git a/test/_community/payload-types.ts b/test/_community/payload-types.ts index ec19fb73bdf..a259f6c7c5c 100644 --- a/test/_community/payload-types.ts +++ b/test/_community/payload-types.ts @@ -70,7 +70,6 @@ export interface UserAuthOperations { export interface Post { id: string; title?: string | null; - someText?: string | null; updatedAt: string; createdAt: string; _status?: ('draft' | 'published') | null; @@ -81,8 +80,6 @@ export interface Post { */ export interface Media { id: string; - alt?: string | null; - canttouchthis?: string | null; updatedAt: string; createdAt: string; url?: string | null; @@ -205,7 +202,6 @@ export interface PayloadMigration { */ export interface PostsSelect { title?: T; - someText?: T; updatedAt?: T; createdAt?: T; _status?: T; @@ -215,8 +211,6 @@ export interface PostsSelect { * via the `definition` "media_select". */ export interface MediaSelect { - alt?: T; - canttouchthis?: T; updatedAt?: T; createdAt?: T; url?: T; @@ -342,4 +336,4 @@ export interface Auth { declare module 'payload' { // @ts-ignore export interface GeneratedTypes extends Config {} -} \ No newline at end of file +} diff --git a/test/dev.ts b/test/dev.ts index 73da4e325e3..3a0846b36d8 100644 --- a/test/dev.ts +++ b/test/dev.ts @@ -52,7 +52,7 @@ await beforeTest() const { rootDir, adminRoute } = getNextRootDir(testSuiteArg) -await safelyRunScriptFunction(runInit, 14000, testSuiteArg, true) +await safelyRunScriptFunction(runInit, 4000, testSuiteArg, true) if (shouldStartMemoryDB) { await startMemoryDB() diff --git a/tsconfig.base.json b/tsconfig.base.json index 01f5644941b..0ea64097ce5 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -28,7 +28,7 @@ } ], "paths": { - "@payload-config": ["./test/_community/config.ts"], + "@payload-config": ["./test/database/config.ts"], "@payloadcms/live-preview": ["./packages/live-preview/src"], "@payloadcms/live-preview-react": ["./packages/live-preview-react/src/index.ts"], "@payloadcms/live-preview-vue": ["./packages/live-preview-vue/src/index.ts"], From 38c4cee10138d2f77452162c501b74d9e04322e3 Mon Sep 17 00:00:00 2001 From: Said Akhrarov <36972061+akhrarovsaid@users.noreply.github.com> Date: Sat, 21 Dec 2024 19:19:26 -0500 Subject: [PATCH 4/4] chore: revert auto trailing whitespace in payload-types