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
130 lines
2.7 KiB
Plaintext
130 lines
2.7 KiB
Plaintext
import { getClientConfig } from '@payloadcms/ui/utilities/getClientConfig';
|
|
import { canAccessAdmin, isEntityHidden, UnauthorizedError } from 'payload';
|
|
import { applyLocaleFiltering } from 'payload/shared';
|
|
import { renderListView } from './index.js';
|
|
export const renderListHandler = async args => {
|
|
const {
|
|
collectionSlug,
|
|
cookies,
|
|
disableActions,
|
|
disableBulkDelete,
|
|
disableBulkEdit,
|
|
disableQueryPresets,
|
|
drawerSlug,
|
|
enableRowSelections,
|
|
locale,
|
|
overrideEntityVisibility,
|
|
permissions,
|
|
query,
|
|
redirectAfterDelete,
|
|
redirectAfterDuplicate,
|
|
req,
|
|
req: {
|
|
i18n,
|
|
payload,
|
|
payload: {
|
|
config
|
|
},
|
|
user
|
|
}
|
|
} = args;
|
|
if (!req.user) {
|
|
throw new UnauthorizedError();
|
|
}
|
|
await canAccessAdmin({
|
|
req
|
|
});
|
|
const clientConfig = getClientConfig({
|
|
config,
|
|
i18n,
|
|
importMap: payload.importMap,
|
|
user
|
|
});
|
|
await applyLocaleFiltering({
|
|
clientConfig,
|
|
config,
|
|
req
|
|
});
|
|
const preferencesKey = `collection-${collectionSlug}`;
|
|
const 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 {
|
|
List
|
|
} = await renderListView({
|
|
clientConfig,
|
|
disableActions,
|
|
disableBulkDelete,
|
|
disableBulkEdit,
|
|
disableQueryPresets,
|
|
drawerSlug,
|
|
enableRowSelections,
|
|
i18n,
|
|
importMap: payload.importMap,
|
|
initPageResult: {
|
|
collectionConfig: payload?.collections?.[collectionSlug]?.config,
|
|
cookies,
|
|
globalConfig: payload.config.globals.find(global => global.slug === collectionSlug),
|
|
languageOptions: undefined,
|
|
locale,
|
|
permissions,
|
|
req,
|
|
translations: undefined,
|
|
visibleEntities
|
|
},
|
|
locale,
|
|
overrideEntityVisibility,
|
|
params: {
|
|
segments: ['collections', collectionSlug]
|
|
},
|
|
payload,
|
|
permissions,
|
|
query,
|
|
redirectAfterDelete,
|
|
redirectAfterDuplicate,
|
|
searchParams: {},
|
|
viewType: 'list'
|
|
});
|
|
return {
|
|
List,
|
|
preferences
|
|
};
|
|
};
|
|
//# sourceMappingURL=handleServerFunction.js.map |