From b65ca6832d7ce0926d682119bc2b769836c517e6 Mon Sep 17 00:00:00 2001 From: Jarrod Flesch <30633324+JarrodMFlesch@users.noreply.github.com> Date: Thu, 21 Aug 2025 14:14:58 -0400 Subject: [PATCH] fix(ui): thread id through instead of from routeParams (#13539) Adjustment to https://github.com/payloadcms/payload/pull/13526 Prefer to thread ID through arguments instead of relying on routeParams which would mean that ID is always a string - would not work for PG dbs or non-text based ID's. --- packages/next/src/views/Document/index.tsx | 1 + .../src/views/Document/renderDocumentSlots.tsx | 15 +++++++++------ packages/translations/src/languages/is.ts | 2 ++ .../ui/src/providers/ServerFunctions/index.tsx | 1 + 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/packages/next/src/views/Document/index.tsx b/packages/next/src/views/Document/index.tsx index c8641f345..08c1ad0b7 100644 --- a/packages/next/src/views/Document/index.tsx +++ b/packages/next/src/views/Document/index.tsx @@ -333,6 +333,7 @@ export const renderDocument = async ({ } const documentSlots = renderDocumentSlots({ + id, collectionConfig, globalConfig, hasSavePermission, diff --git a/packages/next/src/views/Document/renderDocumentSlots.tsx b/packages/next/src/views/Document/renderDocumentSlots.tsx index 7b81e3dae..357ae2681 100644 --- a/packages/next/src/views/Document/renderDocumentSlots.tsx +++ b/packages/next/src/views/Document/renderDocumentSlots.tsx @@ -26,10 +26,11 @@ export const renderDocumentSlots: (args: { collectionConfig?: SanitizedCollectionConfig globalConfig?: SanitizedGlobalConfig hasSavePermission: boolean + id?: number | string permissions: SanitizedDocumentPermissions req: PayloadRequest }) => DocumentSlots = (args) => { - const { collectionConfig, globalConfig, hasSavePermission, req } = args + const { id, collectionConfig, globalConfig, hasSavePermission, req } = args const components: DocumentSlots = {} as DocumentSlots @@ -38,7 +39,7 @@ export const renderDocumentSlots: (args: { const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview const serverProps: ServerProps = { - id: req.routeParams.id as number | string, + id, i18n: req.i18n, payload: req.payload, user: req.user, @@ -169,10 +170,11 @@ export const renderDocumentSlots: (args: { return components } -export const renderDocumentSlotsHandler: ServerFunction<{ collectionSlug: string }> = async ( - args, -) => { - const { collectionSlug, req } = args +export const renderDocumentSlotsHandler: ServerFunction<{ + collectionSlug: string + id?: number | string +}> = async (args) => { + const { id, collectionSlug, req } = args const collectionConfig = req.payload.collections[collectionSlug]?.config @@ -187,6 +189,7 @@ export const renderDocumentSlotsHandler: ServerFunction<{ collectionSlug: string }) return renderDocumentSlots({ + id, collectionConfig, hasSavePermission, permissions: docPermissions, diff --git a/packages/translations/src/languages/is.ts b/packages/translations/src/languages/is.ts index ee86006bc..68abee172 100644 --- a/packages/translations/src/languages/is.ts +++ b/packages/translations/src/languages/is.ts @@ -286,6 +286,7 @@ export const isTranslations = { deletedAt: 'Eytt', deletedCountSuccessfully: 'Eyddi {{count}} {{label}}.', deletedSuccessfully: 'Eytt.', + deleteLabel: 'Eyða {{label}}', deletePermanently: 'Sleppa rusli og eyða varanlega', deleting: 'Eyði...', depth: 'Dýpt', @@ -345,6 +346,7 @@ export const isTranslations = { moveUp: 'Færa upp', moving: 'Færi', movingCount: 'Færi {{count}} {{label}}', + newLabel: 'Nýtt {{label}}', newPassword: 'Nýtt lykilorð', next: 'Næsta', no: 'Nei', diff --git a/packages/ui/src/providers/ServerFunctions/index.tsx b/packages/ui/src/providers/ServerFunctions/index.tsx index 5c9336a5c..91d391e51 100644 --- a/packages/ui/src/providers/ServerFunctions/index.tsx +++ b/packages/ui/src/providers/ServerFunctions/index.tsx @@ -90,6 +90,7 @@ type CopyDataFromLocaleClient = ( type GetDocumentSlots = (args: { collectionSlug: string + id?: number | string signal?: AbortSignal }) => Promise