49 lines
2.5 KiB
TypeScript
49 lines
2.5 KiB
TypeScript
// PEP-44/46: what the PM needs to review a story — the preview stand of its PR, the diff,
|
|
// the screenshots taken by CI, and the Gitea issue it came from.
|
|
import { Eye, FileDiff, CircleDot } from "lucide-react";
|
|
import type { ReviewPreview as Preview } from "@peppa/core";
|
|
import { PanelSection } from "@/components/ActivityAside";
|
|
import { getT } from "@/lib/i18n";
|
|
|
|
export async function ReviewPreview({ preview }: { preview: Preview }) {
|
|
if (!preview.previewUrl && !preview.diffUrl && !preview.issueUrl) return null;
|
|
const t = await getT();
|
|
return (
|
|
<PanelSection title={t("Превью")}>
|
|
<div className="flex flex-col gap-1.5 text-sm">
|
|
{preview.previewUrl ? (
|
|
<a href={preview.previewUrl} target="_blank" rel="noreferrer" className="flex items-center gap-1.5 text-primary [overflow-wrap:anywhere]">
|
|
<Eye className="size-4" /> {t("Посмотреть")}{preview.sha && <span className="font-mono text-xs text-muted-foreground">{preview.sha.slice(0, 7)}</span>}
|
|
</a>
|
|
) : (
|
|
preview.diffUrl && <span className="text-xs text-muted-foreground">{t("Стенда PR ещё нет (деплой превью не настроен или не прошёл).")}</span>
|
|
)}
|
|
{preview.diffUrl && (
|
|
<a href={preview.diffUrl} target="_blank" rel="noreferrer" className="flex items-center gap-1.5 text-primary">
|
|
<FileDiff className="size-4" /> {t("Дифф")}
|
|
</a>
|
|
)}
|
|
{preview.issueUrl && (
|
|
<a href={preview.issueUrl} target="_blank" rel="noreferrer" className="flex items-center gap-1.5 text-primary">
|
|
<CircleDot className="size-4" /> {t("Issue в Gitea")}
|
|
</a>
|
|
)}
|
|
</div>
|
|
{preview.releaseId != null && preview.screenshots.length > 0 && (
|
|
<div className="grid grid-cols-2 gap-2">
|
|
{preview.screenshots.map((s) => {
|
|
const src = `/api/releases/${preview.releaseId}/shots/${s.n}`;
|
|
return (
|
|
<a key={s.n} href={src} target="_blank" rel="noreferrer" title={s.path} className="block overflow-hidden rounded border">
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
<img src={src} alt={t("Скриншот {path}", { path: s.path })} loading="lazy" className="block aspect-[16/10] w-full object-cover object-top" />
|
|
<span className="block truncate px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground">{s.path}</span>
|
|
</a>
|
|
);
|
|
})}
|
|
</div>
|
|
)}
|
|
</PanelSection>
|
|
);
|
|
}
|