internal/web/templates/mr.html

73c8e291f76ca4383165230e62a311bab3d4fa74
gitbay/internal/web/templates/mr.html history · blame · raw

120 lines · 6256 bytes

  1{{define "title"}}!{{.MR.Number}} · {{.Repo.OwnerName}}/{{.Repo.Name}}{{end}}
  2{{define "content"}}
  3{{$base := printf "/%s/%s/mrs/%d" .Repo.OwnerName .Repo.Name .MR.Number}}
  4<h1 class="issuetitle">{{.MR.Title}} <span class="issuenumber">!{{.MR.Number}}</span></h1>
  5<p class="issuemeta"><span class="chip chip-{{.MR.State}}">{{.MR.State}}</span>
  6<a href="/{{.MR.Author}}">{{.MR.Author}}</a> wants to merge <code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code> into <code>{{.MR.TargetRef}}</code></p>
  7
  8{{if .Notice}}<p class="error" role="alert">{{.Notice}}</p>{{end}}
  9
 10<div class="withaside">
 11<div class="mainside">
 12
 13<nav class="subtabs" aria-label="Merge request">
 14  <a {{if eq .View "conversation"}}aria-current="page" {{end}}href="{{$base}}">Conversation{{if .Comments}} <i>{{len .Comments}}</i>{{end}}</a>
 15  <a {{if eq .View "commits"}}aria-current="page" {{end}}href="{{$base}}?view=commits">Commits{{if .Commits}} <i>{{len .Commits}}</i>{{end}}</a>
 16  <a {{if eq .View "diff"}}aria-current="page" {{end}}href="{{$base}}?view=diff">Files changed{{if .Stat.Files}} <i>{{.Stat.Files}}</i>{{end}}</a>
 17</nav>
 18
 19{{if eq .View "conversation"}}
 20{{if .CanEdit}}<details class="editbox"><summary>Edit</summary>
 21<form method="post" action="{{$base}}/edit" class="commentform">
 22<p><input type="text" name="title" aria-label="Title" value="{{.MR.Title}}" required></p>
 23<p><textarea name="body" aria-label="Description" rows="8">{{.MR.Body}}</textarea></p>
 24<p><button type="submit">Save</button></p>
 25</form></details>{{end}}
 26{{if .BodyHTML}}<article class="comment">
 27  <header class="commenthead"><strong><a href="/{{.MR.Author}}">{{.MR.Author}}</a></strong></header>
 28  <div class="rendered">{{.BodyHTML}}</div>
 29</article>{{end}}
 30{{range .Comments}}
 31{{if eq .Kind "system"}}<div class="syscomment">{{.BodyHTML}} <span class="when">{{when .CreatedAt}}</span></div>
 32{{else}}<article class="comment">
 33  <header class="commenthead"><strong><a href="/{{.Author}}">{{.Author}}</a></strong> <span class="when">{{when .CreatedAt}}</span></header>
 34  <div class="rendered">{{.BodyHTML}}</div>
 35</article>{{end}}
 36{{end}}
 37{{if .DetachedThreads}}<h2>Threads on earlier revisions</h2>
 38{{range .DetachedThreads}}<div class="thread stale"><p class="threadstate">{{if .Stale}}stale{{end}}{{if .Resolved}}{{if .Stale}} · {{end}}resolved by {{.Resolved}}{{end}}</p>{{range .Comments}}<p class="commenthead"><strong>{{.Author}}</strong> <span class="when">{{when .CreatedAt}}</span></p><div class="rendered">{{.BodyHTML}}</div>{{end}}{{template "threadact" dict "ID" .ID "Resolved" .Resolved "Base" $base "Can" $.CanWrite}}</div>{{end}}{{end}}
 39{{if .Viewer}}
 40<form method="post" action="{{$base}}/comment" class="commentform">
 41<p><textarea name="body" aria-label="Comment" rows="4" placeholder="Comment as {{.Viewer}}"></textarea></p>
 42<p><button type="submit">Comment</button></p>
 43</form>
 44{{end}}
 45
 46{{else if eq .View "commits"}}
 47<ul class="loglist">
 48{{range .Commits}}<li>
 49  <div class="commitmain">
 50    <p class="subject"><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.Subject}}</a></p>
 51    <p class="meta">{{template "authorname" dict "Name" .AuthorName "User" .AuthorUser "Email" ""}} · {{.Date}}</p>
 52  </div>
 53  <div class="commitside">
 54    {{template "sigbadge" .Sig}}
 55    <code><a href="/{{$.Repo.OwnerName}}/{{$.Repo.Name}}/commit/{{.SHA}}">{{.ShortSHA}}</a></code>
 56  </div>
 57</li>
 58{{else}}<li class="empty">no commits on this merge request</li>
 59{{end}}
 60</ul>
 61
 62{{else}}
 63<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></p>
 64{{template "difffiles" dict "Files" .DiffFiles "Base" $base "Can" .CanWrite}}
 65{{end}}
 66
 67</div>
 68
 69<aside class="aside">
 70  {{if and .CanWrite (or (eq .MR.State "open") (eq .MR.State "source_gone"))}}
 71  <div class="grp">
 72    <h2>Review</h2>
 73    <form method="post" action="{{$base}}/review" class="actions">
 74      <button type="submit" name="verdict" value="approve">Approve</button>
 75      <button type="submit" name="verdict" value="request-changes">Request changes</button>
 76    </form>
 77  </div>
 78  <div class="grp">
 79    <h2>Merge</h2>
 80    {{if .Unresolved}}<p class="row none">{{.Unresolved}} unresolved thread{{if ne .Unresolved 1}}s{{end}}</p>{{end}}
 81    <form method="post" action="{{$base}}/merge" class="actions">
 82      <label class="none" for="strategy">Strategy</label>
 83      <select id="strategy" name="strategy">
 84        <option value="auto">Automatic</option>
 85        <option value="ff">Fast-forward</option>
 86        <option value="merge">Merge commit</option>
 87        <option value="squash">Squash</option>
 88        <option value="rebase">Rebase</option>
 89      </select>
 90      <button type="submit" class="primary">Merge</button>
 91    </form>
 92    <form method="post" action="{{$base}}/close" class="actions">
 93      <button type="submit">Close without merging</button>
 94    </form>
 95  </div>
 96  {{end}}
 97  <div class="grp">
 98    <h2>Reviews</h2>
 99    {{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}}</p>
100    {{else}}<p class="none">No reviews yet</p>{{end}}
101  </div>
102  <div class="grp">
103    <h2>Checks</h2>
104    {{if .Checks}}<p class="row"><span class="badge check-{{.Combined}}">{{.Combined}}</span></p>
105    {{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></p>{{end}}
106    {{else}}<p class="none">No checks reported</p>{{end}}
107  </div>
108  <div class="grp">
109    <h2>Source</h2>
110    <p class="row"><code>{{if .MR.SourcePath}}{{.MR.SourcePath}}:{{end}}{{.MR.SourceRef}}</code></p>
111    <p class="row none">into <code>{{.MR.TargetRef}}</code> at <code>{{short .MR.HeadSHA}}</code></p>
112  </div>
113  {{if .MR.Milestone}}<div class="grp">
114    <h2>Milestone</h2>
115    <p class="row"><a href="/{{.Repo.OwnerName}}/{{.Repo.Name}}/milestones">{{.MR.Milestone}}</a></p>
116  </div>{{end}}
117</aside>
118</div>
119{{end}}
120