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:
@@ -333,6 +333,7 @@ export const renderDocument = async ({
|
||||
}
|
||||
|
||||
const documentSlots = renderDocumentSlots({
|
||||
id,
|
||||
collectionConfig,
|
||||
globalConfig,
|
||||
hasSavePermission,
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -90,6 +90,7 @@ type CopyDataFromLocaleClient = (
|
||||
|
||||
type GetDocumentSlots = (args: {
|
||||
collectionSlug: string
|
||||
id?: number | string
|
||||
signal?: AbortSignal
|
||||
}) => Promise<DocumentSlots>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user