Files
klz-cables.com/.pnpm-store/v10/files/34/8054a6f75b3c73511b6f64a408b52bcd09b0736fcffc83ac20df0ee434e8a532641b1438dfb8b98f3001e2a490646479f664fdce0368de9e4b59b14f11de92
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

59 lines
2.1 KiB
Plaintext

import { getTranslation } from '@payloadcms/translations';
/**
* @deprecated Import from `payload` instead
*/
export var EntityType = /*#__PURE__*/function (EntityType) {
EntityType["collection"] = "collections";
EntityType["global"] = "globals";
return EntityType;
}({});
export function groupNavItems(entities, permissions, i18n) {
const result = entities.reduce((groups, entityToGroup) => {
// Skip entities where admin.group is explicitly false
if (entityToGroup.entity?.admin?.group === false) {
return groups;
}
if (permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read) {
const translatedGroup = getTranslation(entityToGroup.entity.admin.group, i18n);
const labelOrFunction = 'labels' in entityToGroup.entity ? entityToGroup.entity.labels.plural : entityToGroup.entity.label;
const label = typeof labelOrFunction === 'function' ? labelOrFunction({
i18n,
t: i18n.t
}) : labelOrFunction;
if (entityToGroup.entity.admin.group) {
const existingGroup = groups.find(group => getTranslation(group.label, i18n) === translatedGroup);
let matchedGroup = existingGroup;
if (!existingGroup) {
matchedGroup = {
entities: [],
label: translatedGroup
};
groups.push(matchedGroup);
}
matchedGroup.entities.push({
slug: entityToGroup.entity.slug,
type: entityToGroup.type,
label
});
} else {
const defaultGroup = groups.find(group => {
return getTranslation(group.label, i18n) === i18n.t(`general:${entityToGroup.type}`);
});
defaultGroup.entities.push({
slug: entityToGroup.entity.slug,
type: entityToGroup.type,
label
});
}
}
return groups;
}, [{
entities: [],
label: i18n.t('general:collections')
}, {
entities: [],
label: i18n.t('general:globals')
}]);
return result.filter(group => group.entities.length > 0);
}
//# sourceMappingURL=groupNavItems.js.map