internal/web/templates/mr.html

167 lines · 10701 bytes

  1{{define "title"}}!{{.MR.Number}} · {{.Repo.OwnerName}}/{{.Repo.Name}}{{end}}
  2{{define "content"}}
  3{{$base := printf "/%s/%s/mrs/%d" .Repo.OwnerName .Repo.Name .MR.Number}}
  4<h1 class="issuetitle">{{.MR.Title}} <span class="issuenumber">!{{.MR.Number}}</span></h1>
  5<p class="issuemeta"><span class="chip chip-{{.MR.State}}">{{if eq .MR.State "source_gone"}}source gone{{else}}{{.MR.State}}{{end}}</span>{{if .MR.Draft}} <span class="chip chip-neutral">draft</span>{{end}}
  6  {{if and (eq .MR.State "merged") .MR.MergedBy}}merged by <a href="/{{.MR.MergedBy}}">{{.MR.MergedBy}}</a>{{with .MR.MergedAt}} on {{when .}}{{end}}
  7  {{else if and (eq .MR.State "closed") .MR.ClosedBy}}closed without merging by <a href="/{{.MR.ClosedBy}}">{{.MR.ClosedBy}}</a>{{with .MR.ClosedAt}} on {{when .}}{{end}}
  8  {{else if or (eq .MR.State "merged") (eq .MR.State "closed")}}{{if eq .MR.State "merged"}}merged{{else}}closed without merging{{end}}
  9  {{else}}opened by <a href="/{{.MR.Author}}">{{.MR.Author}}</a> on {{when .MR.CreatedAt}}{{end}}
 10  · <code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code> into <code>{{.MR.TargetRef}}</code></p>
 11{{with field . "StackedOn"}}<p class="meta">Stacked on <a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs/{{.Number}}">!{{.Number}} {{.Title}}</a>: merges into its branch until that lands, then onto its target.</p>{{end}}
 12{{with field . "Stacked"}}<p class="meta">Builds on this: {{range $i, $k := .}}{{if $i}}, {{end}}<a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs/{{$k.Number}}">!{{$k.Number}} {{$k.Title}}</a>{{end}}. Merging with squash or rebase is refused while they are open.</p>{{end}}
 13
 14{{if .Notice}}<p class="error" role="alert">{{.Notice}}</p>{{end}}
 15
 16<div class="withaside">
 17<div class="mainside">
 18
 19<nav class="subtabs" aria-label="Merge request">
 20  <a {{if eq .View "conversation"}}aria-current="page" {{end}}href="{{$base}}">Conversation{{if .Comments}} <i>{{len .Comments}}</i>{{end}}</a>
 21  <a {{if eq .View "commits"}}aria-current="page" {{end}}href="{{$base}}?view=commits">Commits{{if .Commits}} <i>{{len .Commits}}</i>{{end}}</a>
 22  <a {{if eq .View "diff"}}aria-current="page" {{end}}href="{{$base}}?view=diff">Files changed{{if .Stat.Files}} <i>{{.Stat.Files}}</i>{{end}}</a>
 23</nav>
 24
 25{{if eq .View "conversation"}}
 26<div class="prose">
 27{{if .CanEdit}}<details class="editbox"><summary>Edit</summary>
 28<form method="post" action="{{$base}}/edit" class="commentform">
 29<p><input type="text" name="title" aria-label="Title" value="{{.MR.Title}}" required></p>
 30<p><textarea name="body" aria-label="Description" rows="8">{{.MR.Body}}</textarea></p>
 31<p><button type="submit" class="btn">Save</button></p>
 32</form></details>{{end}}
 33{{if .BodyHTML}}<article class="comment">
 34  <header class="commenthead"><strong><a href="/{{.MR.Author}}">{{.MR.Author}}</a></strong></header>
 35  <div class="rendered">{{.BodyHTML}}</div>
 36</article>{{end}}
 37{{range .Comments}}
 38{{if eq .Kind "system"}}<div class="syscomment">{{.BodyHTML}} <span class="when">{{when .CreatedAt}}</span></div>
 39{{else}}<article class="comment">
 40  <header class="commenthead"><strong><a href="/{{.Author}}">{{.Author}}</a></strong> <span class="when">{{when .CreatedAt}}</span></header>
 41  <div class="rendered">{{.BodyHTML}}</div>
 42</article>{{end}}
 43{{end}}
 44{{if .DetachedThreads}}<h2>Threads on earlier revisions</h2>
 45{{range .DetachedThreads}}{{template "thread" dict "T" . "Base" $base "Viewer" $.Viewer "Class" "stale"}}{{end}}{{end}}
 46{{if .Viewer}}
 47<form method="post" action="{{$base}}/comment" class="commentform">
 48<p><textarea name="body" aria-label="Comment" rows="4" placeholder="Comment as {{.Viewer}}"></textarea></p>
 49<p><button type="submit">Comment</button></p>
 50</form>
 51{{end}}
 52</div>
 53
 54{{else if eq .View "commits"}}
 55{{if gt .CommitsTotal (len .Commits)}}<p class="meta">first {{len .Commits}} of {{.CommitsTotal}} commits; the rest are in the branch</p>{{end}}
 56<ul class="loglist">
 57{{range .Commits}}<li>
 58  <div class="commitmain">
 59    <p class="subject"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.Subject}}</a></p>
 60    <p class="meta">{{template "authorname" dict "Name" .AuthorName "User" .AuthorUser "Email" ""}} · {{when .Date}}</p>
 61  </div>
 62  <div class="commitside">
 63    {{template "sigbadge" .Sig}}
 64    <code><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></code>
 65  </div>
 66</li>
 67{{else}}<li class="empty">no commits on this merge request</li>
 68{{end}}
 69</ul>
 70
 71{{else}}
 72{{if .DiffFiles}}<p class="diffstat">{{.Stat.Files}} file{{if ne .Stat.Files 1}}s{{end}} changed, <span class="add">+{{.Stat.Adds}}</span> <span class="del">−{{.Stat.Dels}}</span>{{if .DiffTruncated}} · shown up to 4 MiB; the counts and the last file are partial{{end}}</p>
 73{{if .DiffTruncated}}<p class="error" role="alert">This diff is larger than 4 MiB and is cut off below. Fetch the branch to see all of it.</p>{{end}}
 74{{template "difffiles" dict "Files" .DiffFiles "Base" $base "Viewer" .Viewer}}
 75{{else}}<p class="empty-note">No changes between the source and target.{{if .HeadMerged}} The source branch was already merged or fast-forwarded into <code>{{.MR.TargetRef}}</code>.{{end}}</p>{{end}}
 76{{end}}
 77
 78</div>
 79
 80<aside class="aside">
 81  {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
 82  <div class="grp">
 83    <h2>Review</h2>
 84    <form method="post" action="{{$base}}/review" class="actions">
 85      <button type="submit" name="verdict" value="approve" class="btn">Approve</button>
 86      <button type="submit" name="verdict" value="request-changes" class="btn">Request changes</button>
 87    </form>
 88  </div>
 89  <div class="grp">
 90    <h2>Merge</h2>
 91    {{if .Unresolved}}<p class="row none">{{.Unresolved}} unresolved thread{{if ne .Unresolved 1}}s{{end}}</p>{{end}}
 92    <form method="post" action="{{$base}}/merge" class="actions">
 93      <label class="none" for="strategy">Strategy</label>
 94      <select id="strategy" name="strategy">
 95        <option value="auto">Automatic</option>
 96        <option value="ff">Fast-forward</option>
 97        <option value="merge">Merge commit</option>
 98        <option value="squash">Squash</option>
 99        <option value="rebase">Rebase</option>
100      </select>
101      <button type="submit">Merge</button>
102    </form>
103    <form method="post" action="{{$base}}/close" class="actions">
104      <button type="submit" class="danger">Close without merging</button>
105    </form>
106    <form method="post" action="{{$base}}/draft" class="actions">
107      {{if .MR.Draft}}<button type="submit" class="btn">Ready for review</button>
108      {{else}}<input type="hidden" name="draft" value="on"><button type="submit" class="btn">Convert to draft</button>{{end}}
109    </form>
110  </div>
111  {{end}}
112  {{with .Gates}}<div class="grp">
113    <h2>Merge gates</h2>
114    {{if .Unmet}}{{range .Unmet}}<p class="row"><span class="dot bad"></span>{{.}}</p>{{end}}
115    {{else}}<p class="row"><span class="dot ok"></span>All gates met</p>{{end}}
116    {{if .ApprovalsRequired}}<p class="row none">approvals: {{len .Approvals}} of {{.ApprovalsRequired}}{{if .Approvals}} ({{range $i, $a := .Approvals}}{{if $i}}, {{end}}{{$a}}{{end}}){{end}}</p>{{end}}
117    {{range .OwnersOutstanding}}<p class="row none">waiting on {{range $i, $o := .Owners}}{{if $i}} or {{end}}<a href="/{{$o}}">{{$o}}</a>{{end}} for {{range $i, $f := .Files}}{{if $i}}, {{end}}<code>{{$f}}</code>{{end}}</p>{{end}}
118    <p class="row none">{{if .FastForward}}fast-forward possible{{else}}not a fast-forward: rebase, or merge with a merge commit{{end}}</p>
119  </div>{{end}}
120  <div class="grp">
121    <h2>Checks</h2>
122    {{if .Checks}}<p class="row"><span class="badge check-{{.Combined}}">{{.Combined}}</span></p>
123    {{range .Checks}}<p class="row"><span class="dot {{if eq .State "success"}}ok{{else if eq .State "failure"}}bad{{else}}pend{{end}}"></span>{{if .TargetURL}}<a href="{{.TargetURL}}" rel="nofollow">{{.Context}}</a>{{else}}{{.Context}}{{end}} <span class="none">{{.State}}</span><span class="sub">{{when .UpdatedAt}}{{if .Duration}} · {{.Duration}}{{end}}</span></p>{{end}}
124    {{else}}<p class="none">No checks reported</p>{{end}}
125  </div>
126  <div class="grp">
127    <h2>Reviews</h2>
128    {{range .Reviews}}<p class="row"><span class="dot {{if eq .Verdict "approve"}}ok{{else}}pend{{end}}"></span><a href="/{{.Reviewer}}">{{.Reviewer}}</a> {{.Verdict}}{{if .Stale}} <span class="chip chip-stale">stale</span>{{end}}{{if not .Counts}} <span class="chip chip-neutral" title="This reviewer has no write access, so the merge gates do not count it">advisory</span>{{end}}<span class="sub">{{when .CreatedAt}}</span></p>
129    {{else}}<p class="none">none yet</p>{{end}}
130    {{if gt (len .Revisions) 1}}<p class="row none">{{len .Revisions}} revisions pushed. What changed between the last two:
131      <code>gitbay mr range-diff {{.Repo.OwnerName}}/{{.Repo.Name}} {{.MR.Number}}</code></p>{{end}}
132  </div>
133  <div class="grp">
134    <h2>Reviewers</h2>
135    {{if .MR.ReviewRequests}}<p class="row">{{range .MR.ReviewRequests}}<a href="/{{.}}">{{.}}</a> {{end}}</p>
136    {{else}}<p class="none">nobody yet</p>{{end}}
137    {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
138    <form method="post" action="{{$base}}/review-request" class="actions">
139      <input type="text" name="add" aria-label="Add reviewers" placeholder="add, space-separated">
140      <input type="text" name="remove" aria-label="Remove reviewers" placeholder="remove">
141      <button type="submit" class="btn">Apply</button>
142    </form>
143    {{end}}
144  </div>
145  <div class="grp">
146    <h2>Source and target</h2>
147    <p class="row"><code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code> into <code>{{.MR.TargetRef}}</code></p>
148    <p class="row none">{{if eq .MR.State "merged"}}merged at{{else}}head{{end}} <code>{{short .MR.HeadSHA}}</code>{{if .Base}} · base <code>{{short .Base}}</code>{{end}}{{if .SourceGone}} · <span class="chip chip-neutral">branch deleted</span>{{end}}</p>
149    {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
150    <form method="post" action="{{$base}}/retarget" class="actions">
151      <label class="none" for="target">Branch</label>
152      <select id="target" name="target">
153        {{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.MR.TargetRef}} selected{{end}}>{{.Name}}</option>{{end}}
154      </select>
155      <button type="submit" class="btn">Retarget</button>
156    </form>
157    <p class="row none">Retargeting stales existing reviews.</p>
158    {{end}}
159  </div>
160  {{if .MR.Milestone}}<div class="grp">
161    <h2>Milestone</h2>
162    <p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">{{.MR.Milestone}}</a></p>
163  </div>{{end}}
164</aside>
165</div>
166{{end}}
167