import { notFound } from "next/navigation"; import { AutoRefresh } from "@/components/AutoRefresh"; import { Flash, Notice, SessionCard } from "@/components/ui"; import { Board, type Card } from "@/components/Board"; import { columnOf, currentReleases, describeRepo, listReleases, type Release } from "@peppa/runner"; import { requireUser } from "@/lib/auth"; import { board, projectForUserByKey, projectSessions } from "@/lib/queries"; import { getIncidentSettings, listErrorSources, listIncidents, listMembers, repoAudience, repoVisibilityLabel } from "@peppa/core"; import { bugsinkWebhookBase } from "@peppa/runner"; import { IncidentsSection } from "@/components/Incidents"; import { db } from "@/lib/db"; import { addGoal, addProjectMember, addTask, deployProdAction, grantRepoAccessToMembers, removeProjectMember } from "../../actions"; const RELEASE_STATUS: Record = { deploying: "⏳ выкатывается", healthy: "✅ работает", rolled_back: "↩️ откат", failed: "❌ не поднялся", removed: "🗑 удалён", }; export default async function ProjectPage({ params, searchParams }: { params: Promise<{ key: string }>; searchParams: Promise<{ error?: string; created?: string }> }) { const user = await requireUser(); const { key } = await params; const { error, created } = await searchParams; const p = await projectForUserByKey(user.id, key).catch(() => null); if (!p) notFound(); const [{ goals, tasks }, sessions, team, repo, incidentSettings, sources, incidents, releases, current] = await Promise.all([ board(p.id), projectSessions(p.id), listMembers(db, p), describeRepo(db, p), getIncidentSettings(db, p.id), listErrorSources(db, p.id), listIncidents(db, p.id), listReleases(db, p.id, 15), currentReleases(db, p.id), ]); const collaborators = new Set((repo.collaborators ?? []).map((l) => l.toLowerCase())); // Members who are not repo collaborators (only known when Gitea listed them; owners of the namespace see it anyway). const noRepoAccess = (login: string) => repo.collaborators !== null && login.toLowerCase() !== p.giteaOwner.toLowerCase() && !collaborators.has(login.toLowerCase()); const missingAccess = team.members.some((m) => noRepoAccess(m.login)); const isOwner = p.ownerId === user.id; const back = `/p/${p.key}`; const groups = [...goals.map((g) => ({ goal: g })), { goal: null }]; const goalTitle = new Map(goals.map((g) => [g.id, g.title])); const cards: Card[] = tasks.map((t) => ({ key: `${p.key}-${t.number}`, title: t.title, status: t.status, column: columnOf(t.status), goal: t.goalId ? (goalTitle.get(t.goalId) ?? null) : null, })); return ( <> {created && !error && ( Репозиторий создан: {repo.fullName} ({repoVisibilityLabel(repo.private)}).{" "} Открыть в Gitea )}

{p.key} {p.name}

{repo.fullName} · {repoVisibilityLabel(repo.private)}

{groups.map(({ goal }) => (
+ Задача{goal ? ` · 🎯 ${goal.title}` : " без цели"}
{goal && }