// 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 {
}
@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)) {
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) {
@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)) {