AP1.13a: Read-only Gate-Graph aus Abhaengigkeiten.
Test Suite / lint-backend (push) Waiting to run
Test Suite / compose-smoke (push) Waiting to run
Test Suite / k6 /api/health Baseline (push) Blocked by required conditions
Test Suite / playwright-smoke (push) Blocked by required conditions
Deploy Development / deploy (push) Successful in 46s
Test Suite / pytest-backend (push) Has been cancelled

Initiative-API fuer Roadmap-Dependencies, SVG-Layout mit Liste/Graph-Umschalter auf der Zielzustaende-Seite.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-10 15:50:20 +02:00
1 parent 83fdb9a2a2
commit 7f03504c2d
10 files changed
+712 -2

No files matched your search

+186
View File
@@ -0,0 +1,186 @@
import { useEffect, useMemo, useState } from 'react'
import { useNavigate } from 'react-router-dom'
import { listInitiativeRoadmapDependencies } from '../api/roadmap.js'
import { ROADMAP_ITEM_TYPE_LABELS } from '../constants/status.js'
import { gatePath } from '../utils/routes.js'
import { computeGateGraphLayout } from '../plan/gateGraphLayout.js'
import { LoadingState } from './LoadingState.jsx'
import { ErrorState } from './ErrorState.jsx'
import { EmptyState } from './EmptyState.jsx'
function edgePath(edge) {
const midY = (edge.y1 + edge.y2) / 2
return `M ${edge.x1} ${edge.y1} C ${edge.x1} ${midY}, ${edge.x2} ${midY}, ${edge.x2} ${edge.y2}`
}
function truncateTitle(title, max = 28) {
if (!title || title.length <= max) return title || 'Gate'
return `${title.slice(0, max - 1)}…`
}
export function GateMapView({ initiativeId, items }) {
const navigate = useNavigate()
const [dependencies, setDependencies] = useState([])
const [loading, setLoading] = useState(true)
const [error, setError] = useState(null)
useEffect(() => {
if (!initiativeId) {
setDependencies([])
setLoading(false)
return undefined
}
let cancelled = false
setLoading(true)
setError(null)
listInitiativeRoadmapDependencies(initiativeId)
.then((data) => {
if (!cancelled) setDependencies(Array.isArray(data) ? data : [])
})
.catch((err) => {
if (!cancelled) setError(err.message || 'Abhängigkeiten konnten nicht geladen werden.')
})
.finally(() => {
if (!cancelled) setLoading(false)
})
return () => {
cancelled = true
}
}, [initiativeId])
const layout = useMemo(
() => computeGateGraphLayout(items, dependencies),
[items, dependencies],
)
if (!items.length) {
return (
<EmptyState message="Noch kein Plan — strukturiere das Vorhaben in überprüfbare Roadmap-Elemente." />
)
}
if (loading) {
return <LoadingState message="Gate-Graph wird geladen …" />
}
if (error) {
return <ErrorState message={error} />
}
return (
<section className="card gate-map-view">
<div className="section-header">
<div>
<h2>Zielzustände (Graph)</h2>
<p className="section-lead muted">
Read-only Übersicht der Gate-Abhängigkeiten — Bearbeitung auf der Gate-Detailseite
(AP1.13b).
</p>
</div>
</div>
<div className="gate-map-view__legend muted">
<span className="gate-map-view__legend-item">
<span className="gate-map-view__legend-line gate-map-view__legend-line--requires" />
Voraussetzung
</span>
<span className="gate-map-view__legend-item">
<span className="gate-map-view__legend-line gate-map-view__legend-line--blocks" />
Blockiert
</span>
<span className="gate-map-view__legend-item">
<span className="gate-map-view__legend-line gate-map-view__legend-line--related" />
Bezug
</span>
</div>
<div className="gate-map-view__canvas-wrap">
<svg
className="gate-map-view__canvas"
width={layout.width}
height={layout.height}
role="img"
aria-label="Gate-Abhängigkeitsgraph"
>
<defs>
<marker
id="gate-map-arrow-requires"
markerWidth="8"
markerHeight="8"
refX="6"
refY="4"
orient="auto"
>
<path d="M0,0 L8,4 L0,8 Z" className="gate-map-view__arrow gate-map-view__arrow--requires" />
</marker>
<marker
id="gate-map-arrow-blocks"
markerWidth="8"
markerHeight="8"
refX="6"
refY="4"
orient="auto"
>
<path d="M0,0 L8,4 L0,8 Z" className="gate-map-view__arrow gate-map-view__arrow--blocks" />
</marker>
</defs>
{layout.edges.map((edge) => (
<path
key={edge.id}
d={edgePath(edge)}
className={`gate-map-view__edge gate-map-view__edge--${edge.dependency_type}`}
markerEnd={
edge.dependency_type === 'related'
? undefined
: `url(#gate-map-arrow-${edge.dependency_type})`
}
/>
))}
{layout.nodes.map((node) => {
const item = node.item
return (
<g
key={node.id}
className={`gate-map-view__node gate-map-view__node--${item.status || 'planned'}`}
transform={`translate(${node.x}, ${node.y})`}
role="link"
tabIndex={0}
aria-label={`${item.title} öffnen`}
onClick={() => navigate(gatePath(node.id))}
onKeyDown={(event) => {
if (event.key === 'Enter' || event.key === ' ') {
event.preventDefault()
navigate(gatePath(node.id))
}
}}
>
<rect
className="gate-map-view__node-box"
width={node.width}
height={node.height}
rx="8"
ry="8"
/>
<text className="gate-map-view__node-title" x="12" y="28">
{truncateTitle(item.title)}
</text>
<text className="gate-map-view__node-meta" x="12" y="50">
{ROADMAP_ITEM_TYPE_LABELS[item.item_type] || item.item_type || 'Gate'}
</text>
</g>
)
})}
</svg>
</div>
{dependencies.length === 0 && (
<p className="muted gate-map-view__hint">
Noch keine Kanten — Gates sind nach Reihenfolge angeordnet. Abhängigkeiten können auf den
Gate-Detailseiten gepflegt werden (AP1.13b).
</p>
)}
</section>
)
}
@@ -0,0 +1,68 @@
import { useEffect, useState } from 'react'
import { RoadmapPlanSection } from './RoadmapPlanSection.jsx'
import { GateMapView } from './GateMapView.jsx'
import { resolveGatesViewMode, storeGatesViewMode } from '../plan/gateGraphLayout.js'
export function GatesPlanPanel({
initiativeId,
items,
canManage,
onCreate,
onReorder,
onDelete,
busy,
}) {
const [viewMode, setViewMode] = useState(() => resolveGatesViewMode(initiativeId, items.length))
useEffect(() => {
setViewMode(resolveGatesViewMode(initiativeId, items.length))
}, [initiativeId, items.length])
function handleViewChange(mode) {
setViewMode(mode)
storeGatesViewMode(initiativeId, mode)
}
return (
<div className="gates-plan-panel">
<div className="gates-plan-panel__toolbar" role="tablist" aria-label="Zielzustände Ansicht">
<button
type="button"
role="tab"
aria-selected={viewMode === 'list'}
className={
'gates-plan-panel__tab' + (viewMode === 'list' ? ' gates-plan-panel__tab--active' : '')
}
onClick={() => handleViewChange('list')}
>
Liste
</button>
<button
type="button"
role="tab"
aria-selected={viewMode === 'graph'}
className={
'gates-plan-panel__tab' + (viewMode === 'graph' ? ' gates-plan-panel__tab--active' : '')
}
onClick={() => handleViewChange('graph')}
>
Graph
</button>
</div>
{viewMode === 'list' ? (
<RoadmapPlanSection
initiativeId={initiativeId}
items={items}
canManage={canManage}
onCreate={onCreate}
onReorder={onReorder}
onDelete={onDelete}
busy={busy}
/>
) : (
<GateMapView initiativeId={initiativeId} items={items} />
)}
</div>
)
}