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">
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 (only visible to you)
81 </label>
82 </div>
83 <div class="form-group">
84 <label class="checkbox-label">
85 <input
86 type="checkbox"
87 name="is_pinned"
88 value="1"
89 checked={repo.is_pinned === 1}
90 />
91 Pin this repository (always shown at the top of the
92 list)
93 </label>
94 </div>
95 <div class="form-group">
96 <label for="issue_template">
97 Issue template{" "}
98 <span class="text-muted">
99 (Markdown, prefilled when opening a new issue)
100 </span>
101 </label>
102 <textarea
103 id="issue_template"
104 name="issue_template"
105 rows="8"
106 placeholder="## Description&#10;&#10;## Steps to reproduce&#10;&#10;## Expected behavior"
107 >
108 {repo.issue_template ?? ""}
109 </textarea>
110 </div>
111 <div class="form-group">
112 <label for="patch_template">
113 Patch template{" "}
114 <span class="text-muted">
115 (Markdown, prefilled when submitting a new
116 patch)
117 </span>
118 </label>
119 <textarea
120 id="patch_template"
121 name="patch_template"
122 rows="8"
123 placeholder="## Summary&#10;&#10;## Testing"
124 >
125 {repo.patch_template ?? ""}
126 </textarea>
127 </div>
128 <button type="submit" class="btn btn-primary">
129 Save settings
130 </button>
131 </form>
132 <div class="danger-zone">
133 <h2 class="section-title danger-title">Danger zone</h2>
134 <div class="form-card danger-card">
135 <div class="danger-item">
136 <div>
137 <strong>Delete this repository</strong>
138 <p class="text-muted">
139 Once deleted, there is no going back.
140 </p>
141 </div>
142 <details class="confirm-details">
143 <summary class="btn btn-danger">
144 Delete repository
145 </summary>
146 <div class="confirm-popup">
147 Delete {repo.name}? This cannot be undone.
148 <form
149 method="POST"
150 action={`/${repo.name}/settings/delete`}
151 class="inline-form"
152 >
153 <button
154 type="submit"
155 class="btn btn-danger"
156 >
157 Yes, delete
158 </button>
159 </form>
160 </div>
161 </details>
162 </div>
163 </div>
164 </div>
165 </div>
166 </Layout>
167 );
168}
169