From 1ba9feac1a091b66349550c366c2c7dffc38c461 Mon Sep 17 00:00:00 2001 From: Madhura68 Date: Mon, 4 May 2026 21:39:33 +0200 Subject: [PATCH] ui: idea-timeline + pbi-link-card + download-md-button (M12 T-512) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit components/ideas/idea-timeline.tsx: - Chronological merge of IdeaLog + ClaudeQuestion (sorted desc by created_at) - Per-entry icon by log-type (DECISION/NOTE/GRILL_RESULT/PLAN_RESULT/ STATUS_CHANGE/JOB_EVENT) + question-status label - MD3-tokens, vertical timeline rail (border-left + dots) - Question entries show options + answer (border-left highlight) - Metadata expansion via
for log entries components/ideas/idea-pbi-link-card.tsx: - PLANNED + pbi present: green status-done card with PBI link - PLANNED + pbi removed (FK SetNull): blocked-color banner with "Plan opnieuw beschikbaar maken" → relinkIdeaPlanAction - Demo blocked on relink components/ideas/download-md-button.tsx: - Calls downloadIdeaMdAction → builds Blob + anchor + click() - Filename: {idea.code}-{kind}.md - Demo MAY use it (read-only) components/ideas/idea-detail-layout.tsx: - Replaces inline placeholders with extracted components - Md tabs gain Download (.md) button + Edit button row Tests: 546/546 still green. Co-Authored-By: Claude Opus 4.7 (1M context) --- components/ideas/download-md-button.tsx | 55 ++++++++ components/ideas/idea-detail-layout.tsx | 100 ++------------- components/ideas/idea-pbi-link-card.tsx | 85 ++++++++++++ components/ideas/idea-timeline.tsx | 163 ++++++++++++++++++++++++ 4 files changed, 314 insertions(+), 89 deletions(-) create mode 100644 components/ideas/download-md-button.tsx create mode 100644 components/ideas/idea-pbi-link-card.tsx create mode 100644 components/ideas/idea-timeline.tsx diff --git a/components/ideas/download-md-button.tsx b/components/ideas/download-md-button.tsx new file mode 100644 index 0000000..6e1a255 --- /dev/null +++ b/components/ideas/download-md-button.tsx @@ -0,0 +1,55 @@ +'use client' + +// DownloadMdButton — download grill_md of plan_md als .md-bestand. +// Demo MAG downloaden (read-only). Server-action returnt md-string; client +// bouwt een Blob + anchor + click(). + +import { useTransition } from 'react' +import { Download } from 'lucide-react' +import { toast } from 'sonner' + +import { Button } from '@/components/ui/button' +import { downloadIdeaMdAction } from '@/actions/ideas' + +interface Props { + ideaId: string + kind: 'grill' | 'plan' + hasContent: boolean +} + +export function DownloadMdButton({ ideaId, kind, hasContent }: Props) { + const [pending, startTransition] = useTransition() + + function handleClick() { + startTransition(async () => { + const r = await downloadIdeaMdAction(ideaId, kind) + if ('error' in r) { + toast.error(r.error) + return + } + if (!r.data) return + const blob = new Blob([r.data.markdown], { type: 'text/markdown;charset=utf-8' }) + const url = URL.createObjectURL(blob) + const a = document.createElement('a') + a.href = url + a.download = r.data.filename + document.body.appendChild(a) + a.click() + a.remove() + URL.revokeObjectURL(url) + }) + } + + return ( + + ) +} diff --git a/components/ideas/idea-detail-layout.tsx b/components/ideas/idea-detail-layout.tsx index d46b126..0e12ac8 100644 --- a/components/ideas/idea-detail-layout.tsx +++ b/components/ideas/idea-detail-layout.tsx @@ -23,6 +23,9 @@ import type { IdeaDto } from '@/lib/idea-dto' import { updateIdeaAction, archiveIdeaAction } from '@/actions/ideas' import { IdeaRowActions } from '@/components/ideas/idea-row-actions' import { IdeaMdEditor } from '@/components/ideas/idea-md-editor' +import { IdeaPbiLinkCard } from '@/components/ideas/idea-pbi-link-card' +import { IdeaTimeline } from '@/components/ideas/idea-timeline' +import { DownloadMdButton } from '@/components/ideas/download-md-button' const API_TO_DB: Record[0]> = { draft: 'DRAFT', @@ -153,32 +156,8 @@ export function IdeaDetailLayout({ - {/* PBI-link card bij PLANNED — placeholder voor T-512 */} - {idea.status === 'planned' && idea.pbi && ( -
-

- Gematerialiseerd als{' '} - - {idea.pbi.code} — {idea.pbi.title} - -

-
- )} - {idea.status === 'planned' && !idea.pbi && ( -
-

- De gekoppelde PBI bestaat niet meer. Klik om dit idee terug naar - PLAN_READY te zetten en opnieuw te materialiseren. -

-
- )} + {/* PBI-link card / Re-link banner bij PLANNED */} + {/* Tab-switcher */}