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