Kairo-Jinkendo/frontend/src/config/appNav.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

import { LayoutDashboard, FolderKanban, ListChecks } from 'lucide-react'
import { getNavViews } from '../registry/viewRegistry.js'
/** @typedef {{ key: string, to: string, label: string, shortLabel: string, end?: boolean, Icon: import('react').ForwardRefExoticComponent, matchPrefix?: string }} AppNavItem */
const ICON_BY_KEY = {
'kairo.workspace': LayoutDashboard,
'kairo.initiatives': FolderKanban,
'kairo.my_actions': ListChecks,
}
/**
* @param {Set<string>|string[]} capabilities
* @returns {AppNavItem[]}
*/
export function getAppNavItems(capabilities) {
return getNavViews(capabilities).map((view) => ({
key: view.key,
to: view.path,
label: view.navLabel || view.title,
shortLabel: view.shortLabel || view.title,
end: view.path !== '/initiatives',
Icon: ICON_BY_KEY[view.key] || LayoutDashboard,
matchPrefix: view.matchPrefix,
}))
}
/**
* @param {string} pathname
* @param {AppNavItem} item
* @param {boolean} routerIsActive
*/
export function isNavItemActive(pathname, item, routerIsActive) {
if (item.matchPrefix) {
return pathname.startsWith(item.matchPrefix)
}
return routerIsActive
}