ikurotime / gitgud

public
main / internal/interface/web/templates/compare_templ.go
14.2 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 Compare(user *domain.User, repo *domain.Repository, base, head string, branches []string, cmp *domain.Comparison, 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-4 text-lg font-semibold tracking-tight\">Compare changes</h2>")
 51			if templ_7745c5c3_Err != nil {
 52				return templ_7745c5c3_Err
 53			}
 54			if errMsg != "" {
 55				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<div class=\"mb-4 rounded-md border border-closed/30 bg-closed/10 px-3 py-2 text-sm text-closed\">")
 56				if templ_7745c5c3_Err != nil {
 57					return templ_7745c5c3_Err
 58				}
 59				var templ_7745c5c3_Var3 string
 60				templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(errMsg)
 61				if templ_7745c5c3_Err != nil {
 62					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 10, Col: 107}
 63				}
 64				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
 65				if templ_7745c5c3_Err != nil {
 66					return templ_7745c5c3_Err
 67				}
 68				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "</div>")
 69				if templ_7745c5c3_Err != nil {
 70					return templ_7745c5c3_Err
 71				}
 72			}
 73			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, " <form method=\"get\" action=\"")
 74			if templ_7745c5c3_Err != nil {
 75				return templ_7745c5c3_Err
 76			}
 77			var templ_7745c5c3_Var4 templ.SafeURL = templ.SafeURL(repoPath(repo, "/compare"))
 78			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var4)))
 79			if templ_7745c5c3_Err != nil {
 80				return templ_7745c5c3_Err
 81			}
 82			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\" class=\"mb-6 flex flex-wrap items-center gap-2 text-sm\"><span class=\"text-muted\">base</span> <select name=\"base\" class=\"select w-auto py-1.5 font-mono text-xs\">")
 83			if templ_7745c5c3_Err != nil {
 84				return templ_7745c5c3_Err
 85			}
 86			templ_7745c5c3_Err = branchOptions(branches, base).Render(ctx, templ_7745c5c3_Buffer)
 87			if templ_7745c5c3_Err != nil {
 88				return templ_7745c5c3_Err
 89			}
 90			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "</select> <span class=\"text-faint\">←</span> <span class=\"text-muted\">compare</span> <select name=\"head\" class=\"select w-auto py-1.5 font-mono text-xs\"><option value=\"\">select branch</option>")
 91			if templ_7745c5c3_Err != nil {
 92				return templ_7745c5c3_Err
 93			}
 94			templ_7745c5c3_Err = branchOptions(branches, head).Render(ctx, templ_7745c5c3_Buffer)
 95			if templ_7745c5c3_Err != nil {
 96				return templ_7745c5c3_Err
 97			}
 98			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "</select> <button class=\"btn\" type=\"submit\">Compare</button></form>")
 99			if templ_7745c5c3_Err != nil {
100				return templ_7745c5c3_Err
101			}
102			if cmp != nil {
103				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<div class=\"mb-5 flex items-center gap-2 text-sm text-muted\"><span class=\"badge\"><span class=\"text-open\">")
104				if templ_7745c5c3_Err != nil {
105					return templ_7745c5c3_Err
106				}
107				var templ_7745c5c3_Var5 string
108				templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(itoa(len(cmp.Commits)))
109				if templ_7745c5c3_Err != nil {
110					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 27, Col: 72}
111				}
112				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
113				if templ_7745c5c3_Err != nil {
114					return templ_7745c5c3_Err
115				}
116				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</span> commits</span> <span class=\"badge\"><span class=\"text-accent\">")
117				if templ_7745c5c3_Err != nil {
118					return templ_7745c5c3_Err
119				}
120				var templ_7745c5c3_Var6 string
121				templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(itoa(len(cmp.Files)))
122				if templ_7745c5c3_Err != nil {
123					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 28, Col: 72}
124				}
125				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
126				if templ_7745c5c3_Err != nil {
127					return templ_7745c5c3_Err
128				}
129				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "</span> files changed</span></div>")
130				if templ_7745c5c3_Err != nil {
131					return templ_7745c5c3_Err
132				}
133				if user != nil && cmp.Mergeable {
134					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "<div class=\"card mb-6 p-5\"><h3 class=\"mb-3 font-semibold text-ink\">Open a pull request</h3><form method=\"post\" action=\"")
135					if templ_7745c5c3_Err != nil {
136						return templ_7745c5c3_Err
137					}
138					var templ_7745c5c3_Var7 templ.SafeURL = templ.SafeURL(repoPath(repo, "/pulls"))
139					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var7)))
140					if templ_7745c5c3_Err != nil {
141						return templ_7745c5c3_Err
142					}
143					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\" class=\"flex flex-col gap-3\">")
144					if templ_7745c5c3_Err != nil {
145						return templ_7745c5c3_Err
146					}
147					templ_7745c5c3_Err = csrfField().Render(ctx, templ_7745c5c3_Buffer)
148					if templ_7745c5c3_Err != nil {
149						return templ_7745c5c3_Err
150					}
151					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<input type=\"hidden\" name=\"base\" value=\"")
152					if templ_7745c5c3_Err != nil {
153						return templ_7745c5c3_Err
154					}
155					var templ_7745c5c3_Var8 string
156					templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(base)
157					if templ_7745c5c3_Err != nil {
158						return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 35, Col: 51}
159					}
160					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
161					if templ_7745c5c3_Err != nil {
162						return templ_7745c5c3_Err
163					}
164					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "\"> <input type=\"hidden\" name=\"head\" value=\"")
165					if templ_7745c5c3_Err != nil {
166						return templ_7745c5c3_Err
167					}
168					var templ_7745c5c3_Var9 string
169					templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(head)
170					if templ_7745c5c3_Err != nil {
171						return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 36, Col: 51}
172					}
173					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
174					if templ_7745c5c3_Err != nil {
175						return templ_7745c5c3_Err
176					}
177					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\"> <input class=\"input\" type=\"text\" name=\"title\" placeholder=\"Title\" value=\"")
178					if templ_7745c5c3_Err != nil {
179						return templ_7745c5c3_Err
180					}
181					var templ_7745c5c3_Var10 string
182					templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(head)
183					if templ_7745c5c3_Err != nil {
184						return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 37, Col: 84}
185					}
186					_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
187					if templ_7745c5c3_Err != nil {
188						return templ_7745c5c3_Err
189					}
190					templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "\"> <textarea class=\"textarea\" name=\"body\" rows=\"4\" placeholder=\"Description (markdown supported)\"></textarea><div class=\"flex justify-end\"><button class=\"btn btn-primary\" type=\"submit\">Create pull request</button></div></form></div>")
191					if templ_7745c5c3_Err != nil {
192						return templ_7745c5c3_Err
193					}
194				}
195				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, " ")
196				if templ_7745c5c3_Err != nil {
197					return templ_7745c5c3_Err
198				}
199				templ_7745c5c3_Err = commitsList(repo, cmp.Commits).Render(ctx, templ_7745c5c3_Buffer)
200				if templ_7745c5c3_Err != nil {
201					return templ_7745c5c3_Err
202				}
203				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, " ")
204				if templ_7745c5c3_Err != nil {
205					return templ_7745c5c3_Err
206				}
207				templ_7745c5c3_Err = diffFiles(cmp.Files).Render(ctx, templ_7745c5c3_Buffer)
208				if templ_7745c5c3_Err != nil {
209					return templ_7745c5c3_Err
210				}
211			}
212			return nil
213		})
214		templ_7745c5c3_Err = Layout("Compare · "+repo.Name, user).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
215		if templ_7745c5c3_Err != nil {
216			return templ_7745c5c3_Err
217		}
218		return nil
219	})
220}
221
222func branchOptions(branches []string, selected string) templ.Component {
223	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
224		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
225		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
226			return templ_7745c5c3_CtxErr
227		}
228		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
229		if !templ_7745c5c3_IsBuffer {
230			defer func() {
231				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
232				if templ_7745c5c3_Err == nil {
233					templ_7745c5c3_Err = templ_7745c5c3_BufErr
234				}
235			}()
236		}
237		ctx = templ.InitializeContext(ctx)
238		templ_7745c5c3_Var11 := templ.GetChildren(ctx)
239		if templ_7745c5c3_Var11 == nil {
240			templ_7745c5c3_Var11 = templ.NopComponent
241		}
242		ctx = templ.ClearChildren(ctx)
243		for _, b := range branches {
244			if b == selected {
245				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<option value=\"")
246				if templ_7745c5c3_Err != nil {
247					return templ_7745c5c3_Err
248				}
249				var templ_7745c5c3_Var12 string
250				templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(b)
251				if templ_7745c5c3_Err != nil {
252					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 54, Col: 20}
253				}
254				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
255				if templ_7745c5c3_Err != nil {
256					return templ_7745c5c3_Err
257				}
258				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "\" selected>")
259				if templ_7745c5c3_Err != nil {
260					return templ_7745c5c3_Err
261				}
262				var templ_7745c5c3_Var13 string
263				templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(b)
264				if templ_7745c5c3_Err != nil {
265					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 54, Col: 35}
266				}
267				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
268				if templ_7745c5c3_Err != nil {
269					return templ_7745c5c3_Err
270				}
271				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</option>")
272				if templ_7745c5c3_Err != nil {
273					return templ_7745c5c3_Err
274				}
275			} else {
276				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<option value=\"")
277				if templ_7745c5c3_Err != nil {
278					return templ_7745c5c3_Err
279				}
280				var templ_7745c5c3_Var14 string
281				templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(b)
282				if templ_7745c5c3_Err != nil {
283					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 56, Col: 20}
284				}
285				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
286				if templ_7745c5c3_Err != nil {
287					return templ_7745c5c3_Err
288				}
289				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\">")
290				if templ_7745c5c3_Err != nil {
291					return templ_7745c5c3_Err
292				}
293				var templ_7745c5c3_Var15 string
294				templ_7745c5c3_Var15, templ_7745c5c3_Err = templ.JoinStringErrs(b)
295				if templ_7745c5c3_Err != nil {
296					return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/interface/web/templates/compare.templ`, Line: 56, Col: 26}
297				}
298				_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var15))
299				if templ_7745c5c3_Err != nil {
300					return templ_7745c5c3_Err
301				}
302				templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</option>")
303				if templ_7745c5c3_Err != nil {
304					return templ_7745c5c3_Err
305				}
306			}
307		}
308		return nil
309	})
310}
311
312var _ = templruntime.GeneratedTemplate