// SPDX-License-Identifier: AGPL-3.0-or-later package web import "strings" // MRList is the list of the merge requests of a repository: the open ones, // then the merged and closed ones. templ MRList(l Layout, p MRListPage) { @Shell(l, mrListRail(p)) { if p.Live {
}
if p.Newest == "" {

open{ itoa(len(p.Open)) }

@mrRows(p.Open, "Open merge requests") if len(p.Open) == 0 {

no open merge requests.

} if p.OpenNote != "" {

{ p.OpenNote }

} }

merged and closed{ itoa(len(p.Done)) }

@mrRows(p.Done, "Merged and closed merge requests") if len(p.Done) == 0 {

nothing merged or closed yet.

} if p.Older != "" || p.Newest != "" { } } } templ mrRows(rows []MRRow, label string) { if len(rows) > 0 { for _, m := range rows { }
{ m.Number } { m.State } { m.Title } { m.Branches } { m.Author } if m.WhenAt != "" { }
} } templ mrListRail(p MRListPage) {

states

open
awaits review
merged
the target took the branch
closed
refused, branch kept

open one

if len(p.Branches) > 0 {

compare a branch with { p.Default }:

} else {

there is no other branch to merge yet.

} @CloneBlock(p.CLI)
} // MergeRequest is a merge request: its facts, its description, the diff with // the notes under their lines, the general comments; and in the rail the merge // form, the checks, the settings, the commits and the files. templ MergeRequest(l Layout, p MRPage) { @Shell(l, mrRail(p)) {

{ p.Number } { p.Title }

state
{ p.State } if p.MergedShort != "" { { " · " }{ p.MergedShort }{ " · " + p.MergeMode } }
branch
@branchLink(p.Source, p.SourceHref) { " → " } @branchLink(p.Target, p.TargetHref)
opened
{ p.Opened.Name } if p.Opened.WhenAt != "" { { " · " } }
if p.UpdatedAt != "" {
updated
}
if len(p.Desc) > 0 {

@userText(p.Desc)

} if p.Since != nil { } if p.SinceNote != "" {

{ p.SinceNote }

} if p.Invisible {

this diff holds invisible characters (direction controls, zero-width characters). They are shown as <U+XXXX> markers, never applied.

} if p.Note != "" {

{ p.Note }

}
for _, f := range p.Files { @DiffFileView(f, p.DiffView) } if len(p.Files) == 0 {

no changed files.

}

comments{ itoa(p.NUnresolved) } open / { itoa(p.NComments) }

for _, c := range p.Loose { @commentView(c, "") } for _, c := range p.General { @commentView(c, "") } if p.NComments == 0 {

no comments yet.

} if p.GeneralForm != nil { @commentForm(*p.GeneralForm, "") } } } templ branchLink(name, href string) { if href != "" { { name } } else { { name } } } // lineNotes are the comments under a line of the diff, and the form to write // one when the reader asked for it. The diff is in the page twice (unified and // split); the suffix keeps the ids unique, the unified table having none. templ lineNotes(notes []CommentView, form *CommentForm, suffix string) { for _, c := range notes { @commentView(c, suffix) } if form != nil { @commentForm(*form, suffix) } } // commentView is a note: a ruled block, under its line in the diff or in the // list of comments. The text is plain: escaped, its line breaks kept, its // http(s) addresses linked. templ commentView(c CommentView, suffix string) {

{ c.Author } if c.WhenAt != "" { { " " } } if c.Resolved { { " " }resolved } if c.Outdated { { " " }outdated } if c.Where != "" { { " " }{ c.Where } }

@userText(c.Parts)

if c.Resolve != nil {
}
} func boolText(b bool) string { if b { return "true" } return "false" } // commentForm writes a comment, general or on a line. templ commentForm(f CommentForm, suffix string) {
if f.Path != "" { }
if f.Cancel != "" { [cancel] }
} templ mrRail(p MRPage) { if p.Box != nil { @mergeBox(p) }

checks 0

no checks

there is no CI yet: nothing blocks the merge.

settings

modes
{ strings.Join(p.Modes, ", ") }
checks
if p.ChecksBlock { failing ones block the merge } else { do not block the merge }

commits { itoa(len(p.Commits)) }

if len(p.Commits) == 0 {

no commit to merge.

} if p.CommitsNote != "" {

{ p.CommitsNote }

}

files { itoa(len(p.Files)) }

@FileList(p.Files)
} // mergeBox is the first block of the rail of an open request, for the owner: // the merge form (it carries the head that was read), the terminal lines, and // the other things one does with the request. templ mergeBox(p MRPage) {

merge

head
if p.Box.HeadGone { gone: the source branch was deleted } else { { p.HeadShort } }
into
{ p.Target }
if !p.Box.HeadGone {
}
if p.Box.CanMarkRead {
}
if !p.Box.HeadGone {

or from a terminal

@CloneBlock(p.Box.CLI) }
} // Compare is a branch against the default branch: the commits it is ahead by, // its diff when the API can give one, and the form that opens a merge request. templ Compare(l Layout, p ComparePage) { @Shell(l, compareRail(p)) {

{ p.Source } → { p.Target }

branch
{ p.Source }
target
{ p.Target }
ahead
{ p.AheadText }
if p.Note != "" {

{ p.Note }

} if p.Existing != nil {

an open merge request already covers these branches: { p.Existing.Label }

} if p.Create != nil {
} if p.HasDiff { if p.Invisible {

this diff holds invisible characters (direction controls, zero-width characters). They are shown as <U+XXXX> markers, never applied.

}
for _, f := range p.Files { @DiffFileView(f, p.DiffView) }
} } } templ compareRail(p ComparePage) {

commits { itoa(len(p.Ahead)) }

if len(p.Ahead) == 0 {

no commit ahead of { p.Target }.

}
if p.HasDiff {

files { itoa(len(p.Files)) }

@FileList(p.Files)
}

from a terminal

@CloneBlock(p.CLI)
}