NewIssue.tsx
⎇
Raw
1import type { LabelRow, RepositoryRow } from "../../db/index.ts";
2import { labelTextColor } from "../../lib/labelColor.ts";
3import type { SessionUser } from "../../middleware/session.ts";
4import { Layout } from "../layout.tsx";
5import { RepoHeader } from "../repos/RepoHeader.tsx";
6import { RepoNav } from "../repos/RepoNav.tsx";
7
8interface NewIssueProps {
9 user: SessionUser;
10 repo: RepositoryRow;
11 error?: string;
12 template?: string;
13 labels: LabelRow[];
14}
15
16export function NewIssue({
17 user,
18 repo,
19 error,
20 template,
21 labels,
22}: NewIssueProps) {
23 return (
24 <Layout user={user} title={`New issue — ${repo.name}`}>
25 <div class="container">
26 <RepoHeader repo={repo} />
27 <RepoNav repo={repo} active="issues" user={user} />
28 <h2 class="section-title">New issue</h2>
29 {error && <p class="form-error">{error}</p>}
30 <form
31 method="POST"
32 action={`/${repo.name}/issues`}
33 class="form-card"
34 >
35 <div class="form-group">
36 <label for="title">Title</label>
37 <input
38 id="title"
39 name="title"
40 type="text"
41 required
42 placeholder="Short, descriptive title"
43 />
44 </div>
45 <div class="form-group">
46 <label for="body">
47 Description{" "}
48 <span class="text-muted">
49 (Markdown supported, optional)
50 </span>
51 </label>
52 <textarea
53 id="body"
54 name="body"
55 rows="10"
56 placeholder="Describe the issue..."
57 >
58 {template ?? ""}
59 </textarea>
60 </div>
61 {labels.length > 0 &&
62 (user.isAdmin || repo.allow_user_labels === 1) && (
63 <div class="form-group">
64 <span class="form-group-label">Labels</span>
65 <div class="label-checkbox-list">
66 {labels.map((label) => (
67 <label class="label-checkbox-item">
68 <input
69 type="checkbox"
70 name="label_ids"
71 value={String(label.id)}
72 />
73 <span
74 class="label-badge"
75 style={`background:${label.color};color:${labelTextColor(label.color)}`}
76 >
77 {label.name}
78 </span>
79 </label>
80 ))}
81 </div>
82 </div>
83 )}
84 <div class="form-actions">
85 <button type="submit" class="btn btn-primary">
86 Submit issue
87 </button>
88 <a href={`/${repo.name}/issues`} class="btn">
89 Cancel
90 </a>
91 </div>
92 </form>
93 </div>
94 </Layout>
95 );
96}
97