Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
133 lines
2.8 KiB
Plaintext
133 lines
2.8 KiB
Plaintext
import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
|
|
import { canAccessAdmin, isEntityHidden } from 'payload';
|
|
import { applyLocaleFiltering } from 'payload/shared';
|
|
import { renderDocument } from './index.js';
|
|
export const renderDocumentHandler = async args => {
|
|
const {
|
|
collectionSlug,
|
|
cookies,
|
|
disableActions,
|
|
docID,
|
|
drawerSlug,
|
|
initialData,
|
|
locale,
|
|
overrideEntityVisibility,
|
|
paramsOverride,
|
|
permissions,
|
|
redirectAfterCreate,
|
|
redirectAfterDelete,
|
|
redirectAfterDuplicate,
|
|
req,
|
|
req: {
|
|
i18n,
|
|
payload,
|
|
payload: {
|
|
config
|
|
},
|
|
user
|
|
},
|
|
searchParams = {},
|
|
versions
|
|
} = args;
|
|
await canAccessAdmin({
|
|
req
|
|
});
|
|
const clientConfig = getClientConfig({
|
|
config,
|
|
i18n,
|
|
importMap: req.payload.importMap,
|
|
user
|
|
});
|
|
await applyLocaleFiltering({
|
|
clientConfig,
|
|
config,
|
|
req
|
|
});
|
|
let preferences;
|
|
if (docID) {
|
|
const preferencesKey = `${collectionSlug}-edit-${docID}`;
|
|
preferences = await payload.find({
|
|
collection: 'payload-preferences',
|
|
depth: 0,
|
|
limit: 1,
|
|
where: {
|
|
and: [{
|
|
key: {
|
|
equals: preferencesKey
|
|
}
|
|
}, {
|
|
'user.relationTo': {
|
|
equals: user.collection
|
|
}
|
|
}, {
|
|
'user.value': {
|
|
equals: user.id
|
|
}
|
|
}]
|
|
}
|
|
}).then(res => res.docs[0]?.value);
|
|
}
|
|
const visibleEntities = {
|
|
collections: payload.config.collections.map(({
|
|
slug,
|
|
admin: {
|
|
hidden
|
|
}
|
|
}) => !isEntityHidden({
|
|
hidden,
|
|
user
|
|
}) ? slug : null).filter(Boolean),
|
|
globals: payload.config.globals.map(({
|
|
slug,
|
|
admin: {
|
|
hidden
|
|
}
|
|
}) => !isEntityHidden({
|
|
hidden,
|
|
user
|
|
}) ? slug : null).filter(Boolean)
|
|
};
|
|
const {
|
|
data,
|
|
Document
|
|
} = await renderDocument({
|
|
clientConfig,
|
|
disableActions,
|
|
documentSubViewType: 'default',
|
|
drawerSlug,
|
|
i18n,
|
|
importMap: payload.importMap,
|
|
initialData,
|
|
initPageResult: {
|
|
collectionConfig: payload?.collections?.[collectionSlug]?.config,
|
|
cookies,
|
|
docID,
|
|
globalConfig: payload.config.globals.find(global => global.slug === collectionSlug),
|
|
languageOptions: undefined,
|
|
locale,
|
|
permissions,
|
|
req,
|
|
translations: undefined,
|
|
visibleEntities
|
|
},
|
|
locale,
|
|
overrideEntityVisibility,
|
|
params: paramsOverride ?? {
|
|
segments: ['collections', collectionSlug, String(docID)]
|
|
},
|
|
payload,
|
|
permissions,
|
|
redirectAfterCreate,
|
|
redirectAfterDelete,
|
|
redirectAfterDuplicate,
|
|
searchParams,
|
|
versions,
|
|
viewType: 'document'
|
|
});
|
|
return {
|
|
data,
|
|
Document,
|
|
preferences
|
|
};
|
|
};
|
|
//# sourceMappingURL=handleServerFunction.js.map |