internal/web/templates/mr.html

184 lines · 12046 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<div class="withaside">
 19<div class="mainside">
 20
 21<nav class="subtabs" aria-label="Merge request">
 22  <a {{if eq .View "conversation"}}aria-current="page" {{end}}href="{{$base}}">Conversation{{if .Comments}} <i>{{len .Comments}}</i>{{end}}</a>
 23  <a {{if eq .View "commits"}}aria-current="page" {{end}}href="{{$base}}?view=commits">Commits{{if .Commits}} <i>{{len .Commits}}</i>{{end}}</a>
 24  <a {{if eq .View "diff"}}aria-current="page" {{end}}href="{{$base}}?view=diff">Files changed{{if .Stat.Files}} <i>{{.Stat.Files}}</i>{{end}}</a>
 25</nav>
 26
 27{{if eq .View "conversation"}}
 28<div class="prose">
 29{{if .CanEdit}}<details class="editbox"><summary>Edit</summary>
 30<form method="post" action="{{$base}}/edit" class="commentform">
 31<p><input type="text" name="title" aria-label="Title" value="{{.MR.Title}}" required></p>
 32<p><textarea name="body" aria-label="Description" rows="8">{{.MR.Body}}</textarea></p>
 33<p><button type="submit" class="btn">Save</button></p>
 34</form></details>{{end}}
 35{{if .BodyHTML}}<article class="comment">
 36  <header class="commenthead"><strong><a href="/{{.MR.Author}}">{{.MR.Author}}</a></strong></header>
 37  <div class="rendered">{{.BodyHTML}}</div>
 38</article>{{end}}
 39{{range .Comments}}
 40{{if eq .Kind "system"}}<div class="syscomment">{{.BodyHTML}} <span class="when">{{when .CreatedAt}}</span></div>
 41{{else}}<article class="comment">
 42  <header class="commenthead"><strong><a href="/{{.Author}}">{{.Author}}</a></strong> <span class="when">{{when .CreatedAt}}</span></header>
 43  <div class="rendered">{{.BodyHTML}}</div>
 44</article>{{end}}
 45{{end}}
 46{{if .DetachedThreads}}<h2>Threads on earlier revisions</h2>
 47{{range .DetachedThreads}}{{template "thread" dict "T" . "Base" $base "Viewer" $.Viewer "Class" "stale"}}{{end}}{{end}}
 48{{if .Viewer}}
 49<form method="post" action="{{$base}}/comment" class="commentform">
 50<p><textarea name="body" aria-label="Comment" rows="4" placeholder="Comment as {{.Viewer}}"></textarea></p>
 51<p><button type="submit">Comment</button></p>
 52</form>
 53{{end}}
 54</div>
 55
 56{{else if eq .View "commits"}}
 57{{if gt .CommitsTotal (len .Commits)}}<p class="meta">first {{len .Commits}} of {{.CommitsTotal}} commits; the rest are in the branch</p>{{end}}
 58<ul class="loglist">
 59{{range .Commits}}<li>
 60  <div class="commitmain">
 61    <p class="subject"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.Subject}}</a></p>
 62    <p class="meta">{{template "authorname" dict "Name" .AuthorName "User" .AuthorUser "Email" ""}} · {{when .Date}}</p>
 63  </div>
 64  <div class="commitside">
 65    {{template "sigbadge" .Sig}}
 66    <code><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></code>
 67  </div>
 68</li>
 69{{else}}<li class="empty">no commits on this merge request</li>
 70{{end}}
 71</ul>
 72
 73{{else}}
 74{{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>
 75{{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}}
 76{{template "difffiles" dict "Files" .DiffFiles "Base" $base "Viewer" .Viewer}}
 77{{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>
 78{{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}}
 79{{end}}
 80
 81</div>
 82
 83<aside class="aside">
 84  {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
 85  <div class="grp">
 86    <h2>Review</h2>
 87    <form method="post" action="{{$base}}/review" class="actions">
 88      <button type="submit" name="verdict" value="approve" class="btn">Approve</button>
 89      <button type="submit" name="verdict" value="request-changes" class="btn">Request changes</button>
 90    </form>
 91  </div>
 92  <div class="grp">
 93    <h2>Merge</h2>
 94    {{if .Unresolved}}<p class="row none">{{.Unresolved}} unresolved thread{{if ne .Unresolved 1}}s{{end}}</p>{{end}}
 95    <form method="post" action="{{$base}}/merge" class="actions">
 96      <label class="none" for="strategy">Strategy</label>
 97      <select id="strategy" name="strategy">
 98        <option value="auto">Automatic</option>
 99        <option value="ff">Fast-forward</option>
100        <option value="merge">Merge commit</option>
101        <option value="squash">Squash</option>
102        <option value="rebase">Rebase</option>
103      </select>
104      <button type="submit">Merge</button>
105    </form>
106    <form method="post" action="{{$base}}/close" class="actions">
107      <label class="vh" for="by">Closed in favour of</label>
108      <input type="text" id="by" name="by" inputmode="numeric" size="4" placeholder="!N">
109      <button type="submit" class="danger">Close without merging</button>
110    </form>
111    <form method="post" action="{{$base}}/draft" class="actions">
112      {{if .MR.Draft}}<button type="submit" class="btn">Ready for review</button>
113      {{else}}<input type="hidden" name="draft" value="on"><button type="submit" class="btn">Convert to draft</button>{{end}}
114    </form>
115  </div>
116  {{end}}
117  {{with .Gates}}<div class="grp">
118    <h2>Merge gates</h2>
119    {{if .Unmet}}{{range .Unmet}}<p class="row"><span class="dot bad"></span>{{.}}</p>{{end}}
120    {{else}}<p class="row"><span class="dot ok"></span>All gates met</p>{{end}}
121    {{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}}
122    {{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}}
123    <p class="row none">{{if .FastForward}}fast-forward possible{{else}}not a fast-forward: rebase, or merge with a merge commit{{end}}</p>
124  </div>{{end}}
125  <div class="grp">
126    <h2>Checks</h2>
127    {{if .Checks}}<p class="row"><span class="badge check-{{.Combined}}">{{.Combined}}</span></p>
128    {{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}}
129    {{else}}<p class="none">No checks reported</p>{{end}}
130  </div>
131  <div class="grp">
132    <h2>Reviews</h2>
133    {{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>
134    {{else}}<p class="none">none yet</p>{{end}}
135    {{if gt (len .Revisions) 1}}<p class="row none">{{len .Revisions}} revisions pushed. What changed between the last two:
136      <code>gitbay mr range-diff {{.Repo.OwnerName}}/{{.Repo.Name}} {{.MR.Number}}</code></p>{{end}}
137  </div>
138  <div class="grp">
139    <h2>Reviewers</h2>
140    {{if .MR.ReviewRequests}}<p class="row">{{range .MR.ReviewRequests}}<a href="/{{.}}">{{.}}</a> {{end}}</p>
141    {{else}}<p class="none">nobody yet</p>{{end}}
142    {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
143    <form method="post" action="{{$base}}/review-request" class="actions">
144      <input type="text" name="add" aria-label="Add reviewers" placeholder="add, space-separated">
145      <input type="text" name="remove" aria-label="Remove reviewers" placeholder="remove">
146      <button type="submit" class="btn">Apply</button>
147    </form>
148    {{end}}
149  </div>
150  <div class="grp">
151    <h2>Source and target</h2>
152    <p class="row"><code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code> into <code>{{.MR.TargetRef}}</code></p>
153    <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>
154    {{if and .CanEdit (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
155    <form method="post" action="{{$base}}/retarget" class="actions">
156      <label class="none" for="target">Branch</label>
157      <select id="target" name="target">
158        {{range .Branches}}<option value="{{.Name}}"{{if eq .Name $.MR.TargetRef}} selected{{end}}>{{.Name}}</option>{{end}}
159      </select>
160      <button type="submit" class="btn">Retarget</button>
161    </form>
162    <p class="row none">Retargeting stales existing reviews.</p>
163    {{end}}
164  </div>
165  {{if .MR.Milestone}}<div class="grp">
166    <h2>Milestone</h2>
167    <p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">{{.MR.Milestone}}</a></p>
168  </div>{{end}}
169  <div class="grp">
170    <h2>Labels</h2>
171    {{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>
172    {{else}}<p class="none">none yet</p>{{end}}
173    {{if .CanWrite}}
174    <form method="post" action="{{$base}}/label" class="actions">
175      <input type="text" name="add" aria-label="Add labels" placeholder="add, space-separated">
176      <input type="text" name="remove" aria-label="Remove labels" placeholder="remove">
177      <button type="submit" class="btn">Apply</button>
178    </form>
179    {{end}}
180  </div>
181</aside>
182</div>
183{{end}}
184