pull_new.html
·
187 lines
·
8.6 KB
| 1 | {{define "content"}} |
| 2 | <div class="container"> |
| 3 | {{template "repo_header" .}} |
| 4 | |
| 5 | <div class="card mb-4"> |
| 6 | <div class="card-header flex items-center justify-between flex-wrap gap-3"> |
| 7 | <div class="flex items-center gap-2"> |
| 8 | {{icon "git-pull-request" "size-4"}} |
| 9 | <span class="font-semibold text-sm">{{t .Lang "pulls.compare_branches"}}</span> |
| 10 | </div> |
| 11 | <div class="flex items-center gap-2 flex-wrap text-xs"> |
| 12 | {{if gt (len .HeadRepos) 1}} |
| 13 | <label class="text-muted font-medium">{{t .Lang "pulls.head_repo"}}:</label> |
| 14 | <select class="select font-mono text-xs" style="width:auto;min-width:150px;padding:0.25rem 0.5rem;" onchange="window.location.href='?head_repo='+encodeURIComponent(this.value)"> |
| 15 | {{range .HeadRepos}} |
| 16 | <option value="{{.ID}}" {{if eq .ID $.HeadRepo.ID}}selected{{end}}>{{.OwnerUsername}}/{{.Name}}</option> |
| 17 | {{end}} |
| 18 | </select> |
| 19 | {{end}} |
| 20 | <label class="text-muted font-medium">{{t .Lang "pulls.base"}}:</label> |
| 21 | <select class="select font-mono text-xs" style="width:auto;min-width:130px;padding:0.25rem 0.5rem;" onchange="window.location.href='?base='+encodeURIComponent(this.value)+'&head={{.HeadBranch}}&head_repo={{.HeadRepo.ID}}'"> |
| 22 | {{range .BaseBranches}} |
| 23 | <option value="{{.}}" {{if eq . $.BaseBranch}}selected{{end}}>{{.}}</option> |
| 24 | {{end}} |
| 25 | </select> |
| 26 | |
| 27 | <span class="text-muted font-mono">←</span> |
| 28 | |
| 29 | <label class="text-muted font-medium">{{t .Lang "pulls.compare"}}:</label> |
| 30 | <select class="select font-mono text-xs" style="width:auto;min-width:130px;padding:0.25rem 0.5rem;" onchange="window.location.href='?base={{.BaseBranch}}&head='+encodeURIComponent(this.value)+'&head_repo={{.HeadRepo.ID}}'"> |
| 31 | {{range .Branches}} |
| 32 | <option value="{{.}}" {{if eq . $.HeadBranch}}selected{{end}}>{{.}}</option> |
| 33 | {{end}} |
| 34 | </select> |
| 35 | </div> |
| 36 | </div> |
| 37 | |
| 38 | {{if and (eq .BaseBranch .HeadBranch) (eq .HeadRepo.ID .Repo.ID)}} |
| 39 | <div class="card-body text-xs text-muted" style="background:hsl(var(--muted)/0.2);"> |
| 40 | {{icon "alert-circle" "size-4"}} {{t .Lang "pulls.branches_identical"}} |
| 41 | </div> |
| 42 | {{else}} |
| 43 | <div class="card-body text-xs flex items-center gap-2" style="background:hsl(var(--muted)/0.2);"> |
| 44 | {{if .CanMerge}} |
| 45 | <span style="color:hsl(var(--diff-add-fg));" class="flex items-center gap-1.5 font-medium"> |
| 46 | {{icon "check" "size-4"}} {{t .Lang "pulls.able_to_merge"}} |
| 47 | </span> |
| 48 | {{else}} |
| 49 | <span style="color:hsl(var(--diff-del-fg));" class="flex items-center gap-1.5 font-medium"> |
| 50 | {{icon "alert-circle" "size-4"}} {{t .Lang "pulls.cannot_merge_warning"}} |
| 51 | </span> |
| 52 | {{end}} |
| 53 | </div> |
| 54 | {{end}} |
| 55 | </div> |
| 56 | |
| 57 | {{if or (ne .BaseBranch .HeadBranch) (ne .HeadRepo.ID .Repo.ID)}} |
| 58 | <!-- Create PR Form --> |
| 59 | <section class="card mb-4"> |
| 60 | <div class="card-header"> |
| 61 | <span class="font-semibold text-sm">{{t .Lang "pulls.new"}}</span> |
| 62 | {{if ne .HeadRepo.ID .Repo.ID}} |
| 63 | <span class="text-xs text-muted font-mono">{{.HeadRepo.OwnerUsername}}/{{.HeadRepo.Name}} → {{.Repo.OwnerUsername}}/{{.Repo.Name}}</span> |
| 64 | {{end}} |
| 65 | </div> |
| 66 | <form method="post" action="/{{.Repo.OwnerUsername}}/{{.Repo.Name}}/pulls/new" class="card-body flex flex-col gap-3"> |
| 67 | <input type="hidden" name="_csrf" value="{{.CSRFToken}}"> |
| 68 | <input type="hidden" name="base_branch" value="{{.BaseBranch}}"> |
| 69 | <input type="hidden" name="head_branch" value="{{.HeadBranch}}"> |
| 70 | {{if ne .HeadRepo.ID .Repo.ID}}<input type="hidden" name="head_repo" value="{{.HeadRepo.ID}}">{{end}} |
| 71 | |
| 72 | <div> |
| 73 | <label class="label" for="title">{{t .Lang "pulls.title"}}</label> |
| 74 | <input id="title" name="title" type="text" class="input" placeholder="{{t .Lang "pulls.title_ph"}}" required maxlength="200" autofocus> |
| 75 | </div> |
| 76 | |
| 77 | <div> |
| 78 | <label class="label" for="body">{{t .Lang "pulls.body"}}</label> |
| 79 | <textarea id="body" name="body" class="textarea" rows="6" placeholder="{{t .Lang "pulls.body_ph"}}" maxlength="20000"></textarea> |
| 80 | </div> |
| 81 | |
| 82 | <div class="flex items-center justify-end"> |
| 83 | <button type="submit" class="btn btn-primary btn-sm"> |
| 84 | {{icon "git-pull-request" "size-3.5"}} |
| 85 | <span>{{t .Lang "pulls.create_btn"}}</span> |
| 86 | </button> |
| 87 | </div> |
| 88 | </form> |
| 89 | </section> |
| 90 | |
| 91 | <!-- Commits in this comparison --> |
| 92 | {{if .CompareCommits}} |
| 93 | <div class="card mb-4"> |
| 94 | <div class="card-header flex items-center justify-between"> |
| 95 | <span class="font-semibold text-xs text-muted uppercase" style="letter-spacing:0.04em;">{{t .Lang "pulls.commits"}} ({{len .CompareCommits}})</span> |
| 96 | </div> |
| 97 | <div class="dense-list"> |
| 98 | {{range .CompareCommits}} |
| 99 | <div class="dense-row" style="min-height:2.6rem;padding:0.45rem 0.85rem;"> |
| 100 | <div class="flex items-center gap-2 min-w-0"> |
| 101 | <span class="text-muted">{{icon "git-commit" "size-3.5"}}</span> |
| 102 | <span class="font-semibold text-sm truncate">{{.Subject}}</span> |
| 103 | </div> |
| 104 | <div class="flex items-center gap-2 text-xs text-muted flex-shrink-0 font-mono"> |
| 105 | <span>{{.AuthorName}}</span> |
| 106 | <span class="badge badge-outline">{{.ShortHash}}</span> |
| 107 | </div> |
| 108 | </div> |
| 109 | {{end}} |
| 110 | </div> |
| 111 | </div> |
| 112 | {{end}} |
| 113 | |
| 114 | <!-- Diff Viewer --> |
| 115 | {{if .Compare}} |
| 116 | {{if .Compare.Files}} |
| 117 | <div class="flex items-center justify-between mb-3 text-xs text-muted font-mono"> |
| 118 | <span><strong>{{.Compare.FilesChanged}}</strong> {{pluralT .Lang .Compare.FilesChanged "repo.files_changed"}}</span> |
| 119 | <div class="flex items-center gap-2"> |
| 120 | <span style="color:hsl(var(--diff-add-fg));">+{{.Compare.TotalAdditions}}</span> |
| 121 | <span style="color:hsl(var(--diff-del-fg));">-{{.Compare.TotalDeletions}}</span> |
| 122 | </div> |
| 123 | </div> |
| 124 | |
| 125 | <div class="flex flex-col gap-4"> |
| 126 | {{range .Compare.Files}} |
| 127 | <section class="card"> |
| 128 | <div class="card-header" style="padding:0.5rem 0.8rem;"> |
| 129 | <div class="flex items-center gap-2 font-mono text-xs min-w-0"> |
| 130 | {{icon "file-code" "size-4"}} |
| 131 | {{if eq .Status "renamed"}} |
| 132 | <span>{{.OldPath}} → <strong>{{.NewPath}}</strong></span> |
| 133 | {{else}} |
| 134 | <strong>{{.NewPath}}</strong> |
| 135 | {{end}} |
| 136 | </div> |
| 137 | <div class="flex items-center gap-2 font-mono text-xs"> |
| 138 | <span style="color:hsl(var(--diff-add-fg));">+{{.Additions}}</span> |
| 139 | <span style="color:hsl(var(--diff-del-fg));">-{{.Deletions}}</span> |
| 140 | </div> |
| 141 | </div> |
| 142 | |
| 143 | {{if .IsBinary}} |
| 144 | <div class="card-body text-xs text-muted">{{t $.Lang "repo.binary_notice"}}</div> |
| 145 | {{else}} |
| 146 | <div style="overflow-x:auto;"> |
| 147 | <table class="diff-table"> |
| 148 | <tbody> |
| 149 | {{range .Lines}} |
| 150 | {{if eq .Type "hunk"}} |
| 151 | <tr class="diff-row-hunk"> |
| 152 | <td class="diff-num">...</td> |
| 153 | <td class="diff-num">...</td> |
| 154 | <td class="diff-code">{{.Content}}</td> |
| 155 | </tr> |
| 156 | {{else if eq .Type "add"}} |
| 157 | <tr class="diff-row-add"> |
| 158 | <td class="diff-num"></td> |
| 159 | <td class="diff-num">{{.NewNum}}</td> |
| 160 | <td class="diff-code">+{{.Content}}</td> |
| 161 | </tr> |
| 162 | {{else if eq .Type "del"}} |
| 163 | <tr class="diff-row-del"> |
| 164 | <td class="diff-num">{{.OldNum}}</td> |
| 165 | <td class="diff-num"></td> |
| 166 | <td class="diff-code">-{{.Content}}</td> |
| 167 | </tr> |
| 168 | {{else}} |
| 169 | <tr> |
| 170 | <td class="diff-num">{{.OldNum}}</td> |
| 171 | <td class="diff-num">{{.NewNum}}</td> |
| 172 | <td class="diff-code"> {{.Content}}</td> |
| 173 | </tr> |
| 174 | {{end}} |
| 175 | {{end}} |
| 176 | </tbody> |
| 177 | </table> |
| 178 | </div> |
| 179 | {{end}} |
| 180 | </section> |
| 181 | {{end}} |
| 182 | </div> |
| 183 | {{end}} |
| 184 | {{end}} |
| 185 | {{end}} |
| 186 | </div> |
| 187 | {{end}} |