RepoSettings.tsx
Raw
1import type { RepositoryRow } from "../../db/index.ts";
2import type { SessionUser } from "../../middleware/session.ts";
3import { Layout } from "../layout.tsx";
4import { RepoHeader } from "./RepoHeader.tsx";
5import { RepoNav } from "./RepoNav.tsx";
6
7interface RepoSettingsProps {
8 user: SessionUser;
9 repo: RepositoryRow;
10 branches: string[];
11 success?: string;
12 error?: string;
13}
14
15export function RepoSettings({
16 user,
17 repo,
18 branches,
19 success,
20 error,
21}: RepoSettingsProps) {
22 return (
23 <Layout user={user} title={`Settings — ${repo.name}`}>
24 <div class="container container-narrow">
25 <RepoHeader repo={repo} />
26 <RepoNav repo={repo} active="settings" user={user} />
27 {success && <p class="form-success">{success}</p>}
28 {error && <p class="form-error">{error}</p>}
29 <form
30 method="POST"
31 action={`/${repo.name}/settings`}
32 class="form-card"
33 >
34 <div class="form-group">
35 <label for="description">Description</label>
36 <input
37 id="description"
38 name="description"
39 type="text"
40 value={repo.description ?? ""}
41 placeholder="A short description"
42 />
43 </div>
44 <div class="form-group">
45 <label for="default_branch">Default branch</label>
46 {branches.length > 0 ? (
47 <select
48 id="default_branch"
49 name="default_branch"
50 class="branch-select"
51 >
52 {branches.map((b) => (
53 <option
54 value={b}
55 selected={
56 b === repo.default_branch
57 ? true
58 : undefined
59 }
60 >
61 {b}
62 </option>
63 ))}
64 </select>
65 ) : (
66 <p class="form-hint">
67 No branches yet — push your first commit to set
68 the default branch.
69 </p>
70 )}
71 </div>
72 <div class="form-group">
73 <label class="checkbox-label">
74 <input
75 type="checkbox"
76 name="is_private"
77 value="1"
78 checked={repo.is_private === 1}
79 />
80 Private repository
81 </label>
82 </div>
83 <button type="submit" class="btn btn-primary">
84 Save settings
85 </button>
86 </form>
87 <div class="danger-zone">
88 <h2 class="section-title danger-title">Danger zone</h2>
89 <div class="form-card danger-card">
90 <div class="danger-item">
91 <div>
92 <strong>Delete this repository</strong>
93 <p class="text-muted">
94 Once deleted, there is no going back.
95 </p>
96 </div>
97 <details class="confirm-details">
98 <summary class="btn btn-danger">
99 Delete repository
100 </summary>
101 <div class="confirm-popup">
102 Delete {repo.name}? This cannot be undone.
103 <form
104 method="POST"
105 action={`/${repo.name}/settings/delete`}
106 class="inline-form"
107 >
108 <button
109 type="submit"
110 class="btn btn-danger"
111 >
112 Yes, delete
113 </button>
114 </form>
115 </div>
116 </details>
117 </div>
118 </div>
119 </div>
120 </div>
121 </Layout>
122 );
123}
124