- New project form: namespace (personal/org) and visibility (private/public) with hints - provisionProject creates the repo with the chosen visibility (existing repo keeps its own) - After creation: notice with "Открыть в Gitea"; project page "Репозиторий" block: path, namespace kind, visibility, who can see it (read live from Gitea, cached 60 s) - Members without repo access are marked; owner can grant access to all members - MCP create_project takes visibility and returns repo URL + who sees it; list_projects shows URLs - CLI --public, /help, mock-gitea (visibility, /orgs, collaborators), e2e repo-visibility Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
3.9 KiB
TypeScript
80 lines
3.9 KiB
TypeScript
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";
|
||
|
||
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 (
|
||
<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}/<пространство>/<slug></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>
|
||
);
|
||
}
|