internal/web/templates/mr.html

6521399c1c78577eb00f1bcf8947c0900b9cb62e
gitbay/internal/web/templates/mr.html

254 lines · 19173 bytes

  1{{define "width"}}{{if eq .View "diff"}}wide{{else}}reading{{end}}{{end}}
  2{{define "title"}}!{{.MR.Number}} · {{.Repo.OwnerName}}/{{.Repo.Name}}{{end}}
  3{{define "content"}}
  4{{$base := printf "/%s/%s/mrs/%d" .Repo.OwnerName .Repo.Name .MR.Number}}
  5<h1 class="issuetitle">{{.MR.Title}} <span class="issuenumber">!{{.MR.Number}}</span></h1>
  6<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}}
  7  {{if and (eq .MR.State "merged") .MR.MergedBy}}merged by <a href="/{{.MR.MergedBy}}">{{.MR.MergedBy}}</a>{{with .MR.MergedAt}} on {{when .}}{{end}}
  8  {{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}}{{if .MR.SupersededBy}}, in favour of <a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/mrs/{{.MR.SupersededBy}}">!{{.MR.SupersededBy}}</a>{{end}}
  9  {{else if or (eq .MR.State "merged") (eq .MR.State "closed")}}{{if eq .MR.State "merged"}}merged{{else}}closed without merging{{end}}
 10  {{else}}opened by <a href="/{{.MR.Author}}">{{.MR.Author}}</a> on {{when .MR.CreatedAt}}{{end}}
 11  · <code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code> into <code>{{.MR.TargetRef}}</code></p>
 12{{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}}
 13{{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}}
 14{{with field . "Supersedes"}}<p class="meta">supersedes {{range $i, $m := .}}{{if $i}}, {{end}}<a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs/{{$m.Number}}">!{{$m.Number}}</a>{{end}}</p>{{end}}
 15
 16{{if .Notice}}<p class="error" role="alert">{{.Notice}}</p>{{end}}
 17
 18{{$pc := field . "PendingComments"}}
 19<div class="mrbar">
 20<nav class="subtabs" aria-label="Merge request">
 21  <a {{if eq .View "conversation"}}aria-current="page" {{end}}href="{{$base}}">Conversation{{if .Comments}} <i>{{len .Comments}}</i>{{end}}</a>
 22  <a {{if eq .View "commits"}}aria-current="page" {{end}}href="{{$base}}?view=commits">Commits{{if .Commits}} <i>{{len .Commits}}</i>{{end}}</a>
 23  <a {{if eq .View "diff"}}aria-current="page" {{end}}href="{{$base}}?view=diff">Files changed{{if .Stat.Files}} <i>{{.Stat.Files}}</i>{{end}}</a>
 24</nav>
 25{{if and (eq .View "diff") .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
 26<details class="popover finish-review">
 27  <summary class="button">Review changes{{if $pc}} ({{$pc}}){{end}} ▾</summary>
 28  <div class="popmenu review-popmenu">
 29    {{if $pc}}<p class="review-pending">{{$pc}} pending diff comment{{if ne $pc 1}}s{{end}}</p>{{end}}
 30    <form method="post" action="{{$base}}/review" class="actions">
 31      <textarea name="body" aria-label="Review note" rows="3" placeholder="Summary review note (optional)…"></textarea>
 32      <button type="submit" name="verdict" value="approve">Approve</button>
 33      <button type="submit" name="verdict" value="request-changes" class="btn">Request changes</button>
 34      {{if $pc}}<button type="submit" name="verdict" value="comment" class="btn">Submit comments</button>
 35      <button type="submit" name="verdict" value="discard" class="danger">Discard pending</button>{{end}}
 36    </form>
 37  </div>
 38</details>
 39{{end}}
 40</div>
 41
 42{{if eq .View "diff"}}
 43{{$sel := str . "SelectedCommit"}}
 44{{if gt (len .Commits) 1}}
 45<nav class="statebar commit-picker" aria-label="Filter by commit">
 46  <a {{if eq $sel ""}}aria-current="page" {{end}}href="{{$base}}?view=diff{{if .Layout.Carry}}&amp;layout={{.Layout.Carry}}{{end}}">All commits ({{len .Commits}})</a>
 47  {{range .Commits}}<a {{if eq $sel .SHA}}aria-current="page" {{end}}href="{{$base}}?view=diff&amp;commit={{.SHA}}{{if $.Layout.Carry}}&amp;layout={{$.Layout.Carry}}{{end}}" title="{{.Subject}}"><code>{{.ShortSHA}}</code></a>{{end}}
 48</nav>
 49{{end}}
 50{{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>
 51{{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}}
 52{{template "difffiles" dict "Files" .DiffFiles "Base" $base "Viewer" .Viewer "L" .Layout "RepoPath" .Repo.Path "HeadSHA" .MR.HeadSHA}}
 53{{else if .HeadPruned}}<p class="empty-note">The head of this merge request is no longer in the repository; its diff is not available.</p>
 54{{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}}
 55
 56{{else}}
 57<div class="withaside">
 58<div class="mainside">
 59
 60{{if eq .View "conversation"}}
 61<div class="prose">
 62<h2>Discussion</h2>
 63{{if .CanEdit}}<details class="editbox"{{if .Draft.Is "edit"}} open{{end}}><summary>Edit</summary>
 64{{if .Draft.Is "edit"}}{{template "previewblock" .Draft.HTML}}{{end}}
 65<form method="post" action="{{$base}}/edit" class="commentform">
 66<p><input type="text" name="title" aria-label="Title" value="{{.Draft.Or "edit" "title" .MR.Title}}" required></p>
 67<p><textarea name="body" aria-label="Description" rows="8">{{.Draft.Or "edit" "body" .MR.Body}}</textarea></p>
 68<p><button type="submit" class="btn">Save</button> {{template "previewbtn"}}</p>
 69</form></details>{{end}}
 70{{if .BodyHTML}}<article class="comment" id="mr-body">
 71  <header class="commenthead"><strong><a href="/{{.MR.Author}}">{{.MR.Author}}</a></strong>{{if .MR.CreatedAt}} <span class="when">{{when .MR.CreatedAt}}</span>{{end}}{{if $.Viewer}}<span class="grow"></span><button type="button" class="linklike quote-btn" data-quote-from="mr-body">Quote</button>{{end}}</header>
 72  <div class="rendered">{{.BodyHTML}}</div>
 73  {{template "reactions" index .Reactions 0}}
 74</article>{{else}}{{template "reactions" index .Reactions 0}}{{end}}
 75{{range .Comments}}
 76{{if eq .Kind "system"}}<div class="syscomment">{{.BodyHTML}} <span class="when">{{when .CreatedAt}}</span></div>
 77{{else}}<article class="comment" id="comment-{{.ID}}">
 78  <header class="commenthead"><strong><a href="/{{.Author}}">{{.Author}}</a></strong> <a class="when" href="#comment-{{.ID}}">{{when .CreatedAt}}</a>{{if $.Viewer}}<span class="grow"></span><button type="button" class="linklike quote-btn" data-quote-from="comment-{{.ID}}">Quote</button>{{end}}</header>
 79  <div class="rendered">{{.BodyHTML}}</div>
 80  {{template "reactions" index $.Reactions .ID}}
 81</article>{{end}}
 82{{end}}
 83{{if .DetachedThreads}}<h2>Threads on earlier revisions</h2>
 84{{range .DetachedThreads}}{{template "thread" dict "T" . "Base" $base "Viewer" $.Viewer "Class" "stale"}}{{end}}{{end}}
 85{{if .Viewer}}
 86{{if .Draft.Is "comment"}}{{template "previewblock" .Draft.HTML}}{{end}}
 87<form method="post" action="{{$base}}/comment" class="commentform">
 88<p><textarea id="main-comment-box" name="body" aria-label="Comment" rows="4" placeholder="Comment as {{.Viewer}}">{{.Draft.Or "comment" "body" ""}}</textarea></p>
 89<p class="btngroup"><button type="submit">Comment</button> {{template "previewbtn"}} <label class="format-inline"><span class="vh">Comment markup</span><select name="format" aria-label="Comment markup">{{$cfmt := .Draft.Or "comment" "format" "md"}}<option value="md"{{if ne $cfmt "org"}} selected{{end}}>Markdown</option><option value="org"{{if eq $cfmt "org"}} selected{{end}}>Org</option></select></label></p>
 90</form>
 91{{end}}
 92</div>
 93
 94{{else if eq .View "commits"}}
 95{{if gt .CommitsTotal (len .Commits)}}<p class="meta">first {{len .Commits}} of {{.CommitsTotal}} commits; the rest are in the branch</p>{{end}}
 96<ul class="loglist">
 97{{range .Commits}}<li>
 98  <div class="commitmain">
 99    <p class="subject"><a href="{{$base}}?view=diff&amp;commit={{.SHA}}">{{.Subject}}</a></p>
100    <p class="meta">{{template "authorname" dict "Name" .AuthorName "User" .AuthorUser "Email" ""}} · {{when .Date}}</p>
101  </div>
102  <div class="commitside">
103    {{template "sigbadge" .Sig}}
104    <code><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></code>
105  </div>
106</li>
107{{else}}<li class="empty">no commits on this merge request</li>
108{{end}}
109</ul>
110{{end}}
111
112</div>
113
114<aside class="aside">
115  {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
116  <div class="grp">
117    <h2>Review</h2>
118    {{if $pc}}<p class="row review-pending">{{$pc}} pending diff comment{{if ne $pc 1}}s{{end}}</p>{{end}}
119    <form method="post" action="{{$base}}/review" class="actions">
120      <textarea name="body" aria-label="Review note" rows="2" placeholder="Optional review note"></textarea>
121      <button type="submit" name="verdict" value="approve" class="btn">Approve</button>
122      <button type="submit" name="verdict" value="request-changes" class="btn">Request changes</button>
123      {{if $pc}}<button type="submit" name="verdict" value="comment" class="btn">Submit comments</button>
124      <button type="submit" name="verdict" value="discard" class="danger">Discard pending</button>{{end}}
125    </form>
126  </div>
127  <div class="grp">
128    <h2>Merge</h2>
129    {{if .Unresolved}}<p class="row none">{{.Unresolved}} unresolved thread{{if ne .Unresolved 1}}s{{end}}</p>{{end}}
130    {{if .MR.QueuedAt}}<p class="row"><span class="dot pend"></span>Queued to merge by <a href="/{{.MR.QueuedBy}}">{{.MR.QueuedBy}}</a>{{if .MR.QueueStrategy}} ({{.MR.QueueStrategy}}){{end}}<span class="sub">{{when .MR.QueuedAt}}</span></p>
131    {{with .MR.QueueReason}}<p class="row none">waiting: {{.}}</p>{{end}}
132    <form method="post" action="{{$base}}/merge" class="actions">
133      <input type="hidden" name="cancel" value="on">
134      <button type="submit" class="btn">Cancel queued merge</button>
135    </form>{{end}}
136    {{$reqSigned := .Repo.Settings.RequireSignedCommits}}{{$hasStacked := false}}{{with field . "Stacked"}}{{if .}}{{$hasStacked = true}}{{end}}{{end}}
137    <form method="post" action="{{$base}}/merge" class="actions">
138      <label class="none" for="strategy">Strategy</label>
139      <select id="strategy" name="strategy">
140        <option value="auto">Automatic</option>
141        <option value="ff">Fast-forward</option>
142        <option value="merge"{{if $reqSigned}} disabled{{end}}>Merge commit{{if $reqSigned}} (disabled: signed commits){{end}}</option>
143        <option value="squash"{{if or $reqSigned $hasStacked}} disabled{{end}}>Squash{{if $reqSigned}} (disabled: signed commits){{else if $hasStacked}} (disabled: stacked MRs){{end}}</option>
144        <option value="rebase"{{if or $reqSigned $hasStacked}} disabled{{end}}>Rebase{{if $reqSigned}} (disabled: signed commits){{else if $hasStacked}} (disabled: stacked MRs){{end}}</option>
145      </select>
146      <button type="submit">Merge</button>
147      <button type="submit" name="when_ready" value="on" class="btn">Merge when ready</button>
148    </form>
149    {{with .Gates}}{{if and (not .FastForward) (not $reqSigned)}}
150    <form method="post" action="{{$base}}/rebase" class="actions">
151      <button type="submit" class="btn">Rebase onto {{$.MR.TargetRef}}</button>
152    </form>
153    {{end}}{{end}}
154  </div>
155  {{end}}
156  {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
157  <div class="grp">
158    <div class="grp-head">
159      <h2>State</h2>
160      <details class="popover"><summary class="popbtn">Close…</summary><div class="popmenu">
161        <form method="post" action="{{$base}}/close" class="popform">
162          <label class="vh" for="by">Closed in favour of</label>
163          <input type="text" id="by" name="by" size="6" autocomplete="off" placeholder="Superseded by !N">
164          <button type="submit" class="danger">Close without merging</button>
165        </form>
166      </div></details>
167    </div>
168    <form method="post" action="{{$base}}/draft" class="actions">
169      {{if .MR.Draft}}<button type="submit" class="btn">Ready for review</button>
170      {{else}}<input type="hidden" name="draft" value="on"><button type="submit" class="btn">Convert to draft</button>{{end}}
171    </form>
172  </div>
173  {{end}}
174  {{with .Gates}}<div class="grp">
175    <h2>Merge gates</h2>
176    {{if .Unmet}}{{range .Unmet}}<p class="row"><span class="dot bad"></span>{{.}}</p>{{end}}
177    {{else}}<p class="row"><span class="dot ok"></span>All gates met</p>{{end}}
178    {{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}}
179    {{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}}
180    {{range .ChecksMissing}}<p class="row none">waiting on <code>{{.}}</code>, not yet reported</p>{{end}}
181    <p class="row none">{{if .FastForward}}fast-forward possible{{else}}not a fast-forward: rebase, or merge with a merge commit{{end}}</p>
182  </div>{{end}}
183  <div class="grp">
184    <h2>Checks</h2>
185    {{if .Checks}}<p class="row"><span class="badge check-{{.Combined}}">{{.Combined}}</span></p>
186    {{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}}
187    {{else}}<p class="none">No checks reported</p>{{end}}
188  </div>
189  <div class="grp">
190    <h2>Reviews</h2>
191    {{range .Reviews}}<p class="row"><span class="dot {{if eq .Verdict "approve"}}ok{{else if eq .Verdict "request_changes"}}bad{{else}}pend{{end}}"></span><a href="/{{.Reviewer}}">{{.Reviewer}}</a> {{if eq .Verdict "approve"}}approved{{else if eq .Verdict "request_changes"}}requested changes{{else if eq .Verdict "comment"}}commented{{else}}{{.Verdict}}{{end}}{{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>
192    {{else}}<p class="none">none yet</p>{{end}}
193  </div>
194  {{if .Revisions}}<div class="grp">
195    <h2>Revisions</h2>
196    {{range $i, $rv := .Revisions}}<p class="row none">{{add $i 1}}. <code>{{short $rv.SHA}}</code> {{when $rv.CreatedAt}}{{if $i}} · <a href="{{$base}}/range-diff?from={{(index $.Revisions (sub $i 1)).SHA}}&amp;to={{$rv.SHA}}">compare to previous</a>{{end}}</p>
197    {{end}}
198  </div>{{end}}
199  <div class="grp">
200    <div class="grp-head">
201      <h2>Reviewers</h2>
202      {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}<details class="popover"><summary class="popbtn">Edit</summary><div class="popmenu">
203        {{with field . "People"}}<div class="picker-list">{{range .}}<form method="post" action="{{$base}}/review-request" class="inline">{{if hasStr $.MR.ReviewRequests .}}<input type="hidden" name="remove" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.}} ×</button>{{else}}<input type="hidden" name="add" value="{{.}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.}}</button>{{end}}</form>{{end}}</div>
204        <datalist id="repo-people">{{range .}}<option value="{{.}}"></option>{{end}}</datalist>{{end}}
205        <form method="post" action="{{$base}}/review-request" class="popform">
206          <input type="text" name="add" aria-label="Add reviewers" list="repo-people" autocomplete="off" spellcheck="false" placeholder="Add username…">
207          <button type="submit" class="btn">Add</button>
208        </form>
209      </div></details>{{end}}
210    </div>
211    {{if .MR.ReviewRequests}}<p class="row">{{range .MR.ReviewRequests}}<a href="/{{.}}">{{.}}</a> {{end}}</p>
212    {{else}}<p class="none">no reviewers</p>{{end}}
213  </div>
214  <div class="grp">
215    <div class="grp-head">
216      <h2>Branches</h2>
217      {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}<details class="popover"><summary class="popbtn">Retarget</summary><div class="popmenu">
218        <form method="post" action="{{$base}}/retarget" class="popform">
219          <label class="vh" for="target">Branch</label>
220          <select id="target" name="target">
221            {{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.MR.TargetRef}} selected{{end}}>{{.Name}}</option>{{end}}
222          </select>
223          <button type="submit" class="btn">Save</button>
224        </form>
225        <p class="hint">Retargeting stales existing reviews.</p>
226      </div></details>{{end}}
227    </div>
228    <p class="row"><code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code> → <code>{{.MR.TargetRef}}</code></p>
229    <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>
230  </div>
231  {{if .MR.Milestone}}<div class="grp">
232    <h2>Milestone</h2>
233    <p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/mrs?milestone={{urlquery .MR.Milestone}}">{{.MR.Milestone}}</a></p>
234  </div>{{end}}
235  <div class="grp">
236    <div class="grp-head">
237      <h2>Labels</h2>
238      {{if .CanWrite}}<details class="popover"><summary class="popbtn">Edit</summary><div class="popmenu">
239        {{with field . "AllLabels"}}<div class="picker-list">{{range .}}<form method="post" action="{{$base}}/label" class="inline">{{if hasStr $.MR.Labels .Name}}<input type="hidden" name="remove" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="true">{{.Name}} ×</button>{{else}}<input type="hidden" name="add" value="{{.Name}}"><button type="submit" class="picker-btn" aria-pressed="false">{{.Name}}</button>{{end}}</form>{{end}}</div>
240        <datalist id="repo-labels">{{range .}}<option value="{{.Name}}"></option>{{end}}</datalist>{{end}}
241        <form method="post" action="{{$base}}/label" class="popform">
242          <input type="text" name="add" aria-label="Add labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="Add label…">
243          <button type="submit" class="btn">Add</button>
244        </form>
245      </div></details>{{end}}
246    </div>
247    {{if .MR.Labels}}<p class="row">{{range .MR.Labels}}<a class="chip label" style="{{index $.LabelColors .}}" href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/mrs?label={{.}}">{{.}}</a> {{end}}</p>
248    {{else}}<p class="none">{{if or (eq .MR.State "merged") (eq .MR.State "closed")}}no labels{{else}}none yet{{end}}</p>{{end}}
249  </div>
250</aside>
251</div>
252{{end}}
253{{end}}
254
Keyboard shortcuts

Global

⌘K
Command palette & jump
/
Focus search
?
Show this help
g d
Dashboard
g e
Explore repositories
g n
Notifications

Repository & editor

t
Find file in repository
y
Copy immutable SHA permalink
g c
Code tab
g i
Issues tab
g m
Merge requests tab
g b
Builds tab
⌘↵
Submit active form