main / internal/interface/web/templates/pull_detail_templ.go
14.0 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 PullDetail(user *domain.User, repo *domain.Repository, pr *domain.PullRequest, cmp *domain.Comparison, comments []*domain.PRComment, canMerge bool, errMsg string) 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, "pulls").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, " <h2 class=\"mb-2 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(pr.Title)
56 if templ_7745c5c3_Err != nil {
57 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/pull_detail.templ`, Line: 8, Col: 76}
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(pr.Number))
69 if templ_7745c5c3_Err != nil {
70 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/pull_detail.templ`, Line: 8, Col: 134}
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 class=\"mb-6 flex flex-wrap items-center gap-3\">")
77 if templ_7745c5c3_Err != nil {
78 return templ_7745c5c3_Err
79 }
80 if pr.State == domain.PROpen {
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 if pr.State == domain.PRMerged {
86 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<span class=\"badge-merged\"><span class=\"size-2 rounded-full bg-current\"></span> Merged</span> ")
87 if templ_7745c5c3_Err != nil {
88 return templ_7745c5c3_Err
89 }
90 } else {
91 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<span class=\"badge-closed\"><span class=\"size-2 rounded-full border-2 border-current\"></span> Closed</span> ")
92 if templ_7745c5c3_Err != nil {
93 return templ_7745c5c3_Err
94 }
95 }
96 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<span class=\"text-sm text-muted\"><span class=\"font-medium text-ink\">")
97 if templ_7745c5c3_Err != nil {
98 return templ_7745c5c3_Err
99 }
100 var templ_7745c5c3_Var5 string
101 templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(pr.AuthorName)
102 if templ_7745c5c3_Err != nil {
103 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/pull_detail.templ`, Line: 18, Col: 54}
104 }
105 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
106 if templ_7745c5c3_Err != nil {
107 return templ_7745c5c3_Err
108 }
109 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "</span> wants to merge <span class=\"badge font-mono text-accent\">")
110 if templ_7745c5c3_Err != nil {
111 return templ_7745c5c3_Err
112 }
113 var templ_7745c5c3_Var6 string
114 templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(pr.HeadBranch)
115 if templ_7745c5c3_Err != nil {
116 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/pull_detail.templ`, Line: 18, Col: 136}
117 }
118 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
119 if templ_7745c5c3_Err != nil {
120 return templ_7745c5c3_Err
121 }
122 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</span> into <span class=\"badge font-mono text-accent\">")
123 if templ_7745c5c3_Err != nil {
124 return templ_7745c5c3_Err
125 }
126 var templ_7745c5c3_Var7 string
127 templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(pr.BaseBranch)
128 if templ_7745c5c3_Err != nil {
129 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/pull_detail.templ`, Line: 18, Col: 208}
130 }
131 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
132 if templ_7745c5c3_Err != nil {
133 return templ_7745c5c3_Err
134 }
135 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</span></span></div>")
136 if templ_7745c5c3_Err != nil {
137 return templ_7745c5c3_Err
138 }
139 if errMsg != "" {
140 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "<div class=\"mb-4 rounded-md border border-closed/30 bg-closed/10 px-3 py-2 text-sm text-closed\">")
141 if templ_7745c5c3_Err != nil {
142 return templ_7745c5c3_Err
143 }
144 var templ_7745c5c3_Var8 string
145 templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(errMsg)
146 if templ_7745c5c3_Err != nil {
147 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/pull_detail.templ`, Line: 22, Col: 107}
148 }
149 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
150 if templ_7745c5c3_Err != nil {
151 return templ_7745c5c3_Err
152 }
153 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "</div>")
154 if templ_7745c5c3_Err != nil {
155 return templ_7745c5c3_Err
156 }
157 }
158 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, " ")
159 if templ_7745c5c3_Err != nil {
160 return templ_7745c5c3_Err
161 }
162 templ_7745c5c3_Err = commentCard(pr.AuthorName, fmtTime(pr.CreatedAt), pr.Body).Render(ctx, templ_7745c5c3_Buffer)
163 if templ_7745c5c3_Err != nil {
164 return templ_7745c5c3_Err
165 }
166 for _, c := range comments {
167 templ_7745c5c3_Err = commentCard(c.AuthorName, fmtTime(c.CreatedAt), c.Body).Render(ctx, templ_7745c5c3_Buffer)
168 if templ_7745c5c3_Err != nil {
169 return templ_7745c5c3_Err
170 }
171 }
172 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, " <div class=\"card mb-6 p-4\">")
173 if templ_7745c5c3_Err != nil {
174 return templ_7745c5c3_Err
175 }
176 if pr.State == domain.PRMerged {
177 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<div class=\"flex items-center gap-2 text-merged\"><span class=\"size-2 rounded-full bg-merged\"></span> This pull request was merged.</div>")
178 if templ_7745c5c3_Err != nil {
179 return templ_7745c5c3_Err
180 }
181 } else if pr.State == domain.PRClosed {
182 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<div class=\"flex items-center gap-2 text-muted\"><span class=\"size-2 rounded-full bg-faint\"></span> This pull request was closed.</div>")
183 if templ_7745c5c3_Err != nil {
184 return templ_7745c5c3_Err
185 }
186 } else if canMerge {
187 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<div class=\"-mx-4 -mb-4 overflow-hidden rounded-md border border-accent/30\"><div class=\"flex items-center gap-3 bg-accent/[.07] px-4 py-3.5\"><span class=\"flex size-7 shrink-0 items-center justify-center rounded-full bg-grass font-bold text-grassink\">✓</span><div><div class=\"text-sm font-semibold text-ink\">This branch has no conflicts with the base branch</div><div class=\"text-xs text-muted\">Merging can be performed automatically.</div></div></div><form class=\"flex gap-2 px-4 pb-4\" method=\"post\" action=\"")
188 if templ_7745c5c3_Err != nil {
189 return templ_7745c5c3_Err
190 }
191 var templ_7745c5c3_Var9 templ.SafeURL = templ.SafeURL(repoPath(repo, "/pulls/"+itoa(pr.Number)+"/merge"))
192 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var9)))
193 if templ_7745c5c3_Err != nil {
194 return templ_7745c5c3_Err
195 }
196 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "\">")
197 if templ_7745c5c3_Err != nil {
198 return templ_7745c5c3_Err
199 }
200 templ_7745c5c3_Err = csrfField().Render(ctx, templ_7745c5c3_Buffer)
201 if templ_7745c5c3_Err != nil {
202 return templ_7745c5c3_Err
203 }
204 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<button class=\"btn btn-primary\" type=\"submit\">Merge pull request</button></form></div>")
205 if templ_7745c5c3_Err != nil {
206 return templ_7745c5c3_Err
207 }
208 } else if user != nil {
209 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<div class=\"text-sm text-muted\">You don't have permission to merge this pull request.</div>")
210 if templ_7745c5c3_Err != nil {
211 return templ_7745c5c3_Err
212 }
213 } else {
214 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<div class=\"text-sm text-muted\"><a class=\"text-accent hover:underline\" href=\"/login\">Sign in</a> to act on this pull request.</div>")
215 if templ_7745c5c3_Err != nil {
216 return templ_7745c5c3_Err
217 }
218 }
219 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</div>")
220 if templ_7745c5c3_Err != nil {
221 return templ_7745c5c3_Err
222 }
223 if cmp != nil {
224 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "<h3 class=\"mb-2 text-sm font-semibold text-muted\">")
225 if templ_7745c5c3_Err != nil {
226 return templ_7745c5c3_Err
227 }
228 var templ_7745c5c3_Var10 string
229 templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(itoa(len(cmp.Commits)))
230 if templ_7745c5c3_Err != nil {
231 return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/pull_detail.templ`, Line: 54, Col: 77}
232 }
233 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
234 if templ_7745c5c3_Err != nil {
235 return templ_7745c5c3_Err
236 }
237 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, " commits</h3>")
238 if templ_7745c5c3_Err != nil {
239 return templ_7745c5c3_Err
240 }
241 templ_7745c5c3_Err = commitsList(repo, cmp.Commits).Render(ctx, templ_7745c5c3_Buffer)
242 if templ_7745c5c3_Err != nil {
243 return templ_7745c5c3_Err
244 }
245 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, " <h3 class=\"mb-2 text-sm font-semibold text-muted\">Files changed</h3>")
246 if templ_7745c5c3_Err != nil {
247 return templ_7745c5c3_Err
248 }
249 templ_7745c5c3_Err = diffFiles(cmp.Files).Render(ctx, templ_7745c5c3_Buffer)
250 if templ_7745c5c3_Err != nil {
251 return templ_7745c5c3_Err
252 }
253 }
254 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, " ")
255 if templ_7745c5c3_Err != nil {
256 return templ_7745c5c3_Err
257 }
258 if user != nil {
259 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<form method=\"post\" action=\"")
260 if templ_7745c5c3_Err != nil {
261 return templ_7745c5c3_Err
262 }
263 var templ_7745c5c3_Var11 templ.SafeURL = templ.SafeURL(repoPath(repo, "/pulls/"+itoa(pr.Number)+"/comments"))
264 _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var11)))
265 if templ_7745c5c3_Err != nil {
266 return templ_7745c5c3_Err
267 }
268 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "\" class=\"mt-4 flex flex-col gap-3\">")
269 if templ_7745c5c3_Err != nil {
270 return templ_7745c5c3_Err
271 }
272 templ_7745c5c3_Err = csrfField().Render(ctx, templ_7745c5c3_Buffer)
273 if templ_7745c5c3_Err != nil {
274 return templ_7745c5c3_Err
275 }
276 templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "<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>")
277 if templ_7745c5c3_Err != nil {
278 return templ_7745c5c3_Err
279 }
280 }
281 return nil
282 })
283 templ_7745c5c3_Err = Layout(pr.Title+" · "+repo.Name, user).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
284 if templ_7745c5c3_Err != nil {
285 return templ_7745c5c3_Err
286 }
287 return nil
288 })
289}
290
291var _ = templruntime.GeneratedTemplate