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