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 patch)
104 </span>
105 </label>
106 <textarea
107 id="patch_template"
108 name="patch_template"
109 rows="8"
110 placeholder="## Summary&#10;&#10;## Testing"
111 >
112 {repo.patch_template ?? ""}
113 </textarea>
114 </div>
115 <button type="submit" class="btn btn-primary">
116 Save settings
117 </button>
118 </form>
119 <div class="danger-zone">
120 <h2 class="section-title danger-title">Danger zone</h2>
121 <div class="form-card danger-card">
122 <div class="danger-item">
123 <div>
124 <strong>Delete this repository</strong>
125 <p class="text-muted">
126 Once deleted, there is no going back.
127 </p>
128 </div>
129 <details class="confirm-details">
130 <summary class="btn btn-danger">
131 Delete repository
132 </summary>
133 <div class="confirm-popup">
134 Delete {repo.name}? This cannot be undone.
135 <form
136 method="POST"
137 action={`/${repo.name}/settings/delete`}
138 class="inline-form"
139 >
140 <button
141 type="submit"
142 class="btn btn-danger"
143 >
144 Yes, delete
145 </button>
146 </form>
147 </div>
148 </details>
149 </div>
150 </div>
151 </div>
152 </div>
153 </Layout>
154 );
155}
156