main / internal/interface/web/templates/issue_detail_templ.go
12.4 KB · Go Raw
1// Code generated by templ - DO NOT EDIT.
2
3// templ: version: v0.3.865
4package templates
5
6//lint:file-ignore SA4006 This context is only used if a nested component is present.
7
8import "github.com/a-h/templ"
9import templruntime "github.com/a-h/templ/runtime"
10
11import "gitgud/internal/domain"
12
13func IssueDetail(user *domain.User, repo *domain.Repository, issue *domain.Issue, comments []*domain.IssueComment, canModify bool) templ.Component {
14 return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
15 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
16 if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
17 return templ_7745c5c3_CtxErr
18 }
19 templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
20 if !templ_7745c5c3_IsBuffer {
21 defer func() {
22 templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
23 if templ_7745c5c3_Err == nil {
24 templ_7745c5c3_Err = templ_7745c5c3_BufErr
25 }
26 }()
27 }
28 ctx = templ.InitializeContext(ctx)
29 templ_7745c5c3_Var1 := templ.GetChildren(ctx)
30 if templ_7745c5c3_Var1 == nil {
31 templ_7745c5c3_Var1 = templ.NopComponent
32 }
33 ctx = templ.ClearChildren(ctx)
34 templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
35 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
36 templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
37 if !templ_7745c5c3_IsBuffer {
38 defer func() {
39 templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
40 if templ_7745c5c3_Err == nil {
41 templ_7745c5c3_Err = templ_7745c5c3_BufErr
42 }
43 }()
44 }
45 ctx = templ.InitializeContext(ctx)
46 templ_7745c5c3_Err = repoHeader(repo, "issues").Render(ctx, templ_7745c5c3_Buffer)
47 if templ_7745c5c3_Err != nil {
48 return templ_7745c5c3_Err
49 }
50 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, " <div class=\"mb-1 flex items-start gap-3\"><h2 class=\"text-2xl font-semibold tracking-tight text-ink\">")
51 if templ_7745c5c3_Err != nil {
52 return templ_7745c5c3_Err
53 }
54 var templ_7745c5c3_Var3 string
55 templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(issue.Title)
56 if templ_7745c5c3_Err != nil {
57 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/issue_detail.templ`, Line: 9, Col: 75}
58 }
59 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
60 if templ_7745c5c3_Err != nil {
61 return templ_7745c5c3_Err
62 }
63 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " <span class=\"font-normal text-faint\">#")
64 if templ_7745c5c3_Err != nil {
65 return templ_7745c5c3_Err
66 }
67 var templ_7745c5c3_Var4 string
68 templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(itoa(issue.Number))
69 if templ_7745c5c3_Err != nil {
70 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/issue_detail.templ`, Line: 9, Col: 136}
71 }
72 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
73 if templ_7745c5c3_Err != nil {
74 return templ_7745c5c3_Err
75 }
76 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</span></h2></div><div class=\"mb-6 flex items-center gap-3\">")
77 if templ_7745c5c3_Err != nil {
78 return templ_7745c5c3_Err
79 }
80 if issue.State == domain.IssueOpen {
81 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<span class=\"badge-open\"><span class=\"size-2 rounded-full border-2 border-grassink\"></span> Open</span> ")
82 if templ_7745c5c3_Err != nil {
83 return templ_7745c5c3_Err
84 }
85 } else {
86 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<span class=\"badge-closed\"><span class=\"size-2 rounded-full border-2 border-current\"></span> Closed</span> ")
87 if templ_7745c5c3_Err != nil {
88 return templ_7745c5c3_Err
89 }
90 }
91 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<span class=\"meta\">")
92 if templ_7745c5c3_Err != nil {
93 return templ_7745c5c3_Err
94 }
95 var templ_7745c5c3_Var5 string
96 templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(issue.AuthorName)
97 if templ_7745c5c3_Err != nil {
98 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/issue_detail.templ`, Line: 17, Col: 40}
99 }
100 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
101 if templ_7745c5c3_Err != nil {
102 return templ_7745c5c3_Err
103 }
104 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, " opened this on ")
105 if templ_7745c5c3_Err != nil {
106 return templ_7745c5c3_Err
107 }
108 var templ_7745c5c3_Var6 string
109 templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(fmtTime(issue.CreatedAt))
110 if templ_7745c5c3_Err != nil {
111 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/issue_detail.templ`, Line: 17, Col: 84}
112 }
113 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
114 if templ_7745c5c3_Err != nil {
115 return templ_7745c5c3_Err
116 }
117 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</span></div>")
118 if templ_7745c5c3_Err != nil {
119 return templ_7745c5c3_Err
120 }
121 templ_7745c5c3_Err = commentCard(issue.AuthorName, fmtTime(issue.CreatedAt), issue.Body).Render(ctx, templ_7745c5c3_Buffer)
122 if templ_7745c5c3_Err != nil {
123 return templ_7745c5c3_Err
124 }
125 for _, c := range comments {
126 templ_7745c5c3_Err = commentCard(c.AuthorName, fmtTime(c.CreatedAt), c.Body).Render(ctx, templ_7745c5c3_Buffer)
127 if templ_7745c5c3_Err != nil {
128 return templ_7745c5c3_Err
129 }
130 }
131 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, " ")
132 if templ_7745c5c3_Err != nil {
133 return templ_7745c5c3_Err
134 }
135 if canModify {
136 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<form method=\"post\" action=\"")
137 if templ_7745c5c3_Err != nil {
138 return templ_7745c5c3_Err
139 }
140 var templ_7745c5c3_Var7 templ.SafeURL = templ.SafeURL(repoPath(repo, "/issues/"+itoa(issue.Number)+stateAction(issue.State)))
141 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var7)))
142 if templ_7745c5c3_Err != nil {
143 return templ_7745c5c3_Err
144 }
145 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\" class=\"mb-6\">")
146 if templ_7745c5c3_Err != nil {
147 return templ_7745c5c3_Err
148 }
149 templ_7745c5c3_Err = csrfField().Render(ctx, templ_7745c5c3_Buffer)
150 if templ_7745c5c3_Err != nil {
151 return templ_7745c5c3_Err
152 }
153 if issue.State == domain.IssueOpen {
154 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<button class=\"btn btn-danger\" type=\"submit\">Close issue</button>")
155 if templ_7745c5c3_Err != nil {
156 return templ_7745c5c3_Err
157 }
158 } else {
159 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<button class=\"btn\" type=\"submit\">Reopen issue</button>")
160 if templ_7745c5c3_Err != nil {
161 return templ_7745c5c3_Err
162 }
163 }
164 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</form>")
165 if templ_7745c5c3_Err != nil {
166 return templ_7745c5c3_Err
167 }
168 }
169 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, " ")
170 if templ_7745c5c3_Err != nil {
171 return templ_7745c5c3_Err
172 }
173 if user != nil {
174 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<form method=\"post\" action=\"")
175 if templ_7745c5c3_Err != nil {
176 return templ_7745c5c3_Err
177 }
178 var templ_7745c5c3_Var8 templ.SafeURL = templ.SafeURL(repoPath(repo, "/issues/"+itoa(issue.Number)+"/comments"))
179 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var8)))
180 if templ_7745c5c3_Err != nil {
181 return templ_7745c5c3_Err
182 }
183 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "\" class=\"flex flex-col gap-3\">")
184 if templ_7745c5c3_Err != nil {
185 return templ_7745c5c3_Err
186 }
187 templ_7745c5c3_Err = csrfField().Render(ctx, templ_7745c5c3_Buffer)
188 if templ_7745c5c3_Err != nil {
189 return templ_7745c5c3_Err
190 }
191 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<textarea class=\"textarea\" name=\"body\" rows=\"4\" placeholder=\"Leave a comment… (markdown supported)\"></textarea><div class=\"flex justify-end\"><button class=\"btn btn-primary\" type=\"submit\">Comment</button></div></form>")
192 if templ_7745c5c3_Err != nil {
193 return templ_7745c5c3_Err
194 }
195 } else {
196 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<p class=\"text-sm text-muted\"><a class=\"text-accent hover:underline\" href=\"/login\">Sign in</a> to comment.</p>")
197 if templ_7745c5c3_Err != nil {
198 return templ_7745c5c3_Err
199 }
200 }
201 return nil
202 })
203 templ_7745c5c3_Err = Layout(issue.Title+" · "+repo.Name, user).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
204 if templ_7745c5c3_Err != nil {
205 return templ_7745c5c3_Err
206 }
207 return nil
208 })
209}
210
211func commentCard(author, when, body string) templ.Component {
212 return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
213 templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
214 if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
215 return templ_7745c5c3_CtxErr
216 }
217 templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
218 if !templ_7745c5c3_IsBuffer {
219 defer func() {
220 templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
221 if templ_7745c5c3_Err == nil {
222 templ_7745c5c3_Err = templ_7745c5c3_BufErr
223 }
224 }()
225 }
226 ctx = templ.InitializeContext(ctx)
227 templ_7745c5c3_Var9 := templ.GetChildren(ctx)
228 if templ_7745c5c3_Var9 == nil {
229 templ_7745c5c3_Var9 = templ.NopComponent
230 }
231 ctx = templ.ClearChildren(ctx)
232 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<div class=\"card mb-4 overflow-hidden\"><div class=\"flex items-center gap-2 border-b border-line bg-[#0e1410] px-4 py-2.5\">")
233 if templ_7745c5c3_Err != nil {
234 return templ_7745c5c3_Err
235 }
236 templ_7745c5c3_Err = avatar(author, "size-5").Render(ctx, templ_7745c5c3_Buffer)
237 if templ_7745c5c3_Err != nil {
238 return templ_7745c5c3_Err
239 }
240 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<span class=\"text-sm font-medium text-ink\">")
241 if templ_7745c5c3_Err != nil {
242 return templ_7745c5c3_Err
243 }
244 var templ_7745c5c3_Var10 string
245 templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(author)
246 if templ_7745c5c3_Err != nil {
247 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/issue_detail.templ`, Line: 51, Col: 54}
248 }
249 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
250 if templ_7745c5c3_Err != nil {
251 return templ_7745c5c3_Err
252 }
253 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</span> <span class=\"meta\">commented on ")
254 if templ_7745c5c3_Err != nil {
255 return templ_7745c5c3_Err
256 }
257 var templ_7745c5c3_Var11 string
258 templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(when)
259 if templ_7745c5c3_Err != nil {
260 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/issue_detail.templ`, Line: 52, Col: 41}
261 }
262 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
263 if templ_7745c5c3_Err != nil {
264 return templ_7745c5c3_Err
265 }
266 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</span></div><div class=\"prose-dark px-4 py-3\">")
267 if templ_7745c5c3_Err != nil {
268 return templ_7745c5c3_Err
269 }
270 templ_7745c5c3_Err = templ.Raw(markdown(body)).Render(ctx, templ_7745c5c3_Buffer)
271 if templ_7745c5c3_Err != nil {
272 return templ_7745c5c3_Err
273 }
274 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</div></div>")
275 if templ_7745c5c3_Err != nil {
276 return templ_7745c5c3_Err
277 }
278 return nil
279 })
280}
281
282var _ = templruntime.GeneratedTemplate