HTML · 15181 bytes Raw Blame History
1 {{ define "page" -}}
2 <section class="shithub-pull-view">
3 <header class="shithub-pull-head">
4 <h1>
5 <span>{{ .PR.ITitle }}</span>
6 <span class="shithub-issue-num">#{{ .PR.INumber }}</span>
7 </h1>
8 <div class="shithub-issue-meta">
9 {{ if .PR.MergedAt.Valid }}
10 <span class="shithub-pill shithub-pull-merged">⏵ Merged</span>
11 {{ else if eq (printf "%s" .PR.IState) "open" }}
12 <span class="shithub-pill shithub-issues-state-open">{{ if .PR.Draft }}◔ Draft{{ else }}● Open{{ end }}</span>
13 {{ else }}
14 <span class="shithub-pill shithub-issues-state-closed">✗ Closed</span>
15 {{ end }}
16 {{ if .AuthorName }}<a href="/{{ .AuthorName }}">{{ .AuthorName }}</a>{{ end }}
17 wants to merge <code>{{ .PR.HeadRef }}</code> into <code>{{ .PR.BaseRef }}</code>
18 </div>
19 </header>
20
21 <nav class="shithub-pull-tabs">
22 <a class="shithub-pull-tab {{ if eq .Tab "conversation" }}shithub-pull-tab-active{{ end }}"
23 href="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}">Conversation</a>
24 <a class="shithub-pull-tab {{ if eq .Tab "commits" }}shithub-pull-tab-active{{ end }}"
25 href="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}/commits">Commits</a>
26 <a class="shithub-pull-tab {{ if eq .Tab "files" }}shithub-pull-tab-active{{ end }}"
27 href="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}/files">Files changed</a>
28 <a class="shithub-pull-tab {{ if eq .Tab "checks" }}shithub-pull-tab-active{{ end }}"
29 href="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}/checks">Checks</a>
30 </nav>
31
32 {{ if eq .Tab "conversation" }}
33 <div class="shithub-pull-grid">
34 <article class="shithub-issue-thread">
35 <div class="shithub-comment">
36 <div class="shithub-comment-head">
37 {{ if .AuthorName }}<a href="/{{ .AuthorName }}">{{ .AuthorName }}</a>{{ end }}
38 <time datetime="{{ .PR.ICreatedAt.Time.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .PR.ICreatedAt.Time }}</time>
39 </div>
40 <div class="shithub-comment-body markdown-body">
41 {{ if .PR.IBodyHtmlCached.Valid }}{{ safeHTML .PR.IBodyHtmlCached.String }}{{ else }}<p>{{ .PR.IBody }}</p>{{ end }}
42 </div>
43 </div>
44 {{ range .Comments }}
45 <div class="shithub-comment">
46 <div class="shithub-comment-head">
47 {{ if .AuthorName }}<a href="/{{ .AuthorName }}">{{ .AuthorName }}</a>{{ end }}
48 commented
49 <time datetime="{{ .C.CreatedAt.Time.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .C.CreatedAt.Time }}</time>
50 </div>
51 <div class="shithub-comment-body markdown-body">
52 {{ if .C.BodyHtmlCached.Valid }}{{ safeHTML .C.BodyHtmlCached.String }}{{ else }}<p>{{ .C.Body }}</p>{{ end }}
53 </div>
54 </div>
55 {{ end }}
56 {{ range .Events }}
57 <div class="shithub-event">
58 <span class="shithub-event-kind">{{ .Kind }}</span>
59 <time datetime="{{ .CreatedAt.Time.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .CreatedAt.Time }}</time>
60 </div>
61 {{ end }}
62 </article>
63
64 <aside class="shithub-pull-merge">
65 {{ if .Reviews }}
66 <section class="shithub-pull-reviews">
67 <h3>Reviews</h3>
68 <ul class="shithub-pull-reviews-list">
69 {{ range .Reviews }}
70 <li class="shithub-pull-review-{{ printf "%s" .R.State }}{{ if .R.DismissedAt.Valid }} shithub-pull-review-dismissed{{ end }}">
71 <span class="shithub-pull-review-state">
72 {{ if eq (printf "%s" .R.State) "approve" }}✓ approved{{ else if eq (printf "%s" .R.State) "request_changes" }}✗ changes requested{{ else }}● commented{{ end }}
73 </span>
74 {{ if .AuthorName }}<a href="/{{ .AuthorName }}">{{ .AuthorName }}</a>{{ end }}
75 <time datetime="{{ .R.SubmittedAt.Time.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .R.SubmittedAt.Time }}</time>
76 {{ if .R.DismissedAt.Valid }}<small>dismissed</small>{{ end }}
77 </li>
78 {{ end }}
79 </ul>
80 </section>
81 {{ end }}
82
83 {{ if .ReviewRequests }}
84 <section class="shithub-pull-reviewers">
85 <h3>Reviewers</h3>
86 <ul class="shithub-pull-reviewers-list">
87 {{ range .ReviewRequests }}
88 {{ if not .R.DismissedAt.Valid }}
89 <li>
90 <a href="/{{ .Username }}">@{{ .Username }}</a>
91 {{ if .R.SatisfiedByReviewID.Valid }}<small>reviewed</small>{{ else }}<small>pending</small>{{ end }}
92 </li>
93 {{ end }}
94 {{ end }}
95 </ul>
96 </section>
97 {{ end }}
98
99 {{ if .Viewer.ID }}
100 <details class="shithub-pull-request-reviewer">
101 <summary class="shithub-button">Request review</summary>
102 <form method="post" action="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}/reviewers">
103 <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
104 <input type="text" name="username" placeholder="username" required>
105 <button type="submit" class="shithub-button">Request</button>
106 </form>
107 </details>
108
109 {{ if not .PR.MergedAt.Valid }}
110 {{ if eq (printf "%s" .PR.IState) "open" }}
111 <details class="shithub-pull-submit-review">
112 <summary class="shithub-button">Submit review</summary>
113 <form method="post" action="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}/reviews" class="shithub-pull-review-form">
114 <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
115 <textarea name="body" rows="4" placeholder="Leave a review comment (optional)"></textarea>
116 <select name="state">
117 <option value="comment">Comment</option>
118 {{ if not (and .PR.IAuthorUserID.Valid (eq .PR.IAuthorUserID.Int64 .Viewer.ID)) }}
119 <option value="approve">Approve</option>
120 <option value="request_changes">Request changes</option>
121 {{ end }}
122 </select>
123 <button type="submit" class="shithub-button shithub-button-primary">Submit</button>
124 </form>
125 </details>
126 {{ end }}
127 {{ end }}
128 {{ end }}
129
130 {{ if .PR.MergedAt.Valid }}
131 <p>Merged via <code>{{ printf "%s" .PR.MergeMethod.PrMergeMethod }}</code>.</p>
132 {{ else if eq (printf "%s" .PR.IState) "closed" }}
133 <p>This PR is closed without being merged.</p>
134 {{ else }}
135 <h3>Mergeability</h3>
136 <p class="shithub-pull-state-{{ printf "%s" .PR.MergeableState }}">
137 {{ printf "%s" .PR.MergeableState }}
138 </p>
139 {{ if .Viewer.ID }}
140 {{ if eq (printf "%s" .PR.MergeableState) "clean" }}
141 <form method="post" action="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}/merge" class="shithub-pull-merge-form">
142 <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
143 <select name="method">
144 {{ if .Repo.AllowMergeCommit }}<option value="merge" {{ if eq (printf "%s" .Repo.DefaultMergeMethod) "merge" }}selected{{ end }}>Merge commit</option>{{ end }}
145 {{ if .Repo.AllowSquashMerge }}<option value="squash" {{ if eq (printf "%s" .Repo.DefaultMergeMethod) "squash" }}selected{{ end }}>Squash and merge</option>{{ end }}
146 {{ if .Repo.AllowRebaseMerge }}<option value="rebase" {{ if eq (printf "%s" .Repo.DefaultMergeMethod) "rebase" }}selected{{ end }}>Rebase and merge</option>{{ end }}
147 </select>
148 <button type="submit" class="shithub-button shithub-button-primary">Merge pull request</button>
149 </form>
150 {{ else if eq (printf "%s" .PR.MergeableState) "dirty" }}
151 <p class="shithub-error">This branch has conflicts that must be resolved manually.</p>
152 {{ else if eq (printf "%s" .PR.MergeableState) "behind" }}
153 <p class="shithub-muted">Head has no commits ahead of base.</p>
154 {{ else }}
155 <p class="shithub-muted">Mergeability is being computed…</p>
156 {{ end }}
157 <form method="post" action="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}/state" class="shithub-pull-state-form">
158 <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
159 <button type="submit" name="state" value="closed" class="shithub-button">Close pull request</button>
160 </form>
161 {{ if .PR.Draft }}
162 <form method="post" action="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}/ready">
163 <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
164 <button type="submit" class="shithub-button">Ready for review</button>
165 </form>
166 {{ end }}
167 {{ end }}
168 {{ end }}
169 </aside>
170 </div>
171 {{ else if eq .Tab "commits" }}
172 <ul class="shithub-pull-commits">
173 {{ range .Commits }}
174 <li>
175 <a href="/{{ $.Owner }}/{{ $.Repo.Name }}/commit/{{ .Sha }}"><code>{{ slice .Sha 0 7 }}</code></a>
176 {{ .Subject }}
177 <small>by {{ .AuthorName }}</small>
178 </li>
179 {{ else }}
180 <li class="shithub-muted">No commits.</li>
181 {{ end }}
182 </ul>
183 {{ else if eq .Tab "files" }}
184 {{ if .DiffHTML }}
185 <div class="shithub-diff">{{ safeHTML .DiffHTML }}</div>
186 {{ else }}
187 <p class="shithub-muted">No diff available.</p>
188 {{ end }}
189
190 {{ if .ThreadsByFile }}
191 <section class="shithub-pull-threads">
192 <h3>Inline comments</h3>
193 {{ range $path, $threads := .ThreadsByFile }}
194 {{ if $threads }}
195 <details class="shithub-pull-thread-file" open>
196 <summary><code>{{ $path }}</code> · {{ len $threads }}</summary>
197 {{ range $threads }}
198 <div class="shithub-pull-thread{{ if not .C.CurrentPosition.Valid }} shithub-pull-thread-outdated{{ end }}{{ if .C.ResolvedAt.Valid }} shithub-pull-thread-resolved{{ end }}">
199 <div class="shithub-comment-head">
200 {{ if .AuthorName }}<a href="/{{ .AuthorName }}">{{ .AuthorName }}</a>{{ end }}
201 line {{ .C.OriginalLine }}
202 <time datetime="{{ .C.CreatedAt.Time.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .C.CreatedAt.Time }}</time>
203 {{ if not .C.CurrentPosition.Valid }}<span class="shithub-pill">outdated</span>{{ end }}
204 {{ if .C.ResolvedAt.Valid }}<span class="shithub-pill">resolved</span>{{ end }}
205 </div>
206 <div class="shithub-comment-body markdown-body">
207 {{ if .C.BodyHtmlCached.Valid }}{{ safeHTML .C.BodyHtmlCached.String }}{{ else }}<p>{{ .C.Body }}</p>{{ end }}
208 </div>
209 {{ if $.Viewer.ID }}
210 <div class="shithub-pull-thread-actions">
211 <form method="post" action="/{{ $.Owner }}/{{ $.Repo.Name }}/pulls/{{ $.PR.INumber }}/review-comments/{{ .C.ID }}/reply">
212 <input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}">
213 <textarea name="body" rows="2" placeholder="Reply…"></textarea>
214 <button type="submit" class="shithub-button">Reply</button>
215 </form>
216 <form method="post" action="/{{ $.Owner }}/{{ $.Repo.Name }}/pulls/{{ $.PR.INumber }}/review-comments/{{ .C.ID }}/{{ if .C.ResolvedAt.Valid }}reopen{{ else }}resolve{{ end }}">
217 <input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}">
218 <button type="submit" class="shithub-button">{{ if .C.ResolvedAt.Valid }}Reopen{{ else }}Resolve{{ end }}</button>
219 </form>
220 </div>
221 {{ end }}
222 </div>
223 {{ end }}
224 </details>
225 {{ end }}
226 {{ end }}
227
228 {{ if .Viewer.ID }}
229 <details class="shithub-pull-add-comment">
230 <summary class="shithub-button">Add inline comment</summary>
231 <form method="post" action="/{{ .Owner }}/{{ .Repo.Name }}/pulls/{{ .PR.INumber }}/review-comments">
232 <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}">
233 <input type="text" name="file_path" placeholder="path" required>
234 <input type="number" name="line" placeholder="line" required>
235 <input type="number" name="position" placeholder="position" required>
236 <input type="hidden" name="commit_sha" value="{{ .PR.HeadOid }}">
237 <input type="hidden" name="side" value="right">
238 <textarea name="body" rows="3" required></textarea>
239 <button type="submit" class="shithub-button">Add comment</button>
240 </form>
241 </details>
242 {{ end }}
243 </section>
244 {{ end }}
245 {{ else if eq .Tab "checks" }}
246 {{ if .CheckGroups }}
247 <section class="shithub-pull-checks">
248 {{ range .CheckGroups }}
249 <div class="shithub-pull-check-suite">
250 <h3>
251 <span class="shithub-pull-check-app">{{ .Suite.AppSlug }}</span>
252 <span class="shithub-pull-check-suite-status shithub-pull-check-status-{{ printf "%s" .Suite.Status }}">
253 {{ printf "%s" .Suite.Status }}
254 </span>
255 {{ if .Suite.Conclusion.Valid }}
256 <span class="shithub-pull-check-conclusion shithub-pull-check-conclusion-{{ printf "%s" .Suite.Conclusion.CheckConclusion }}">
257 {{ printf "%s" .Suite.Conclusion.CheckConclusion }}
258 </span>
259 {{ end }}
260 </h3>
261 <ul class="shithub-pull-check-runs">
262 {{ range .Runs }}
263 <li class="shithub-pull-check-run">
264 <span class="shithub-pull-check-status shithub-pull-check-status-{{ printf "%s" .R.Status }}"></span>
265 <strong>{{ .R.Name }}</strong>
266 {{ if .R.Conclusion.Valid }}
267 <span class="shithub-pull-check-conclusion shithub-pull-check-conclusion-{{ printf "%s" .R.Conclusion.CheckConclusion }}">
268 {{ printf "%s" .R.Conclusion.CheckConclusion }}
269 </span>
270 {{ else }}
271 <span class="shithub-muted">{{ printf "%s" .R.Status }}</span>
272 {{ end }}
273 {{ if .R.CompletedAt.Valid }}<small><time datetime="{{ .R.CompletedAt.Time.Format "2006-01-02T15:04:05Z" }}">{{ relativeTime .R.CompletedAt.Time }}</time></small>{{ end }}
274 {{ if .R.DetailsUrl }}<a href="{{ .R.DetailsUrl }}" rel="noopener noreferrer">details</a>{{ end }}
275 {{ if .SummaryHTML }}
276 <details>
277 <summary class="shithub-muted">summary</summary>
278 <div class="markdown-body">{{ .SummaryHTML }}</div>
279 </details>
280 {{ end }}
281 </li>
282 {{ end }}
283 </ul>
284 </div>
285 {{ end }}
286 </section>
287 {{ else }}
288 <p class="shithub-muted">No checks have reported on <code>{{ slice .PR.HeadOid 0 7 }}</code>. Post via <code>POST /api/v1/repos/{{ .Owner }}/{{ .Repo.Name }}/check-runs</code>.</p>
289 {{ end }}
290 {{ end }}
291 </section>
292 {{- end }}