import { THEME_CSS, escapeHtml, escapeAttr } from "../render/layout"; import { BUILD_ID } from "../build"; import { projectSettingsTabsHTML } from "./projectUpstreams"; import { listLabels, type ProjectRow, type UserRow, type LabelRow } from "../store"; interface Flash { kind: "ok" | "err"; msg: string; } const PALETTE = [ "#888888", "#e11d48", "#db2777", "#9333ea", "#4f46e5", "#2563eb", "#0891b2", "#0d9488", "#16a34a", "#ca8a04", "#d97706", "#92400e", ]; function colorDot(c: string): string { return ``; } function labelRowHtml(l: LabelRow, owner: string, repo: string): string { const base = `/${encodeURIComponent(owner)}/${encodeURIComponent(repo)}/settings/labels/${l.id}`; const exclusiveBadge = l.exclusive === 1 ? `互斥` : ""; const archivedBadge = l.is_archived === 1 ? `已归档` : ""; return ` ${colorDot(l.color)}${escapeHtml(l.name)} ${exclusiveBadge}${archivedBadge} ${escapeHtml(l.description || "—")}
`; } export async function buildProjectLabelsPage( _viewer: UserRow, project: ProjectRow, flash: Flash | null, ): Promise { const labels = await listLabels(project.id, true); const rowsHtml = labels.length ? `${labels.map((l) => labelRowHtml(l, project.owner, project.name)).join("")}
标签描述操作
` : `
该项目还没有标签。在下方创建。
`; const flashHtml = flash ? `
${escapeHtml(flash.msg)}
` : ""; const createAction = `/${encodeURIComponent(project.owner)}/${encodeURIComponent(project.name)}/settings/labels/add`; const paletteHtml = PALETTE.map((c) => ``).join(""); return ` 标签 · ${escapeHtml(project.owner)}/${escapeHtml(project.name)}
🏷️ ${escapeHtml(project.owner)}/${escapeHtml(project.name)} · 标签

${escapeHtml(project.owner)}/${escapeHtml(project.name)} · 标签

${projectSettingsTabsHTML(project.owner, project.name, "labels")} ${flashHtml}

已有标签(${labels.length})

${rowsHtml}

新建标签

${paletteHtml}
名称含 / 时,/ 前的部分为 scope。同一 scope 下的互斥标签,一个 issue 只能贴一个。

编辑标签

`; }