diff --git a/src/app/core/services/navigation-config.service.ts b/src/app/core/services/navigation-config.service.ts index 9d6be6fca..8bf3929bd 100644 --- a/src/app/core/services/navigation-config.service.ts +++ b/src/app/core/services/navigation-config.service.ts @@ -107,6 +107,36 @@ export function flattenNavRoutes( }); } +/** A permission-filtered navigation leaf suitable for global search. */ +export interface NavSearchResult { + route: string; + label: string; + groupLabel?: string; + icon?: string; +} + +/** + * Flattens a navigation tree into searchable leaf routes, carrying the parent + * group's label key for display context (e.g. "Organization › Offices"). + */ +export function flattenNavRoutes( + items: readonly NavItemConfig[], + groupLabelKey?: string, +): { route: string; labelKey: string; groupLabelKey?: string; icon?: string }[] { + return items.flatMap((item) => { + if (item.divider) { + return []; + } + if (item.children) { + return flattenNavRoutes(item.children, item.labelKey); + } + if (!item.route) { + return []; + } + return [{ route: item.route, labelKey: item.labelKey, groupLabelKey, icon: item.icon }]; + }); +} + /** * The application's full navigation tree, transcribed from the sidebar * template. Permission and feature-flag gates match the ones already applied