peppa/apps/web/components/ReviewPreview.tsx
Асель 6ab17456af PEP-44, PEP-46: review preview with screenshots; Gitea issues, PR comments, manual merge
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-14 06:06:57 +05:00

47 lines
2.4 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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";
export function ReviewPreview({ preview }: { preview: Preview }) {
if (!preview.previewUrl && !preview.diffUrl && !preview.issueUrl) return null;
return (
<PanelSection title="Превью">
<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" /> Посмотреть{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">Стенда 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" /> Дифф
</a>
)}
{preview.issueUrl && (
<a href={preview.issueUrl} target="_blank" rel="noreferrer" className="flex items-center gap-1.5 text-primary">
<CircleDot className="size-4" /> 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={`Скриншот ${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>
);
}