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