AP0.6: Kairo Workspace UX mit Frontend Widget/View Registry und Vitest.
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 29s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 12s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 29s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 12s
This commit is contained in:
1 parent
802c9259dc
commit
0e7184a59e
38 files changed
+2362
-386
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { WIDGETS, getWidgetsForArea } from '../registry/widgetRegistry.js'
|
||||
import { VIEWS, getNavViews } from '../registry/viewRegistry.js'
|
||||
|
||||
describe('widgetRegistry', () => {
|
||||
it('contains expected AP0.6 widgets', () => {
|
||||
const keys = WIDGETS.map((w) => w.key)
|
||||
expect(keys).toContain('kairo.my_open_actions')
|
||||
expect(keys).toContain('kairo.active_initiatives')
|
||||
expect(keys).toContain('kairo.blocked_actions')
|
||||
expect(keys).toContain('kairo.tenant_context')
|
||||
})
|
||||
|
||||
it('filters widgets by capability', () => {
|
||||
const all = getWidgetsForArea('workspace', [
|
||||
'kairo.action.read',
|
||||
'kairo.initiative.read',
|
||||
])
|
||||
expect(all.length).toBe(4)
|
||||
|
||||
const readOnly = getWidgetsForArea('workspace', ['kairo.initiative.read'])
|
||||
expect(readOnly.some((w) => w.key === 'kairo.my_open_actions')).toBe(false)
|
||||
expect(readOnly.some((w) => w.key === 'kairo.active_initiatives')).toBe(true)
|
||||
})
|
||||
})
|
||||
|
||||
describe('viewRegistry', () => {
|
||||
it('contains workspace and initiatives views', () => {
|
||||
const keys = VIEWS.map((v) => v.key)
|
||||
expect(keys).toContain('kairo.workspace')
|
||||
expect(keys).toContain('kairo.initiatives')
|
||||
})
|
||||
|
||||
it('filters nav views by capability', () => {
|
||||
const nav = getNavViews(['kairo.initiative.read'])
|
||||
expect(nav.some((v) => v.key === 'kairo.workspace')).toBe(false)
|
||||
expect(nav.some((v) => v.key === 'kairo.initiatives')).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,51 @@
|
||||
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)
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
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)
|
||||
}
|
||||
Reference in new issue
Block a user