import config from "../../config.ts"; import type { IssueCommentRow, IssueRow, LabelRow, RepositoryRow, } from "../../db/index.ts"; import { displayName } from "../../lib/users.ts"; import type { SessionUser } from "../../middleware/session.ts"; import { Avatar } from "../Avatar.tsx"; import { CommentThread } from "../CommentThread.tsx"; import { DateWithEdited } from "../DateWithEdited.tsx"; import { EditableTitle } from "../EditableTitle.tsx"; import { LabelBadges } from "../LabelBadges.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 baseUrl = `/${repo.name}/issues/${issue.number}`; const canEditIssue = user != null && (user.isAdmin || (user.id === issue.author_id && issue.status === "open")); const canManageLabels = user != null && (user.isAdmin || (repo.allow_user_labels === 1 && user.id === issue.author_id)); return (
#{issue.number} {issue.status} {canEditIssue && (
{user?.isAdmin && issue.status === "open" && (
)} {user?.isAdmin && (
)}
Delete
Permanently delete this issue?
)}
{displayName(issue.author_username)}
{canEditIssue && (
Edit Stop editing
)}
{canEditIssue && (
)}
{bodyHtml || ( No description provided. )}
); }