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
31 lines
644 B
Plaintext
31 lines
644 B
Plaintext
function isHidden(hidden, user) {
|
|
if (typeof hidden === 'function') {
|
|
try {
|
|
return hidden({
|
|
user
|
|
});
|
|
} catch {
|
|
return true;
|
|
}
|
|
}
|
|
return !!hidden;
|
|
}
|
|
export function getVisibleEntities({
|
|
req
|
|
}) {
|
|
return {
|
|
collections: req.payload.config.collections.map(({
|
|
slug,
|
|
admin: {
|
|
hidden
|
|
}
|
|
}) => !isHidden(hidden, req.user) ? slug : null).filter(Boolean),
|
|
globals: req.payload.config.globals.map(({
|
|
slug,
|
|
admin: {
|
|
hidden
|
|
}
|
|
}) => !isHidden(hidden, req.user) ? slug : null).filter(Boolean)
|
|
};
|
|
}
|
|
//# sourceMappingURL=getVisibleEntities.js.map |