| 1 | {{define "branches"}} |
| 2 | {{template "layout-start" .}} |
| 3 | <header class="pagehead"> |
| 4 | <h1>{{t "title.branches"}}</h1> |
| 5 | {{if .CanWrite}}<button type="button" data-branch-open="create">{{t "branch.create"}}</button>{{end}} |
| 6 | </header> |
| 7 | <label class="branchsearch">{{t "branch.search"}} |
| 8 | <input type="search" data-branch-filter autocomplete="off" placeholder="{{t "branch.search"}}"> |
| 9 | </label> |
| 10 | <div class="hscroll"> |
| 11 | <table class="branchtable"> |
| 12 | <thead> |
| 13 | <tr> |
| 14 | <th>{{t "branch.name"}}</th> |
| 15 | <th>{{t "branch.last"}}</th> |
| 16 | <th>{{t "branch.compare"}}</th> |
| 17 | <th>{{t "mr.pipeline"}}</th> |
| 18 | <th>{{t "mr.title"}}</th> |
| 19 | <th>{{t "branch.actions"}}</th> |
| 20 | </tr> |
| 21 | </thead> |
| 22 | <tbody> |
| 23 | {{range .Branches}} |
| 24 | <tr data-branch-row data-name="{{.Name}}"> |
| 25 | <td> |
| 26 | <a href="/{{$.Repo.FullPath}}?rev={{urlquery .Name}}">{{.Name}}</a> |
| 27 | {{if .Default}}<span class="pill">{{t "branch.default"}}</span>{{end}} |
| 28 | {{if .Protected}}<span class="pill">{{t "vis.protected"}}</span>{{end}} |
| 29 | </td> |
| 30 | <td> |
| 31 | {{if .SHA}}<a href="/{{$.Repo.FullPath}}/-/commit/{{.SHA}}"><code>{{.Short}}</code></a> <span class="subject" title="{{.Subject}}">{{.Subject}}</span> <span class="muted when-short" title="{{.WhenTitle}}">{{.When}}</span>{{end}} |
| 32 | </td> |
| 33 | <td class="nums"> |
| 34 | {{if and (eq .Ahead 0) (eq .Behind 0)}}<span class="muted">{{t "branch.even"}}</span>{{else}} |
| 35 | {{if .Ahead}}<span class="addstat">{{t "branch.ahead" .Ahead}}</span>{{end}} |
| 36 | {{if .Behind}}<span class="delstat">{{t "branch.behind" .Behind}}</span>{{end}} |
| 37 | {{end}} |
| 38 | </td> |
| 39 | <td> |
| 40 | {{if .PipeStatus}}<a class="status {{.PipeStatus}}" href="/{{$.Repo.FullPath}}/-/pipelines/{{.PipeID}}"><span class="mark"></span>{{.PipeLabel}}</a>{{end}} |
| 41 | </td> |
| 42 | <td class="mrlinks"> |
| 43 | {{range .OpenMRs}}<a href="/{{$.Repo.FullPath}}/-/merge-requests/{{.}}">!{{.}}</a>{{end}} |
| 44 | </td> |
| 45 | <td class="branchacts"> |
| 46 | <div class="branchline"> |
| 47 | {{if not .Default}} |
| 48 | <a class="tiny" href="/{{$.Repo.FullPath}}/-/compare?from={{urlquery $.Repo.DefaultBranch}}&to={{urlquery .Name}}">{{t "branch.compare"}}</a> |
| 49 | {{if not .OpenMRs}}<a class="tiny" href="/{{$.Repo.FullPath}}/-/merge-requests/new?source={{urlquery .Name}}&target={{urlquery $.Repo.DefaultBranch}}">{{t "branch.mrShort"}}</a>{{end}} |
| 50 | {{end}} |
| 51 | {{if and $.CanWrite (not .Default) (not .Protected)}} |
| 52 | <details class="rowmenu tiny-menu"> |
| 53 | <summary aria-label="{{t "branch.more"}}">⋯</summary> |
| 54 | <div class="menu-panel"> |
| 55 | <button type="button" class="ghost" data-rename="{{.Name}}">{{t "branch.rename"}}</button> |
| 56 | <button type="button" class="ghost" data-delete="{{.Name}}">{{t "branch.delete"}}</button> |
| 57 | </div> |
| 58 | </details> |
| 59 | {{end}} |
| 60 | </div> |
| 61 | </td> |
| 62 | </tr> |
| 63 | {{else}} |
| 64 | <tr><td colspan="6" class="muted">{{t "repo.noBranches"}}</td></tr> |
| 65 | {{end}} |
| 66 | </tbody> |
| 67 | </table> |
| 68 | </div> |
| 69 | {{if .CanWrite}} |
| 70 | <dialog class="branch-dialog" data-branch-dialog="create"> |
| 71 | <form method="post" action="/{{.Repo.FullPath}}/-/branches"> |
| 72 | <h2>{{t "branch.create"}}</h2> |
| 73 | <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| 74 | <label>{{t "branch.name"}} <input name="name" required autocomplete="off"></label> |
| 75 | <label>{{t "branch.from"}} |
| 76 | <input name="from" list="branch-revs" value="{{.Repo.DefaultBranch}}" required> |
| 77 | </label> |
| 78 | <datalist id="branch-revs"> |
| 79 | {{range .Branches}}<option value="{{.Name}}"></option>{{end}} |
| 80 | {{range .Tags}}<option value="{{.Name}}"></option>{{end}} |
| 81 | </datalist> |
| 82 | <div class="row"> |
| 83 | <button type="submit">{{t "branch.create"}}</button> |
| 84 | <button type="button" class="ghost" data-dialog-close>{{t "action.cancel"}}</button> |
| 85 | </div> |
| 86 | </form> |
| 87 | </dialog> |
| 88 | <dialog class="branch-dialog" data-branch-dialog="delete"> |
| 89 | <form method="post" action="/{{.Repo.FullPath}}/-/branches/delete"> |
| 90 | <h2>{{t "branch.delete"}}</h2> |
| 91 | <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| 92 | <input type="hidden" name="name" value="" data-delete-name> |
| 93 | <p data-delete-ask data-pattern="{{t "branch.deleteAsk" "%s"}}"></p> |
| 94 | <label>{{t "branch.confirm"}} <input name="confirm" required autocomplete="off"></label> |
| 95 | <div class="row"> |
| 96 | <button type="submit">{{t "branch.delete"}}</button> |
| 97 | <button type="button" class="ghost" data-dialog-close>{{t "action.cancel"}}</button> |
| 98 | </div> |
| 99 | </form> |
| 100 | </dialog> |
| 101 | <dialog class="branch-dialog" data-branch-dialog="rename"> |
| 102 | <form method="post" action="/{{.Repo.FullPath}}/-/branches/rename"> |
| 103 | <h2>{{t "branch.rename"}}</h2> |
| 104 | <input type="hidden" name="csrf" value="{{.CSRF}}"> |
| 105 | <input type="hidden" name="name" value="" data-rename-name> |
| 106 | <p data-rename-ask data-pattern="{{t "branch.renameAsk" "%s"}}"></p> |
| 107 | <label>{{t "branch.name"}} <input name="new_name" required autocomplete="off"></label> |
| 108 | <label>{{t "branch.confirm"}} <input name="confirm" required autocomplete="off"></label> |
| 109 | <div class="row"> |
| 110 | <button type="submit">{{t "branch.rename"}}</button> |
| 111 | <button type="button" class="ghost" data-dialog-close>{{t "action.cancel"}}</button> |
| 112 | </div> |
| 113 | </form> |
| 114 | </dialog> |
| 115 | <script src="/assets/branch.js"></script> |
| 116 | {{end}} |
| 117 | {{template "layout-end" .}} |
| 118 | {{end}} |