* feat(PBI-58): Vitest-tests voor SoloTaskCard veldmapping en 4-regels layout Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): server action fetchJobsPageData voor jobs-pagina Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): SSE-route /api/realtime/jobs voor user-scoped job-events Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): JobCard component voor jobs-pagina Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): JobDetailPane component voor jobs-pagina Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): API route GET /api/jobs/[id]/sub-tasks voor sprint task executions Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): SprintSubTasksPane component voor jobs-pagina Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): Zustand store useJobsStore voor jobs-pagina Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): useJobsRealtime hook met SSE-verbinding en store-updates Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): JobsBoard 3-kolom SplitPane client component Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): /jobs server page met JobsBoard Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> * feat(PBI-59): Jobs nav-link toevoegen aan NavBar Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4a63b4b01f
commit
f166186374
6 changed files with 327 additions and 0 deletions
96
components/jobs/jobs-board.tsx
Normal file
96
components/jobs/jobs-board.tsx
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
'use client'
|
||||
|
||||
import { useEffect } from 'react'
|
||||
import { SplitPane } from '@/components/split-pane/split-pane'
|
||||
import JobCard from './job-card'
|
||||
import JobDetailPane from './job-detail-pane'
|
||||
import SprintSubTasksPane from './sprint-sub-tasks-pane'
|
||||
import { useJobsStore } from '@/stores/jobs-store'
|
||||
import useJobsRealtime from '@/hooks/use-jobs-realtime'
|
||||
import type { JobWithRelations } from '@/actions/jobs-page'
|
||||
|
||||
interface JobsBoardProps {
|
||||
initialActiveJobs: JobWithRelations[]
|
||||
initialDoneJobs: JobWithRelations[]
|
||||
}
|
||||
|
||||
function jobToCardProps(j: JobWithRelations) {
|
||||
return {
|
||||
id: j.id,
|
||||
kind: j.kind,
|
||||
status: j.status,
|
||||
taskCode: j.taskCode,
|
||||
taskTitle: j.taskTitle,
|
||||
ideaCode: j.ideaCode,
|
||||
ideaTitle: j.ideaTitle,
|
||||
sprintGoal: j.sprintGoal,
|
||||
sprintCode: j.sprintCode,
|
||||
productName: j.productName,
|
||||
branch: j.branch,
|
||||
error: j.error,
|
||||
summary: j.summary,
|
||||
}
|
||||
}
|
||||
|
||||
export default function JobsBoard({ initialActiveJobs, initialDoneJobs }: JobsBoardProps) {
|
||||
const { activeJobs, doneJobs, selectedJobId, initJobs, setSelectedJobId } = useJobsStore()
|
||||
useJobsRealtime()
|
||||
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
useEffect(() => { initJobs(initialActiveJobs, initialDoneJobs) }, [])
|
||||
|
||||
const selectedJob = [...activeJobs, ...doneJobs].find(j => j.id === selectedJobId) ?? null
|
||||
|
||||
const leftPane = (
|
||||
<div className="overflow-y-auto h-full p-2 space-y-2">
|
||||
{activeJobs.map(j => (
|
||||
<JobCard
|
||||
key={j.id}
|
||||
{...jobToCardProps(j)}
|
||||
isSelected={j.id === selectedJobId}
|
||||
onClick={() => setSelectedJobId(j.id)}
|
||||
/>
|
||||
))}
|
||||
{activeJobs.length === 0 && (
|
||||
<p className="text-sm text-muted-foreground text-center py-8">Geen actieve jobs</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
const middlePane = (
|
||||
<div className="flex flex-col h-full overflow-hidden">
|
||||
<SprintSubTasksPane
|
||||
jobId={selectedJobId}
|
||||
isSprintJob={selectedJob?.kind === 'SPRINT_IMPLEMENTATION'}
|
||||
/>
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
<JobDetailPane job={selectedJob} />
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
const rightPane = (
|
||||
<div className="overflow-y-auto h-full p-2 space-y-2">
|
||||
{doneJobs.map(j => (
|
||||
<JobCard
|
||||
key={j.id}
|
||||
{...jobToCardProps(j)}
|
||||
isSelected={j.id === selectedJobId}
|
||||
onClick={() => setSelectedJobId(j.id)}
|
||||
/>
|
||||
))}
|
||||
{doneJobs.length === 0 && (
|
||||
<p className="text-sm text-muted-foreground text-center py-8">Nog geen afgeronde jobs</p>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
|
||||
return (
|
||||
<SplitPane
|
||||
panes={[leftPane, middlePane, rightPane]}
|
||||
defaultSplit={[25, 50, 25]}
|
||||
cookieKey="jobs"
|
||||
tabLabels={['Actief', 'Details', 'Klaar']}
|
||||
/>
|
||||
)
|
||||
}
|
||||
67
components/jobs/sprint-sub-tasks-pane.tsx
Normal file
67
components/jobs/sprint-sub-tasks-pane.tsx
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
'use client'
|
||||
|
||||
import { useEffect, useState } from 'react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { JOB_STATUS_LABELS, JOB_STATUS_COLORS } from '@/components/shared/job-status'
|
||||
import type { ClaudeJobStatusApi } from '@/lib/job-status'
|
||||
|
||||
type SubTask = {
|
||||
id: string
|
||||
taskCode: string | null
|
||||
taskTitle: string
|
||||
status: string
|
||||
}
|
||||
|
||||
interface SprintSubTasksPaneProps {
|
||||
jobId: string | null
|
||||
isSprintJob: boolean
|
||||
}
|
||||
|
||||
function SubTaskList({ jobId }: { jobId: string }) {
|
||||
const [subTasks, setSubTasks] = useState<SubTask[]>([])
|
||||
const [loading, setLoading] = useState(true)
|
||||
|
||||
useEffect(() => {
|
||||
const controller = new AbortController()
|
||||
|
||||
fetch(`/api/jobs/${jobId}/sub-tasks`, { signal: controller.signal })
|
||||
.then(res => res.json())
|
||||
.then((data: SubTask[]) => {
|
||||
setSubTasks(data)
|
||||
setLoading(false)
|
||||
})
|
||||
.catch(() => {
|
||||
setLoading(false)
|
||||
})
|
||||
|
||||
return () => controller.abort()
|
||||
}, [jobId])
|
||||
|
||||
if (loading) {
|
||||
return <div className="text-xs text-muted-foreground p-3">Laden…</div>
|
||||
}
|
||||
|
||||
if (subTasks.length === 0) return null
|
||||
|
||||
return (
|
||||
<div className="border-b p-2 space-y-1 max-h-44 overflow-y-auto shrink-0">
|
||||
{subTasks.map(t => {
|
||||
const apiStatus = t.status.toLowerCase() as ClaudeJobStatusApi
|
||||
return (
|
||||
<div key={t.id} className="flex items-center gap-2 py-1 px-2 rounded hover:bg-surface-container text-sm">
|
||||
<span className="text-xs font-mono text-muted-foreground w-16 shrink-0 truncate">{t.taskCode}</span>
|
||||
<span className="flex-1 truncate">{t.taskTitle}</span>
|
||||
<span className={cn('text-xs px-1.5 py-0.5 rounded-full border', JOB_STATUS_COLORS[apiStatus])}>
|
||||
{JOB_STATUS_LABELS[apiStatus] ?? t.status}
|
||||
</span>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default function SprintSubTasksPane({ jobId, isSprintJob }: SprintSubTasksPaneProps) {
|
||||
if (!isSprintJob || !jobId) return null
|
||||
return <SubTaskList key={jobId} jobId={jobId} />
|
||||
}
|
||||
|
|
@ -143,6 +143,7 @@ export function NavBar({
|
|||
: disabledSpan('Solo')}
|
||||
{navLink('/insights', 'Insights', pathname.startsWith('/insights'))}
|
||||
{navLink('/ideas', 'Ideas', pathname.startsWith('/ideas'))}
|
||||
{navLink('/jobs', 'Jobs', pathname.startsWith('/jobs'))}
|
||||
{navLink('/manual', 'Manual', pathname.startsWith('/manual'))}
|
||||
{roles.includes('ADMIN') && navLink('/admin', 'Admin', pathname.startsWith('/admin'))}
|
||||
</nav>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue