mirror of
https://github.com/hex248/sprint.git
synced 2026-02-08 02:33:01 +00:00
column configuration
This commit is contained in:
@@ -1,25 +1,45 @@
|
||||
import type { IssueRecord } from "@issue/shared";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
|
||||
export function IssuesTable({ issues }: { issues: IssueRecord[] }) {
|
||||
export function IssuesTable({
|
||||
issues,
|
||||
columns = {},
|
||||
}: {
|
||||
issues: IssueRecord[];
|
||||
columns?: { id?: boolean; title?: boolean; description?: boolean; assignee?: boolean };
|
||||
}) {
|
||||
return (
|
||||
<Table>
|
||||
<TableHeader>
|
||||
<TableRow>
|
||||
<TableHead>ID</TableHead>
|
||||
<TableHead>Title</TableHead>
|
||||
<TableHead>Description</TableHead>
|
||||
{(columns.id == null || columns.id === true) && (
|
||||
<TableHead className="w-[50px] border-r">ID</TableHead>
|
||||
)}
|
||||
{(columns.title == null || columns.title === true) && <TableHead>Title</TableHead>}
|
||||
{(columns.description == null || columns.description === true) && (
|
||||
<TableHead>Description</TableHead>
|
||||
)}
|
||||
{/* below is kept blank to fill the space, used as the "Assignee" column */}
|
||||
<TableHead></TableHead>
|
||||
{(columns.assignee == null || columns.assignee === true) && <TableHead></TableHead>}
|
||||
</TableRow>
|
||||
</TableHeader>
|
||||
<TableBody>
|
||||
{issues.map((issue) => (
|
||||
<TableRow key={issue.id}>
|
||||
<TableCell className="font-medium">{issue.id}</TableCell>
|
||||
<TableCell>{issue.title}</TableCell>
|
||||
<TableCell>{issue.description}</TableCell>
|
||||
<TableCell>?</TableCell>
|
||||
<TableRow key={issue.id} className="cursor-pointer">
|
||||
{(columns.id == null || columns.id === true) && (
|
||||
<TableCell className="font-medium border-r">
|
||||
{String(issue.id).padStart(3, "0")}
|
||||
</TableCell>
|
||||
)}
|
||||
{(columns.title == null || columns.title === true) && (
|
||||
<TableCell>{issue.title}</TableCell>
|
||||
)}
|
||||
{(columns.description == null || columns.description === true) && (
|
||||
<TableCell className="overflow-hide">{issue.description}</TableCell>
|
||||
)}
|
||||
{(columns.assignee == null || columns.assignee === true) && (
|
||||
<TableCell className={"text-right"}>?</TableCell>
|
||||
)}
|
||||
</TableRow>
|
||||
))}
|
||||
</TableBody>
|
||||
|
||||
Reference in New Issue
Block a user