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