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