Files
klz-cables.com/.pnpm-store/v10/files/67/42b3920922579958f3b44624101b32a1d08c2912e220c2642c8828a3ce133dde480aa1108c6585c4db30f29a58dda4771993d54d83fa220984ae2d2639317f
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

1 line
5.0 KiB
Plaintext

{"version":3,"file":"groupNavItems.js","names":["getTranslation","EntityType","groupNavItems","entities","permissions","i18n","result","reduce","groups","entityToGroup","entity","admin","group","type","toLowerCase","slug","read","translatedGroup","labelOrFunction","labels","plural","label","t","existingGroup","find","matchedGroup","push","defaultGroup","filter","length"],"sources":["../../src/utilities/groupNavItems.ts"],"sourcesContent":["import type { I18nClient } from '@payloadcms/translations'\nimport type {\n SanitizedCollectionConfig,\n SanitizedGlobalConfig,\n SanitizedPermissions,\n StaticLabel,\n} from 'payload'\n\nimport { getTranslation } from '@payloadcms/translations'\n\n/**\n * @deprecated Import from `payload` instead\n */\nexport enum EntityType {\n collection = 'collections',\n global = 'globals',\n}\n\nexport type EntityToGroup =\n | {\n entity: SanitizedCollectionConfig\n type: EntityType.collection\n }\n | {\n entity: SanitizedGlobalConfig\n type: EntityType.global\n }\n\nexport type NavGroupType = {\n entities: {\n label: StaticLabel\n slug: string\n type: EntityType\n }[]\n label: string\n}\n\nexport function groupNavItems(\n entities: EntityToGroup[],\n permissions: SanitizedPermissions,\n i18n: I18nClient,\n): NavGroupType[] {\n const result = entities.reduce(\n (groups, entityToGroup) => {\n // Skip entities where admin.group is explicitly false\n if (entityToGroup.entity?.admin?.group === false) {\n return groups\n }\n\n if (permissions?.[entityToGroup.type.toLowerCase()]?.[entityToGroup.entity.slug]?.read) {\n const translatedGroup = getTranslation(entityToGroup.entity.admin.group, i18n)\n\n const labelOrFunction =\n 'labels' in entityToGroup.entity\n ? entityToGroup.entity.labels.plural\n : entityToGroup.entity.label\n\n const label =\n typeof labelOrFunction === 'function'\n ? labelOrFunction({ i18n, t: i18n.t })\n : labelOrFunction\n\n if (entityToGroup.entity.admin.group) {\n const existingGroup = groups.find(\n (group) => getTranslation(group.label, i18n) === translatedGroup,\n ) as NavGroupType\n\n let matchedGroup: NavGroupType = existingGroup\n\n if (!existingGroup) {\n matchedGroup = { entities: [], label: translatedGroup }\n groups.push(matchedGroup)\n }\n\n matchedGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label,\n })\n } else {\n const defaultGroup = groups.find((group) => {\n return getTranslation(group.label, i18n) === i18n.t(`general:${entityToGroup.type}`)\n }) as NavGroupType\n defaultGroup.entities.push({\n slug: entityToGroup.entity.slug,\n type: entityToGroup.type,\n label,\n })\n }\n }\n\n return groups\n },\n [\n {\n entities: [],\n label: i18n.t('general:collections'),\n },\n {\n entities: [],\n label: i18n.t('general:globals'),\n },\n ],\n )\n\n return result.filter((group) => group.entities.length > 0)\n}\n"],"mappings":"AAQA,SAASA,cAAc,QAAQ;AAE/B;;;AAGA,OAAO,IAAAC,UAAK,0BAAAA,UAAA;;;SAAAA,UAAA;;AAwBZ,OAAO,SAASC,cACdC,QAAyB,EACzBC,WAAiC,EACjCC,IAAgB;EAEhB,MAAMC,MAAA,GAASH,QAAA,CAASI,MAAM,CAC5B,CAACC,MAAA,EAAQC,aAAA;IACP;IACA,IAAIA,aAAA,CAAcC,MAAM,EAAEC,KAAA,EAAOC,KAAA,KAAU,OAAO;MAChD,OAAOJ,MAAA;IACT;IAEA,IAAIJ,WAAA,GAAcK,aAAA,CAAcI,IAAI,CAACC,WAAW,GAAG,GAAGL,aAAA,CAAcC,MAAM,CAACK,IAAI,CAAC,EAAEC,IAA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