import type { LabelRow, PatchRow, RepositoryRow } from "../../db/index.ts"; import { formatDate } from "../../lib/formatDate.ts"; import { labelTextColor } from "../../lib/labelColor.ts"; import { displayName } from "../../lib/users.ts"; import type { SessionUser } from "../../middleware/session.ts"; import { Avatar } from "../Avatar.tsx"; import { Layout } from "../layout.tsx"; import { Pagination, type PaginationInfo } from "../Pagination.tsx"; import { RepoHeader } from "../repos/RepoHeader.tsx"; import { RepoNav } from "../repos/RepoNav.tsx"; interface PatchListProps { user: SessionUser | null; repo: RepositoryRow; patches: (PatchRow & { author_username: string; author_avatar_version: number | null; })[]; status: string; counts: Record; pagination: PaginationInfo; repoLabels: LabelRow[]; selectedLabelIds: number[]; labelsByPatchId: Map; } export function PatchList({ user, repo, patches, status, counts, pagination, repoLabels, selectedLabelIds, labelsByPatchId, }: PatchListProps) { const labelsParam = selectedLabelIds.length > 0 ? `&labels=${selectedLabelIds.map(String).join(",")}` : ""; return (
{repoLabels.length > 0 && (
Filter by label {selectedLabelIds.length > 0 && ( {selectedLabelIds.length} )}
{repoLabels.map((label) => ( ))}
Clear
)} {!!user && ( Upload patch )}
{patches.length === 0 ? (

No {status} patches.

) : (
    {patches.map((patch) => { const labels = labelsByPatchId.get(patch.id) ?? []; const unsafeAuthor = displayName( patch.author_username, ); return (
  • {patch.title} #{patch.number}
    {labels.length > 0 && (
    {labels.map((label) => ( {label.name} ))}
    )}
    by {unsafeAuthor}
  • ); })}
)}
); }