Skip to content

Commit 48842ed

Browse files
a1012112796zeripathsilverwindtechknowlogick
authored
ui: Show update branch item in merge box when it's necessary (#11761)
* ui: Show update branch item in merge box when it's necessary As title, should show it without care about whether this pr can be merged. fix #10959 Signed-off-by: a1012112796 <[email protected]> * fix ui * Fix ui, thanks to @silverwind. Co-authored-by: silverwind <[email protected]> * fix lint * Update templates/repo/issue/view_content/pull.tmpl Co-authored-by: silverwind <[email protected]> * Apply review suggestion Co-authored-by: zeripath <[email protected]> Co-authored-by: silverwind <[email protected]> Co-authored-by: techknowlogick <[email protected]>
1 parent 0159851 commit 48842ed

File tree

2 files changed

+53
-22
lines changed

2 files changed

+53
-22
lines changed

templates/repo/issue/view_content/pull.tmpl

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
{{- else}}red{{end}}">{{svg "octicon-git-merge" 32}}</a>
7676
<div class="content">
7777
{{template "repo/pulls/status" .}}
78+
{{$canAutoMerge := false}}
7879
<div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}}">
7980
{{if .Issue.PullRequest.HasMerged}}
8081
<div class="item text purple">
@@ -188,6 +189,30 @@
188189
{{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
189190
</div>
190191
{{end}}
192+
{{end}}
193+
194+
{{$canAutoMerge = true}}
195+
{{if (gt .Issue.PullRequest.CommitsBehind 0)}}
196+
<div class="ui divider"></div>
197+
<div class="item item-section text grey">
198+
<div class="item-section-left">
199+
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
200+
{{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
201+
</div>
202+
<div class="item-section-right">
203+
{{if .UpdateAllowed}}
204+
<form action="{{.Link}}/update" method="post" class="ui update-branch-form">
205+
{{.CsrfTokenHtml}}
206+
<button class="ui compact button" data-do="update">
207+
<span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
208+
</button>
209+
</form>
210+
{{end}}
211+
</div>
212+
</div>
213+
{{end}}
214+
215+
{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .RequireSigned) .WillSign)}}
191216
{{if .AllowMerge}}
192217
{{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
193218
{{$approvers := .Issue.PullRequest.GetApprovers}}
@@ -300,6 +325,7 @@
300325
</div>
301326
</div>
302327
{{else}}
328+
<div class="ui divider"></div>
303329
<div class="item text red">
304330
{{svg "octicon-x" 16}}
305331
{{$.i18n.Tr "repo.pulls.no_merge_desc"}}
@@ -310,32 +336,13 @@
310336
</div>
311337
{{end}}
312338
{{else}}
339+
<div class="ui divider"></div>
313340
<div class="item text grey">
314341
{{svg "octicon-info" 16}}
315342
{{$.i18n.Tr "repo.pulls.no_merge_access"}}
316343
</div>
317344
{{end}}
318345
{{end}}
319-
{{if gt .Issue.PullRequest.CommitsBehind 0}}
320-
<div class="ui very compact branch-update grid">
321-
<div class="row">
322-
<div class="item text gray eleven wide left floated column">
323-
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
324-
{{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
325-
</div>
326-
{{if .UpdateAllowed}}
327-
<div class="item text five wide right floated column">
328-
<form action="{{.Link}}/update" method="post">
329-
{{.CsrfTokenHtml}}
330-
<button class="ui button" data-do="update">
331-
<span class="item text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
332-
</button>
333-
</form>
334-
</div>
335-
{{end}}
336-
</div>
337-
</div>
338-
{{end}}
339346
{{else}}
340347
{{/* Merge conflict without specific file. Suggest manual merge, only if all reviews and status checks OK. */}}
341348
{{if .IsBlockedByApprovals}}
@@ -374,6 +381,21 @@
374381
</div>
375382
{{end}}
376383
{{end}}
384+
385+
{{if and (gt .Issue.PullRequest.CommitsBehind 0) (not .Issue.IsClosed) (not .Issue.PullRequest.IsChecking) (not .IsPullFilesConflicted) (not .IsPullRequestBroken) (not $canAutoMerge)}}
386+
<div class="item text grey">
387+
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
388+
{{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
389+
{{if .UpdateAllowed}}
390+
<form action="{{.Link}}/update" method="post" class="ui floating right">
391+
{{.CsrfTokenHtml}}
392+
<button class="ui compact button" data-do="update">
393+
<span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
394+
</button>
395+
</form>
396+
{{end}}
397+
</div>
398+
{{end}}
377399
</div>
378400
</div>
379401
</div>

web_src/less/_repository.less

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -995,8 +995,17 @@
995995
> .merge-section {
996996
background-color: #f7f7f7;
997997

998-
.item + .item {
999-
padding-top: .5rem;
998+
.item {
999+
padding: .25rem 0;
1000+
}
1001+
1002+
.item-section {
1003+
display: flex;
1004+
align-items: center;
1005+
justify-content: space-between;
1006+
padding: 0;
1007+
margin-top: -.25rem;
1008+
margin-bottom: -.25rem;
10001009
}
10011010

10021011
.divider {

0 commit comments

Comments
 (0)