import type { IssueCommentRow, IssueRow, LabelRow, RepositoryRow, } from "../../db/index.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 { DateWithEdited } from "../DateWithEdited.tsx"; import { Layout } from "../layout.tsx"; import { ReactionBar, type ReactionCount } from "../ReactionBar.tsx"; import { RepoHeader } from "../repos/RepoHeader.tsx"; import { RepoNav } from "../repos/RepoNav.tsx"; interface IssueDetailProps { user: SessionUser | null; repo: RepositoryRow; issue: IssueRow & { author_username: string; author_avatar_version: number | null; }; bodyHtml: string; comments: (IssueCommentRow & { author_username: string; author_avatar_version: number | null; bodyHtml: string; })[]; reactions: ReactionCount[]; commentReactions: Map; issueLabels: LabelRow[]; repoLabels: LabelRow[]; } export function IssueDetail({ user, repo, issue, bodyHtml, comments, reactions, commentReactions, issueLabels, repoLabels, }: IssueDetailProps) { const canEditIssue = user != null && (user.isAdmin || (user.id === issue.author_id && issue.status === "open")); const canEditComment = (c: IssueCommentRow) => user != null && (user.isAdmin || (user.id === c.author_id && issue.status === "open")); return (
#{issue.number}

{issue.title}

{canEditIssue && ( <>
Edit title
)}
{issue.status} {canEditIssue && (
{user?.isAdmin && issue.status === "open" && (
)} {user?.isAdmin && (
)}
Delete
Permanently delete this issue?
)}
{(issueLabels.length > 0 || user?.isAdmin) && (
{issueLabels.map((label) => ( {label.name} {user?.isAdmin && (
)}
))} {user?.isAdmin && repoLabels.filter( (l) => !issueLabels.some((il) => il.id === l.id), ).length > 0 && (
)}
)}
{displayName(issue.author_username)}
{canEditIssue && (
Edit Stop editing
)}
{canEditIssue && (
)}
{bodyHtml || ( No description provided. )}
{comments.map((comment) => (
{displayName(comment.author_username)}
{canEditComment(comment) && (
Edit Stop editing
)}
{canEditComment(comment) && (
)}
{comment.bodyHtml}
))} {user && (

Add a comment