forked from cardosofelipe/fast-next-template
feat(frontend): implement issue management pages (#42)
Add complete issue management feature for Syndarix projects: - Issue list page with filtering, sorting, and bulk actions - Issue detail page with status workflow and activity timeline - IssueFilters component with search, status, priority, sprint, assignee - IssueTable component with sortable columns and selection support - BulkActions toolbar for batch operations - StatusWorkflow component for interactive status changes - ActivityTimeline component for issue history - IssueDetailPanel component showing assignee, labels, development info - StatusBadge, PriorityBadge, SyncStatusIndicator components - TanStack Query hooks with optimistic updates - Mock data for development (API integration points marked) - Unit tests for badge and indicator components - E2E tests for list and detail pages Uses mock data until backend API is implemented. Components follow design system guidelines with WCAG AA accessibility compliance. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
265
frontend/e2e/issues.spec.ts
Normal file
265
frontend/e2e/issues.spec.ts
Normal file
@@ -0,0 +1,265 @@
|
||||
/**
|
||||
* Issue Management E2E Tests
|
||||
*
|
||||
* Tests for the issue list and detail pages.
|
||||
*/
|
||||
|
||||
import { test, expect } from '@playwright/test';
|
||||
|
||||
test.describe('Issue Management', () => {
|
||||
// Use a test project ID
|
||||
const projectId = 'test-project-123';
|
||||
|
||||
test.beforeEach(async ({ page }) => {
|
||||
// Mock authentication - inject test auth store
|
||||
await page.addInitScript(() => {
|
||||
window.__TEST_AUTH_STORE__ = {
|
||||
getState: () => ({
|
||||
isAuthenticated: true,
|
||||
user: { id: 'test-user', email: 'test@example.com', is_superuser: false },
|
||||
accessToken: 'test-token',
|
||||
refreshToken: 'test-refresh',
|
||||
}),
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Issue List Page', () => {
|
||||
test('displays issues list', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
// Wait for the page to load
|
||||
await expect(page.getByRole('heading', { name: /issues/i })).toBeVisible();
|
||||
|
||||
// Should show issue count
|
||||
await expect(page.getByText(/issues found/i)).toBeVisible();
|
||||
});
|
||||
|
||||
test('has search functionality', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
const searchInput = page.getByPlaceholder('Search issues...');
|
||||
await expect(searchInput).toBeVisible();
|
||||
|
||||
// Type in search
|
||||
await searchInput.fill('authentication');
|
||||
|
||||
// Wait for debounced search (mock data should filter)
|
||||
await page.waitForTimeout(500);
|
||||
});
|
||||
|
||||
test('has status filter', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
// Find status filter
|
||||
const statusFilter = page.getByRole('combobox', { name: /filter by status/i });
|
||||
await expect(statusFilter).toBeVisible();
|
||||
|
||||
// Open and select a status
|
||||
await statusFilter.click();
|
||||
await page.getByRole('option', { name: /in progress/i }).click();
|
||||
});
|
||||
|
||||
test('can toggle extended filters', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
// Extended filters should not be visible initially
|
||||
await expect(page.getByLabel('Priority')).not.toBeVisible();
|
||||
|
||||
// Click filter toggle
|
||||
await page.getByRole('button', { name: /toggle extended filters/i }).click();
|
||||
|
||||
// Extended filters should now be visible
|
||||
await expect(page.getByLabel('Priority')).toBeVisible();
|
||||
await expect(page.getByLabel('Sprint')).toBeVisible();
|
||||
await expect(page.getByLabel('Assignee')).toBeVisible();
|
||||
});
|
||||
|
||||
test('can select issues for bulk actions', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
// Wait for issues to load
|
||||
await page.waitForSelector('[data-testid^="issue-row-"]');
|
||||
|
||||
// Select first issue checkbox
|
||||
const firstCheckbox = page.getByRole('checkbox', { name: /select issue/i }).first();
|
||||
await firstCheckbox.click();
|
||||
|
||||
// Bulk actions bar should appear
|
||||
await expect(page.getByText('1 selected')).toBeVisible();
|
||||
await expect(page.getByRole('button', { name: /change status/i })).toBeVisible();
|
||||
});
|
||||
|
||||
test('navigates to issue detail when clicking row', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
// Wait for issues to load
|
||||
await page.waitForSelector('[data-testid^="issue-row-"]');
|
||||
|
||||
// Click on first issue row
|
||||
await page.locator('[data-testid^="issue-row-"]').first().click();
|
||||
|
||||
// Should navigate to detail page
|
||||
await expect(page).toHaveURL(/\/issues\/[^/]+$/);
|
||||
});
|
||||
|
||||
test('has new issue button', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
await expect(page.getByRole('button', { name: /new issue/i })).toBeVisible();
|
||||
});
|
||||
|
||||
test('has sync button', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
await expect(page.getByRole('button', { name: /sync/i })).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Issue Detail Page', () => {
|
||||
const issueId = 'ISS-001';
|
||||
|
||||
test('displays issue details', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
// Wait for the page to load
|
||||
await expect(page.getByRole('heading', { level: 1 })).toBeVisible();
|
||||
|
||||
// Should show issue number
|
||||
await expect(page.getByText(/#\d+/)).toBeVisible();
|
||||
});
|
||||
|
||||
test('displays status badge', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
// Should show status
|
||||
await expect(
|
||||
page.getByText(/open|in progress|in review|blocked|done|closed/i).first()
|
||||
).toBeVisible();
|
||||
});
|
||||
|
||||
test('displays priority badge', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
// Should show priority
|
||||
await expect(page.getByText(/high|medium|low/i).first()).toBeVisible();
|
||||
});
|
||||
|
||||
test('has back button', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
const backButton = page.getByRole('link', { name: /back to issues/i });
|
||||
await expect(backButton).toBeVisible();
|
||||
});
|
||||
|
||||
test('displays status workflow panel', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
// Should show status workflow
|
||||
await expect(page.getByRole('heading', { name: /status workflow/i })).toBeVisible();
|
||||
|
||||
// Should show all status options
|
||||
await expect(page.getByRole('radiogroup', { name: /issue status/i })).toBeVisible();
|
||||
});
|
||||
|
||||
test('displays activity timeline', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
// Should show activity section
|
||||
await expect(page.getByRole('heading', { name: /activity/i })).toBeVisible();
|
||||
|
||||
// Should have add comment button
|
||||
await expect(page.getByRole('button', { name: /add comment/i })).toBeVisible();
|
||||
});
|
||||
|
||||
test('displays issue details panel', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
// Should show details section
|
||||
await expect(page.getByRole('heading', { name: /details/i })).toBeVisible();
|
||||
|
||||
// Should show assignee info
|
||||
await expect(page.getByText(/assignee/i)).toBeVisible();
|
||||
});
|
||||
|
||||
test('can change status via workflow', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
// Wait for page to load
|
||||
await page.waitForSelector('[role="radiogroup"]');
|
||||
|
||||
// Click on a different status
|
||||
const inProgressOption = page.getByRole('radio', { name: /in progress/i });
|
||||
await inProgressOption.click();
|
||||
|
||||
// The status should update (optimistic update)
|
||||
await expect(inProgressOption).toHaveAttribute('aria-checked', 'true');
|
||||
});
|
||||
|
||||
test('displays description', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
// Should show description heading
|
||||
await expect(page.getByRole('heading', { name: /description/i })).toBeVisible();
|
||||
});
|
||||
|
||||
test('shows edit button', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
await expect(page.getByRole('button', { name: /edit/i })).toBeVisible();
|
||||
});
|
||||
|
||||
test('shows external link when available', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/${issueId}`);
|
||||
|
||||
// The mock data includes an external URL
|
||||
await expect(page.getByRole('link', { name: /view in gitea/i })).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
||||
test.describe('Accessibility', () => {
|
||||
test('issue list has proper heading structure', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
// Main heading should be h1
|
||||
const h1 = page.getByRole('heading', { level: 1 });
|
||||
await expect(h1).toBeVisible();
|
||||
});
|
||||
|
||||
test('issue list table has proper ARIA labels', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues`);
|
||||
|
||||
// Wait for table to load
|
||||
await page.waitForSelector('[data-testid^="issue-row-"]');
|
||||
|
||||
// Checkboxes should have labels
|
||||
const checkboxes = page.getByRole('checkbox');
|
||||
const count = await checkboxes.count();
|
||||
expect(count).toBeGreaterThan(0);
|
||||
|
||||
// First checkbox should have accessible label
|
||||
await expect(checkboxes.first()).toHaveAccessibleName();
|
||||
});
|
||||
|
||||
test('issue detail has proper radiogroup for status', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/ISS-001`);
|
||||
|
||||
// Status workflow should be a radiogroup
|
||||
const radiogroup = page.getByRole('radiogroup', { name: /issue status/i });
|
||||
await expect(radiogroup).toBeVisible();
|
||||
|
||||
// Each status should be a radio button
|
||||
const radios = page.getByRole('radio');
|
||||
const count = await radios.count();
|
||||
expect(count).toBe(6); // 6 statuses
|
||||
});
|
||||
|
||||
test('activity timeline has proper list structure', async ({ page }) => {
|
||||
await page.goto(`/en/projects/${projectId}/issues/ISS-001`);
|
||||
|
||||
// Activity should be a list
|
||||
const list = page.getByRole('list', { name: /issue activity/i });
|
||||
await expect(list).toBeVisible();
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,204 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* Issue Detail Page
|
||||
*
|
||||
* Displays full issue details with status workflow and activity timeline.
|
||||
*
|
||||
* @module app/[locale]/(authenticated)/projects/[id]/issues/[issueId]/page
|
||||
*/
|
||||
|
||||
import { use } from 'react';
|
||||
import Link from 'next/link';
|
||||
import {
|
||||
ArrowLeft,
|
||||
Calendar,
|
||||
Clock,
|
||||
ExternalLink,
|
||||
Edit,
|
||||
} from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import {
|
||||
StatusBadge,
|
||||
PriorityBadge,
|
||||
SyncStatusIndicator,
|
||||
StatusWorkflow,
|
||||
ActivityTimeline,
|
||||
IssueDetailPanel,
|
||||
useIssue,
|
||||
useUpdateIssueStatus,
|
||||
getPrimaryTransition,
|
||||
} from '@/features/issues';
|
||||
import type { IssueStatus } from '@/features/issues';
|
||||
|
||||
interface IssueDetailPageProps {
|
||||
params: Promise<{
|
||||
locale: string;
|
||||
id: string;
|
||||
issueId: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export default function IssueDetailPage({ params }: IssueDetailPageProps) {
|
||||
const { locale, id: projectId, issueId } = use(params);
|
||||
|
||||
const { data: issue, isLoading, error } = useIssue(issueId);
|
||||
const updateStatus = useUpdateIssueStatus();
|
||||
|
||||
const handleStatusChange = (status: IssueStatus) => {
|
||||
updateStatus.mutate({ issueId, status });
|
||||
};
|
||||
|
||||
const primaryTransition = issue ? getPrimaryTransition(issue.status) : undefined;
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="rounded-lg border border-destructive bg-destructive/10 p-6 text-center">
|
||||
<h2 className="text-lg font-semibold text-destructive">Error Loading Issue</h2>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
Failed to load issue details. Please try again later.
|
||||
</p>
|
||||
<div className="mt-4 flex justify-center gap-2">
|
||||
<Link href={`/${locale}/projects/${projectId}/issues`}>
|
||||
<Button variant="outline">Back to Issues</Button>
|
||||
</Link>
|
||||
<Button
|
||||
variant="outline"
|
||||
onClick={() => window.location.reload()}
|
||||
>
|
||||
Retry
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (isLoading || !issue) {
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-6">
|
||||
<div className="space-y-6">
|
||||
<div className="flex items-start gap-4">
|
||||
<Skeleton className="h-10 w-10" />
|
||||
<div className="flex-1 space-y-2">
|
||||
<Skeleton className="h-6 w-48" />
|
||||
<Skeleton className="h-8 w-96" />
|
||||
<Skeleton className="h-4 w-64" />
|
||||
</div>
|
||||
</div>
|
||||
<div className="grid gap-6 lg:grid-cols-3">
|
||||
<div className="space-y-6 lg:col-span-2">
|
||||
<Skeleton className="h-64 w-full" />
|
||||
<Skeleton className="h-96 w-full" />
|
||||
</div>
|
||||
<div className="space-y-6">
|
||||
<Skeleton className="h-64 w-full" />
|
||||
<Skeleton className="h-48 w-full" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-6">
|
||||
<div className="space-y-6">
|
||||
{/* Header */}
|
||||
<div className="flex items-start gap-4">
|
||||
<Link href={`/${locale}/projects/${projectId}/issues`}>
|
||||
<Button variant="ghost" size="icon" aria-label="Back to issues">
|
||||
<ArrowLeft className="h-4 w-4" aria-hidden="true" />
|
||||
</Button>
|
||||
</Link>
|
||||
<div className="flex-1 space-y-2">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<span className="font-mono text-muted-foreground">#{issue.number}</span>
|
||||
<StatusBadge status={issue.status} />
|
||||
<PriorityBadge priority={issue.priority} />
|
||||
<SyncStatusIndicator status={issue.sync_status} showLabel />
|
||||
</div>
|
||||
<h1 className="text-2xl font-bold">{issue.title}</h1>
|
||||
<div className="flex flex-wrap items-center gap-4 text-sm text-muted-foreground">
|
||||
<div className="flex items-center gap-1">
|
||||
<Calendar className="h-4 w-4" aria-hidden="true" />
|
||||
Created {new Date(issue.created_at).toLocaleDateString()}
|
||||
</div>
|
||||
<div className="flex items-center gap-1">
|
||||
<Clock className="h-4 w-4" aria-hidden="true" />
|
||||
Updated {new Date(issue.updated_at).toLocaleDateString()}
|
||||
</div>
|
||||
{issue.external_url && (
|
||||
<a
|
||||
href={issue.external_url}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="flex items-center gap-1 text-primary hover:underline"
|
||||
>
|
||||
<ExternalLink className="h-4 w-4" aria-hidden="true" />
|
||||
View in Gitea
|
||||
</a>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" size="sm">
|
||||
<Edit className="mr-2 h-4 w-4" aria-hidden="true" />
|
||||
Edit
|
||||
</Button>
|
||||
{primaryTransition && (
|
||||
<Button
|
||||
size="sm"
|
||||
onClick={() => handleStatusChange(primaryTransition.to)}
|
||||
disabled={updateStatus.isPending}
|
||||
>
|
||||
{updateStatus.isPending ? 'Updating...' : primaryTransition.label}
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid gap-6 lg:grid-cols-3">
|
||||
{/* Main Content */}
|
||||
<div className="space-y-6 lg:col-span-2">
|
||||
{/* Description Card */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle>Description</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="prose prose-sm max-w-none dark:prose-invert">
|
||||
<pre className="whitespace-pre-wrap font-sans text-sm">
|
||||
{issue.description}
|
||||
</pre>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Activity Timeline */}
|
||||
<ActivityTimeline
|
||||
activities={issue.activity}
|
||||
onAddComment={() => {}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Sidebar */}
|
||||
<div className="space-y-6">
|
||||
{/* Status Workflow */}
|
||||
<StatusWorkflow
|
||||
currentStatus={issue.status}
|
||||
onStatusChange={handleStatusChange}
|
||||
disabled={updateStatus.isPending}
|
||||
/>
|
||||
|
||||
{/* Issue Details */}
|
||||
<IssueDetailPanel issue={issue} />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,195 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* Project Issues List Page
|
||||
*
|
||||
* Displays filterable, sortable list of issues for a project.
|
||||
* Supports bulk actions and sync with external trackers.
|
||||
*
|
||||
* @module app/[locale]/(authenticated)/projects/[id]/issues/page
|
||||
*/
|
||||
|
||||
import { useState, use } from 'react';
|
||||
import { useRouter } from 'next/navigation';
|
||||
import { Plus, Upload } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Skeleton } from '@/components/ui/skeleton';
|
||||
import {
|
||||
IssueFilters,
|
||||
IssueTable,
|
||||
BulkActions,
|
||||
useIssues,
|
||||
} from '@/features/issues';
|
||||
import type { IssueFiltersType, IssueSort } from '@/features/issues';
|
||||
|
||||
interface ProjectIssuesPageProps {
|
||||
params: Promise<{
|
||||
locale: string;
|
||||
id: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
export default function ProjectIssuesPage({ params }: ProjectIssuesPageProps) {
|
||||
const { locale, id: projectId } = use(params);
|
||||
const router = useRouter();
|
||||
|
||||
// Filter state
|
||||
const [filters, setFilters] = useState<IssueFiltersType>({
|
||||
status: 'all',
|
||||
priority: 'all',
|
||||
sprint: 'all',
|
||||
assignee: 'all',
|
||||
});
|
||||
|
||||
// Sort state
|
||||
const [sort, setSort] = useState<IssueSort>({
|
||||
field: 'updated_at',
|
||||
direction: 'desc',
|
||||
});
|
||||
|
||||
// Selection state
|
||||
const [selectedIssues, setSelectedIssues] = useState<string[]>([]);
|
||||
|
||||
// Fetch issues
|
||||
const { data, isLoading, error } = useIssues(projectId, filters, sort);
|
||||
|
||||
const handleIssueClick = (issueId: string) => {
|
||||
router.push(`/${locale}/projects/${projectId}/issues/${issueId}`);
|
||||
};
|
||||
|
||||
const handleBulkChangeStatus = () => {
|
||||
// TODO: Open status change dialog
|
||||
};
|
||||
|
||||
const handleBulkAssign = () => {
|
||||
// TODO: Open assign dialog
|
||||
};
|
||||
|
||||
const handleBulkAddLabels = () => {
|
||||
// TODO: Open labels dialog
|
||||
};
|
||||
|
||||
const handleBulkDelete = () => {
|
||||
// TODO: Confirm and delete
|
||||
};
|
||||
|
||||
const handleSync = () => {
|
||||
// TODO: Sync all issues
|
||||
};
|
||||
|
||||
const handleNewIssue = () => {
|
||||
// TODO: Navigate to new issue page or open dialog
|
||||
};
|
||||
|
||||
if (error) {
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-8">
|
||||
<div className="rounded-lg border border-destructive bg-destructive/10 p-6 text-center">
|
||||
<h2 className="text-lg font-semibold text-destructive">Error Loading Issues</h2>
|
||||
<p className="mt-2 text-sm text-muted-foreground">
|
||||
Failed to load issues. Please try again later.
|
||||
</p>
|
||||
<Button
|
||||
variant="outline"
|
||||
className="mt-4"
|
||||
onClick={() => window.location.reload()}
|
||||
>
|
||||
Retry
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="container mx-auto px-4 py-6">
|
||||
<div className="space-y-6">
|
||||
{/* Header */}
|
||||
<div className="flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div>
|
||||
<h1 className="text-3xl font-bold">Issues</h1>
|
||||
<p className="text-muted-foreground">
|
||||
{isLoading ? (
|
||||
<Skeleton className="h-4 w-24" />
|
||||
) : (
|
||||
`${data?.pagination.total || 0} issues found`
|
||||
)}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" size="sm" onClick={handleSync}>
|
||||
<Upload className="mr-2 h-4 w-4" aria-hidden="true" />
|
||||
Sync
|
||||
</Button>
|
||||
<Button size="sm" onClick={handleNewIssue}>
|
||||
<Plus className="mr-2 h-4 w-4" aria-hidden="true" />
|
||||
New Issue
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Filters */}
|
||||
<IssueFilters filters={filters} onFiltersChange={setFilters} />
|
||||
|
||||
{/* Bulk Actions */}
|
||||
<BulkActions
|
||||
selectedCount={selectedIssues.length}
|
||||
onChangeStatus={handleBulkChangeStatus}
|
||||
onAssign={handleBulkAssign}
|
||||
onAddLabels={handleBulkAddLabels}
|
||||
onDelete={handleBulkDelete}
|
||||
/>
|
||||
|
||||
{/* Issue Table */}
|
||||
{isLoading ? (
|
||||
<div className="space-y-2">
|
||||
{[...Array(5)].map((_, i) => (
|
||||
<Skeleton key={i} className="h-16 w-full" />
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<IssueTable
|
||||
issues={data?.data || []}
|
||||
selectedIssues={selectedIssues}
|
||||
onSelectionChange={setSelectedIssues}
|
||||
onIssueClick={handleIssueClick}
|
||||
sort={sort}
|
||||
onSortChange={setSort}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Pagination info */}
|
||||
{data && data.pagination.total > 0 && (
|
||||
<div className="flex items-center justify-between text-sm text-muted-foreground">
|
||||
<span>
|
||||
Showing {(data.pagination.page - 1) * data.pagination.page_size + 1} to{' '}
|
||||
{Math.min(
|
||||
data.pagination.page * data.pagination.page_size,
|
||||
data.pagination.total
|
||||
)}{' '}
|
||||
of {data.pagination.total} issues
|
||||
</span>
|
||||
{data.pagination.total_pages > 1 && (
|
||||
<div className="flex gap-2">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={!data.pagination.has_prev}
|
||||
>
|
||||
Previous
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
disabled={!data.pagination.has_next}
|
||||
>
|
||||
Next
|
||||
</Button>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
84
frontend/src/features/issues/components/ActivityTimeline.tsx
Normal file
84
frontend/src/features/issues/components/ActivityTimeline.tsx
Normal file
@@ -0,0 +1,84 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* ActivityTimeline Component
|
||||
*
|
||||
* Displays issue activity history.
|
||||
*
|
||||
* @module features/issues/components/ActivityTimeline
|
||||
*/
|
||||
|
||||
import { MessageSquare, Bot, User } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { IssueActivity } from '../types';
|
||||
|
||||
interface ActivityTimelineProps {
|
||||
activities: IssueActivity[];
|
||||
onAddComment?: () => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function ActivityTimeline({
|
||||
activities,
|
||||
onAddComment,
|
||||
className,
|
||||
}: ActivityTimelineProps) {
|
||||
return (
|
||||
<Card className={className}>
|
||||
<CardHeader>
|
||||
<div className="flex items-center justify-between">
|
||||
<CardTitle className="flex items-center gap-2">
|
||||
<MessageSquare className="h-5 w-5" aria-hidden="true" />
|
||||
Activity
|
||||
</CardTitle>
|
||||
{onAddComment && (
|
||||
<Button variant="outline" size="sm" onClick={onAddComment}>
|
||||
Add Comment
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-6" role="list" aria-label="Issue activity">
|
||||
{activities.map((item, index) => (
|
||||
<div
|
||||
key={item.id}
|
||||
className="flex gap-4"
|
||||
role="listitem"
|
||||
>
|
||||
<div className="relative flex flex-col items-center">
|
||||
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-muted">
|
||||
{item.actor.type === 'agent' ? (
|
||||
<Bot className="h-4 w-4" aria-hidden="true" />
|
||||
) : (
|
||||
<User className="h-4 w-4" aria-hidden="true" />
|
||||
)}
|
||||
</div>
|
||||
{index < activities.length - 1 && (
|
||||
<div className="absolute top-8 h-full w-px bg-border" aria-hidden="true" />
|
||||
)}
|
||||
</div>
|
||||
<div className={cn('flex-1', index < activities.length - 1 && 'pb-6')}>
|
||||
<div className="flex flex-wrap items-baseline gap-2">
|
||||
<span className="font-medium">{item.actor.name}</span>
|
||||
<span className="text-sm text-muted-foreground">{item.message}</span>
|
||||
</div>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
<time dateTime={item.timestamp}>{item.timestamp}</time>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{activities.length === 0 && (
|
||||
<div className="py-8 text-center text-muted-foreground">
|
||||
No activity yet
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
70
frontend/src/features/issues/components/BulkActions.tsx
Normal file
70
frontend/src/features/issues/components/BulkActions.tsx
Normal file
@@ -0,0 +1,70 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* BulkActions Component
|
||||
*
|
||||
* Actions bar for bulk operations on selected issues.
|
||||
*
|
||||
* @module features/issues/components/BulkActions
|
||||
*/
|
||||
|
||||
import { Trash2 } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { cn } from '@/lib/utils';
|
||||
|
||||
interface BulkActionsProps {
|
||||
selectedCount: number;
|
||||
onChangeStatus: () => void;
|
||||
onAssign: () => void;
|
||||
onAddLabels: () => void;
|
||||
onDelete: () => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function BulkActions({
|
||||
selectedCount,
|
||||
onChangeStatus,
|
||||
onAssign,
|
||||
onAddLabels,
|
||||
onDelete,
|
||||
className,
|
||||
}: BulkActionsProps) {
|
||||
if (selectedCount === 0) return null;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn(
|
||||
'flex items-center gap-4 rounded-lg border bg-muted/50 p-3',
|
||||
className
|
||||
)}
|
||||
role="toolbar"
|
||||
aria-label="Bulk actions for selected issues"
|
||||
>
|
||||
<span className="text-sm font-medium">
|
||||
{selectedCount} selected
|
||||
</span>
|
||||
<Separator orientation="vertical" className="h-6" />
|
||||
<div className="flex gap-2">
|
||||
<Button variant="outline" size="sm" onClick={onChangeStatus}>
|
||||
Change Status
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={onAssign}>
|
||||
Assign
|
||||
</Button>
|
||||
<Button variant="outline" size="sm" onClick={onAddLabels}>
|
||||
Add Labels
|
||||
</Button>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="text-destructive hover:text-destructive"
|
||||
onClick={onDelete}
|
||||
>
|
||||
<Trash2 className="mr-2 h-4 w-4" aria-hidden="true" />
|
||||
Delete
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
163
frontend/src/features/issues/components/IssueDetailPanel.tsx
Normal file
163
frontend/src/features/issues/components/IssueDetailPanel.tsx
Normal file
@@ -0,0 +1,163 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* IssueDetailPanel Component
|
||||
*
|
||||
* Side panel showing issue details (assignee, labels, sprint, etc.)
|
||||
*
|
||||
* @module features/issues/components/IssueDetailPanel
|
||||
*/
|
||||
|
||||
import { GitBranch, GitPullRequest, Tag, Bot, User } from 'lucide-react';
|
||||
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Separator } from '@/components/ui/separator';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { IssueDetail } from '../types';
|
||||
|
||||
interface IssueDetailPanelProps {
|
||||
issue: IssueDetail;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function IssueDetailPanel({ issue, className }: IssueDetailPanelProps) {
|
||||
return (
|
||||
<div className={cn('space-y-6', className)}>
|
||||
{/* Assignment Panel */}
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">Details</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{/* Assignee */}
|
||||
<div>
|
||||
<p className="text-sm text-muted-foreground">Assignee</p>
|
||||
{issue.assignee ? (
|
||||
<div className="mt-1 flex items-center gap-2">
|
||||
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-primary/10 text-sm font-medium text-primary">
|
||||
{issue.assignee.avatar ||
|
||||
(issue.assignee.type === 'agent' ? (
|
||||
<Bot className="h-4 w-4" aria-hidden="true" />
|
||||
) : (
|
||||
<User className="h-4 w-4" aria-hidden="true" />
|
||||
))}
|
||||
</div>
|
||||
<div>
|
||||
<p className="font-medium">{issue.assignee.name}</p>
|
||||
<p className="text-xs text-muted-foreground capitalize">
|
||||
{issue.assignee.type}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
) : (
|
||||
<p className="mt-1 text-sm text-muted-foreground">Unassigned</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* Reporter */}
|
||||
<div>
|
||||
<p className="text-sm text-muted-foreground">Reporter</p>
|
||||
<div className="mt-1 flex items-center gap-2">
|
||||
<div className="flex h-8 w-8 items-center justify-center rounded-full bg-muted text-sm font-medium">
|
||||
{issue.reporter.avatar ||
|
||||
(issue.reporter.type === 'agent' ? (
|
||||
<Bot className="h-4 w-4" aria-hidden="true" />
|
||||
) : (
|
||||
<User className="h-4 w-4" aria-hidden="true" />
|
||||
))}
|
||||
</div>
|
||||
<p className="font-medium">{issue.reporter.name}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* Sprint */}
|
||||
<div>
|
||||
<p className="text-sm text-muted-foreground">Sprint</p>
|
||||
<p className="font-medium">{issue.sprint || 'Backlog'}</p>
|
||||
</div>
|
||||
|
||||
{/* Story Points */}
|
||||
{issue.story_points !== null && (
|
||||
<div>
|
||||
<p className="text-sm text-muted-foreground">Story Points</p>
|
||||
<p className="font-medium">{issue.story_points}</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Due Date */}
|
||||
{issue.due_date && (
|
||||
<div>
|
||||
<p className="text-sm text-muted-foreground">Due Date</p>
|
||||
<p className="font-medium">
|
||||
{new Date(issue.due_date).toLocaleDateString()}
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Separator />
|
||||
|
||||
{/* Labels */}
|
||||
<div>
|
||||
<p className="text-sm text-muted-foreground">Labels</p>
|
||||
<div className="mt-2 flex flex-wrap gap-1">
|
||||
{issue.labels.map((label) => (
|
||||
<Badge
|
||||
key={label.id}
|
||||
variant="secondary"
|
||||
className="text-xs"
|
||||
style={
|
||||
label.color
|
||||
? { backgroundColor: `${label.color}20`, color: label.color }
|
||||
: undefined
|
||||
}
|
||||
>
|
||||
<Tag className="mr-1 h-3 w-3" aria-hidden="true" />
|
||||
{label.name}
|
||||
</Badge>
|
||||
))}
|
||||
{issue.labels.length === 0 && (
|
||||
<span className="text-sm text-muted-foreground">No labels</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
{/* Development */}
|
||||
{(issue.branch || issue.pull_request) && (
|
||||
<Card>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">Development</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent className="space-y-4">
|
||||
{issue.branch && (
|
||||
<div className="flex items-center gap-2">
|
||||
<GitBranch
|
||||
className="h-4 w-4 text-muted-foreground"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="font-mono text-sm">{issue.branch}</span>
|
||||
</div>
|
||||
)}
|
||||
{issue.pull_request && (
|
||||
<div className="flex items-center gap-2">
|
||||
<GitPullRequest
|
||||
className="h-4 w-4 text-muted-foreground"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<span className="text-sm">{issue.pull_request}</span>
|
||||
<Badge variant="outline" className="text-xs">
|
||||
Open
|
||||
</Badge>
|
||||
</div>
|
||||
)}
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
205
frontend/src/features/issues/components/IssueFilters.tsx
Normal file
205
frontend/src/features/issues/components/IssueFilters.tsx
Normal file
@@ -0,0 +1,205 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* IssueFilters Component
|
||||
*
|
||||
* Filter controls for the issue list.
|
||||
*
|
||||
* @module features/issues/components/IssueFilters
|
||||
*/
|
||||
|
||||
import { useState } from 'react';
|
||||
import { Search, Filter } from 'lucide-react';
|
||||
import { Input } from '@/components/ui/input';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from '@/components/ui/select';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { IssueFilters as IssueFiltersType, IssueStatus, IssuePriority } from '../types';
|
||||
import { STATUS_ORDER, PRIORITY_ORDER, STATUS_CONFIG, PRIORITY_CONFIG } from '../constants';
|
||||
import { mockSprints, mockAssignees } from '../mocks';
|
||||
|
||||
interface IssueFiltersProps {
|
||||
filters: IssueFiltersType;
|
||||
onFiltersChange: (filters: IssueFiltersType) => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function IssueFilters({ filters, onFiltersChange, className }: IssueFiltersProps) {
|
||||
const [showExtended, setShowExtended] = useState(false);
|
||||
|
||||
const handleSearchChange = (value: string) => {
|
||||
onFiltersChange({ ...filters, search: value || undefined });
|
||||
};
|
||||
|
||||
const handleStatusChange = (value: string) => {
|
||||
onFiltersChange({
|
||||
...filters,
|
||||
status: value as IssueStatus | 'all',
|
||||
});
|
||||
};
|
||||
|
||||
const handlePriorityChange = (value: string) => {
|
||||
onFiltersChange({
|
||||
...filters,
|
||||
priority: value as IssuePriority | 'all',
|
||||
});
|
||||
};
|
||||
|
||||
const handleSprintChange = (value: string) => {
|
||||
onFiltersChange({
|
||||
...filters,
|
||||
sprint: value as string | 'all' | 'backlog',
|
||||
});
|
||||
};
|
||||
|
||||
const handleAssigneeChange = (value: string) => {
|
||||
onFiltersChange({
|
||||
...filters,
|
||||
assignee: value as string | 'all' | 'unassigned',
|
||||
});
|
||||
};
|
||||
|
||||
const handleClearFilters = () => {
|
||||
onFiltersChange({
|
||||
search: undefined,
|
||||
status: 'all',
|
||||
priority: 'all',
|
||||
sprint: 'all',
|
||||
assignee: 'all',
|
||||
labels: undefined,
|
||||
});
|
||||
};
|
||||
|
||||
const hasActiveFilters =
|
||||
filters.search ||
|
||||
(filters.status && filters.status !== 'all') ||
|
||||
(filters.priority && filters.priority !== 'all') ||
|
||||
(filters.sprint && filters.sprint !== 'all') ||
|
||||
(filters.assignee && filters.assignee !== 'all');
|
||||
|
||||
return (
|
||||
<div className={cn('space-y-4', className)}>
|
||||
{/* Search and Quick Filters */}
|
||||
<div className="flex flex-col gap-4 sm:flex-row">
|
||||
<div className="relative flex-1">
|
||||
<Search
|
||||
className="absolute left-3 top-1/2 h-4 w-4 -translate-y-1/2 text-muted-foreground"
|
||||
aria-hidden="true"
|
||||
/>
|
||||
<Input
|
||||
id="issue-search"
|
||||
placeholder="Search issues..."
|
||||
value={filters.search || ''}
|
||||
onChange={(e) => handleSearchChange(e.target.value)}
|
||||
className="pl-9"
|
||||
aria-label="Search issues"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex gap-2">
|
||||
<Select value={filters.status || 'all'} onValueChange={handleStatusChange}>
|
||||
<SelectTrigger className="w-32" aria-label="Filter by status">
|
||||
<SelectValue placeholder="Status" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All Status</SelectItem>
|
||||
{STATUS_ORDER.map((status) => (
|
||||
<SelectItem key={status} value={status}>
|
||||
{STATUS_CONFIG[status].label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<Button
|
||||
variant="outline"
|
||||
size="icon"
|
||||
onClick={() => setShowExtended(!showExtended)}
|
||||
className={cn(showExtended && 'bg-muted')}
|
||||
aria-expanded={showExtended}
|
||||
aria-label="Toggle extended filters"
|
||||
>
|
||||
<Filter className="h-4 w-4" aria-hidden="true" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Extended Filters */}
|
||||
{showExtended && (
|
||||
<Card className="p-4">
|
||||
<div className="grid gap-4 sm:grid-cols-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="priority-filter">Priority</Label>
|
||||
<Select
|
||||
value={filters.priority || 'all'}
|
||||
onValueChange={handlePriorityChange}
|
||||
>
|
||||
<SelectTrigger id="priority-filter">
|
||||
<SelectValue placeholder="All" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All</SelectItem>
|
||||
{PRIORITY_ORDER.map((priority) => (
|
||||
<SelectItem key={priority} value={priority}>
|
||||
{PRIORITY_CONFIG[priority].label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="sprint-filter">Sprint</Label>
|
||||
<Select value={filters.sprint || 'all'} onValueChange={handleSprintChange}>
|
||||
<SelectTrigger id="sprint-filter">
|
||||
<SelectValue placeholder="All" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All Sprints</SelectItem>
|
||||
{mockSprints.map((sprint) => (
|
||||
<SelectItem key={sprint} value={sprint}>
|
||||
{sprint}
|
||||
</SelectItem>
|
||||
))}
|
||||
<SelectItem value="backlog">Backlog</SelectItem>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="assignee-filter">Assignee</Label>
|
||||
<Select
|
||||
value={filters.assignee || 'all'}
|
||||
onValueChange={handleAssigneeChange}
|
||||
>
|
||||
<SelectTrigger id="assignee-filter">
|
||||
<SelectValue placeholder="All" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">All</SelectItem>
|
||||
<SelectItem value="unassigned">Unassigned</SelectItem>
|
||||
{mockAssignees.map((assignee) => (
|
||||
<SelectItem key={assignee.id} value={assignee.id}>
|
||||
{assignee.name}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
</div>
|
||||
<div className="flex items-end">
|
||||
{hasActiveFilters && (
|
||||
<Button variant="ghost" size="sm" onClick={handleClearFilters}>
|
||||
Clear Filters
|
||||
</Button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
265
frontend/src/features/issues/components/IssueTable.tsx
Normal file
265
frontend/src/features/issues/components/IssueTable.tsx
Normal file
@@ -0,0 +1,265 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* IssueTable Component
|
||||
*
|
||||
* Sortable table displaying issues with selection support.
|
||||
*
|
||||
* @module features/issues/components/IssueTable
|
||||
*/
|
||||
|
||||
import { ChevronUp, ChevronDown, MoreVertical, Bot, User, CircleDot } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { Checkbox } from '@/components/ui/checkbox';
|
||||
import { Card } from '@/components/ui/card';
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@/components/ui/table';
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuSeparator,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import type { IssueSummary, IssueSort, IssueSortField, IssueSortDirection } from '../types';
|
||||
|
||||
/**
|
||||
* Convert our sort direction to ARIA sort value
|
||||
*/
|
||||
function toAriaSortValue(
|
||||
field: IssueSortField,
|
||||
currentField: IssueSortField,
|
||||
direction: IssueSortDirection
|
||||
): 'ascending' | 'descending' | 'none' | undefined {
|
||||
if (field !== currentField) return undefined;
|
||||
return direction === 'asc' ? 'ascending' : 'descending';
|
||||
}
|
||||
|
||||
import { StatusBadge } from './StatusBadge';
|
||||
import { PriorityBadge } from './PriorityBadge';
|
||||
import { SyncStatusIndicator } from './SyncStatusIndicator';
|
||||
|
||||
interface IssueTableProps {
|
||||
issues: IssueSummary[];
|
||||
selectedIssues: string[];
|
||||
onSelectionChange: (ids: string[]) => void;
|
||||
onIssueClick: (id: string) => void;
|
||||
sort: IssueSort;
|
||||
onSortChange: (sort: IssueSort) => void;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function IssueTable({
|
||||
issues,
|
||||
selectedIssues,
|
||||
onSelectionChange,
|
||||
onIssueClick,
|
||||
sort,
|
||||
onSortChange,
|
||||
className,
|
||||
}: IssueTableProps) {
|
||||
const handleSelectAll = () => {
|
||||
if (selectedIssues.length === issues.length) {
|
||||
onSelectionChange([]);
|
||||
} else {
|
||||
onSelectionChange(issues.map((i) => i.id));
|
||||
}
|
||||
};
|
||||
|
||||
const handleSelectIssue = (id: string, e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
if (selectedIssues.includes(id)) {
|
||||
onSelectionChange(selectedIssues.filter((i) => i !== id));
|
||||
} else {
|
||||
onSelectionChange([...selectedIssues, id]);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSort = (field: IssueSortField) => {
|
||||
if (sort.field === field) {
|
||||
onSortChange({
|
||||
field,
|
||||
direction: sort.direction === 'asc' ? 'desc' : 'asc',
|
||||
});
|
||||
} else {
|
||||
onSortChange({ field, direction: 'desc' });
|
||||
}
|
||||
};
|
||||
|
||||
const SortIcon = ({ field }: { field: IssueSortField }) => {
|
||||
if (sort.field !== field) return null;
|
||||
return sort.direction === 'asc' ? (
|
||||
<ChevronUp className="ml-1 inline h-4 w-4" aria-hidden="true" />
|
||||
) : (
|
||||
<ChevronDown className="ml-1 inline h-4 w-4" aria-hidden="true" />
|
||||
);
|
||||
};
|
||||
|
||||
const allSelected = selectedIssues.length === issues.length && issues.length > 0;
|
||||
const someSelected = selectedIssues.length > 0 && !allSelected;
|
||||
|
||||
return (
|
||||
<Card className={className}>
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead className="w-12">
|
||||
<Checkbox
|
||||
checked={allSelected}
|
||||
ref={(el) => {
|
||||
if (el) {
|
||||
(el as unknown as HTMLInputElement).indeterminate = someSelected;
|
||||
}
|
||||
}}
|
||||
onCheckedChange={handleSelectAll}
|
||||
aria-label={allSelected ? 'Deselect all issues' : 'Select all issues'}
|
||||
/>
|
||||
</TableHead>
|
||||
<TableHead
|
||||
className="w-20 cursor-pointer select-none"
|
||||
onClick={() => handleSort('number')}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-sort={toAriaSortValue('number', sort.field, sort.direction)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleSort('number')}
|
||||
>
|
||||
#
|
||||
<SortIcon field="number" />
|
||||
</TableHead>
|
||||
<TableHead>Title</TableHead>
|
||||
<TableHead className="w-32">Status</TableHead>
|
||||
<TableHead
|
||||
className="w-24 cursor-pointer select-none"
|
||||
onClick={() => handleSort('priority')}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-sort={toAriaSortValue('priority', sort.field, sort.direction)}
|
||||
onKeyDown={(e) => e.key === 'Enter' && handleSort('priority')}
|
||||
>
|
||||
Priority
|
||||
<SortIcon field="priority" />
|
||||
</TableHead>
|
||||
<TableHead className="w-40">Assignee</TableHead>
|
||||
<TableHead className="w-28">Sprint</TableHead>
|
||||
<TableHead className="w-10">Sync</TableHead>
|
||||
<TableHead className="w-10">
|
||||
<span className="sr-only">Actions</span>
|
||||
</TableHead>
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{issues.map((issue) => (
|
||||
<TableRow
|
||||
key={issue.id}
|
||||
className="cursor-pointer"
|
||||
onClick={() => onIssueClick(issue.id)}
|
||||
data-testid={`issue-row-${issue.id}`}
|
||||
>
|
||||
<TableCell onClick={(e) => handleSelectIssue(issue.id, e)}>
|
||||
<Checkbox
|
||||
checked={selectedIssues.includes(issue.id)}
|
||||
onCheckedChange={() => {}}
|
||||
aria-label={`Select issue ${issue.number}`}
|
||||
/>
|
||||
</TableCell>
|
||||
<TableCell className="font-mono text-sm text-muted-foreground">
|
||||
{issue.number}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<div className="space-y-1">
|
||||
<p className="font-medium">{issue.title}</p>
|
||||
<div className="flex flex-wrap gap-1">
|
||||
{issue.labels.slice(0, 3).map((label) => (
|
||||
<Badge key={label} variant="secondary" className="text-xs">
|
||||
{label}
|
||||
</Badge>
|
||||
))}
|
||||
{issue.labels.length > 3 && (
|
||||
<Badge variant="outline" className="text-xs">
|
||||
+{issue.labels.length - 3}
|
||||
</Badge>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<StatusBadge status={issue.status} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<PriorityBadge priority={issue.priority} />
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{issue.assignee ? (
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex h-6 w-6 items-center justify-center rounded-full bg-primary/10 text-xs font-medium text-primary">
|
||||
{issue.assignee.type === 'agent' ? (
|
||||
<Bot className="h-3 w-3" aria-hidden="true" />
|
||||
) : (
|
||||
<User className="h-3 w-3" aria-hidden="true" />
|
||||
)}
|
||||
</div>
|
||||
<span className="text-sm">{issue.assignee.name}</span>
|
||||
</div>
|
||||
) : (
|
||||
<span className="text-sm text-muted-foreground">Unassigned</span>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
{issue.sprint ? (
|
||||
<Badge variant="outline" className="text-xs">
|
||||
{issue.sprint}
|
||||
</Badge>
|
||||
) : (
|
||||
<span className="text-xs text-muted-foreground">Backlog</span>
|
||||
)}
|
||||
</TableCell>
|
||||
<TableCell>
|
||||
<SyncStatusIndicator status={issue.sync_status} />
|
||||
</TableCell>
|
||||
<TableCell onClick={(e) => e.stopPropagation()}>
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button
|
||||
variant="ghost"
|
||||
size="icon"
|
||||
className="h-8 w-8"
|
||||
aria-label={`Actions for issue ${issue.number}`}
|
||||
>
|
||||
<MoreVertical className="h-4 w-4" aria-hidden="true" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => onIssueClick(issue.id)}>
|
||||
View Details
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem>Edit</DropdownMenuItem>
|
||||
<DropdownMenuItem>Assign</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem>Sync with Tracker</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem className="text-destructive">Delete</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
{issues.length === 0 && (
|
||||
<div className="py-12 text-center">
|
||||
<CircleDot className="mx-auto h-12 w-12 text-muted-foreground" aria-hidden="true" />
|
||||
<h3 className="mt-4 font-semibold">No issues found</h3>
|
||||
<p className="text-muted-foreground">Try adjusting your search or filters</p>
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
29
frontend/src/features/issues/components/PriorityBadge.tsx
Normal file
29
frontend/src/features/issues/components/PriorityBadge.tsx
Normal file
@@ -0,0 +1,29 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* PriorityBadge Component
|
||||
*
|
||||
* Displays issue priority with appropriate styling.
|
||||
*
|
||||
* @module features/issues/components/PriorityBadge
|
||||
*/
|
||||
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { IssuePriority } from '../types';
|
||||
import { PRIORITY_CONFIG } from '../constants';
|
||||
|
||||
interface PriorityBadgeProps {
|
||||
priority: IssuePriority;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function PriorityBadge({ priority, className }: PriorityBadgeProps) {
|
||||
const config = PRIORITY_CONFIG[priority] || PRIORITY_CONFIG.medium;
|
||||
|
||||
return (
|
||||
<Badge className={cn(config.color, className)} variant="outline">
|
||||
{config.label}
|
||||
</Badge>
|
||||
);
|
||||
}
|
||||
51
frontend/src/features/issues/components/StatusBadge.tsx
Normal file
51
frontend/src/features/issues/components/StatusBadge.tsx
Normal file
@@ -0,0 +1,51 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* StatusBadge Component
|
||||
*
|
||||
* Displays issue status with appropriate icon and color.
|
||||
*
|
||||
* @module features/issues/components/StatusBadge
|
||||
*/
|
||||
|
||||
import {
|
||||
CircleDot,
|
||||
PlayCircle,
|
||||
Clock,
|
||||
AlertCircle,
|
||||
CheckCircle2,
|
||||
XCircle,
|
||||
} from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { IssueStatus } from '../types';
|
||||
import { STATUS_CONFIG } from '../constants';
|
||||
|
||||
const STATUS_ICONS = {
|
||||
open: CircleDot,
|
||||
in_progress: PlayCircle,
|
||||
in_review: Clock,
|
||||
blocked: AlertCircle,
|
||||
done: CheckCircle2,
|
||||
closed: XCircle,
|
||||
} as const;
|
||||
|
||||
interface StatusBadgeProps {
|
||||
status: IssueStatus;
|
||||
className?: string;
|
||||
showLabel?: boolean;
|
||||
}
|
||||
|
||||
export function StatusBadge({ status, className, showLabel = true }: StatusBadgeProps) {
|
||||
const config = STATUS_CONFIG[status] || STATUS_CONFIG.open;
|
||||
const Icon = STATUS_ICONS[status] || CircleDot;
|
||||
|
||||
return (
|
||||
<div className={cn('flex items-center gap-1.5', config.color, className)}>
|
||||
<Icon className="h-4 w-4" aria-hidden="true" />
|
||||
{showLabel && (
|
||||
<span className="text-sm font-medium">{config.label}</span>
|
||||
)}
|
||||
<span className="sr-only">{config.label}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
86
frontend/src/features/issues/components/StatusWorkflow.tsx
Normal file
86
frontend/src/features/issues/components/StatusWorkflow.tsx
Normal file
@@ -0,0 +1,86 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* StatusWorkflow Component
|
||||
*
|
||||
* Interactive status selector with workflow transitions.
|
||||
*
|
||||
* @module features/issues/components/StatusWorkflow
|
||||
*/
|
||||
|
||||
import {
|
||||
CircleDot,
|
||||
PlayCircle,
|
||||
Clock,
|
||||
AlertCircle,
|
||||
CheckCircle2,
|
||||
XCircle,
|
||||
} from 'lucide-react';
|
||||
import { Card, CardHeader, CardTitle, CardContent } from '@/components/ui/card';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { IssueStatus } from '../types';
|
||||
import { STATUS_ORDER, STATUS_CONFIG } from '../constants';
|
||||
|
||||
const STATUS_ICONS = {
|
||||
open: CircleDot,
|
||||
in_progress: PlayCircle,
|
||||
in_review: Clock,
|
||||
blocked: AlertCircle,
|
||||
done: CheckCircle2,
|
||||
closed: XCircle,
|
||||
} as const;
|
||||
|
||||
interface StatusWorkflowProps {
|
||||
currentStatus: IssueStatus;
|
||||
onStatusChange: (status: IssueStatus) => void;
|
||||
disabled?: boolean;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function StatusWorkflow({
|
||||
currentStatus,
|
||||
onStatusChange,
|
||||
disabled = false,
|
||||
className,
|
||||
}: StatusWorkflowProps) {
|
||||
return (
|
||||
<Card className={className}>
|
||||
<CardHeader>
|
||||
<CardTitle className="text-lg">Status Workflow</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-2" role="radiogroup" aria-label="Issue status">
|
||||
{STATUS_ORDER.map((status) => {
|
||||
const config = STATUS_CONFIG[status];
|
||||
const Icon = STATUS_ICONS[status];
|
||||
const isActive = currentStatus === status;
|
||||
|
||||
return (
|
||||
<button
|
||||
key={status}
|
||||
type="button"
|
||||
role="radio"
|
||||
aria-checked={isActive}
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
'flex w-full items-center gap-2 rounded-lg p-2 text-left transition-colors',
|
||||
isActive
|
||||
? 'bg-primary/10 text-primary'
|
||||
: 'hover:bg-muted',
|
||||
disabled && 'cursor-not-allowed opacity-50'
|
||||
)}
|
||||
onClick={() => !disabled && onStatusChange(status)}
|
||||
>
|
||||
<Icon className={cn('h-4 w-4', config.color)} aria-hidden="true" />
|
||||
<span className="text-sm">{config.label}</span>
|
||||
{isActive && (
|
||||
<CheckCircle2 className="ml-auto h-4 w-4" aria-hidden="true" />
|
||||
)}
|
||||
</button>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
'use client';
|
||||
|
||||
/**
|
||||
* SyncStatusIndicator Component
|
||||
*
|
||||
* Displays sync status with external issue trackers.
|
||||
*
|
||||
* @module features/issues/components/SyncStatusIndicator
|
||||
*/
|
||||
|
||||
import { CheckCircle2, RefreshCw, AlertCircle, AlertTriangle } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import type { SyncStatus } from '../types';
|
||||
import { SYNC_STATUS_CONFIG } from '../constants';
|
||||
|
||||
const SYNC_ICONS = {
|
||||
synced: CheckCircle2,
|
||||
pending: RefreshCw,
|
||||
conflict: AlertTriangle,
|
||||
error: AlertCircle,
|
||||
} as const;
|
||||
|
||||
interface SyncStatusIndicatorProps {
|
||||
status: SyncStatus;
|
||||
className?: string;
|
||||
showLabel?: boolean;
|
||||
}
|
||||
|
||||
export function SyncStatusIndicator({
|
||||
status,
|
||||
className,
|
||||
showLabel = false,
|
||||
}: SyncStatusIndicatorProps) {
|
||||
const config = SYNC_STATUS_CONFIG[status] || SYNC_STATUS_CONFIG.synced;
|
||||
const Icon = SYNC_ICONS[status] || CheckCircle2;
|
||||
const isPending = status === 'pending';
|
||||
|
||||
return (
|
||||
<div
|
||||
className={cn('flex items-center gap-1', className)}
|
||||
title={config.label}
|
||||
role="status"
|
||||
aria-label={`Sync status: ${config.label}`}
|
||||
>
|
||||
<Icon
|
||||
className={cn('h-3.5 w-3.5', config.color, isPending && 'animate-spin')}
|
||||
aria-hidden="true"
|
||||
/>
|
||||
{showLabel && <span className={cn('text-xs', config.color)}>{config.label}</span>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
15
frontend/src/features/issues/components/index.ts
Normal file
15
frontend/src/features/issues/components/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Issue Management Components
|
||||
*
|
||||
* @module features/issues/components
|
||||
*/
|
||||
|
||||
export { StatusBadge } from './StatusBadge';
|
||||
export { PriorityBadge } from './PriorityBadge';
|
||||
export { SyncStatusIndicator } from './SyncStatusIndicator';
|
||||
export { IssueFilters } from './IssueFilters';
|
||||
export { IssueTable } from './IssueTable';
|
||||
export { BulkActions } from './BulkActions';
|
||||
export { StatusWorkflow } from './StatusWorkflow';
|
||||
export { ActivityTimeline } from './ActivityTimeline';
|
||||
export { IssueDetailPanel } from './IssueDetailPanel';
|
||||
106
frontend/src/features/issues/constants.ts
Normal file
106
frontend/src/features/issues/constants.ts
Normal file
@@ -0,0 +1,106 @@
|
||||
/**
|
||||
* Issue Management Constants
|
||||
*
|
||||
* Configuration for status, priority, and workflow.
|
||||
*
|
||||
* @module features/issues/constants
|
||||
*/
|
||||
|
||||
import type {
|
||||
IssueStatus,
|
||||
IssuePriority,
|
||||
StatusConfig,
|
||||
PriorityConfig,
|
||||
StatusTransition,
|
||||
} from './types';
|
||||
|
||||
/**
|
||||
* Status configuration with labels and colors
|
||||
*/
|
||||
export const STATUS_CONFIG: Record<IssueStatus, StatusConfig> = {
|
||||
open: { label: 'Open', color: 'text-blue-500' },
|
||||
in_progress: { label: 'In Progress', color: 'text-yellow-500' },
|
||||
in_review: { label: 'In Review', color: 'text-purple-500' },
|
||||
blocked: { label: 'Blocked', color: 'text-red-500' },
|
||||
done: { label: 'Done', color: 'text-green-500' },
|
||||
closed: { label: 'Closed', color: 'text-muted-foreground' },
|
||||
};
|
||||
|
||||
/**
|
||||
* Priority configuration with labels and colors
|
||||
*/
|
||||
export const PRIORITY_CONFIG: Record<IssuePriority, PriorityConfig> = {
|
||||
high: { label: 'High', color: 'bg-red-100 text-red-800 dark:bg-red-900 dark:text-red-200' },
|
||||
medium: {
|
||||
label: 'Medium',
|
||||
color: 'bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200',
|
||||
},
|
||||
low: { label: 'Low', color: 'bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200' },
|
||||
};
|
||||
|
||||
/**
|
||||
* Status workflow transitions
|
||||
* Defines which status transitions are available from each status
|
||||
*/
|
||||
export const STATUS_TRANSITIONS: StatusTransition[] = [
|
||||
{ from: 'open', to: 'in_progress', label: 'Start Work' },
|
||||
{ from: 'in_progress', to: 'in_review', label: 'Submit for Review' },
|
||||
{ from: 'in_progress', to: 'blocked', label: 'Mark Blocked' },
|
||||
{ from: 'in_review', to: 'done', label: 'Mark Done' },
|
||||
{ from: 'in_review', to: 'in_progress', label: 'Request Changes' },
|
||||
{ from: 'blocked', to: 'in_progress', label: 'Unblock' },
|
||||
{ from: 'done', to: 'closed', label: 'Close Issue' },
|
||||
{ from: 'closed', to: 'open', label: 'Reopen' },
|
||||
];
|
||||
|
||||
/**
|
||||
* Get available transitions for a given status
|
||||
*/
|
||||
export function getAvailableTransitions(currentStatus: IssueStatus): StatusTransition[] {
|
||||
return STATUS_TRANSITIONS.filter((t) => t.from === currentStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get primary transition for a given status (the main workflow action)
|
||||
*/
|
||||
export function getPrimaryTransition(currentStatus: IssueStatus): StatusTransition | undefined {
|
||||
const transitions = getAvailableTransitions(currentStatus);
|
||||
return transitions[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* All possible statuses in workflow order
|
||||
*/
|
||||
export const STATUS_ORDER: IssueStatus[] = [
|
||||
'open',
|
||||
'in_progress',
|
||||
'in_review',
|
||||
'blocked',
|
||||
'done',
|
||||
'closed',
|
||||
];
|
||||
|
||||
/**
|
||||
* All possible priorities in order
|
||||
*/
|
||||
export const PRIORITY_ORDER: IssuePriority[] = ['high', 'medium', 'low'];
|
||||
|
||||
/**
|
||||
* Sync status configuration
|
||||
*/
|
||||
export const SYNC_STATUS_CONFIG = {
|
||||
synced: { label: 'Synced', color: 'text-green-500' },
|
||||
pending: { label: 'Syncing', color: 'text-yellow-500' },
|
||||
conflict: { label: 'Conflict', color: 'text-orange-500' },
|
||||
error: { label: 'Sync Error', color: 'text-red-500' },
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* Default page size for issue list
|
||||
*/
|
||||
export const DEFAULT_PAGE_SIZE = 25;
|
||||
|
||||
/**
|
||||
* Maximum issues for bulk actions
|
||||
*/
|
||||
export const MAX_BULK_SELECTION = 100;
|
||||
15
frontend/src/features/issues/hooks/index.ts
Normal file
15
frontend/src/features/issues/hooks/index.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
/**
|
||||
* Issue Management Hooks
|
||||
*
|
||||
* @module features/issues/hooks
|
||||
*/
|
||||
|
||||
export {
|
||||
useIssues,
|
||||
useIssue,
|
||||
useUpdateIssue,
|
||||
useUpdateIssueStatus,
|
||||
useBulkIssueAction,
|
||||
useSyncIssue,
|
||||
issueKeys,
|
||||
} from './useIssues';
|
||||
332
frontend/src/features/issues/hooks/useIssues.ts
Normal file
332
frontend/src/features/issues/hooks/useIssues.ts
Normal file
@@ -0,0 +1,332 @@
|
||||
/**
|
||||
* Issue Management React Query Hooks
|
||||
*
|
||||
* Hooks for fetching and mutating issues.
|
||||
* Uses TanStack Query for server state management.
|
||||
*
|
||||
* Note: Until backend API is implemented, these hooks use mock data.
|
||||
* The API integration points are marked for future implementation.
|
||||
*
|
||||
* @module features/issues/hooks/useIssues
|
||||
*/
|
||||
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import type {
|
||||
IssueSummary,
|
||||
IssueDetail,
|
||||
IssueFilters,
|
||||
IssueSort,
|
||||
IssueUpdateRequest,
|
||||
IssueBulkActionRequest,
|
||||
PaginatedIssuesResponse,
|
||||
} from '../types';
|
||||
import { mockIssues, mockIssueDetail } from '../mocks';
|
||||
|
||||
/**
|
||||
* Query keys for issues
|
||||
*/
|
||||
export const issueKeys = {
|
||||
all: ['issues'] as const,
|
||||
lists: () => [...issueKeys.all, 'list'] as const,
|
||||
list: (projectId: string, filters?: IssueFilters, sort?: IssueSort) =>
|
||||
[...issueKeys.lists(), projectId, filters, sort] as const,
|
||||
details: () => [...issueKeys.all, 'detail'] as const,
|
||||
detail: (issueId: string) => [...issueKeys.details(), issueId] as const,
|
||||
};
|
||||
|
||||
/**
|
||||
* Mock filtering and sorting logic
|
||||
* This simulates server-side filtering until API is ready
|
||||
*/
|
||||
function filterAndSortIssues(
|
||||
issues: IssueSummary[],
|
||||
filters?: IssueFilters,
|
||||
sort?: IssueSort
|
||||
): IssueSummary[] {
|
||||
let result = [...issues];
|
||||
|
||||
if (filters) {
|
||||
// Search filter
|
||||
if (filters.search) {
|
||||
const searchLower = filters.search.toLowerCase();
|
||||
result = result.filter(
|
||||
(issue) =>
|
||||
issue.title.toLowerCase().includes(searchLower) ||
|
||||
issue.description.toLowerCase().includes(searchLower) ||
|
||||
issue.number.toString().includes(searchLower)
|
||||
);
|
||||
}
|
||||
|
||||
// Status filter
|
||||
if (filters.status && filters.status !== 'all') {
|
||||
result = result.filter((issue) => issue.status === filters.status);
|
||||
}
|
||||
|
||||
// Priority filter
|
||||
if (filters.priority && filters.priority !== 'all') {
|
||||
result = result.filter((issue) => issue.priority === filters.priority);
|
||||
}
|
||||
|
||||
// Sprint filter
|
||||
if (filters.sprint && filters.sprint !== 'all') {
|
||||
if (filters.sprint === 'backlog') {
|
||||
result = result.filter((issue) => !issue.sprint);
|
||||
} else {
|
||||
result = result.filter((issue) => issue.sprint === filters.sprint);
|
||||
}
|
||||
}
|
||||
|
||||
// Assignee filter
|
||||
if (filters.assignee && filters.assignee !== 'all') {
|
||||
if (filters.assignee === 'unassigned') {
|
||||
result = result.filter((issue) => !issue.assignee);
|
||||
} else {
|
||||
result = result.filter((issue) => issue.assignee?.id === filters.assignee);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Sorting
|
||||
if (sort) {
|
||||
const direction = sort.direction === 'asc' ? 1 : -1;
|
||||
result.sort((a, b) => {
|
||||
switch (sort.field) {
|
||||
case 'number':
|
||||
return (a.number - b.number) * direction;
|
||||
case 'priority': {
|
||||
const priorityOrder = { high: 3, medium: 2, low: 1 };
|
||||
return (priorityOrder[a.priority] - priorityOrder[b.priority]) * direction;
|
||||
}
|
||||
case 'updated_at':
|
||||
return (new Date(a.updated_at).getTime() - new Date(b.updated_at).getTime()) * direction;
|
||||
case 'created_at':
|
||||
return (new Date(a.created_at).getTime() - new Date(b.created_at).getTime()) * direction;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to fetch paginated issues for a project
|
||||
*
|
||||
* @param projectId - Project ID
|
||||
* @param filters - Optional filters
|
||||
* @param sort - Optional sort configuration
|
||||
* @param page - Page number (1-based)
|
||||
* @param pageSize - Number of items per page
|
||||
*/
|
||||
export function useIssues(
|
||||
projectId: string,
|
||||
filters?: IssueFilters,
|
||||
sort?: IssueSort,
|
||||
page: number = 1,
|
||||
pageSize: number = 25
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: issueKeys.list(projectId, filters, sort),
|
||||
queryFn: async (): Promise<PaginatedIssuesResponse> => {
|
||||
// TODO: Replace with actual API call when backend is ready
|
||||
// const response = await getProjectIssues({
|
||||
// path: { project_id: projectId },
|
||||
// query: { ...filters, ...sort, page, page_size: pageSize },
|
||||
// });
|
||||
|
||||
// Simulate API delay
|
||||
await new Promise((resolve) => setTimeout(resolve, 300));
|
||||
|
||||
const filteredIssues = filterAndSortIssues(mockIssues, filters, sort);
|
||||
const start = (page - 1) * pageSize;
|
||||
const paginatedIssues = filteredIssues.slice(start, start + pageSize);
|
||||
|
||||
return {
|
||||
data: paginatedIssues,
|
||||
pagination: {
|
||||
total: filteredIssues.length,
|
||||
page,
|
||||
page_size: pageSize,
|
||||
total_pages: Math.ceil(filteredIssues.length / pageSize),
|
||||
has_next: start + pageSize < filteredIssues.length,
|
||||
has_prev: page > 1,
|
||||
},
|
||||
};
|
||||
},
|
||||
staleTime: 30000, // 30 seconds
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to fetch a single issue detail
|
||||
*
|
||||
* @param issueId - Issue ID
|
||||
*/
|
||||
export function useIssue(issueId: string) {
|
||||
return useQuery({
|
||||
queryKey: issueKeys.detail(issueId),
|
||||
queryFn: async (): Promise<IssueDetail> => {
|
||||
// TODO: Replace with actual API call when backend is ready
|
||||
// const response = await getIssue({
|
||||
// path: { issue_id: issueId },
|
||||
// });
|
||||
|
||||
// Simulate API delay
|
||||
await new Promise((resolve) => setTimeout(resolve, 200));
|
||||
|
||||
// Return mock detail for any issue ID
|
||||
return {
|
||||
...mockIssueDetail,
|
||||
id: issueId,
|
||||
};
|
||||
},
|
||||
staleTime: 30000,
|
||||
enabled: !!issueId,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to update an issue
|
||||
*/
|
||||
export function useUpdateIssue() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
issueId,
|
||||
data,
|
||||
}: {
|
||||
issueId: string;
|
||||
data: IssueUpdateRequest;
|
||||
}): Promise<IssueDetail> => {
|
||||
// TODO: Replace with actual API call when backend is ready
|
||||
// const response = await updateIssue({
|
||||
// path: { issue_id: issueId },
|
||||
// body: data,
|
||||
// });
|
||||
|
||||
// Simulate API delay
|
||||
await new Promise((resolve) => setTimeout(resolve, 300));
|
||||
|
||||
// Return updated mock data - only apply non-label fields from data
|
||||
return {
|
||||
...mockIssueDetail,
|
||||
id: issueId,
|
||||
title: data.title || mockIssueDetail.title,
|
||||
description: data.description || mockIssueDetail.description,
|
||||
status: data.status || mockIssueDetail.status,
|
||||
priority: data.priority || mockIssueDetail.priority,
|
||||
sprint: data.sprint !== undefined ? data.sprint : mockIssueDetail.sprint,
|
||||
due_date: data.due_date !== undefined ? data.due_date : mockIssueDetail.due_date,
|
||||
};
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
// Invalidate and update cache
|
||||
queryClient.invalidateQueries({ queryKey: issueKeys.lists() });
|
||||
queryClient.setQueryData(issueKeys.detail(data.id), data);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to update issue status (optimistic update)
|
||||
*/
|
||||
export function useUpdateIssueStatus() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({
|
||||
issueId,
|
||||
status,
|
||||
}: {
|
||||
issueId: string;
|
||||
status: IssueUpdateRequest['status'];
|
||||
}): Promise<IssueDetail> => {
|
||||
// TODO: Replace with actual API call
|
||||
await new Promise((resolve) => setTimeout(resolve, 300));
|
||||
|
||||
return {
|
||||
...mockIssueDetail,
|
||||
id: issueId,
|
||||
status: status || mockIssueDetail.status,
|
||||
};
|
||||
},
|
||||
onMutate: async ({ issueId, status }) => {
|
||||
// Cancel outgoing refetches
|
||||
await queryClient.cancelQueries({ queryKey: issueKeys.detail(issueId) });
|
||||
|
||||
// Snapshot previous value
|
||||
const previousIssue = queryClient.getQueryData<IssueDetail>(issueKeys.detail(issueId));
|
||||
|
||||
// Optimistically update
|
||||
if (previousIssue && status) {
|
||||
queryClient.setQueryData(issueKeys.detail(issueId), {
|
||||
...previousIssue,
|
||||
status,
|
||||
});
|
||||
}
|
||||
|
||||
return { previousIssue };
|
||||
},
|
||||
onError: (_err, { issueId }, context) => {
|
||||
// Rollback on error
|
||||
if (context?.previousIssue) {
|
||||
queryClient.setQueryData(issueKeys.detail(issueId), context.previousIssue);
|
||||
}
|
||||
},
|
||||
onSettled: () => {
|
||||
// Invalidate lists to refetch
|
||||
queryClient.invalidateQueries({ queryKey: issueKeys.lists() });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook for bulk actions on issues
|
||||
*/
|
||||
export function useBulkIssueAction() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (request: IssueBulkActionRequest): Promise<{ affected_count: number }> => {
|
||||
// TODO: Replace with actual API call
|
||||
await new Promise((resolve) => setTimeout(resolve, 500));
|
||||
|
||||
return { affected_count: request.issue_ids.length };
|
||||
},
|
||||
onSuccess: () => {
|
||||
// Invalidate all issue queries
|
||||
queryClient.invalidateQueries({ queryKey: issueKeys.all });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Hook to sync an issue with external tracker
|
||||
*/
|
||||
export function useSyncIssue() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async ({ issueId }: { issueId: string }): Promise<IssueSummary> => {
|
||||
// TODO: Replace with actual API call
|
||||
// const response = await syncIssue({
|
||||
// path: { issue_id: issueId },
|
||||
// body: { direction: 'bidirectional' },
|
||||
// });
|
||||
|
||||
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||
|
||||
const issue = mockIssues.find((i) => i.id === issueId);
|
||||
return {
|
||||
...(issue || mockIssues[0]),
|
||||
sync_status: 'synced',
|
||||
};
|
||||
},
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: issueKeys.lists() });
|
||||
queryClient.invalidateQueries({ queryKey: issueKeys.detail(data.id) });
|
||||
},
|
||||
});
|
||||
}
|
||||
70
frontend/src/features/issues/index.ts
Normal file
70
frontend/src/features/issues/index.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* Issue Management Feature
|
||||
*
|
||||
* Complete issue tracking and management for Syndarix projects.
|
||||
*
|
||||
* @module features/issues
|
||||
*/
|
||||
|
||||
// Components
|
||||
export {
|
||||
StatusBadge,
|
||||
PriorityBadge,
|
||||
SyncStatusIndicator,
|
||||
IssueFilters,
|
||||
IssueTable,
|
||||
BulkActions,
|
||||
StatusWorkflow,
|
||||
ActivityTimeline,
|
||||
IssueDetailPanel,
|
||||
} from './components';
|
||||
|
||||
// Hooks
|
||||
export {
|
||||
useIssues,
|
||||
useIssue,
|
||||
useUpdateIssue,
|
||||
useUpdateIssueStatus,
|
||||
useBulkIssueAction,
|
||||
useSyncIssue,
|
||||
issueKeys,
|
||||
} from './hooks';
|
||||
|
||||
// Types - use explicit names to avoid collision with component IssueFilters
|
||||
export type {
|
||||
IssueStatus,
|
||||
IssuePriority,
|
||||
SyncStatus,
|
||||
ActorType,
|
||||
IssueAssignee,
|
||||
IssueLabel,
|
||||
IssueActivity,
|
||||
IssueSummary,
|
||||
IssueDetail,
|
||||
IssueFilters as IssueFiltersType,
|
||||
IssueSortField,
|
||||
IssueSortDirection,
|
||||
IssueSort,
|
||||
IssueBulkAction,
|
||||
IssueBulkActionRequest,
|
||||
IssueUpdateRequest,
|
||||
IssueSyncRequest,
|
||||
StatusTransition,
|
||||
StatusConfig,
|
||||
PriorityConfig,
|
||||
PaginatedIssuesResponse,
|
||||
} from './types';
|
||||
|
||||
// Constants
|
||||
export {
|
||||
STATUS_CONFIG,
|
||||
PRIORITY_CONFIG,
|
||||
STATUS_TRANSITIONS,
|
||||
getAvailableTransitions,
|
||||
getPrimaryTransition,
|
||||
STATUS_ORDER,
|
||||
PRIORITY_ORDER,
|
||||
SYNC_STATUS_CONFIG,
|
||||
DEFAULT_PAGE_SIZE,
|
||||
MAX_BULK_SELECTION,
|
||||
} from './constants';
|
||||
252
frontend/src/features/issues/mocks.ts
Normal file
252
frontend/src/features/issues/mocks.ts
Normal file
@@ -0,0 +1,252 @@
|
||||
/**
|
||||
* Issue Management Mock Data
|
||||
*
|
||||
* Mock data for development and testing.
|
||||
* This will be removed once the backend API is implemented.
|
||||
*
|
||||
* @module features/issues/mocks
|
||||
*/
|
||||
|
||||
import type { IssueSummary, IssueDetail } from './types';
|
||||
|
||||
/**
|
||||
* Mock issues for list view
|
||||
*/
|
||||
export const mockIssues: IssueSummary[] = [
|
||||
{
|
||||
id: 'ISS-001',
|
||||
number: 42,
|
||||
title: 'Implement user authentication flow',
|
||||
description:
|
||||
'Create complete authentication flow with login, register, and password reset.',
|
||||
status: 'in_progress',
|
||||
priority: 'high',
|
||||
labels: ['feature', 'auth', 'backend'],
|
||||
sprint: 'Sprint 3',
|
||||
assignee: { id: 'agent-be', name: 'Backend Engineer', type: 'agent' },
|
||||
created_at: '2025-01-15T10:30:00Z',
|
||||
updated_at: '2025-01-20T14:22:00Z',
|
||||
sync_status: 'synced',
|
||||
},
|
||||
{
|
||||
id: 'ISS-002',
|
||||
number: 43,
|
||||
title: 'Design product catalog component',
|
||||
description: 'Create reusable product card and catalog grid components.',
|
||||
status: 'in_review',
|
||||
priority: 'medium',
|
||||
labels: ['feature', 'frontend', 'ui'],
|
||||
sprint: 'Sprint 3',
|
||||
assignee: { id: 'agent-fe', name: 'Frontend Engineer', type: 'agent' },
|
||||
created_at: '2025-01-16T09:00:00Z',
|
||||
updated_at: '2025-01-20T15:30:00Z',
|
||||
sync_status: 'synced',
|
||||
},
|
||||
{
|
||||
id: 'ISS-003',
|
||||
number: 44,
|
||||
title: 'Fix cart total calculation bug',
|
||||
description: 'Cart total shows incorrect amount when discount is applied.',
|
||||
status: 'blocked',
|
||||
priority: 'high',
|
||||
labels: ['bug', 'critical', 'backend'],
|
||||
sprint: 'Sprint 3',
|
||||
assignee: { id: 'agent-be', name: 'Backend Engineer', type: 'agent' },
|
||||
created_at: '2025-01-17T11:00:00Z',
|
||||
updated_at: '2025-01-20T13:00:00Z',
|
||||
sync_status: 'pending',
|
||||
blocked_by: 'Waiting for discount API specification',
|
||||
},
|
||||
{
|
||||
id: 'ISS-004',
|
||||
number: 45,
|
||||
title: 'Add product search functionality',
|
||||
description: 'Implement full-text search with filters for the product catalog.',
|
||||
status: 'open',
|
||||
priority: 'medium',
|
||||
labels: ['feature', 'search', 'backend'],
|
||||
sprint: 'Sprint 3',
|
||||
assignee: null,
|
||||
created_at: '2025-01-18T14:00:00Z',
|
||||
updated_at: '2025-01-18T14:00:00Z',
|
||||
sync_status: 'synced',
|
||||
},
|
||||
{
|
||||
id: 'ISS-005',
|
||||
number: 46,
|
||||
title: 'Optimize database queries for product listing',
|
||||
description: 'Performance optimization for product queries with pagination.',
|
||||
status: 'done',
|
||||
priority: 'low',
|
||||
labels: ['performance', 'backend', 'database'],
|
||||
sprint: 'Sprint 2',
|
||||
assignee: { id: 'agent-be', name: 'Backend Engineer', type: 'agent' },
|
||||
created_at: '2025-01-10T09:00:00Z',
|
||||
updated_at: '2025-01-18T10:00:00Z',
|
||||
sync_status: 'synced',
|
||||
},
|
||||
{
|
||||
id: 'ISS-006',
|
||||
number: 47,
|
||||
title: 'Create checkout page wireframes',
|
||||
description: 'Design wireframes for the checkout flow including payment selection.',
|
||||
status: 'done',
|
||||
priority: 'high',
|
||||
labels: ['design', 'checkout', 'ui'],
|
||||
sprint: 'Sprint 2',
|
||||
assignee: { id: 'agent-po', name: 'Product Owner', type: 'agent' },
|
||||
created_at: '2025-01-08T08:00:00Z',
|
||||
updated_at: '2025-01-15T16:00:00Z',
|
||||
sync_status: 'synced',
|
||||
},
|
||||
{
|
||||
id: 'ISS-007',
|
||||
number: 48,
|
||||
title: 'Implement responsive navigation',
|
||||
description: 'Create mobile-friendly navigation with hamburger menu.',
|
||||
status: 'open',
|
||||
priority: 'medium',
|
||||
labels: ['feature', 'frontend', 'responsive'],
|
||||
sprint: null,
|
||||
assignee: null,
|
||||
created_at: '2025-01-19T10:00:00Z',
|
||||
updated_at: '2025-01-19T10:00:00Z',
|
||||
sync_status: 'synced',
|
||||
},
|
||||
{
|
||||
id: 'ISS-008',
|
||||
number: 49,
|
||||
title: 'Set up E2E test framework',
|
||||
description: 'Configure Playwright for end-to-end testing.',
|
||||
status: 'in_progress',
|
||||
priority: 'medium',
|
||||
labels: ['testing', 'infrastructure'],
|
||||
sprint: 'Sprint 3',
|
||||
assignee: { id: 'agent-qa', name: 'QA Engineer', type: 'agent' },
|
||||
created_at: '2025-01-20T08:00:00Z',
|
||||
updated_at: '2025-01-20T12:00:00Z',
|
||||
sync_status: 'synced',
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Mock issue detail for detail view
|
||||
*/
|
||||
export const mockIssueDetail: IssueDetail = {
|
||||
id: 'ISS-001',
|
||||
number: 42,
|
||||
title: 'Implement user authentication flow',
|
||||
description: `## Overview
|
||||
Create a complete authentication flow for the e-commerce platform.
|
||||
|
||||
## Requirements
|
||||
- Login with email/password
|
||||
- Registration with email verification
|
||||
- Password reset functionality
|
||||
- OAuth support (Google, GitHub)
|
||||
- JWT token management
|
||||
- Session handling
|
||||
|
||||
## Acceptance Criteria
|
||||
- [ ] Users can register with email and password
|
||||
- [ ] Users receive email verification link
|
||||
- [ ] Users can log in with verified email
|
||||
- [ ] Password reset email is sent within 30 seconds
|
||||
- [ ] OAuth buttons redirect properly
|
||||
- [x] JWT tokens are stored securely
|
||||
- [x] Tokens refresh automatically
|
||||
|
||||
## Technical Notes
|
||||
- Use FastAPI security utilities
|
||||
- Store sessions in Redis
|
||||
- Follow OWASP guidelines`,
|
||||
status: 'in_progress',
|
||||
priority: 'high',
|
||||
labels: [
|
||||
{ id: 'lbl-1', name: 'feature', color: '#3b82f6' },
|
||||
{ id: 'lbl-2', name: 'auth', color: '#8b5cf6' },
|
||||
{ id: 'lbl-3', name: 'backend', color: '#10b981' },
|
||||
{ id: 'lbl-4', name: 'security', color: '#ef4444' },
|
||||
],
|
||||
sprint: 'Sprint 3',
|
||||
milestone: 'MVP Launch',
|
||||
story_points: 8,
|
||||
assignee: { id: 'agent-be', name: 'Backend Engineer', type: 'agent', avatar: 'BE' },
|
||||
reporter: { id: 'agent-po', name: 'Product Owner', type: 'agent', avatar: 'PO' },
|
||||
created_at: '2025-01-15T10:30:00Z',
|
||||
updated_at: '2025-01-20T14:22:00Z',
|
||||
due_date: '2025-02-01',
|
||||
sync_status: 'synced',
|
||||
external_url: 'https://gitea.example.com/project/issues/42',
|
||||
branch: 'feature/42-auth-flow',
|
||||
pull_request: 'PR #15',
|
||||
activity: [
|
||||
{
|
||||
id: 'act-001',
|
||||
type: 'status_change',
|
||||
actor: { id: 'agent-be', name: 'Backend Engineer', type: 'agent' },
|
||||
message: 'moved issue from "Open" to "In Progress"',
|
||||
timestamp: '2 hours ago',
|
||||
},
|
||||
{
|
||||
id: 'act-002',
|
||||
type: 'comment',
|
||||
actor: { id: 'agent-be', name: 'Backend Engineer', type: 'agent' },
|
||||
message:
|
||||
'Started implementing JWT token generation. Using HS256 algorithm as discussed in architecture meeting.',
|
||||
timestamp: '3 hours ago',
|
||||
},
|
||||
{
|
||||
id: 'act-003',
|
||||
type: 'assignment',
|
||||
actor: { id: 'agent-po', name: 'Product Owner', type: 'agent' },
|
||||
message: 'assigned this issue to Backend Engineer',
|
||||
timestamp: '1 day ago',
|
||||
},
|
||||
{
|
||||
id: 'act-004',
|
||||
type: 'label',
|
||||
actor: { id: 'agent-po', name: 'Product Owner', type: 'agent' },
|
||||
message: 'added labels: security, backend',
|
||||
timestamp: '1 day ago',
|
||||
},
|
||||
{
|
||||
id: 'act-005',
|
||||
type: 'created',
|
||||
actor: { id: 'agent-po', name: 'Product Owner', type: 'agent' },
|
||||
message: 'created this issue',
|
||||
timestamp: '5 days ago',
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
/**
|
||||
* Mock sprints for filter options
|
||||
*/
|
||||
export const mockSprints = ['Sprint 3', 'Sprint 2', 'Sprint 1'];
|
||||
|
||||
/**
|
||||
* Mock assignees for filter options
|
||||
*/
|
||||
export const mockAssignees = [
|
||||
{ id: 'agent-be', name: 'Backend Engineer', type: 'agent' as const },
|
||||
{ id: 'agent-fe', name: 'Frontend Engineer', type: 'agent' as const },
|
||||
{ id: 'agent-qa', name: 'QA Engineer', type: 'agent' as const },
|
||||
{ id: 'agent-po', name: 'Product Owner', type: 'agent' as const },
|
||||
];
|
||||
|
||||
/**
|
||||
* Mock labels for filter options
|
||||
*/
|
||||
export const mockLabels = [
|
||||
'feature',
|
||||
'bug',
|
||||
'backend',
|
||||
'frontend',
|
||||
'ui',
|
||||
'auth',
|
||||
'testing',
|
||||
'performance',
|
||||
'design',
|
||||
'infrastructure',
|
||||
];
|
||||
192
frontend/src/features/issues/types/index.ts
Normal file
192
frontend/src/features/issues/types/index.ts
Normal file
@@ -0,0 +1,192 @@
|
||||
/**
|
||||
* Issue Management Types
|
||||
*
|
||||
* Type definitions for the issue tracking feature.
|
||||
* These types align with the backend API schema for issues.
|
||||
*
|
||||
* @module features/issues/types
|
||||
*/
|
||||
|
||||
/**
|
||||
* Issue status values
|
||||
*/
|
||||
export type IssueStatus = 'open' | 'in_progress' | 'in_review' | 'blocked' | 'done' | 'closed';
|
||||
|
||||
/**
|
||||
* Issue priority values
|
||||
*/
|
||||
export type IssuePriority = 'high' | 'medium' | 'low';
|
||||
|
||||
/**
|
||||
* Sync status with external trackers
|
||||
*/
|
||||
export type SyncStatus = 'synced' | 'pending' | 'conflict' | 'error';
|
||||
|
||||
/**
|
||||
* Actor type for issue activity
|
||||
*/
|
||||
export type ActorType = 'agent' | 'human';
|
||||
|
||||
/**
|
||||
* Issue assignee
|
||||
*/
|
||||
export interface IssueAssignee {
|
||||
id: string;
|
||||
name: string;
|
||||
type: ActorType;
|
||||
avatar?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue label
|
||||
*/
|
||||
export interface IssueLabel {
|
||||
id: string;
|
||||
name: string;
|
||||
color?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue activity item
|
||||
*/
|
||||
export interface IssueActivity {
|
||||
id: string;
|
||||
type: 'status_change' | 'comment' | 'assignment' | 'label' | 'created' | 'branch' | 'pr';
|
||||
actor: IssueAssignee;
|
||||
message: string;
|
||||
timestamp: string;
|
||||
metadata?: Record<string, unknown>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue summary for list views
|
||||
*/
|
||||
export interface IssueSummary {
|
||||
id: string;
|
||||
number: number;
|
||||
title: string;
|
||||
description: string;
|
||||
status: IssueStatus;
|
||||
priority: IssuePriority;
|
||||
labels: string[];
|
||||
sprint: string | null;
|
||||
assignee: IssueAssignee | null;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
sync_status: SyncStatus;
|
||||
blocked_by?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Full issue detail
|
||||
*/
|
||||
export interface IssueDetail extends Omit<IssueSummary, 'labels'> {
|
||||
labels: IssueLabel[];
|
||||
milestone: string | null;
|
||||
story_points: number | null;
|
||||
reporter: IssueAssignee;
|
||||
due_date: string | null;
|
||||
external_url: string | null;
|
||||
branch: string | null;
|
||||
pull_request: string | null;
|
||||
activity: IssueActivity[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue filters
|
||||
*/
|
||||
export interface IssueFilters {
|
||||
search?: string;
|
||||
status?: IssueStatus | 'all';
|
||||
priority?: IssuePriority | 'all';
|
||||
sprint?: string | 'all' | 'backlog';
|
||||
assignee?: string | 'all' | 'unassigned';
|
||||
labels?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue sort options
|
||||
*/
|
||||
export type IssueSortField = 'number' | 'priority' | 'updated_at' | 'created_at' | 'status';
|
||||
export type IssueSortDirection = 'asc' | 'desc';
|
||||
|
||||
export interface IssueSort {
|
||||
field: IssueSortField;
|
||||
direction: IssueSortDirection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bulk action types
|
||||
*/
|
||||
export type IssueBulkAction = 'change_status' | 'assign' | 'add_labels' | 'delete';
|
||||
|
||||
export interface IssueBulkActionRequest {
|
||||
action: IssueBulkAction;
|
||||
issue_ids: string[];
|
||||
payload?: {
|
||||
status?: IssueStatus;
|
||||
assignee_id?: string;
|
||||
labels?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue update request
|
||||
*/
|
||||
export interface IssueUpdateRequest {
|
||||
title?: string;
|
||||
description?: string;
|
||||
status?: IssueStatus;
|
||||
priority?: IssuePriority;
|
||||
assignee_id?: string | null;
|
||||
labels?: string[];
|
||||
sprint?: string | null;
|
||||
due_date?: string | null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Issue sync request
|
||||
*/
|
||||
export interface IssueSyncRequest {
|
||||
direction?: 'push' | 'pull' | 'bidirectional';
|
||||
}
|
||||
|
||||
/**
|
||||
* Status workflow transition
|
||||
*/
|
||||
export interface StatusTransition {
|
||||
from: IssueStatus;
|
||||
to: IssueStatus;
|
||||
label: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Status configuration
|
||||
*/
|
||||
export interface StatusConfig {
|
||||
label: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Priority configuration
|
||||
*/
|
||||
export interface PriorityConfig {
|
||||
label: string;
|
||||
color: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Paginated issues response
|
||||
*/
|
||||
export interface PaginatedIssuesResponse {
|
||||
data: IssueSummary[];
|
||||
pagination: {
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
total_pages: number;
|
||||
has_next: boolean;
|
||||
has_prev: boolean;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* PriorityBadge Component Tests
|
||||
*/
|
||||
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { PriorityBadge } from '@/features/issues/components/PriorityBadge';
|
||||
import type { IssuePriority } from '@/features/issues/types';
|
||||
|
||||
describe('PriorityBadge', () => {
|
||||
const priorities: IssuePriority[] = ['high', 'medium', 'low'];
|
||||
|
||||
it.each(priorities)('renders %s priority correctly', (priority) => {
|
||||
render(<PriorityBadge priority={priority} />);
|
||||
|
||||
// The priority should be displayed as capitalized
|
||||
const capitalizedPriority = priority.charAt(0).toUpperCase() + priority.slice(1);
|
||||
expect(screen.getByText(capitalizedPriority)).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('applies custom className', () => {
|
||||
render(<PriorityBadge priority="high" className="custom-class" />);
|
||||
|
||||
const badge = screen.getByText('High');
|
||||
expect(badge).toHaveClass('custom-class');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,49 @@
|
||||
/**
|
||||
* StatusBadge Component Tests
|
||||
*/
|
||||
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { StatusBadge } from '@/features/issues/components/StatusBadge';
|
||||
import type { IssueStatus } from '@/features/issues/types';
|
||||
|
||||
const statusLabels: Record<IssueStatus, string> = {
|
||||
open: 'Open',
|
||||
in_progress: 'In Progress',
|
||||
in_review: 'In Review',
|
||||
blocked: 'Blocked',
|
||||
done: 'Done',
|
||||
closed: 'Closed',
|
||||
};
|
||||
|
||||
describe('StatusBadge', () => {
|
||||
const statuses: IssueStatus[] = ['open', 'in_progress', 'in_review', 'blocked', 'done', 'closed'];
|
||||
|
||||
it.each(statuses)('renders %s status correctly', (status) => {
|
||||
render(<StatusBadge status={status} />);
|
||||
|
||||
// Check that the status text is present - use getAllByText since we have both visible and sr-only
|
||||
const elements = screen.getAllByText(statusLabels[status]);
|
||||
expect(elements.length).toBeGreaterThanOrEqual(1);
|
||||
});
|
||||
|
||||
it('hides label when showLabel is false', () => {
|
||||
render(<StatusBadge status="open" showLabel={false} />);
|
||||
|
||||
// The sr-only text should still be present
|
||||
expect(screen.getByText('Open')).toHaveClass('sr-only');
|
||||
});
|
||||
|
||||
it('applies custom className', () => {
|
||||
const { container } = render(<StatusBadge status="open" className="custom-class" />);
|
||||
|
||||
const wrapper = container.firstChild;
|
||||
expect(wrapper).toHaveClass('custom-class');
|
||||
});
|
||||
|
||||
it('renders with accessible label', () => {
|
||||
render(<StatusBadge status="open" showLabel={false} />);
|
||||
|
||||
// Should have sr-only text for screen readers
|
||||
expect(screen.getByText('Open')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,45 @@
|
||||
/**
|
||||
* SyncStatusIndicator Component Tests
|
||||
*/
|
||||
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { SyncStatusIndicator } from '@/features/issues/components/SyncStatusIndicator';
|
||||
import type { SyncStatus } from '@/features/issues/types';
|
||||
|
||||
describe('SyncStatusIndicator', () => {
|
||||
const statuses: SyncStatus[] = ['synced', 'pending', 'conflict', 'error'];
|
||||
|
||||
it.each(statuses)('renders %s status correctly', (status) => {
|
||||
render(<SyncStatusIndicator status={status} />);
|
||||
|
||||
// Should have accessible label containing "Sync status"
|
||||
const element = screen.getByRole('status');
|
||||
expect(element).toHaveAttribute('aria-label', expect.stringContaining('Sync status'));
|
||||
});
|
||||
|
||||
it('shows label when showLabel is true', () => {
|
||||
render(<SyncStatusIndicator status="synced" showLabel />);
|
||||
|
||||
expect(screen.getByText('Synced')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('hides label by default', () => {
|
||||
render(<SyncStatusIndicator status="synced" />);
|
||||
|
||||
expect(screen.queryByText('Synced')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('applies custom className', () => {
|
||||
render(<SyncStatusIndicator status="synced" className="custom-class" />);
|
||||
|
||||
const element = screen.getByRole('status');
|
||||
expect(element).toHaveClass('custom-class');
|
||||
});
|
||||
|
||||
it('shows spinning icon for pending status', () => {
|
||||
const { container } = render(<SyncStatusIndicator status="pending" />);
|
||||
|
||||
const icon = container.querySelector('svg');
|
||||
expect(icon).toHaveClass('animate-spin');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user