peppa/apps/web/app/(app)/projects/new/page.tsx
Асель 28fbde4add PEP-38: console foundation — Tailwind v4, shadcn/ui components, dark theme, three-panel layout
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 16:21:43 +05:00

83 lines
4.0 KiB
TypeScript
Raw 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.

import { giteaForUser, type GiteaOrg } from "@peppa/core";
import { loadEnv } from "@peppa/shared";
import { Flash } from "@/components/ui";
import { requireUser } from "@/lib/auth";
import { db } from "@/lib/db";
import { createProjectAction } from "../../actions";
import { Workspace } from "@/components/Workspace";
export default async function NewProject({ searchParams }: { searchParams: Promise<{ error?: string }> }) {
const user = await requireUser();
const { error } = await searchParams;
let orgs: GiteaOrg[] = [];
let giteaError: string | undefined;
const giteaUrl = loadEnv().GITEA_URL.replace(/^https?:\/\//, "");
try {
orgs = await (await giteaForUser(db, user)).orgsWithRepoCreate(user.login);
} catch (e) {
giteaError = (e as Error).message;
}
return (
<Workspace>
<section className="narrow">
<h1>Новый проект</h1>
<Flash error={error ?? giteaError} />
<form action={createProjectAction} className="stack">
<input type="hidden" name="back" value="/projects/new" />
<label>
Название
<input type="text" name="name" required placeholder="Платёжный сервис" />
</label>
<div className="row">
<label className="grow">
Репозиторий (slug)
<input type="text" name="slug" required pattern="[a-z0-9][a-z0-9-]*" placeholder="payments" />
</label>
<label>
Ключ задач
<input type="text" name="key" required pattern="[A-Za-z][A-Za-z0-9]{1,9}" placeholder="PAY" className="short" />
</label>
</div>
<label>
Пространство в Gitea
<select name="owner" defaultValue={user.login}>
<option value={user.login}>{user.login} — личное</option>
{orgs.map((o) => (
<option key={o.id} value={o.username}>{o.username} — организация</option>
))}
</select>
</label>
<p className="muted">
Репозиторий будет <span className="mono">{giteaUrl}/&lt;пространство&gt;/&lt;slug&gt;</span>. В личном пространстве приватный репозиторий видите
только вы, <span className="mono">peppa-bot</span> и участники проекта; в организации — ещё её участники с доступом к репозиториям.
{orgs.length === 0 && " Организаций, где вы можете создавать репозитории, нет."}
</p>
<fieldset>
<legend>Видимость</legend>
<label className="inline">
<input type="radio" name="visibility" value="private" defaultChecked /> Приватный — только те, кому выдан доступ
</label>
<label className="inline">
<input type="radio" name="visibility" value="public" /> Публичный — все, у кого есть доступ к Gitea
</label>
</fieldset>
<fieldset>
<legend>Репозиторий</legend>
<label className="inline">
<input type="radio" name="mode" value="new" defaultChecked /> Создать новый
</label>
<label className="inline">
<input type="radio" name="mode" value="existing" /> Подключить существующий (нужны права админа; видимость не меняется)
</label>
</fieldset>
<p className="muted">
Пеппа добавит <span className="mono">peppa-bot</span> соавтором, положит AGENTS.md, .mcp.json и .peppa/project.json из шаблона и запустит
openspec init. Занимает до ~15 секунд.
</p>
<button className="primary">Создать проект</button>
</form>
</section>
</Workspace>
);
}