PBI-46: Sprint-niveau jobflow met cascade-FAIL (F1/F2/F4 Scrum4Me) (#136)
* ST-1243: F1 schema + propagateStatusUpwards-helper voor sprint-flow Schema-uitbreidingen voor de sprint-niveau jobflow (PBI-46): - TaskStatus, StoryStatus, PbiStatus, SprintStatus krijgen FAILED - Nieuwe enums: SprintRunStatus, PrStrategy - Nieuw SprintRun-model dat per-task ClaudeJobs groepeert - ClaudeJob.sprint_run_id koppeling + index - Product.pr_strategy (default SPRINT) - Bijhorende Prisma-migratie propagateStatusUpwards vervangt updateTaskStatusWithStoryPromotion en herevalueert de keten Task → Story → PBI → Sprint → SprintRun bij elke task-statuswijziging. Bij FAILED cancelt het sibling-jobs in dezelfde SprintRun. PBI-status BLOCKED blijft handmatig en wordt niet overschreven. Status-mappers + theme krijgen failed-token + label-uitbreidingen. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ST-1244: F2 sprint-runs actions + deprecate per-task enqueues actions/sprint-runs.ts (nieuw): - startSprintRunAction met pre-flight (impl_plan / open ClaudeQuestion / PBI BLOCKED|FAILED) - Maakt SprintRun + ClaudeJobs in PBI→Story→Task volgorde - resumeSprintAction zet FAILED tasks/stories/PBIs terug en start nieuwe SprintRun - cancelSprintRunAction breekt lopende SprintRun af zonder cascade actions/claude-jobs.ts: - enqueueClaudeJobAction, enqueueAllTodoJobsAction, previewEnqueueAllAction, enqueueClaudeJobsBatchAction nu deprecation-stubs (UI-cleanup volgt in F4) - cancelClaudeJobAction blijft beschikbaar voor losse jobs Tests bijgewerkt: 11 nieuwe sprint-runs tests, claude-jobs(-batch) tests herzien naar deprecation-asserties. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * ST-1246: F4 UI Start/Resume/Cancel sprint + pr_strategy dropdown - components/sprint/sprint-run-controls.tsx: knoppen Start Sprint (sprintStatus=ACTIVE), Hervat sprint (sprintStatus=FAILED) en Annuleer sprint-run (lopende run). Pre-flight blocker-modal toont blockers met directe links naar de relevante pagina's. - components/products/pr-strategy-select.tsx: dropdown SPRINT|STORY in product-settings, met optimistic update + sonner-toast op fail. - actions/products.ts: updatePrStrategyAction (eigenaar-only, demo-block). - Sprint-page: query op actieve SprintRun + tonen van controls-balk. Live cascade-visualisatie (T-634) staat als follow-up genoteerd — huidige sprint-board statusbadges volstaan voor MVP. De Solo-board "Voer uit"-knoppen zijn niet expliciet verwijderd; ze tonen nu de deprecation-error van de gestubde actions tot de Solo-flow opnieuw ontworpen wordt. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
ab8c3dca3f
commit
77617e89ac
25 changed files with 1798 additions and 1014 deletions
189
components/sprint/sprint-run-controls.tsx
Normal file
189
components/sprint/sprint-run-controls.tsx
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
'use client'
|
||||
|
||||
import { useState, useTransition } from 'react'
|
||||
import { toast } from 'sonner'
|
||||
import {
|
||||
startSprintRunAction,
|
||||
resumeSprintAction,
|
||||
cancelSprintRunAction,
|
||||
type PreFlightBlocker,
|
||||
} from '@/actions/sprint-runs'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import {
|
||||
Dialog,
|
||||
DialogContent,
|
||||
DialogDescription,
|
||||
DialogFooter,
|
||||
DialogHeader,
|
||||
DialogTitle,
|
||||
} from '@/components/ui/dialog'
|
||||
|
||||
type SprintStatusValue = 'ACTIVE' | 'COMPLETED' | 'FAILED'
|
||||
type SprintRunStatusValue =
|
||||
| 'QUEUED'
|
||||
| 'RUNNING'
|
||||
| 'PAUSED'
|
||||
| 'DONE'
|
||||
| 'FAILED'
|
||||
| 'CANCELLED'
|
||||
| null
|
||||
|
||||
interface Props {
|
||||
sprintId: string
|
||||
productId: string
|
||||
sprintStatus: SprintStatusValue
|
||||
activeSprintRunId: string | null
|
||||
activeSprintRunStatus: SprintRunStatusValue
|
||||
isDemo: boolean
|
||||
}
|
||||
|
||||
const BLOCKER_LABELS: Record<PreFlightBlocker['type'], string> = {
|
||||
task_no_plan: 'Task zonder implementation plan',
|
||||
open_question: 'Openstaande vraag aan jou',
|
||||
pbi_blocked: 'PBI is geblokkeerd of gefaald',
|
||||
}
|
||||
|
||||
function blockerHref(productId: string, blocker: PreFlightBlocker): string {
|
||||
switch (blocker.type) {
|
||||
case 'task_no_plan':
|
||||
return `/products/${productId}/sprint?editTask=${blocker.id}`
|
||||
case 'open_question':
|
||||
return `/products/${productId}/sprint`
|
||||
case 'pbi_blocked':
|
||||
return `/products/${productId}`
|
||||
}
|
||||
}
|
||||
|
||||
export function SprintRunControls({
|
||||
sprintId,
|
||||
productId,
|
||||
sprintStatus,
|
||||
activeSprintRunId,
|
||||
activeSprintRunStatus,
|
||||
isDemo,
|
||||
}: Props) {
|
||||
const [pending, startTransition] = useTransition()
|
||||
const [blockers, setBlockers] = useState<PreFlightBlocker[] | null>(null)
|
||||
|
||||
const hasActiveRun =
|
||||
activeSprintRunId !== null &&
|
||||
(activeSprintRunStatus === 'QUEUED' ||
|
||||
activeSprintRunStatus === 'RUNNING' ||
|
||||
activeSprintRunStatus === 'PAUSED')
|
||||
|
||||
const canStart = sprintStatus === 'ACTIVE' && !hasActiveRun
|
||||
const canResume = sprintStatus === 'FAILED'
|
||||
const canCancel = hasActiveRun
|
||||
|
||||
function handleStart() {
|
||||
startTransition(async () => {
|
||||
const result = await startSprintRunAction({ sprint_id: sprintId })
|
||||
if (result.ok) {
|
||||
toast.success(`Sprint gestart (${result.jobs_count} taak(s) klaar)`)
|
||||
} else if (result.error === 'PRE_FLIGHT_BLOCKED' && 'blockers' in result) {
|
||||
setBlockers(result.blockers)
|
||||
} else {
|
||||
toast.error(result.error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleResume() {
|
||||
startTransition(async () => {
|
||||
const result = await resumeSprintAction({ sprint_id: sprintId })
|
||||
if (result.ok) {
|
||||
toast.success(`Sprint hervat (${result.jobs_count} taak(s) klaar)`)
|
||||
} else if (result.error === 'PRE_FLIGHT_BLOCKED' && 'blockers' in result) {
|
||||
setBlockers(result.blockers)
|
||||
} else {
|
||||
toast.error(result.error)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function handleCancel() {
|
||||
if (!activeSprintRunId) return
|
||||
if (!confirm('Sprint annuleren? Openstaande taken blijven TO_DO.')) return
|
||||
startTransition(async () => {
|
||||
const result = await cancelSprintRunAction({ sprint_run_id: activeSprintRunId })
|
||||
if (result.ok) toast.success('Sprint geannuleerd')
|
||||
else toast.error(result.error)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="flex items-center gap-2">
|
||||
{canStart && (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleStart}
|
||||
disabled={pending || isDemo}
|
||||
className="text-xs"
|
||||
>
|
||||
Start Sprint
|
||||
</Button>
|
||||
)}
|
||||
{canResume && (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleResume}
|
||||
disabled={pending || isDemo}
|
||||
variant="default"
|
||||
className="text-xs"
|
||||
>
|
||||
Hervat sprint
|
||||
</Button>
|
||||
)}
|
||||
{canCancel && (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={handleCancel}
|
||||
disabled={pending || isDemo}
|
||||
variant="outline"
|
||||
className="text-xs"
|
||||
>
|
||||
Annuleer sprint-run
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Dialog open={blockers !== null} onOpenChange={(open) => { if (!open) setBlockers(null) }}>
|
||||
<DialogContent className="max-w-lg">
|
||||
<DialogHeader>
|
||||
<DialogTitle>Sprint kan nog niet starten</DialogTitle>
|
||||
<DialogDescription>
|
||||
Los eerst onderstaande punten op. Klik op een item om er direct naar
|
||||
te navigeren.
|
||||
</DialogDescription>
|
||||
</DialogHeader>
|
||||
|
||||
<ul className="flex flex-col gap-2 max-h-80 overflow-y-auto">
|
||||
{blockers?.map((b, i) => (
|
||||
<li
|
||||
key={`${b.type}-${b.id}-${i}`}
|
||||
className="rounded-md border border-border bg-surface-container-low px-3 py-2"
|
||||
>
|
||||
<div className="text-xs uppercase tracking-wide text-muted-foreground">
|
||||
{BLOCKER_LABELS[b.type]}
|
||||
</div>
|
||||
<a
|
||||
href={blockerHref(productId, b)}
|
||||
className="text-sm text-primary hover:underline break-words"
|
||||
>
|
||||
{b.label}
|
||||
</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
||||
<DialogFooter>
|
||||
<Button variant="outline" onClick={() => setBlockers(null)}>
|
||||
Sluit
|
||||
</Button>
|
||||
</DialogFooter>
|
||||
</DialogContent>
|
||||
</Dialog>
|
||||
</>
|
||||
)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue