feat(backlog): Epic-Hierarchie mit parent_backlog_id (ADP P2)
Deploy Development / deploy (push) Successful in 48s
Test Suite / pytest-backend (push) Successful in 3m54s
Test Suite / lint-backend (push) Successful in 3s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 19s
Test Suite / playwright-smoke (push) Successful in 15s

Epics als Backlog-Container mit Baum-UI, Convert-Guard und pytest-Abdeckung — Roll-up bleibt für P4 offen.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
LarsandCursor committed 2026-07-27 09:22:20 +02:00
1 parent dc6f25b673
commit f33135b87f
12 files changed
+473 -27

No files matched your search

+27 -6
View File
@@ -1,45 +1,59 @@
import { useMemo } from 'react'
import {
BACKLOG_STATUSES,
BACKLOG_STATUS_LABELS,
BACKLOG_ITEM_KINDS,
BACKLOG_ITEM_KINDS_WITH_EPIC,
BACKLOG_ITEM_KIND_LABELS,
PRIORITIES,
PRIORITY_LABELS,
} from '../constants/status.js'
import { GateSelect } from './GateSelect.jsx'
import { FeatureParentSelect } from './FeatureParentSelect.jsx'
import { EpicParentSelect } from './EpicParentSelect.jsx'
export function BacklogItemForm({
initial = {},
roadmapItems = [],
featureActions = [],
epicItems = [],
epicHierarchyEnabled = false,
onSubmit,
onCancel,
busy = false,
submitLabel = 'Speichern',
allowStatus = true,
}) {
const itemKinds = epicHierarchyEnabled ? BACKLOG_ITEM_KINDS_WITH_EPIC : BACKLOG_ITEM_KINDS
const initialKind = initial.item_kind || 'story'
const isEpic = initialKind === 'epic'
async function handleSubmit(e) {
e.preventDefault()
const form = e.target
const gateValue = form.roadmap_item_id?.value ?? ''
const parentValue = form.parent_action_id?.value ?? ''
const epicValue = form.parent_backlog_id?.value ?? ''
const itemKind = form.item_kind?.value || 'story'
await onSubmit({
title: form.title.value.trim(),
description: form.description.value,
status: form.status?.value,
priority: form.priority.value,
item_kind: form.item_kind?.value || 'story',
item_kind: itemKind,
roadmap_item_id: gateValue || undefined,
clear_roadmap_item: gateValue === '',
parent_action_id: parentValue || undefined,
clear_parent_action: parentValue === '',
parent_action_id: itemKind === 'epic' ? undefined : parentValue || undefined,
clear_parent_action: itemKind === 'epic' ? true : parentValue === '',
parent_backlog_id: itemKind === 'epic' ? undefined : epicValue || undefined,
clear_parent_backlog: itemKind === 'epic' ? true : epicValue === '',
})
}
const statusLocked = initial.status === 'converted'
const showFeatureRef =
(initial.item_kind || 'story') !== 'story' || featureActions.length > 0
!isEpic &&
((initial.item_kind || 'story') !== 'story' || featureActions.length > 0)
return (
<form className="form workspace-form backlog-item-form" onSubmit={handleSubmit}>
@@ -67,10 +81,10 @@ export function BacklogItemForm({
Typ
<select
name="item_kind"
defaultValue={initial.item_kind || 'story'}
defaultValue={initialKind}
disabled={statusLocked}
>
{BACKLOG_ITEM_KINDS.map((kind) => (
{itemKinds.map((kind) => (
<option key={kind} value={kind}>
{BACKLOG_ITEM_KIND_LABELS[kind]}
</option>
@@ -113,6 +127,13 @@ export function BacklogItemForm({
disabled={statusLocked}
/>
)}
{epicHierarchyEnabled && !isEpic && (
<EpicParentSelect
epicItems={epicItems}
defaultValue={initial.parent_backlog_id || ''}
disabled={statusLocked}
/>
)}
{showFeatureRef && (
<FeatureParentSelect
featureActions={featureActions}
+37 -6
View File
@@ -7,6 +7,7 @@ import { BacklogItemForm } from './BacklogItemForm.jsx'
import { ReorderControls } from './ReorderControls.jsx'
import { gateTitleById } from './GateSelect.jsx'
import { computeDropPatches, computeMovePatches, sortByOrder } from '../utils/reorder.js'
import { buildBacklogDisplayRows, listEpicBacklogItems } from '../utils/backlogTree.js'
import { useMinWidth } from '../hooks/useMinWidth.js'
import { BACKLOG_ITEM_KIND_LABELS } from '../constants/status.js'
import { actionTitleById } from '../utils/actionReferences.js'
@@ -82,6 +83,18 @@ export function BacklogSection({
[items],
)
const epicItems = useMemo(() => listEpicBacklogItems(items), [items])
const displayRows = useMemo(() => buildBacklogDisplayRows(items), [items])
const epicTitleById = useMemo(() => {
const map = new Map()
for (const epic of epicItems) {
map.set(epic.id, epic.title)
}
return map
}, [epicItems])
const epicHierarchyEnabled = sprintPlanningEnabled
function closeModal() {
setModalMode(null)
}
@@ -94,6 +107,7 @@ export function BacklogSection({
roadmap_item_id: payload.roadmap_item_id,
item_kind: payload.item_kind,
parent_action_id: payload.parent_action_id,
parent_backlog_id: payload.parent_backlog_id,
status: payload.status || 'new',
})
closeModal()
@@ -111,6 +125,8 @@ export function BacklogSection({
item_kind: payload.item_kind,
parent_action_id: payload.parent_action_id,
clear_parent_action: payload.clear_parent_action,
parent_backlog_id: payload.parent_backlog_id,
clear_parent_backlog: payload.clear_parent_backlog,
})
if (ok !== false) closeModal()
}
@@ -158,7 +174,9 @@ export function BacklogSection({
const modalTitle =
modalMode?.kind === 'create' ? 'Backlog-Item anlegen' : 'Backlog-Item bearbeiten'
const committableItems = sortedItems.filter((item) => COMMITTABLE_STATUSES.has(item.status))
const committableItems = sortedItems.filter(
(item) => COMMITTABLE_STATUSES.has(item.status) && item.item_kind !== 'epic',
)
const selectedCommittable = committableItems.filter((item) => selectedIds.has(item.id))
function toggleSelected(itemId) {
@@ -267,20 +285,24 @@ export function BacklogSection({
{items.length === 0 && <EmptyState message="Backlog ist leer." />}
<ul className="item-list backlog-reorder-list">
{sortedItems.map((item, index) => {
{displayRows.map(({ item, depth }) => {
const isDragging = dragItemId === item.id
const isDropTarget = dropTargetId === item.id && dragItemId && dragItemId !== item.id
const reorderable = canReorder && item.status !== 'converted'
const isEpic = item.item_kind === 'epic'
const flatIndex = sortedItems.findIndex((row) => row.id === item.id)
return (
<li
key={item.id}
className={
'list-item card-list-item backlog-reorder-item' +
(depth > 0 ? ' backlog-reorder-item--child' : '') +
(isDragging ? ' backlog-reorder-item--dragging' : '') +
(isDropTarget ? ' backlog-reorder-item--drop-target' : '') +
(reorderable && isDesktop ? ' backlog-reorder-item--draggable' : '')
}
style={depth > 0 ? { marginLeft: `${depth * 1.25}rem` } : undefined}
draggable={reorderable && isDesktop}
onDragStart={(event) => handleDragStart(event, item.id)}
onDragEnd={handleDragEnd}
@@ -292,7 +314,7 @@ export function BacklogSection({
⋮⋮
</span>
)}
{showSprintPlanning && canManage && COMMITTABLE_STATUSES.has(item.status) && (
{showSprintPlanning && canManage && COMMITTABLE_STATUSES.has(item.status) && !isEpic && (
<label className="backlog-select-checkbox">
<input
type="checkbox"
@@ -318,6 +340,11 @@ export function BacklogSection({
{item.description && (
<p className="list-item-desc">{item.description}</p>
)}
{item.parent_backlog_id && (
<p className="list-item-sub muted">
Epic: {epicTitleById.get(item.parent_backlog_id) || '…'}
</p>
)}
{item.parent_action_id && (
<p className="list-item-sub muted">
Feature: {actionTitleById(featureActions, item.parent_action_id) || '…'}
@@ -334,8 +361,8 @@ export function BacklogSection({
{reorderable && !isDesktop && (
<ReorderControls
itemId={item.id}
canMoveUp={index > 0}
canMoveDown={index < sortedItems.length - 1}
canMoveUp={flatIndex > 0}
canMoveDown={flatIndex < sortedItems.length - 1}
onMove={(direction) => handleMove(item.id, direction)}
busy={busy}
/>
@@ -344,7 +371,7 @@ export function BacklogSection({
<PriorityBadge priority={item.priority} />
{canManage && item.status !== 'converted' && (
<>
{COMMITTABLE_STATUSES.has(item.status) && (
{COMMITTABLE_STATUSES.has(item.status) && !isEpic && (
<button
type="button"
className="btn btn-primary btn-sm"
@@ -393,6 +420,8 @@ export function BacklogSection({
<BacklogItemForm
roadmapItems={roadmapItems}
featureActions={featureActions}
epicItems={epicItems}
epicHierarchyEnabled={epicHierarchyEnabled}
onSubmit={handleCreateSubmit}
onCancel={closeModal}
busy={busy}
@@ -404,6 +433,8 @@ export function BacklogSection({
initial={modalMode.item}
roadmapItems={roadmapItems}
featureActions={featureActions}
epicItems={epicItems.filter((epic) => epic.id !== modalMode.item.id)}
epicHierarchyEnabled={epicHierarchyEnabled}
onSubmit={handleEditSubmit}
onCancel={closeModal}
busy={busy}
@@ -0,0 +1,24 @@
export function EpicParentSelect({ epicItems = [], defaultValue = '', disabled = false }) {
if (!epicItems.length) {
return (
<label>
Epic (optional)
<p className="muted form-hint">Lege zuerst ein Epic an, um Stories zuzuordnen.</p>
</label>
)
}
return (
<label>
Epic (optional)
<select name="parent_backlog_id" defaultValue={defaultValue || ''} disabled={disabled}>
<option value="">— kein Epic —</option>
{epicItems.map((epic) => (
<option key={epic.id} value={epic.id}>
{epic.title}
</option>
))}
</select>
</label>
)
}
+2
View File
@@ -62,7 +62,9 @@ export const BACKLOG_STATUS_LABELS = {
}
export const BACKLOG_ITEM_KINDS = ['story', 'bug', 'issue']
export const BACKLOG_ITEM_KINDS_WITH_EPIC = ['epic', 'story', 'bug', 'issue']
export const BACKLOG_ITEM_KIND_LABELS = {
epic: 'Epic',
story: 'Story',
bug: 'Bug',
issue: 'Issue',
+53
View File
@@ -0,0 +1,53 @@
import { sortByOrder } from './reorder.js'
/**
* Flache Anzeige-Reihenfolge: Epics an Wurzel, Stories/Bugs/Issues eingerückt darunter.
* @param {Array<{ id: string, item_kind?: string, parent_backlog_id?: string | null, status?: string }>} items
* @returns {Array<{ item: object, depth: number }>}
*/
export function buildBacklogDisplayRows(items) {
const active = sortByOrder((items || []).filter((item) => item.status !== 'converted'))
const childrenByEpic = new Map()
const roots = []
for (const item of active) {
if (item.parent_backlog_id) {
const list = childrenByEpic.get(item.parent_backlog_id) || []
list.push(item)
childrenByEpic.set(item.parent_backlog_id, list)
} else {
roots.push(item)
}
}
const rows = []
const linkedChildIds = new Set()
for (const root of roots) {
rows.push({ item: root, depth: 0 })
if (root.item_kind === 'epic') {
const children = sortByOrder(childrenByEpic.get(root.id) || [])
for (const child of children) {
linkedChildIds.add(child.id)
rows.push({ item: child, depth: 1 })
}
}
}
for (const item of active) {
if (item.parent_backlog_id && !linkedChildIds.has(item.id)) {
rows.push({ item, depth: 0 })
}
}
return rows
}
/**
* @param {Array<{ id: string, item_kind?: string, status?: string }>} items
*/
export function listEpicBacklogItems(items) {
return (items || []).filter(
(item) => item.item_kind === 'epic' && item.status !== 'converted',
)
}
+28
View File
@@ -0,0 +1,28 @@
import { describe, expect, it } from 'vitest'
import { buildBacklogDisplayRows, listEpicBacklogItems } from './backlogTree.js'
describe('backlogTree', () => {
it('gruppiert Stories unter Epic', () => {
const items = [
{ id: 'e1', title: 'Epic A', item_kind: 'epic', sort_order: 0, status: 'accepted' },
{ id: 's1', title: 'Story 1', item_kind: 'story', parent_backlog_id: 'e1', sort_order: 0, status: 'new' },
{ id: 's2', title: 'Story 2', item_kind: 'story', parent_backlog_id: 'e1', sort_order: 10, status: 'new' },
{ id: 'x1', title: 'Los', item_kind: 'story', sort_order: 20, status: 'new' },
]
const rows = buildBacklogDisplayRows(items)
expect(rows.map((r) => [r.item.id, r.depth])).toEqual([
['e1', 0],
['s1', 1],
['s2', 1],
['x1', 0],
])
})
it('listEpicBacklogItems filtert konvertierte Epics', () => {
const items = [
{ id: 'e1', item_kind: 'epic', status: 'accepted' },
{ id: 'e2', item_kind: 'epic', status: 'converted' },
]
expect(listEpicBacklogItems(items).map((i) => i.id)).toEqual(['e1'])
})
})