52 lines
1.4 KiB
JavaScript
52 lines
1.4 KiB
JavaScript
|
|
import { WorkspacePage } from '../pages/WorkspacePage.jsx'
|
||
|
|
import { InitiativesPage } from '../pages/InitiativesPage.jsx'
|
||
|
|
import { InitiativeDetailPage } from '../pages/InitiativeDetailPage.jsx'
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @typedef {Object} ViewDefinition
|
||
|
|
* @property {string} key
|
||
|
|
* @property {string} path
|
||
|
|
* @property {string} title
|
||
|
|
* @property {string} [requiredCapability]
|
||
|
|
* @property {import('react').ComponentType<any>} component
|
||
|
|
* @property {boolean} [showInNav]
|
||
|
|
*/
|
||
|
|
|
||
|
|
/** @type {ViewDefinition[]} */
|
||
|
|
export const VIEWS = [
|
||
|
|
{
|
||
|
|
key: 'kairo.workspace',
|
||
|
|
path: '/workspace',
|
||
|
|
title: 'Workspace',
|
||
|
|
requiredCapability: 'kairo.action.read',
|
||
|
|
component: WorkspacePage,
|
||
|
|
showInNav: true,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: 'kairo.initiatives',
|
||
|
|
path: '/initiatives',
|
||
|
|
title: 'Vorhaben',
|
||
|
|
requiredCapability: 'kairo.initiative.read',
|
||
|
|
component: InitiativesPage,
|
||
|
|
showInNav: true,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: 'kairo.initiative_detail',
|
||
|
|
path: '/initiatives/:id',
|
||
|
|
title: 'Vorhaben-Detail',
|
||
|
|
requiredCapability: 'kairo.initiative.read',
|
||
|
|
component: InitiativeDetailPage,
|
||
|
|
showInNav: false,
|
||
|
|
},
|
||
|
|
]
|
||
|
|
|
||
|
|
export function getNavViews(capabilities) {
|
||
|
|
const capSet = capabilities instanceof Set ? capabilities : new Set(capabilities)
|
||
|
|
return VIEWS.filter((v) => v.showInNav !== false)
|
||
|
|
.filter((v) => !v.requiredCapability || capSet.has(v.requiredCapability))
|
||
|
|
}
|
||
|
|
|
||
|
|
export function getViewByKey(key) {
|
||
|
|
return VIEWS.find((v) => v.key === key)
|
||
|
|
}
|