internal/web/templates/mr.html

353f68a2e57ac692964b73ae1f9acd91fcdcae20
gitbay/internal/web/templates/mr.html history · blame · raw

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