Main's new wording (PEP-123 «Продакт» words) kept and wrapped in t()/m();
wording(mode, locale) gives English words for {task}/{runner} placeholders;
glossary check (pnpm lint) passes; English for all new keys (en/merge-*.ts).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
113 lines
7.8 KiB
TypeScript
113 lines
7.8 KiB
TypeScript
// PEP-42: plan an epic — the planner proposes stories with dependencies; the PM edits and approves.
|
||
import Link from "next/link";
|
||
import { notFound } from "next/navigation";
|
||
import { Sparkles } from "lucide-react";
|
||
import { getEpic, listTasks } from "@peppa/core";
|
||
import { getPlanDraft } from "@peppa/runner";
|
||
import { Hidden } from "@/components/cards";
|
||
import { Empty, Flash, PageHeader, Section } from "@/components/common";
|
||
import { PendingButton } from "@/components/PendingButton";
|
||
import { Button } from "@/components/ui/button";
|
||
import { Input, Textarea } from "@/components/ui/input";
|
||
import { Workspace } from "@/components/Workspace";
|
||
import { requireUser, words } from "@/lib/auth";
|
||
import { db } from "@/lib/db";
|
||
import { getT } from "@/lib/i18n";
|
||
import { intlLocale } from "@peppa/shared/i18n";
|
||
import { projectForUserByKey } from "@/lib/queries";
|
||
import { applyPlanAction, discardPlanAction, planEpicAction } from "../../../../board-actions";
|
||
|
||
export default async function PlanEpicPage({ params, searchParams }: { params: Promise<{ key: string; epic: string }>; searchParams: Promise<{ error?: string }> }) {
|
||
const user = await requireUser();
|
||
const { key, epic: epicParam } = await params;
|
||
const { error } = await searchParams;
|
||
const t = await getT();
|
||
const w = await words();
|
||
const p = await projectForUserByKey(user.id, key).catch(() => null);
|
||
if (!p) notFound();
|
||
const epic = await getEpic(db, p.id, Number(epicParam)).catch(() => null);
|
||
if (!epic) notFound();
|
||
const [draft, existing] = await Promise.all([getPlanDraft(db, epic.id), listTasks(db, { projectId: p.id, goalId: epic.id })]);
|
||
const back = `/p/${p.key}/plan/${epic.id}`;
|
||
|
||
return (
|
||
<Workspace aside={null}>
|
||
<Flash error={error} />
|
||
<PageHeader
|
||
crumbs={
|
||
<>
|
||
<Link href={`/p/${p.key}`} className="text-muted-foreground hover:text-foreground">{p.name}</Link>
|
||
<span className="text-muted-foreground">/</span>
|
||
<Link href={`/p/${p.key}?epic=${epic.id}`} className="text-muted-foreground hover:text-foreground">{t("эпик «{name}»", { name: epic.title })}</Link>
|
||
</>
|
||
}
|
||
title={t("Спланировать эпик «{name}»", { name: epic.title })}
|
||
>
|
||
{w.engineer
|
||
? t("Планировщик (короткая сессия Claude на подписке пула проекта) предложит {tasks} с критериями готовности и порядком. Ничего не создаётся, пока вы не утвердите план.", { tasks: w.task("accPl") })
|
||
: t("Планировщик предложит {tasks} с критериями готовности и порядком. Ничего не создаётся, пока вы не утвердите план.", { tasks: w.task("accPl") })}
|
||
</PageHeader>
|
||
|
||
<Section title={t("Эпик")}>
|
||
<div className="rounded-lg border bg-card p-3 text-sm whitespace-pre-wrap">{epic.description || <span className="text-muted-foreground">{t("Без описания — опишите эпик в «Настройках проекта → Эпики», так план будет точнее.")}</span>}</div>
|
||
{existing.length > 0 && (
|
||
<p className="m-0 text-sm text-muted-foreground">
|
||
{t("Уже есть {tasks}: {keys} — планировщик их не повторит и может от них зависеть.", { tasks: w.task("pl"), keys: existing.map((x) => x.key).join(", ") })}
|
||
</p>
|
||
)}
|
||
<form action={planEpicAction} className="flex flex-col gap-2">
|
||
<Hidden fields={{ projectId: p.id, epicId: epic.id, back }} />
|
||
<Textarea name="wishes" rows={2} defaultValue={draft?.wishes ?? ""} placeholder={t("Пожелания планировщику (необязательно): например, «сначала API, потом экран», «без новых зависимостей»")} aria-label={t("Пожелания планировщику")} />
|
||
<PendingButton pendingText={t("Планировщик думает (до 3 минут)…")} className="self-start">
|
||
<Sparkles />
|
||
{draft ? t("Спланировать заново") : t("Спланировать")}
|
||
</PendingButton>
|
||
</form>
|
||
</Section>
|
||
|
||
<Section title={draft ? t("Черновик плана — {tasks}", { tasks: w.tasks(draft.stories.length) }) : t("Черновик плана")}>
|
||
{!draft ? (
|
||
<Empty>{t("Черновика нет. Нажмите «Спланировать».")}</Empty>
|
||
) : (
|
||
<>
|
||
<form action={applyPlanAction} className="flex flex-col gap-3">
|
||
<Hidden fields={{ projectId: p.id, epicId: epic.id, back, count: draft.stories.length }} />
|
||
{draft.stories.map((s, i) => {
|
||
const n = i + 1;
|
||
return (
|
||
<fieldset key={n} className="m-0 flex flex-col gap-2 rounded-lg border bg-card p-3">
|
||
<legend className="sr-only">{t("{Task} № {n} плана", { Task: w.Task(), n })}</legend>
|
||
<div className="flex items-center gap-2">
|
||
<input type="checkbox" name={`keep_${n}`} defaultChecked aria-label={t("Создать {task} {n}", { task: w.task("acc"), n })} className="size-4 accent-primary" />
|
||
<span className="font-mono text-xs text-muted-foreground">№{n}</span>
|
||
<Input name={`title_${n}`} required minLength={3} defaultValue={s.title} aria-label={t("Название {task} {n}", { task: w.task("gen"), n })} className="h-8 flex-1" />
|
||
</div>
|
||
<Textarea name={`description_${n}`} rows={5} defaultValue={s.description} aria-label={t("Описание {task} {n}", { task: w.task("gen"), n })} />
|
||
<label className="flex items-center gap-2 text-sm">
|
||
<span className="text-muted-foreground whitespace-nowrap">{t("Ждёт")}</span>
|
||
<Input name={`deps_${n}`} defaultValue={s.dependsOn.join(", ")} placeholder={t("номера плана или ключи: 1, {key}-3", { key: p.key })} aria-label={t("Зависимости {task} {n}", { task: w.task("gen"), n })} className="h-8" />
|
||
</label>
|
||
</fieldset>
|
||
);
|
||
})}
|
||
<p className="m-0 text-xs text-muted-foreground">
|
||
{w.engineer
|
||
? t("Снимите галочку, чтобы не создавать {task}. {Tasks} встанут в конец бэклога в этом порядке; зависимые диспетчер не возьмёт, пока предшественники не в ревью или готово.", { task: w.task("acc"), Tasks: w.Task("pl") })
|
||
: t("Снимите галочку, чтобы не создавать {task}. {Tasks} встанут в конец бэклога в этом порядке; зависимую задачу агенты возьмут, когда будут готовы те, которых она ждёт.", { task: w.task("acc"), Tasks: w.Task("pl") })}
|
||
</p>
|
||
<Button variant="default" className="self-start">{t("Создать {tasks}", { tasks: w.task("accPl") })}</Button>
|
||
</form>
|
||
<form action={discardPlanAction}>
|
||
<Hidden fields={{ projectId: p.id, epicId: epic.id, back }} />
|
||
<Button size="sm" variant="ghost">{t("Удалить черновик")}</Button>
|
||
</form>
|
||
<p className="m-0 text-xs text-muted-foreground">
|
||
{t("Черновик от {date}, {author}.", { date: new Date(draft.createdAt).toLocaleString(intlLocale(t.locale), { dateStyle: "short", timeStyle: "short" }), author: draft.createdBy })}
|
||
</p>
|
||
</>
|
||
)}
|
||
</Section>
|
||
</Workspace>
|
||
);
|
||
}
|