Kairo-Jinkendo/frontend/src/registry/viewRegistry.js

62 lines
1.7 KiB
JavaScript
Raw Normal View History

import { WorkspacePage } from '../pages/WorkspacePage.jsx'
import { InitiativesPage } from '../pages/InitiativesPage.jsx'
import { MyActionsPage } from '../pages/MyActionsPage.jsx'
/** @type {import('./viewRegistry.js').ViewDefinition[]} */
export const VIEWS = [
{
key: 'kairo.workspace',
path: '/workspace',
title: 'Workspace',
navLabel: 'Workspace',
shortLabel: 'Start',
requiredCapability: 'kairo.action.read',
component: WorkspacePage,
showInNav: true,
},
{
key: 'kairo.initiatives',
path: '/initiatives',
title: 'Vorhaben',
navLabel: 'Vorhaben',
shortLabel: 'Vorhaben',
matchPrefix: '/initiatives',
requiredCapability: 'kairo.initiative.read',
component: InitiativesPage,
showInNav: true,
},
{
key: 'kairo.my_actions',
path: '/my-actions',
title: 'Meine Maßnahmen',
navLabel: 'Meine Maßnahmen',
shortLabel: 'Maßnahmen',
requiredCapability: 'kairo.action.read',
component: MyActionsPage,
showInNav: true,
},
]
/**
* @typedef {Object} ViewDefinition
* @property {string} key
* @property {string} path
* @property {string} title
* @property {string} [navLabel]
* @property {string} [shortLabel]
* @property {string} [matchPrefix]
* @property {string} [requiredCapability]
* @property {import('react').ComponentType<any>} component
* @property {boolean} [showInNav]
*/
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)
}