Files
klz-cables.com/.pnpm-store/v10/files/bb/76762a6a66630a50dce4b2cf1b93061a7717884d13035f4b1ad8dcd3f8a74ff9df0cee2989e408628de32ad93f23582ba97108d6d4db6a8a2aced4c21f374d
Marc Mintel 5397309103
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
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

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