Files
klz-cables.com/.pnpm-store/v10/files/31/2e70c061bca7d23fc86952f6c8e358f0c4219dbc54177bc0e328397dc70b8bfd11e1742fdbdb5dbf37386323219c85f95e34272b1edbde44a05fcb349ea923
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

57 lines
2.0 KiB
Plaintext

import { defaultAccess } from '../auth/defaultAccess.js';
export const lockedDocumentsCollectionSlug = 'payload-locked-documents';
export const getLockedDocumentsCollection = (config)=>{
const lockableCollections = config.collections.filter((collectionConfig)=>collectionConfig.lockDocuments !== false).map((collectionConfig)=>collectionConfig.slug);
const lockableGlobals = config.globals ? config.globals.filter((globalConfig)=>globalConfig.lockDocuments !== false) : [];
const authCollections = config.collections.filter((collectionConfig)=>collectionConfig.auth).map((collectionConfig)=>collectionConfig.slug);
// If there are no lockable collections AND no lockable globals, don't create the collection
if (lockableCollections.length === 0 && lockableGlobals.length === 0) {
return null;
}
// If there are no auth collections, we can't track who locked the document
// so we shouldn't create the locked-documents collection
if (authCollections.length === 0) {
return null;
}
const fields = [];
// Only include the document field if there are lockable collections
if (lockableCollections.length > 0) {
fields.push({
name: 'document',
type: 'relationship',
index: true,
maxDepth: 0,
relationTo: lockableCollections
});
}
// Always include globalSlug field for tracking global locks
fields.push({
name: 'globalSlug',
type: 'text',
index: true
});
// Always include user field
fields.push({
name: 'user',
type: 'relationship',
maxDepth: 1,
relationTo: authCollections,
required: true
});
return {
slug: lockedDocumentsCollectionSlug,
access: {
create: defaultAccess,
delete: defaultAccess,
read: defaultAccess,
update: defaultAccess
},
admin: {
hidden: true
},
fields,
lockDocuments: false
};
};
//# sourceMappingURL=config.js.map