* feat(PBI-49): add debugProps helper + Vitest test
Adds lib/debug.ts with debugProps(id, component, file) that returns
data-debug-id and data-debug-label attrs in dev mode, empty object in
production. Adds __tests__/lib/debug.test.ts covering both modes.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* docs(PBI-49): add debug-id pattern doc + CLAUDE.md reference
Adds docs/patterns/debug-id.md documenting the named-component boundary
rule (6 punten), helper-voorbeeld, skip-criteria en motivatie voor
handmatige pad-argumenten. Voegt verwijzing toe aan CLAUDE.md
patterns-tabel.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(PBI-49): migrate 17 shared/ components to debugProps helper
Replace hardcoded data-debug-id + data-debug-label attribute pairs with
{...debugProps(id, component, file)} spread in all 17 components/shared/
files. Existing debug-ids preserved unchanged.
* feat(PBI-49): add debugProps to backlog/, sprint/, solo/ components
* feat(PBI-49): add debugProps to jobs/ + ideas/ components
* feat(PBI-49): add debugProps to products/ + settings/ + notifications/ components
* feat(PBI-49): add debugProps to admin/ + dashboard/ + dialogs/ + mobile/ + split-pane/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* fix(PBI-49): use attr(data-debug-id) for debug tooltip in globals.css
* refactor(PBI-49): remove data-debug-label from debugProps helper + test
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* refactor(PBI-49): strip unused component/file args from debugProps in shared/
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(PBI-49): add BEM sub-element data-debug-id to StatusBar, NavBar, PanelNavBar
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(PBI-49): add BEM sub-element data-debug-id to components/sprint/*
- new-sprint-dialog: __submit on submit button
- sprint-backlog: __list on SprintBacklogLeft + SprintBacklogRight scroll areas
- sprint-board-client: root wrapper div (display:contents) + __drag-overlay
- sprint-header: __title on goal button, __dates on dates button, __actions on action cluster
- sprint-run-controls: root on controls div, __start/__cancel on action buttons; __blockers-dialog on dialog content
- start-sprint-button: root on trigger button, __dialog on dialog content, __submit on submit button
- sync-active-sprint-cookie: no debug-id (returns null, side-effect only), comment added
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(PBI-49): add BEM sub-element data-debug-id to components/backlog/*
* feat(PBI-49): add BEM sub-element data-debug-id to components/ideas/*
* feat(PBI-49): add BEM sub-element data-debug-id to components/dashboard/* + components/markdown.tsx
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(PBI-49): add BEM sub-element data-debug-id to new-product-button
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(PBI-49): add BEM sub-element data-debug-id to components/solo/*
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(PBI-49): add BEM sub-elements to nav-status-indicators
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(PBI-49): add BEM sub-element data-debug-id to components/jobs/*
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(PBI-49): add BEM sub-element data-debug-id to components/products/*
* feat(PBI-49): add BEM sub-element data-debug-id to components/notifications/*
- answer-modal: __content (scroll area), __submit (footer)
- notifications-bridge: skip comment (bridge, non-rendering wrapper)
- notifications-realtime-mount: skip comment (returns null)
- notifications-sheet: __header, __items (questions list)
- push-toggle: __switch (button), __label (button text) on subscribed/unsubscribed states
* feat(PBI-49): add BEM sub-element data-debug-id to components/settings/*
- leave-product-button: root only (single-button component)
- min-quota-editor: __input (number input), __save (save button)
- profile-editor: __username (bio/short-description input), __save (submit)
- role-manager: __roles (checkbox list), __add (save button)
- token-manager: __tokens (active tokens list), __generate (create button)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
* feat(PBI-49): add BEM sub-element data-debug-id to admin, auth, dialogs, entity-dialog, mobile, split-pane
* docs(PBI-49): add debug-labels BEM pattern doc + CLAUDE.md entry
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
163 lines
6.4 KiB
TypeScript
163 lines
6.4 KiB
TypeScript
'use client'
|
|
|
|
import Link from 'next/link'
|
|
import { useRouter } from 'next/navigation'
|
|
import { useState, useTransition } from 'react'
|
|
import { Pencil } from 'lucide-react'
|
|
import { toast } from 'sonner'
|
|
import { Button } from '@/components/ui/button'
|
|
import { Badge } from '@/components/ui/badge'
|
|
import { CodeBadge } from '@/components/shared/code-badge'
|
|
import { DemoTooltip } from '@/components/shared/demo-tooltip'
|
|
import { restoreProductAction } from '@/actions/products'
|
|
import { setActiveProductAction } from '@/actions/active-product'
|
|
import { ProductDialog, type ProductDialogProduct } from '@/components/dialogs/product-dialog'
|
|
import { debugProps } from '@/lib/debug'
|
|
|
|
interface Product {
|
|
id: string
|
|
name: string
|
|
code: string | null
|
|
description: string | null
|
|
repo_url: string | null
|
|
definition_of_done: string | null
|
|
auto_pr: boolean
|
|
}
|
|
|
|
interface ProductListProps {
|
|
products: Product[]
|
|
isDemo: boolean
|
|
showArchived?: boolean
|
|
activeProductId: string | null
|
|
}
|
|
|
|
export function ProductList({ products, isDemo, showArchived = false, activeProductId }: ProductListProps) {
|
|
const router = useRouter()
|
|
const [, startTransition] = useTransition()
|
|
const [editingProduct, setEditingProduct] = useState<ProductDialogProduct | null>(null)
|
|
|
|
function handleRestore(id: string) {
|
|
startTransition(async () => {
|
|
const result = await restoreProductAction(id)
|
|
if ('error' in result) toast.error(result.error ?? 'Herstellen mislukt')
|
|
else { toast.success('Product hersteld'); router.refresh() }
|
|
})
|
|
}
|
|
|
|
function handleActivate(id: string) {
|
|
startTransition(async () => {
|
|
const result = await setActiveProductAction(id)
|
|
if (result?.error) toast.error(typeof result.error === 'string' ? result.error : 'Activeren mislukt')
|
|
else router.push(`/products/${id}`)
|
|
})
|
|
}
|
|
|
|
if (products.length === 0) {
|
|
return (
|
|
<div className="bg-surface-container-low rounded-xl border border-border p-12 text-center space-y-3" {...debugProps('product-list', 'ProductList', 'components/dashboard/product-list.tsx')}>
|
|
<p className="text-muted-foreground">
|
|
{showArchived
|
|
? 'Geen gearchiveerde producten.'
|
|
: 'Je hebt nog geen producten aangemaakt.'}
|
|
</p>
|
|
<DemoTooltip show={isDemo}>
|
|
<Button variant="outline" nativeButton={false} render={<Link href={isDemo ? '#' : '/products/new'} />} disabled={isDemo}>
|
|
Maak je eerste product aan
|
|
</Button>
|
|
</DemoTooltip>
|
|
</div>
|
|
)
|
|
}
|
|
|
|
return (
|
|
<div className="grid gap-3" {...debugProps('product-list', 'ProductList', 'components/dashboard/product-list.tsx')}>
|
|
{products.map(product => (
|
|
<div
|
|
key={product.id}
|
|
onClick={() => !showArchived && router.push(`/products/${product.id}`)}
|
|
className={`group bg-surface-container-low border border-border rounded-xl p-4 transition-colors ${
|
|
showArchived ? 'opacity-60' : 'cursor-pointer hover:border-primary'
|
|
}`}
|
|
data-debug-id="product-list__items"
|
|
>
|
|
<div className="flex items-start justify-between gap-4" data-debug-id="product-list__header">
|
|
<div className="min-w-0">
|
|
<div className="flex items-center gap-2">
|
|
{product.code && <CodeBadge code={product.code} />}
|
|
<p className="font-medium text-foreground group-hover:text-primary transition-colors truncate">
|
|
{product.name}
|
|
</p>
|
|
</div>
|
|
{product.description && (
|
|
<p className="text-sm text-muted-foreground mt-1 line-clamp-1">
|
|
{product.description.slice(0, 80)}{product.description.length > 80 ? '…' : ''}
|
|
</p>
|
|
)}
|
|
</div>
|
|
<div className="flex items-center gap-3 shrink-0">
|
|
{product.repo_url && (
|
|
<a
|
|
href={product.repo_url}
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
onClick={e => e.stopPropagation()}
|
|
className="text-xs text-muted-foreground hover:text-primary underline"
|
|
>
|
|
Repo
|
|
</a>
|
|
)}
|
|
{!showArchived && (
|
|
<>
|
|
<DemoTooltip show={isDemo}>
|
|
<button
|
|
onClick={(e) => { e.stopPropagation(); if (!isDemo) setEditingProduct(product) }}
|
|
className="opacity-0 group-hover:opacity-100 inline-flex items-center justify-center min-h-7 min-w-7 text-muted-foreground hover:text-foreground rounded disabled:opacity-40 disabled:cursor-not-allowed"
|
|
aria-label="Bewerk product"
|
|
disabled={isDemo}
|
|
>
|
|
<Pencil size={14} />
|
|
</button>
|
|
</DemoTooltip>
|
|
{product.id === activeProductId
|
|
? <Badge className="bg-primary-container text-primary-container-foreground text-xs px-2 py-0">Actief</Badge>
|
|
: (
|
|
<DemoTooltip show={isDemo}>
|
|
<button
|
|
onClick={(e) => { e.stopPropagation(); if (!isDemo) handleActivate(product.id) }}
|
|
className="text-xs text-primary hover:underline disabled:opacity-40 disabled:cursor-not-allowed disabled:no-underline"
|
|
disabled={isDemo}
|
|
>
|
|
Activeer
|
|
</button>
|
|
</DemoTooltip>
|
|
)
|
|
}
|
|
</>
|
|
)}
|
|
{showArchived && (
|
|
<DemoTooltip show={isDemo}>
|
|
<button
|
|
onClick={(e) => { e.stopPropagation(); if (!isDemo) handleRestore(product.id) }}
|
|
className="text-xs text-primary hover:underline disabled:opacity-40 disabled:cursor-not-allowed"
|
|
disabled={isDemo}
|
|
>
|
|
Herstellen
|
|
</button>
|
|
</DemoTooltip>
|
|
)}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
))}
|
|
{editingProduct && (
|
|
<ProductDialog
|
|
mode="edit"
|
|
open={!!editingProduct}
|
|
onOpenChange={(v) => { if (!v) setEditingProduct(null) }}
|
|
product={editingProduct}
|
|
isDemo={isDemo}
|
|
/>
|
|
)}
|
|
</div>
|
|
)
|
|
}
|