Sprint: Idee regril mogelijkheid (#144)
* feat(ST-cmovhveef): add PLANNED to GRILL_TRIGGERABLE_FROM and PLANNED→GRILLING transition - GRILL_TRIGGERABLE_FROM now includes 'PLANNED' in actions/ideas.ts - ALLOWED_TRANSITIONS PLANNED entry extended with 'GRILLING' in lib/idea-status.ts - Updated canTransition test to reflect the new re-grill-from-PLANNED behavior * test(ST-cmovhvef3): add exhaustive re-grill canTransition test covering PLANNED Adds a loop test that asserts canTransition(status, 'GRILLING') for all statuses in GRILL_TRIGGERABLE_FROM that support the transition, explicitly documenting PLANNED as a valid re-grill entry point. * feat(ST-cmovhvegf): add existingPbi pre-check in materializeIdeaPlanAction - Adds options.allowAlongside parameter to control behaviour when a PBI with executed tasks already exists. - Returns 409 PBI_HAS_ACTIVE_TASKS:<code> when tasks are DONE/IN_PROGRESS and allowAlongside is not set. - Auto-deletes the old PBI inside the transaction when no tasks have been executed (atomic replace). - Alongside mode (allowAlongside=true) skips deletion and creates a new PBI. * test(ST-cmovhveh3): add pre-check integration tests for materializeIdeaPlanAction Three new scenarios in ideas-crud.test.ts: - auto-vervang: old PBI deleted in transaction when no executed tasks - conflict-409: returns PBI_HAS_ACTIVE_TASKS:<code> with active tasks - alongside: skips delete and creates new PBI when allowAlongside=true Also adds task.count, pbi.findUnique, pbi.delete to prisma mock. * feat(ST-cmovhveih): remove PLANNED-blokkering in idea-row-actions, add inline Bekijk-PBI button - Removed grillBlockedReason guard for status==='planned', enabling re-grill from PLANNED - Removed the early return for PLANNED that hid all standard buttons - Added conditional 'Bekijk <code>' button at the start of the standard button set, visible only when status==='planned' and PBI + product_id are present * feat(ST-cmovhvej7): add PBI_HAS_ACTIVE_TASKS alongside-dialoog in materialize handler When materializeIdeaPlanAction returns code 409 with PBI_HAS_ACTIVE_TASKS:<code>, a confirm dialog offers the user a choice: create new PBI alongside the existing one or cancel. Alongside=true retries the action; cancel leaves the idea in PLAN_READY.
This commit is contained in:
parent
2d27c41d38
commit
5cb3abbd3d
5 changed files with 130 additions and 34 deletions
|
|
@ -61,7 +61,6 @@ export function IdeaRowActions({ idea, isDemo, onArchive }: IdeaRowActionsProps)
|
|||
// ---- Grill Me ----
|
||||
const grillBlockedReason = (() => {
|
||||
if (status === 'grilling' || status === 'planning') return 'Job loopt al'
|
||||
if (status === 'planned') return 'Idee is gepland — open de PBI'
|
||||
if (!hasProductWithRepo) return 'Idee heeft een product met repo nodig'
|
||||
if (!workerOk) return 'Geen Claude-worker actief'
|
||||
return null
|
||||
|
|
@ -108,15 +107,24 @@ export function IdeaRowActions({ idea, isDemo, onArchive }: IdeaRowActionsProps)
|
|||
function handleMaterialize() {
|
||||
if (!confirm('Plan materialiseren? Dit maakt PBI + stories + taken aan.')) return
|
||||
startTransition(async () => {
|
||||
const r = await materializeIdeaPlanAction(idea.id)
|
||||
let r = await materializeIdeaPlanAction(idea.id)
|
||||
|
||||
if ('error' in r && r.code === 409 && r.error.startsWith('PBI_HAS_ACTIVE_TASKS:')) {
|
||||
const pbiCode = r.error.split(':')[1]
|
||||
const alongside = confirm(
|
||||
`De bestaande PBI (${pbiCode}) heeft uitgevoerde taken.\n` +
|
||||
`OK = nieuwe PBI naast bestaande aanmaken.\n` +
|
||||
`Annuleren = stoppen.`
|
||||
)
|
||||
if (!alongside) return
|
||||
r = await materializeIdeaPlanAction(idea.id, { allowAlongside: true })
|
||||
}
|
||||
|
||||
if ('error' in r) {
|
||||
toast.error(r.error)
|
||||
return
|
||||
}
|
||||
toast.success(`Gematerialiseerd als ${r.data?.pbi_code}`)
|
||||
// Navigeer naar de product-backlog. Anchor-scrolling per-PBI bestaat
|
||||
// (nog) niet in pbi-list, dus gewoon naar de overview-pagina; de nieuwe
|
||||
// PBI is de meest recente.
|
||||
if (idea.product_id) {
|
||||
router.push(`/products/${idea.product_id}`)
|
||||
} else {
|
||||
|
|
@ -125,35 +133,20 @@ export function IdeaRowActions({ idea, isDemo, onArchive }: IdeaRowActionsProps)
|
|||
})
|
||||
}
|
||||
|
||||
// PLANNED-state: kortere variant met "Bekijk PBI"-link
|
||||
if (status === 'planned' && idea.pbi && idea.product_id) {
|
||||
return (
|
||||
<div className="flex items-center gap-1.5">
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
{/* Bekijk PBI — alleen zichtbaar in PLANNED */}
|
||||
{status === 'planned' && idea.pbi && idea.product_id && (
|
||||
<Button
|
||||
size="sm"
|
||||
variant="outline"
|
||||
onClick={() =>
|
||||
router.push(`/products/${idea.product_id}`)
|
||||
}
|
||||
size="sm"
|
||||
onClick={() => router.push(`/products/${idea.product_id!}`)}
|
||||
>
|
||||
Bekijk {idea.pbi.code}
|
||||
<ExternalLink className="ml-1 size-3.5" />
|
||||
</Button>
|
||||
<Button
|
||||
size="sm"
|
||||
variant="ghost"
|
||||
onClick={() => router.push(`/ideas/${idea.id}`)}
|
||||
aria-label="Open idee"
|
||||
title="Open idee"
|
||||
>
|
||||
<ArrowRight className="size-4" />
|
||||
</Button>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
)}
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-1">
|
||||
{/* Grill Me */}
|
||||
<ActionButton
|
||||
label="Grill"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue