internal/web/templates/mr.html

ac8d910ff31c2fadc452928e1d56c64b4af25495
gitbay/internal/web/templates/mr.html

256 lines · 19497 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{{if $sel}}<p class="meta">One commit's changes, read-only. Review comments go on <a href="{{$base}}?view=diff{{if .Layout.Carry}}&amp;layout={{.Layout.Carry}}{{end}}">all commits</a>.</p>
 53{{template "difffiles" dict "Files" .DiffFiles "Base" "" "Viewer" "" "L" .Layout "RepoPath" .Repo.Path "HeadSHA" $sel}}
 54{{else}}{{template "difffiles" dict "Files" .DiffFiles "Base" $base "Viewer" .Viewer "L" .Layout "RepoPath" .Repo.Path "HeadSHA" .MR.HeadSHA}}{{end}}
 55{{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>
 56{{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}}
 57
 58{{else}}
 59<div class="withaside">
 60<div class="mainside">
 61
 62{{if eq .View "conversation"}}
 63<div class="prose">
 64<h2>Discussion</h2>
 65{{if .CanEdit}}<details class="editbox"{{if .Draft.Is "edit"}} open{{end}}><summary>Edit</summary>
 66{{if .Draft.Is "edit"}}{{template "previewblock" .Draft.HTML}}{{end}}
 67<form method="post" action="{{$base}}/edit" class="commentform">
 68<p><input type="text" name="title" aria-label="Title" value="{{.Draft.Or "edit" "title" .MR.Title}}" required></p>
 69<p><textarea name="body" aria-label="Description" rows="8">{{.Draft.Or "edit" "body" .MR.Body}}</textarea></p>
 70<p><button type="submit" class="btn">Save</button> {{template "previewbtn"}}</p>
 71</form></details>{{end}}
 72{{if .BodyHTML}}<article class="comment" id="mr-body">
 73  <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>
 74  <div class="rendered">{{.BodyHTML}}</div>
 75  {{template "reactions" index .Reactions 0}}
 76</article>{{else}}{{template "reactions" index .Reactions 0}}{{end}}
 77{{range .Comments}}
 78{{if eq .Kind "system"}}<div class="syscomment">{{.BodyHTML}} <span class="when">{{when .CreatedAt}}</span></div>
 79{{else}}<article class="comment" id="comment-{{.ID}}">
 80  <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>
 81  <div class="rendered">{{.BodyHTML}}</div>
 82  {{template "reactions" index $.Reactions .ID}}
 83</article>{{end}}
 84{{end}}
 85{{if .DetachedThreads}}<h2>Threads on earlier revisions</h2>
 86{{range .DetachedThreads}}{{template "thread" dict "T" . "Base" $base "Viewer" $.Viewer "Class" "stale"}}{{end}}{{end}}
 87{{if .Viewer}}
 88{{if .Draft.Is "comment"}}{{template "previewblock" .Draft.HTML}}{{end}}
 89<form method="post" action="{{$base}}/comment" class="commentform">
 90<p><textarea id="main-comment-box" name="body" aria-label="Comment" rows="4" placeholder="Comment as {{.Viewer}}">{{.Draft.Or "comment" "body" ""}}</textarea></p>
 91<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>
 92</form>
 93{{end}}
 94</div>
 95
 96{{else if eq .View "commits"}}
 97{{if gt .CommitsTotal (len .Commits)}}<p class="meta">first {{len .Commits}} of {{.CommitsTotal}} commits; the rest are in the branch</p>{{end}}
 98<ul class="loglist">
 99{{range .Commits}}<li>
100  <div class="commitmain">
101    <p class="subject"><a href="{{$base}}?view=diff&amp;commit={{.SHA}}">{{.Subject}}</a></p>
102    <p class="meta">{{template "authorname" dict "Name" .AuthorName "User" .AuthorUser "Email" ""}} · {{when .Date}}</p>
103  </div>
104  <div class="commitside">
105    {{template "sigbadge" .Sig}}
106    <code><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></code>
107  </div>
108</li>
109{{else}}<li class="empty">no commits on this merge request</li>
110{{end}}
111</ul>
112{{end}}
113
114</div>
115
116<aside class="aside">
117  {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
118  <div class="grp">
119    <h2>Review</h2>
120    {{if $pc}}<p class="row review-pending">{{$pc}} pending diff comment{{if ne $pc 1}}s{{end}}</p>{{end}}
121    <form method="post" action="{{$base}}/review" class="actions">
122      <textarea name="body" aria-label="Review note" rows="2" placeholder="Optional review note"></textarea>
123      <button type="submit" name="verdict" value="approve" class="btn">Approve</button>
124      <button type="submit" name="verdict" value="request-changes" class="btn">Request changes</button>
125      {{if $pc}}<button type="submit" name="verdict" value="comment" class="btn">Submit comments</button>
126      <button type="submit" name="verdict" value="discard" class="danger">Discard pending</button>{{end}}
127    </form>
128  </div>
129  <div class="grp">
130    <h2>Merge</h2>
131    {{if .Unresolved}}<p class="row none">{{.Unresolved}} unresolved thread{{if ne .Unresolved 1}}s{{end}}</p>{{end}}
132    {{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>
133    {{with .MR.QueueReason}}<p class="row none">waiting: {{.}}</p>{{end}}
134    <form method="post" action="{{$base}}/merge" class="actions">
135      <input type="hidden" name="cancel" value="on">
136      <button type="submit" class="btn">Cancel queued merge</button>
137    </form>{{end}}
138    {{$reqSigned := .Repo.Settings.RequireSignedCommits}}{{$hasStacked := false}}{{with field . "Stacked"}}{{if .}}{{$hasStacked = true}}{{end}}{{end}}
139    <form method="post" action="{{$base}}/merge" class="actions">
140      <label class="none" for="strategy">Strategy</label>
141      <select id="strategy" name="strategy">
142        <option value="auto">Automatic</option>
143        <option value="ff">Fast-forward</option>
144        <option value="merge"{{if $reqSigned}} disabled{{end}}>Merge commit{{if $reqSigned}} (disabled: signed commits){{end}}</option>
145        <option value="squash"{{if or $reqSigned $hasStacked}} disabled{{end}}>Squash{{if $reqSigned}} (disabled: signed commits){{else if $hasStacked}} (disabled: stacked MRs){{end}}</option>
146        <option value="rebase"{{if or $reqSigned $hasStacked}} disabled{{end}}>Rebase{{if $reqSigned}} (disabled: signed commits){{else if $hasStacked}} (disabled: stacked MRs){{end}}</option>
147      </select>
148      <button type="submit">Merge</button>
149      <button type="submit" name="when_ready" value="on" class="btn">Merge when ready</button>
150    </form>
151    {{with .Gates}}{{if and (not .FastForward) (not $reqSigned)}}
152    <form method="post" action="{{$base}}/rebase" class="actions">
153      <button type="submit" class="btn">Rebase onto {{$.MR.TargetRef}}</button>
154    </form>
155    {{end}}{{end}}
156  </div>
157  {{end}}
158  {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
159  <div class="grp">
160    <div class="grp-head">
161      <h2>State</h2>
162      <details class="popover"><summary class="popbtn">Close…</summary><div class="popmenu">
163        <form method="post" action="{{$base}}/close" class="popform">
164          <label class="vh" for="by">Closed in favour of</label>
165          <input type="text" id="by" name="by" size="6" autocomplete="off" placeholder="Superseded by !N">
166          <button type="submit" class="danger">Close without merging</button>
167        </form>
168      </div></details>
169    </div>
170    <form method="post" action="{{$base}}/draft" class="actions">
171      {{if .MR.Draft}}<button type="submit" class="btn">Ready for review</button>
172      {{else}}<input type="hidden" name="draft" value="on"><button type="submit" class="btn">Convert to draft</button>{{end}}
173    </form>
174  </div>
175  {{end}}
176  {{with .Gates}}<div class="grp">
177    <h2>Merge gates</h2>
178    {{if .Unmet}}{{range .Unmet}}<p class="row"><span class="dot bad"></span>{{.}}</p>{{end}}
179    {{else}}<p class="row"><span class="dot ok"></span>All gates met</p>{{end}}
180    {{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}}
181    {{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}}
182    {{range .ChecksMissing}}<p class="row none">waiting on <code>{{.}}</code>, not yet reported</p>{{end}}
183    <p class="row none">{{if .FastForward}}fast-forward possible{{else}}not a fast-forward: rebase, or merge with a merge commit{{end}}</p>
184  </div>{{end}}
185  <div class="grp">
186    <h2>Checks</h2>
187    {{if .Checks}}<p class="row"><span class="badge check-{{.Combined}}">{{.Combined}}</span></p>
188    {{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}}
189    {{else}}<p class="none">No checks reported</p>{{end}}
190  </div>
191  <div class="grp">
192    <h2>Reviews</h2>
193    {{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>
194    {{else}}<p class="none">none yet</p>{{end}}
195  </div>
196  {{if .Revisions}}<div class="grp">
197    <h2>Revisions</h2>
198    {{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>
199    {{end}}
200  </div>{{end}}
201  <div class="grp">
202    <div class="grp-head">
203      <h2>Reviewers</h2>
204      {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}<details class="popover"><summary class="popbtn">Edit</summary><div class="popmenu">
205        {{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>
206        <datalist id="repo-people">{{range .}}<option value="{{.}}"></option>{{end}}</datalist>{{end}}
207        <form method="post" action="{{$base}}/review-request" class="popform">
208          <input type="text" name="add" aria-label="Add reviewers" list="repo-people" autocomplete="off" spellcheck="false" placeholder="Add username…">
209          <button type="submit" class="btn">Add</button>
210        </form>
211      </div></details>{{end}}
212    </div>
213    {{if .MR.ReviewRequests}}<p class="row">{{range .MR.ReviewRequests}}<a href="/{{.}}">{{.}}</a> {{end}}</p>
214    {{else}}<p class="none">no reviewers</p>{{end}}
215  </div>
216  <div class="grp">
217    <div class="grp-head">
218      <h2>Branches</h2>
219      {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}<details class="popover"><summary class="popbtn">Retarget</summary><div class="popmenu">
220        <form method="post" action="{{$base}}/retarget" class="popform">
221          <label class="vh" for="target">Branch</label>
222          <select id="target" name="target">
223            {{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.MR.TargetRef}} selected{{end}}>{{.Name}}</option>{{end}}
224          </select>
225          <button type="submit" class="btn">Save</button>
226        </form>
227        <p class="hint">Retargeting stales existing reviews.</p>
228      </div></details>{{end}}
229    </div>
230    <p class="row"><code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code> → <code>{{.MR.TargetRef}}</code></p>
231    <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>
232  </div>
233  {{if .MR.Milestone}}<div class="grp">
234    <h2>Milestone</h2>
235    <p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/mrs?milestone={{urlquery .MR.Milestone}}">{{.MR.Milestone}}</a></p>
236  </div>{{end}}
237  <div class="grp">
238    <div class="grp-head">
239      <h2>Labels</h2>
240      {{if .CanWrite}}<details class="popover"><summary class="popbtn">Edit</summary><div class="popmenu">
241        {{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>
242        <datalist id="repo-labels">{{range .}}<option value="{{.Name}}"></option>{{end}}</datalist>{{end}}
243        <form method="post" action="{{$base}}/label" class="popform">
244          <input type="text" name="add" aria-label="Add labels" list="repo-labels" autocomplete="off" spellcheck="false" placeholder="Add label…">
245          <button type="submit" class="btn">Add</button>
246        </form>
247      </div></details>{{end}}
248    </div>
249    {{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>
250    {{else}}<p class="none">{{if or (eq .MR.State "merged") (eq .MR.State "closed")}}no labels{{else}}none yet{{end}}</p>{{end}}
251  </div>
252</aside>
253</div>
254{{end}}
255{{end}}
256
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