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,151 @@
|
||||
import { useState, useEffect } from 'react'
|
||||
import { fetchSetupStatus, login, register } from '../api/me.js'
|
||||
import { useSession } from '../context/SessionContext.jsx'
|
||||
|
||||
export function AuthPanel() {
|
||||
const { applyLogin } = useSession()
|
||||
const [setup, setSetup] = useState(null)
|
||||
const [setupLoading, setSetupLoading] = useState(true)
|
||||
const [setupError, setSetupError] = useState(null)
|
||||
const [authMode, setAuthMode] = useState('login')
|
||||
const [email, setEmail] = useState('')
|
||||
const [password, setPassword] = useState('')
|
||||
const [displayName, setDisplayName] = useState('')
|
||||
const [organizationName, setOrganizationName] = useState('')
|
||||
const [passwordConfirm, setPasswordConfirm] = useState('')
|
||||
const [authError, setAuthError] = useState(null)
|
||||
const [authBusy, setAuthBusy] = useState(false)
|
||||
|
||||
useEffect(() => {
|
||||
fetchSetupStatus()
|
||||
.then((body) => {
|
||||
setSetup(body)
|
||||
if (body.registration_open) setAuthMode('register')
|
||||
})
|
||||
.catch((err) => setSetupError(err.message))
|
||||
.finally(() => setSetupLoading(false))
|
||||
}, [])
|
||||
|
||||
async function handleLogin(e) {
|
||||
e.preventDefault()
|
||||
setAuthBusy(true)
|
||||
setAuthError(null)
|
||||
try {
|
||||
const body = await login(email, password)
|
||||
applyLogin(body)
|
||||
} catch (err) {
|
||||
setAuthError(err.message)
|
||||
} finally {
|
||||
setAuthBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRegister(e) {
|
||||
e.preventDefault()
|
||||
if (password !== passwordConfirm) {
|
||||
setAuthError('Passwörter stimmen nicht überein')
|
||||
return
|
||||
}
|
||||
setAuthBusy(true)
|
||||
setAuthError(null)
|
||||
try {
|
||||
const body = await register({
|
||||
email,
|
||||
password,
|
||||
display_name: displayName,
|
||||
organization_name: organizationName || undefined,
|
||||
})
|
||||
applyLogin(body)
|
||||
} catch (err) {
|
||||
setAuthError(err.message)
|
||||
} finally {
|
||||
setAuthBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
const registrationOpen = setup?.registration_open === true
|
||||
|
||||
return (
|
||||
<main className="shell auth-shell">
|
||||
<header className="hero">
|
||||
<h1>Jinkendo Kairo</h1>
|
||||
<p>Operativer Program Director — AP0.6 Workspace</p>
|
||||
</header>
|
||||
|
||||
<section className="card auth-card">
|
||||
<h2>{registrationOpen ? 'Ersteinrichtung' : 'Anmelden'}</h2>
|
||||
|
||||
{setupLoading && <p className="muted">Prüfe Ersteinrichtung …</p>}
|
||||
{setupError && <p className="error">{setupError}</p>}
|
||||
|
||||
{!setupLoading && !setupError && (
|
||||
<>
|
||||
<div className="tabs" role="tablist">
|
||||
<button
|
||||
type="button"
|
||||
className={authMode === 'login' ? 'tab active' : 'tab'}
|
||||
onClick={() => { setAuthMode('login'); setAuthError(null) }}
|
||||
>
|
||||
Anmelden
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className={authMode === 'register' ? 'tab active' : 'tab'}
|
||||
disabled={!registrationOpen}
|
||||
onClick={() => { setAuthMode('register'); setAuthError(null) }}
|
||||
>
|
||||
Registrieren
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{authMode === 'login' && (
|
||||
<form className="form" onSubmit={handleLogin}>
|
||||
<label>
|
||||
E-Mail
|
||||
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} required />
|
||||
</label>
|
||||
<label>
|
||||
Passwort
|
||||
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} minLength={8} required />
|
||||
</label>
|
||||
<button type="submit" disabled={authBusy}>
|
||||
{authBusy ? 'Anmelden …' : 'Anmelden'}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
|
||||
{authMode === 'register' && registrationOpen && (
|
||||
<form className="form" onSubmit={handleRegister}>
|
||||
<label>
|
||||
Anzeigename
|
||||
<input value={displayName} onChange={(e) => setDisplayName(e.target.value)} required />
|
||||
</label>
|
||||
<label>
|
||||
Organisation (optional)
|
||||
<input value={organizationName} onChange={(e) => setOrganizationName(e.target.value)} />
|
||||
</label>
|
||||
<label>
|
||||
E-Mail
|
||||
<input type="email" value={email} onChange={(e) => setEmail(e.target.value)} required />
|
||||
</label>
|
||||
<label>
|
||||
Passwort
|
||||
<input type="password" value={password} onChange={(e) => setPassword(e.target.value)} minLength={8} required />
|
||||
</label>
|
||||
<label>
|
||||
Passwort bestätigen
|
||||
<input type="password" value={passwordConfirm} onChange={(e) => setPasswordConfirm(e.target.value)} minLength={8} required />
|
||||
</label>
|
||||
<button type="submit" disabled={authBusy}>
|
||||
{authBusy ? 'Registrieren …' : 'Systemadmin anlegen'}
|
||||
</button>
|
||||
</form>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{authError && <p className="error">{authError}</p>}
|
||||
</section>
|
||||
</main>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,233 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Link, useParams } from 'react-router-dom'
|
||||
import {
|
||||
getInitiative,
|
||||
listInitiativeActions,
|
||||
createInitiativeAction,
|
||||
} from '../api/initiatives.js'
|
||||
import { updateAction, setActionAssignments } from '../api/actions.js'
|
||||
import { ACTION_STATUS_LABELS } from '../constants/status.js'
|
||||
import { StatusBadge } from '../components/StatusBadge.jsx'
|
||||
import { PriorityBadge } from '../components/PriorityBadge.jsx'
|
||||
import { ActionForm } from '../components/ActionForm.jsx'
|
||||
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 { useSession } from '../context/SessionContext.jsx'
|
||||
|
||||
export function InitiativeDetailPage() {
|
||||
const { id } = useParams()
|
||||
const { context } = useSession()
|
||||
const { hasCapability } = useCapabilities()
|
||||
const actors = actorsFromContext(context)
|
||||
|
||||
const [initiative, setInitiative] = useState(null)
|
||||
const [actions, setActions] = useState([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState(null)
|
||||
const [showActionForm, setShowActionForm] = useState(false)
|
||||
const [editingAction, setEditingAction] = useState(null)
|
||||
const [formBusy, setFormBusy] = useState(false)
|
||||
const [hideDone, setHideDone] = useState(true)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const [initData, actionData] = await Promise.all([
|
||||
getInitiative(id),
|
||||
listInitiativeActions(id),
|
||||
])
|
||||
setInitiative(initData)
|
||||
setActions(actionData)
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [id])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
const visibleActions = hideDone
|
||||
? actions.filter((a) => a.status !== 'done' && a.status !== 'discarded')
|
||||
: actions
|
||||
|
||||
async function handleCreateAction(payload) {
|
||||
setFormBusy(true)
|
||||
try {
|
||||
const assigned =
|
||||
payload.assigned_actor_ids?.length > 0
|
||||
? payload.assigned_actor_ids
|
||||
: context?.actor?.id
|
||||
? [context.actor.id]
|
||||
: []
|
||||
await createInitiativeAction(id, { ...payload, assigned_actor_ids: assigned })
|
||||
setShowActionForm(false)
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setFormBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleUpdateAction(actionId, payload) {
|
||||
setFormBusy(true)
|
||||
try {
|
||||
await updateAction(actionId, {
|
||||
title: payload.title,
|
||||
description: payload.description,
|
||||
status: payload.status,
|
||||
priority: payload.priority,
|
||||
})
|
||||
if (hasCapability('kairo.action.manage')) {
|
||||
await setActionAssignments(actionId, payload.assigned_actor_ids || [])
|
||||
}
|
||||
setEditingAction(null)
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setFormBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
async function handleQuickStatus(action, status) {
|
||||
if (!hasCapability('kairo.action.manage')) return
|
||||
try {
|
||||
await updateAction(action.id, { status })
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
}
|
||||
}
|
||||
|
||||
if (loading) return <LoadingState message="Lade Vorhaben …" />
|
||||
if (error && !initiative) return <ErrorState message={error} onRetry={load} />
|
||||
if (!initiative) return <ErrorState message="Vorhaben nicht gefunden." />
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<nav className="breadcrumb">
|
||||
<Link to="/initiatives">Vorhaben</Link>
|
||||
<span aria-hidden="true"> / </span>
|
||||
<span>{initiative.title}</span>
|
||||
</nav>
|
||||
|
||||
<header className="page-header detail-header">
|
||||
<div>
|
||||
<h1>{initiative.title}</h1>
|
||||
{initiative.goal && <p className="detail-goal">{initiative.goal}</p>}
|
||||
<div className="detail-badges">
|
||||
<StatusBadge kind="initiative" status={initiative.status} />
|
||||
<PriorityBadge priority={initiative.priority} />
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
{error && <p className="error">{error}</p>}
|
||||
|
||||
<section className="card">
|
||||
<div className="section-header">
|
||||
<h2>Maßnahmen</h2>
|
||||
<div className="section-actions">
|
||||
<label className="checkbox-label inline-filter">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={hideDone}
|
||||
onChange={(e) => setHideDone(e.target.checked)}
|
||||
/>
|
||||
Erledigte ausblenden
|
||||
</label>
|
||||
{hasCapability('kairo.action.manage') && (
|
||||
<button type="button" onClick={() => { setShowActionForm((v) => !v); setEditingAction(null) }}>
|
||||
{showActionForm ? 'Abbrechen' : 'Maßnahme anlegen'}
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{showActionForm && (
|
||||
<div className="inline-form-block">
|
||||
<ActionForm
|
||||
actors={actors}
|
||||
onSubmit={handleCreateAction}
|
||||
onCancel={() => setShowActionForm(false)}
|
||||
busy={formBusy}
|
||||
submitLabel="Maßnahme anlegen"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{visibleActions.length === 0 && (
|
||||
<EmptyState message="Noch keine Maßnahmen in diesem Vorhaben." />
|
||||
)}
|
||||
|
||||
<ul className="item-list actions-detail-list">
|
||||
{visibleActions.map((action) => (
|
||||
<li key={action.id} className="list-item card-list-item">
|
||||
{editingAction === action.id ? (
|
||||
<ActionForm
|
||||
initial={action}
|
||||
actors={actors}
|
||||
onSubmit={(payload) => handleUpdateAction(action.id, payload)}
|
||||
onCancel={() => setEditingAction(null)}
|
||||
busy={formBusy}
|
||||
submitLabel="Speichern"
|
||||
/>
|
||||
) : (
|
||||
<>
|
||||
<div className="list-item-main">
|
||||
<strong>{action.title}</strong>
|
||||
{action.description && (
|
||||
<p className="list-item-desc">{action.description}</p>
|
||||
)}
|
||||
{action.assigned_actor_ids?.length > 0 && (
|
||||
<p className="muted list-item-sub">
|
||||
Zugewiesen: {action.assigned_actor_ids.length} Actor(s)
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
<div className="list-item-meta action-controls">
|
||||
<StatusBadge status={action.status} />
|
||||
<PriorityBadge priority={action.priority} />
|
||||
{hasCapability('kairo.action.manage') && (
|
||||
<>
|
||||
<select
|
||||
className="inline-select"
|
||||
value={action.status}
|
||||
onChange={(e) => handleQuickStatus(action, e.target.value)}
|
||||
aria-label="Status ändern"
|
||||
>
|
||||
{['open', 'in_progress', 'blocked', 'done', 'discarded'].map((s) => (
|
||||
<option key={s} value={s}>
|
||||
{ACTION_STATUS_LABELS[s]}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
<button
|
||||
type="button"
|
||||
className="secondary"
|
||||
onClick={() => {
|
||||
setEditingAction(action.id)
|
||||
setShowActionForm(false)
|
||||
}}
|
||||
>
|
||||
Bearbeiten
|
||||
</button>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</section>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
import { useCallback, useEffect, useState } from 'react'
|
||||
import { Link } from 'react-router-dom'
|
||||
import { listInitiatives, listInitiativeActions } from '../api/initiatives.js'
|
||||
import { countOpenActions } from '../api/actions.js'
|
||||
import { StatusBadge } from '../components/StatusBadge.jsx'
|
||||
import { PriorityBadge } from '../components/PriorityBadge.jsx'
|
||||
import { InitiativeForm } from '../components/InitiativeForm.jsx'
|
||||
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 { useSession } from '../context/SessionContext.jsx'
|
||||
import { createInitiative } from '../api/initiatives.js'
|
||||
|
||||
export function InitiativesPage() {
|
||||
const { context } = useSession()
|
||||
const { hasCapability } = useCapabilities()
|
||||
const [initiatives, setInitiatives] = useState([])
|
||||
const [openCounts, setOpenCounts] = useState({})
|
||||
const [loading, setLoading] = useState(true)
|
||||
const [error, setError] = useState(null)
|
||||
const [showForm, setShowForm] = useState(false)
|
||||
const [formBusy, setFormBusy] = useState(false)
|
||||
|
||||
const load = useCallback(async () => {
|
||||
setLoading(true)
|
||||
setError(null)
|
||||
try {
|
||||
const data = await listInitiatives()
|
||||
const active = data.filter((i) => i.status === 'active' || i.status === 'paused')
|
||||
setInitiatives(active)
|
||||
|
||||
const counts = {}
|
||||
await Promise.all(
|
||||
active.map(async (initiative) => {
|
||||
try {
|
||||
const actions = await listInitiativeActions(initiative.id)
|
||||
counts[initiative.id] = countOpenActions(actions)
|
||||
} catch {
|
||||
counts[initiative.id] = null
|
||||
}
|
||||
}),
|
||||
)
|
||||
setOpenCounts(counts)
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setLoading(false)
|
||||
}
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
load()
|
||||
}, [load])
|
||||
|
||||
async function handleCreate(payload) {
|
||||
setFormBusy(true)
|
||||
try {
|
||||
await createInitiative({ ...payload, owner_actor_id: context?.actor?.id })
|
||||
setShowForm(false)
|
||||
await load()
|
||||
} catch (err) {
|
||||
setError(err.message)
|
||||
} finally {
|
||||
setFormBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page">
|
||||
<header className="page-header">
|
||||
<div>
|
||||
<h1>Vorhaben</h1>
|
||||
<p className="muted">Aktive und pausierte Vorhaben im Tenant.</p>
|
||||
</div>
|
||||
{hasCapability('kairo.initiative.manage') && (
|
||||
<button type="button" onClick={() => setShowForm((v) => !v)}>
|
||||
{showForm ? 'Abbrechen' : 'Vorhaben anlegen'}
|
||||
</button>
|
||||
)}
|
||||
</header>
|
||||
|
||||
{showForm && (
|
||||
<section className="card inline-form-card">
|
||||
<h2>Neues Vorhaben</h2>
|
||||
<InitiativeForm
|
||||
onSubmit={handleCreate}
|
||||
onCancel={() => setShowForm(false)}
|
||||
busy={formBusy}
|
||||
submitLabel="Vorhaben anlegen"
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
|
||||
{loading && <LoadingState message="Lade Vorhaben …" />}
|
||||
{!loading && error && <ErrorState message={error} onRetry={load} />}
|
||||
{!loading && !error && initiatives.length === 0 && (
|
||||
<EmptyState message="Noch keine Vorhaben. Lege dein erstes Vorhaben an." />
|
||||
)}
|
||||
{!loading && !error && initiatives.length > 0 && (
|
||||
<ul className="item-list initiatives-list">
|
||||
{initiatives.map((item) => (
|
||||
<li key={item.id} className="list-item card-list-item">
|
||||
<div className="list-item-main">
|
||||
<Link to={`/initiatives/${item.id}`}>
|
||||
<strong>{item.title}</strong>
|
||||
</Link>
|
||||
{item.goal && <p className="list-item-desc">{item.goal}</p>}
|
||||
</div>
|
||||
<div className="list-item-meta">
|
||||
<StatusBadge kind="initiative" status={item.status} />
|
||||
<PriorityBadge priority={item.priority} />
|
||||
{openCounts[item.id] != null && (
|
||||
<span className="muted">{openCounts[item.id]} offen</span>
|
||||
)}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
import { Link } from 'react-router-dom'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { useCapabilities } from '../hooks/useCapabilities.js'
|
||||
import { getWidgetsForArea } from '../registry/widgetRegistry.js'
|
||||
import { useSession } from '../context/SessionContext.jsx'
|
||||
import { InitiativeForm } from '../components/InitiativeForm.jsx'
|
||||
import { createInitiative } from '../api/initiatives.js'
|
||||
import { useState } from 'react'
|
||||
|
||||
export function WorkspacePage() {
|
||||
const navigate = useNavigate()
|
||||
const { context } = useSession()
|
||||
const { capabilities, hasCapability } = useCapabilities()
|
||||
const widgets = getWidgetsForArea('workspace', capabilities)
|
||||
const [showForm, setShowForm] = useState(false)
|
||||
const [formBusy, setFormBusy] = useState(false)
|
||||
const [formError, setFormError] = useState(null)
|
||||
|
||||
async function handleCreateInitiative(payload) {
|
||||
setFormBusy(true)
|
||||
setFormError(null)
|
||||
try {
|
||||
await createInitiative({
|
||||
...payload,
|
||||
owner_actor_id: context?.actor?.id,
|
||||
})
|
||||
setShowForm(false)
|
||||
navigate('/initiatives')
|
||||
} catch (err) {
|
||||
setFormError(err.message)
|
||||
} finally {
|
||||
setFormBusy(false)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="page workspace-page">
|
||||
<header className="page-header">
|
||||
<div>
|
||||
<h1>Workspace</h1>
|
||||
<p className="muted">Dein Überblick über Vorhaben und Maßnahmen.</p>
|
||||
</div>
|
||||
{hasCapability('kairo.initiative.manage') && (
|
||||
<button type="button" onClick={() => setShowForm((v) => !v)}>
|
||||
{showForm ? 'Abbrechen' : 'Vorhaben anlegen'}
|
||||
</button>
|
||||
)}
|
||||
</header>
|
||||
|
||||
{showForm && (
|
||||
<section className="card inline-form-card">
|
||||
<h2>Neues Vorhaben</h2>
|
||||
{formError && <p className="error">{formError}</p>}
|
||||
<InitiativeForm
|
||||
onSubmit={handleCreateInitiative}
|
||||
onCancel={() => setShowForm(false)}
|
||||
busy={formBusy}
|
||||
submitLabel="Vorhaben anlegen"
|
||||
/>
|
||||
</section>
|
||||
)}
|
||||
|
||||
<div className="widget-grid">
|
||||
{widgets.map((widget) => {
|
||||
const Component = widget.component
|
||||
return <Component key={widget.key} />
|
||||
})}
|
||||
</div>
|
||||
|
||||
{hasCapability('kairo.initiative.read') && (
|
||||
<p className="page-footer-link">
|
||||
<Link to="/initiatives">Zur Vorhabenliste →</Link>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in new issue
Block a user