72 lines
2.1 KiB
JavaScript
72 lines
2.1 KiB
JavaScript
|
|
import { MyOpenActionsWidget } from '../widgets/MyOpenActionsWidget.jsx'
|
||
|
|
import { InitiativesWidget } from '../widgets/InitiativesWidget.jsx'
|
||
|
|
import { BlockedActionsWidget } from '../widgets/BlockedActionsWidget.jsx'
|
||
|
|
import { TenantContextWidget } from '../widgets/TenantContextWidget.jsx'
|
||
|
|
|
||
|
|
/** @typedef {import('react').ComponentType<any>} WidgetComponent */
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @typedef {Object} WidgetDefinition
|
||
|
|
* @property {string} key
|
||
|
|
* @property {string} title
|
||
|
|
* @property {string} [description]
|
||
|
|
* @property {string} area
|
||
|
|
* @property {string} [requiredCapability]
|
||
|
|
* @property {number} defaultOrder
|
||
|
|
* @property {WidgetComponent} component
|
||
|
|
*/
|
||
|
|
|
||
|
|
/** @type {WidgetDefinition[]} */
|
||
|
|
export const WIDGETS = [
|
||
|
|
{
|
||
|
|
key: 'kairo.tenant_context',
|
||
|
|
title: 'Kontext',
|
||
|
|
description: 'Aktiver Tenant und Actor',
|
||
|
|
area: 'workspace',
|
||
|
|
defaultOrder: 0,
|
||
|
|
component: TenantContextWidget,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: 'kairo.my_open_actions',
|
||
|
|
title: 'Meine offenen Maßnahmen',
|
||
|
|
description: 'Offene Maßnahmen, die mir zugewiesen sind',
|
||
|
|
area: 'workspace',
|
||
|
|
requiredCapability: 'kairo.action.read',
|
||
|
|
defaultOrder: 10,
|
||
|
|
component: MyOpenActionsWidget,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: 'kairo.blocked_actions',
|
||
|
|
title: 'Blockierte Maßnahmen',
|
||
|
|
description: 'Mir zugewiesene blockierte Maßnahmen',
|
||
|
|
area: 'workspace',
|
||
|
|
requiredCapability: 'kairo.action.read',
|
||
|
|
defaultOrder: 20,
|
||
|
|
component: BlockedActionsWidget,
|
||
|
|
},
|
||
|
|
{
|
||
|
|
key: 'kairo.active_initiatives',
|
||
|
|
title: 'Aktive Vorhaben',
|
||
|
|
description: 'Aktive und pausierte Vorhaben im Tenant',
|
||
|
|
area: 'workspace',
|
||
|
|
requiredCapability: 'kairo.initiative.read',
|
||
|
|
defaultOrder: 30,
|
||
|
|
component: InitiativesWidget,
|
||
|
|
},
|
||
|
|
]
|
||
|
|
|
||
|
|
/**
|
||
|
|
* @param {string} area
|
||
|
|
* @param {Set<string>|string[]} capabilities
|
||
|
|
*/
|
||
|
|
export function getWidgetsForArea(area, capabilities) {
|
||
|
|
const capSet = capabilities instanceof Set ? capabilities : new Set(capabilities)
|
||
|
|
return WIDGETS.filter((w) => w.area === area)
|
||
|
|
.filter((w) => !w.requiredCapability || capSet.has(w.requiredCapability))
|
||
|
|
.sort((a, b) => a.defaultOrder - b.defaultOrder)
|
||
|
|
}
|
||
|
|
|
||
|
|
export function getWidgetByKey(key) {
|
||
|
|
return WIDGETS.find((w) => w.key === key)
|
||
|
|
}
|