AP0.7: Tenant Hardening, Actor Directory und Data Layer Minimum
Deploy Development / deploy (push) Successful in 47s
Test Suite / pytest-backend (push) Successful in 42s
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 47s
Test Suite / pytest-backend (push) Successful in 42s
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
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
36487d2869
commit
db06af0489
32 files changed
+1424
-43
No files matched your search
@@ -1,9 +1,22 @@
|
||||
/**
|
||||
* AP0.6: Kein GET /api/actors im Backend.
|
||||
* Actor-Zuweisung nutzt TenantContext (aktueller Human Actor).
|
||||
* Siehe Abschlussbericht AP0.6 §9.
|
||||
*/
|
||||
import { apiFetch } from './client.js'
|
||||
|
||||
/**
|
||||
* @param {{ actor_type?: string, include_inactive?: boolean, q?: string }} [params]
|
||||
*/
|
||||
export function listActors(params = {}) {
|
||||
const search = new URLSearchParams()
|
||||
if (params.actor_type) search.set('actor_type', params.actor_type)
|
||||
if (params.include_inactive) search.set('include_inactive', 'true')
|
||||
if (params.q) search.set('q', params.q)
|
||||
const qs = search.toString()
|
||||
return apiFetch(`/api/actors${qs ? `?${qs}` : ''}`)
|
||||
}
|
||||
|
||||
export function getActor(id) {
|
||||
return apiFetch(`/api/actors/${id}`)
|
||||
}
|
||||
|
||||
/** Fallback wenn Actor Directory nicht erreichbar (AP0.6-Kompatibilität). */
|
||||
export function actorsFromContext(context) {
|
||||
if (!context?.actor?.id) return []
|
||||
return [
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
import { apiFetch } from './client.js'
|
||||
|
||||
export function getWorkspaceSummary() {
|
||||
return apiFetch('/api/workspace/summary')
|
||||
}
|
||||
|
||||
export function listWorkspaceOpenActions() {
|
||||
return apiFetch('/api/workspace/actions/open')
|
||||
}
|
||||
|
||||
export function listWorkspaceBlockedActions() {
|
||||
return apiFetch('/api/workspace/actions/blocked')
|
||||
}
|
||||
|
||||
export function listWorkspaceActiveInitiatives(limit = 5) {
|
||||
return apiFetch(`/api/workspace/initiatives/active?limit=${limit}`)
|
||||
}
|
||||
|
||||
export function getActorWorkload() {
|
||||
return apiFetch('/api/workspace/actors/workload')
|
||||
}
|
||||
@@ -5,6 +5,10 @@ import { ActorSelect } from './ActorSelect.jsx'
|
||||
export function ActionForm({
|
||||
initial = {},
|
||||
actors = [],
|
||||
actorsLoading = false,
|
||||
actorsError = null,
|
||||
actorsUsedFallback = false,
|
||||
onReloadActors,
|
||||
onSubmit,
|
||||
onCancel,
|
||||
busy = false,
|
||||
@@ -55,7 +59,14 @@ export function ActionForm({
|
||||
))}
|
||||
</select>
|
||||
</label>
|
||||
<ActorSelect actors={actors} defaultSelected={defaultActors} />
|
||||
<ActorSelect
|
||||
actors={actors}
|
||||
defaultSelected={defaultActors}
|
||||
loading={actorsLoading}
|
||||
error={actorsError}
|
||||
usedFallback={actorsUsedFallback}
|
||||
onRetry={onReloadActors}
|
||||
/>
|
||||
<div className="form-actions">
|
||||
<button type="submit" className="btn btn-primary" disabled={busy}>
|
||||
{busy ? 'Speichern …' : submitLabel}
|
||||
|
||||
@@ -1,4 +1,36 @@
|
||||
export function ActorSelect({ actors = [], defaultSelected = [], label = 'Zugewiesene Actors' }) {
|
||||
const ACTOR_TYPE_LABELS = {
|
||||
human: 'Mensch',
|
||||
agent: 'Agent',
|
||||
working_group: 'Arbeitsgruppe',
|
||||
external_system: 'Externes System',
|
||||
}
|
||||
|
||||
export function ActorSelect({
|
||||
actors = [],
|
||||
defaultSelected = [],
|
||||
label = 'Zugewiesene Actors',
|
||||
loading = false,
|
||||
error = null,
|
||||
usedFallback = false,
|
||||
onRetry,
|
||||
}) {
|
||||
if (loading) {
|
||||
return <p className="muted actor-select-hint">Actors werden geladen …</p>
|
||||
}
|
||||
|
||||
if (error && !actors.length) {
|
||||
return (
|
||||
<div className="actor-select actor-select--error">
|
||||
<p className="error">{error}</p>
|
||||
{onRetry && (
|
||||
<button type="button" className="btn btn-secondary" onClick={onRetry}>
|
||||
Erneut laden
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (!actors.length) {
|
||||
return (
|
||||
<p className="muted actor-select-hint">
|
||||
@@ -18,12 +50,17 @@ export function ActorSelect({ actors = [], defaultSelected = [], label = 'Zugewi
|
||||
defaultChecked={defaultSelected.includes(actor.id)}
|
||||
/>
|
||||
{actor.name}
|
||||
{actor.actor_type && <span className="muted"> ({actor.actor_type})</span>}
|
||||
{actor.actor_type && (
|
||||
<span className="muted">
|
||||
{' '}
|
||||
({ACTOR_TYPE_LABELS[actor.actor_type] || actor.actor_type})
|
||||
</span>
|
||||
)}
|
||||
</label>
|
||||
))}
|
||||
{actors.length === 1 && (
|
||||
{usedFallback && (
|
||||
<p className="muted actor-select-hint">
|
||||
AP0.6: Nur der aktuelle Actor — Tenant-Actor-Liste folgt in AP0.7.
|
||||
Actor Directory nicht erreichbar — Fallback auf aktuellen Actor.
|
||||
</p>
|
||||
)}
|
||||
</fieldset>
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { listActors, actorsFromContext } from '../api/actors.js'
|
||||
import { useSession } from '../context/SessionContext.jsx'
|
||||
|
||||
/**
|
||||
* Lädt Tenant-Actor-Directory; Fallback auf Human Actor aus Context.
|
||||
*/
|
||||
export function useActors() {
|
||||
const { context } = useSession()
|
||||
const [actors, setActors] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState(null)
|
||||
const [usedFallback, setUsedFallback] = useState(false)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
setUsedFallback(false)
|
||||
try {
|
||||
const data = await listActors()
|
||||
setActors(data)
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
const fallback = actorsFromContext(context)
|
||||
setActors(fallback)
|
||||
setUsedFallback(fallback.length > 0)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [context])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
return { actors, loading, error, usedFallback, reload: load }
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
createInitiativeAction,
|
||||
} from '../api/initiatives.js'
|
||||
import { updateAction, setActionAssignments } from '../api/actions.js'
|
||||
import { actorsFromContext } from '../api/actors.js'
|
||||
import { ACTION_STATUS_LABELS } from '../constants/status.js'
|
||||
import { StatusBadge } from '../components/StatusBadge.jsx'
|
||||
import { PriorityBadge } from '../components/PriorityBadge.jsx'
|
||||
@@ -15,13 +14,20 @@ import { EmptyState } from '../components/EmptyState.jsx'
|
||||
import { ErrorState } from '../components/ErrorState.jsx'
|
||||
import { LoadingState } from '../components/LoadingState.jsx'
|
||||
import { useCapabilities } from '../hooks/useCapabilities.js'
|
||||
import { useActors } from '../hooks/useActors.js'
|
||||
import { useSession } from '../context/SessionContext.jsx'
|
||||
|
||||
export function InitiativeDetailPage() {
|
||||
const { id } = useParams()
|
||||
const { context } = useSession()
|
||||
const { hasCapability } = useCapabilities()
|
||||
const actors = actorsFromContext(context)
|
||||
const {
|
||||
actors,
|
||||
loading: actorsLoading,
|
||||
error: actorsError,
|
||||
usedFallback: actorsUsedFallback,
|
||||
reload: reloadActors,
|
||||
} = useActors()
|
||||
|
||||
const [initiative, setInitiative] = useState(null)
|
||||
const [actions, setActions] = useState([])
|
||||
@@ -178,6 +184,10 @@ export function InitiativeDetailPage() {
|
||||
<div className="inline-form-block">
|
||||
<ActionForm
|
||||
actors={actors}
|
||||
actorsLoading={actorsLoading}
|
||||
actorsError={actorsError}
|
||||
actorsUsedFallback={actorsUsedFallback}
|
||||
onReloadActors={reloadActors}
|
||||
onSubmit={handleCreateAction}
|
||||
onCancel={() => setShowActionForm(false)}
|
||||
busy={formBusy}
|
||||
@@ -197,6 +207,10 @@ export function InitiativeDetailPage() {
|
||||
<ActionForm
|
||||
initial={action}
|
||||
actors={actors}
|
||||
actorsLoading={actorsLoading}
|
||||
actorsError={actorsError}
|
||||
actorsUsedFallback={actorsUsedFallback}
|
||||
onReloadActors={reloadActors}
|
||||
onSubmit={(payload) => handleUpdateAction(action.id, payload)}
|
||||
onCancel={() => setEditingAction(null)}
|
||||
busy={formBusy}
|
||||
|
||||
@@ -10,6 +10,7 @@ describe('widgetRegistry', () => {
|
||||
expect(keys).toContain('kairo.active_initiatives')
|
||||
expect(keys).toContain('kairo.blocked_actions')
|
||||
expect(keys).toContain('kairo.tenant_context')
|
||||
expect(keys).toContain('kairo.workspace_summary')
|
||||
})
|
||||
|
||||
it('filters widgets by capability', () => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { MyOpenActionsWidget } from '../widgets/MyOpenActionsWidget.jsx'
|
||||
import { InitiativesWidget } from '../widgets/InitiativesWidget.jsx'
|
||||
import { BlockedActionsWidget } from '../widgets/BlockedActionsWidget.jsx'
|
||||
import { TenantContextWidget } from '../widgets/TenantContextWidget.jsx'
|
||||
import { WorkspaceSummaryWidget } from '../widgets/WorkspaceSummaryWidget.jsx'
|
||||
|
||||
/** @typedef {import('react').ComponentType<any>} WidgetComponent */
|
||||
|
||||
@@ -26,6 +27,15 @@ export const WIDGETS = [
|
||||
defaultOrder: 0,
|
||||
component: TenantContextWidget,
|
||||
},
|
||||
{
|
||||
key: 'kairo.workspace_summary',
|
||||
title: 'Überblick',
|
||||
description: 'Workspace-Kennzahlen aus Data Layer',
|
||||
area: 'workspace',
|
||||
requiredCapability: 'kairo.workspace.read',
|
||||
defaultOrder: 5,
|
||||
component: WorkspaceSummaryWidget,
|
||||
},
|
||||
{
|
||||
key: 'kairo.my_open_actions',
|
||||
title: 'Meine offenen Maßnahmen',
|
||||
|
||||
@@ -24,3 +24,36 @@
|
||||
.mt-sm {
|
||||
margin-top: 0.75rem;
|
||||
}
|
||||
|
||||
.summary-metrics {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(2, 1fr);
|
||||
gap: 0.75rem 1rem;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
@media (min-width: 769px) {
|
||||
.summary-metrics {
|
||||
grid-template-columns: repeat(4, 1fr);
|
||||
}
|
||||
}
|
||||
|
||||
.summary-metric {
|
||||
padding: 0.75rem;
|
||||
background: var(--jk-surface-raised);
|
||||
border-radius: 8px;
|
||||
border: 1px solid var(--jk-border);
|
||||
}
|
||||
|
||||
.summary-metric dt {
|
||||
margin: 0;
|
||||
font-size: 0.8125rem;
|
||||
color: var(--jk-text-muted);
|
||||
}
|
||||
|
||||
.summary-metric dd {
|
||||
margin: 0.25rem 0 0;
|
||||
font-size: 1.375rem;
|
||||
font-weight: 600;
|
||||
color: var(--jk-text);
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { listMyOpenActions } from '../api/actions.js'
|
||||
import { listWorkspaceBlockedActions } from '../api/workspace.js'
|
||||
import { ActionList } from '../components/ActionList.jsx'
|
||||
import { EmptyState } from '../components/EmptyState.jsx'
|
||||
import { ErrorState } from '../components/ErrorState.jsx'
|
||||
@@ -16,8 +16,8 @@ export function BlockedActionsWidget() {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const data = await listMyOpenActions()
|
||||
setActions(data.filter((a) => a.status === 'blocked'))
|
||||
const data = await listWorkspaceBlockedActions()
|
||||
setActions(data)
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { listInitiatives } from '../api/initiatives.js'
|
||||
import { listWorkspaceActiveInitiatives } from '../api/workspace.js'
|
||||
import { StatusBadge } from '../components/StatusBadge.jsx'
|
||||
import { PriorityBadge } from '../components/PriorityBadge.jsx'
|
||||
import { EmptyState } from '../components/EmptyState.jsx'
|
||||
@@ -17,10 +17,8 @@ export function InitiativesWidget() {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const data = await listInitiatives()
|
||||
setInitiatives(
|
||||
data.filter((i) => i.status === 'active' || i.status === 'paused').slice(0, 5),
|
||||
)
|
||||
const data = await listWorkspaceActiveInitiatives(5)
|
||||
setInitiatives(data)
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { listMyOpenActions } from '../api/actions.js'
|
||||
import { listWorkspaceOpenActions } from '../api/workspace.js'
|
||||
import { ActionList } from '../components/ActionList.jsx'
|
||||
import { EmptyState } from '../components/EmptyState.jsx'
|
||||
import { ErrorState } from '../components/ErrorState.jsx'
|
||||
@@ -16,8 +16,8 @@ export function MyOpenActionsWidget() {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const data = await listMyOpenActions()
|
||||
setActions(data.filter((a) => a.status !== 'blocked'))
|
||||
const data = await listWorkspaceOpenActions()
|
||||
setActions(data)
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { getWorkspaceSummary } from '../api/workspace.js'
|
||||
import { ErrorState } from '../components/ErrorState.jsx'
|
||||
import { LoadingState } from '../components/LoadingState.jsx'
|
||||
import { WidgetCard } from '../components/WidgetCard.jsx'
|
||||
|
||||
export function WorkspaceSummaryWidget() {
|
||||
const [summary, setSummary] = useState(null)
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState(null)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const data = await getWorkspaceSummary()
|
||||
setSummary(data)
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
return (
|
||||
<WidgetCard
|
||||
title="Überblick"
|
||||
subtitle="Kennzahlen für deinen Workspace"
|
||||
actions={
|
||||
<button type="button" className="btn btn-ghost" onClick={load} disabled={loading}>
|
||||
Aktualisieren
|
||||
</button>
|
||||
}
|
||||
>
|
||||
{loading && <LoadingState />}
|
||||
{!loading && error && <ErrorState message={error} onRetry={load} />}
|
||||
{!loading && !error && summary && (
|
||||
<dl className="summary-metrics">
|
||||
<div className="summary-metric">
|
||||
<dt>Offene Maßnahmen</dt>
|
||||
<dd>{summary.open_actions_count}</dd>
|
||||
</div>
|
||||
<div className="summary-metric">
|
||||
<dt>Blockiert</dt>
|
||||
<dd>{summary.blocked_actions_count}</dd>
|
||||
</div>
|
||||
<div className="summary-metric">
|
||||
<dt>Aktive Vorhaben</dt>
|
||||
<dd>{summary.active_initiatives_count}</dd>
|
||||
</div>
|
||||
<div className="summary-metric">
|
||||
<dt>Erledigt (7 Tage)</dt>
|
||||
<dd>{summary.done_actions_recent_count}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
)}
|
||||
</WidgetCard>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user