NewPatch.tsx
Raw
1import type { RepositoryRow } from "../../db/index.ts";
2import type { SessionUser } from "../../middleware/session.ts";
3import { Layout } from "../layout.tsx";
4import { RepoHeader } from "../repos/RepoHeader.tsx";
5import { RepoNav } from "../repos/RepoNav.tsx";
6
7interface NewPatchProps {
8 user: SessionUser;
9 repo: RepositoryRow;
10 error?: string;
11 template?: string;
12}
13
14export function NewPatch({ user, repo, error, template }: NewPatchProps) {
15 return (
16 <Layout user={user} title={`New patch — ${repo.name}`}>
17 <div class="container">
18 <RepoHeader repo={repo} />
19 <RepoNav repo={repo} active="patches" user={user} />
20 <h2 class="section-title">Upload patch</h2>
21 {error && <p class="form-error">{error}</p>}
22 <form
23 method="POST"
24 action={`/${repo.name}/patches`}
25 enctype="multipart/form-data"
26 class="form-card"
27 >
28 <div class="form-group">
29 <label for="title">Title</label>
30 <input
31 id="title"
32 name="title"
33 type="text"
34 required
35 placeholder="What does this patch do?"
36 />
37 </div>
38 <div class="form-group">
39 <label for="description">
40 Description{" "}
41 <span class="text-muted">
42 (Markdown supported, optional)
43 </span>
44 </label>
45 <textarea id="description" name="description" rows="5">
46 {template ?? ""}
47 </textarea>
48 </div>
49 <div class="form-group">
50 <label for="patch_file">
51 Patch file <span class="text-muted">(.patch)</span>
52 </label>
53 <input
54 id="patch_file"
55 name="patch_file"
56 type="file"
57 accept=".patch"
58 required
59 />
60 </div>
61 <div class="form-actions">
62 <button type="submit" class="btn btn-primary">
63 Upload patch
64 </button>
65 <a href={`/${repo.name}/patches`} class="btn btn-ghost">
66 Cancel
67 </a>
68 </div>
69 </form>
70 </div>
71 </Layout>
72 );
73}
74