Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions src/app/core/services/navigation-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down