Kairo-Jinkendo/frontend/src/config/appNav.js
Lars e42edd86fa
Some checks failed
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Failing after 1m46s
Test Suite / k6 /api/health Baseline (push) Has been skipped
Test Suite / playwright-smoke (push) Has been skipped
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
AP1.9a: Arbeitsmodi-Shell mit Scope, Objekt-Routen und Legacy-Redirects.
Ersetzt die Vorhaben-Tab-Navigation durch Cockpit/Ausführen/Planen/Kontrolle/Team, Deep Links für APs/Projekte/Gates und Programm-Scope im Header.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-08 12:55:37 +02:00

56 lines
1.5 KiB
JavaScript

import {
Gauge,
LayoutDashboard,
Map,
Play,
Users,
FolderKanban,
} 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, objectPrefixes?: string[] }} AppNavItem */
const ICON_BY_KEY = {
'kairo.cockpit': LayoutDashboard,
'kairo.work': Play,
'kairo.plan': Map,
'kairo.control': Gauge,
'kairo.team': Users,
'kairo.initiatives': FolderKanban,
}
/**
* @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 === '/cockpit' || view.path === '/team',
Icon: ICON_BY_KEY[view.key] || LayoutDashboard,
matchPrefix: view.matchPrefix,
objectPrefixes: view.objectPrefixes,
}))
}
/**
* @param {string} pathname
* @param {AppNavItem} item
* @param {boolean} routerIsActive
*/
export function isNavItemActive(pathname, item, routerIsActive) {
if (item.matchPrefix && pathname.startsWith(item.matchPrefix)) {
return true
}
if (item.objectPrefixes?.some((prefix) => pathname.startsWith(prefix))) {
return true
}
if (item.key === 'kairo.initiatives' && pathname.startsWith('/initiatives')) {
return true
}
return routerIsActive
}