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
46 id="description"
47 name="description"
48 rows="5"
49 >
50 {template ?? ""}
51 </textarea>
52 </div>
53 <div class="form-group">
54 <label for="patch_file">
55 Patch file <span class="text-muted">(.patch)</span>
56 </label>
57 <input
58 id="patch_file"
59 name="patch_file"
60 type="file"
61 accept=".patch"
62 required
63 />
64 </div>
65 <div class="form-actions">
66 <button type="submit" class="btn btn-primary">
67 Upload patch
68 </button>
69 <a href={`/${repo.name}/patches`} class="btn btn-ghost">
70 Cancel
71 </a>
72 </div>
73 </form>
74 </div>
75 </Layout>
76 );
77}
78