// Project page tabs «Код», «Спеки», «PR» and the epics block of «⋯ Настройки проекта» (PEP-66).
import { Archive, ExternalLink, GitBranch, GitPullRequest } from "lucide-react";
import type { Epic, SpecSummary } from "@peppa/core";
import type { OpenPull, RepoOverview } from "@peppa/runner";
import { addEpic, editEpic } from "../../actions";
import { Hidden } from "@/components/cards";
import { Disclosure, Empty, Key, Section, StatusBadge } from "@/components/common";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Input, Textarea } from "@/components/ui/input";
const when = (iso: string | null) => (iso ? new Date(iso).toLocaleString("ru-RU", { dateStyle: "short", timeStyle: "short" }) : "—");
function plural(n: number, one: string, few: string, many: string) {
const m10 = n % 10;
const m100 = n % 100;
return m10 === 1 && m100 !== 11 ? one : m10 >= 2 && m10 <= 4 && (m100 < 12 || m100 > 14) ? few : many;
}
export function CodeTab({ code }: { code: RepoOverview }) {
const gitea = (
);
if (code.error) {
return (
);
}
return (
README {code.readme && {code.readme.path}}>} actions={gitea}>
{code.readme ? (
{code.readme.text}
) : (
{code.defaultBranch ? `В ветке ${code.defaultBranch} нет README.` : "Репозиторий пуст."}
)}
{code.branches.length === 0 ? (
Веток нет.
) : (
{code.branches.map((b) => (
-
{b.name}
{b.name === code.defaultBranch && по умолчанию}
{b.sha.slice(0, 7)}
))}
)}
{code.commits.length === 0 ? (
Коммитов нет.
) : (
)}
);
}
export function SpecsTab({ specs }: { specs: SpecSummary[] }) {
return (
Что система умеет сейчас: требования OpenSpec из рабочей копии (openspec/specs). Обновляются, когда стори архивирует свой change.
{specs.length === 0 ? (
Спек ещё нет — они появляются после archive первого change.
) : (
specs.map((s) => (
{s.name}
{s.requirements} {plural(s.requirements, "требование", "требования", "требований")}
{s.purpose && {s.purpose.split("\n")[0]}}
}
>
{s.text}
))
)}
);
}
const CI_TONE = { success: "ok", failure: "danger", pending: "info", none: "muted", not_configured: "muted" } as const;
export function PullsTab({ pulls, error, repoUrl }: { pulls: OpenPull[]; error: string | null; repoUrl: string }) {
return (
Все PR в Gitea
}
>
{error ? (
{error}.
) : pulls.length === 0 ? (
Открытых PR нет.
) : (
pulls.map((p) => (
{p.branch}
{p.task ? (
<>
· {p.task.key}
{p.task.ci.label}
>
) : (
· не стори Пеппы
)}
))
)}
);
}
/** «⋯ Настройки проекта» → Эпики: labels that group stories (stored as goals). */
/** PEP-34: done/total of an epic as a thin bar. */
export function ProgressBar({ done, total, className }: { done: number; total: number; className?: string }) {
const pct = total ? Math.round((done / total) * 100) : 0;
return (
);
}
export function EpicsPanel({ projectId, projectKey, epics, progress, back }: { projectId: number; projectKey: string; epics: Epic[]; progress: Map; back: string }) {
return (
{epics.length === 0 &&
Эпиков нет. Эпик — метка, которая группирует стори; его описание агент получает вместе со стори.
}
{epics.map((e) => (
›
{e.title}
{progress.get(e.id)?.done ?? 0}/{progress.get(e.id)?.total ?? 0}
#{e.id}
))}
);
}