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.
This commit is contained in:
Jarrod Flesch
2025-08-21 14:14:58 -04:00
committed by GitHub
parent 76741eb722
commit b65ca6832d
4 changed files with 13 additions and 6 deletions

View File

@@ -333,6 +333,7 @@ export const renderDocument = async ({
} }
const documentSlots = renderDocumentSlots({ const documentSlots = renderDocumentSlots({
id,
collectionConfig, collectionConfig,
globalConfig, globalConfig,
hasSavePermission, hasSavePermission,

View File

@@ -26,10 +26,11 @@ export const renderDocumentSlots: (args: {
collectionConfig?: SanitizedCollectionConfig collectionConfig?: SanitizedCollectionConfig
globalConfig?: SanitizedGlobalConfig globalConfig?: SanitizedGlobalConfig
hasSavePermission: boolean hasSavePermission: boolean
id?: number | string
permissions: SanitizedDocumentPermissions permissions: SanitizedDocumentPermissions
req: PayloadRequest req: PayloadRequest
}) => DocumentSlots = (args) => { }) => DocumentSlots = (args) => {
const { collectionConfig, globalConfig, hasSavePermission, req } = args const { id, collectionConfig, globalConfig, hasSavePermission, req } = args
const components: DocumentSlots = {} as DocumentSlots const components: DocumentSlots = {} as DocumentSlots
@@ -38,7 +39,7 @@ export const renderDocumentSlots: (args: {
const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview const isPreviewEnabled = collectionConfig?.admin?.preview || globalConfig?.admin?.preview
const serverProps: ServerProps = { const serverProps: ServerProps = {
id: req.routeParams.id as number | string, id,
i18n: req.i18n, i18n: req.i18n,
payload: req.payload, payload: req.payload,
user: req.user, user: req.user,
@@ -169,10 +170,11 @@ export const renderDocumentSlots: (args: {
return components return components
} }
export const renderDocumentSlotsHandler: ServerFunction<{ collectionSlug: string }> = async ( export const renderDocumentSlotsHandler: ServerFunction<{
args, collectionSlug: string
) => { id?: number | string
const { collectionSlug, req } = args }> = async (args) => {
const { id, collectionSlug, req } = args
const collectionConfig = req.payload.collections[collectionSlug]?.config const collectionConfig = req.payload.collections[collectionSlug]?.config
@@ -187,6 +189,7 @@ export const renderDocumentSlotsHandler: ServerFunction<{ collectionSlug: string
}) })
return renderDocumentSlots({ return renderDocumentSlots({
id,
collectionConfig, collectionConfig,
hasSavePermission, hasSavePermission,
permissions: docPermissions, permissions: docPermissions,

View File

@@ -286,6 +286,7 @@ export const isTranslations = {
deletedAt: 'Eytt', deletedAt: 'Eytt',
deletedCountSuccessfully: 'Eyddi {{count}} {{label}}.', deletedCountSuccessfully: 'Eyddi {{count}} {{label}}.',
deletedSuccessfully: 'Eytt.', deletedSuccessfully: 'Eytt.',
deleteLabel: 'Eyða {{label}}',
deletePermanently: 'Sleppa rusli og eyða varanlega', deletePermanently: 'Sleppa rusli og eyða varanlega',
deleting: 'Eyði...', deleting: 'Eyði...',
depth: 'Dýpt', depth: 'Dýpt',
@@ -345,6 +346,7 @@ export const isTranslations = {
moveUp: 'Færa upp', moveUp: 'Færa upp',
moving: 'Færi', moving: 'Færi',
movingCount: 'Færi {{count}} {{label}}', movingCount: 'Færi {{count}} {{label}}',
newLabel: 'Nýtt {{label}}',
newPassword: 'Nýtt lykilorð', newPassword: 'Nýtt lykilorð',
next: 'Næsta', next: 'Næsta',
no: 'Nei', no: 'Nei',

View File

@@ -90,6 +90,7 @@ type CopyDataFromLocaleClient = (
type GetDocumentSlots = (args: { type GetDocumentSlots = (args: {
collectionSlug: string collectionSlug: string
id?: number | string
signal?: AbortSignal signal?: AbortSignal
}) => Promise<DocumentSlots> }) => Promise<DocumentSlots>