Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Show update branch item in merge box when it's necessary #11761

Merged
merged 12 commits into from
Jun 13, 2020
62 changes: 42 additions & 20 deletions templates/repo/issue/view_content/pull.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
{{- else}}red{{end}}">{{svg "octicon-git-merge" 32}}</a>
<div class="content">
{{template "repo/pulls/status" .}}
{{$canAutoMerge := false}}
<div class="ui attached merge-section segment {{if not $.LatestCommitStatus}}no-header{{end}}">
{{if .Issue.PullRequest.HasMerged}}
<div class="item text purple">
Expand Down Expand Up @@ -188,6 +189,30 @@
{{$.i18n.Tr (printf "repo.signing.wont_sign.%s" .WontSignReason) }}
</div>
{{end}}
{{end}}

{{$canAutoMerge = true}}
{{if (gt .Issue.PullRequest.CommitsBehind 0)}}
<div class="ui divider"></div>
<div class="item item-section text grey">
<div class="item-section-left">
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
{{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
</div>
<div class="item-section-right">
{{if .UpdateAllowed}}
<form action="{{.Link}}/update" method="post" class="ui update-branch-form">
{{.CsrfTokenHtml}}
<button class="ui compact button" data-do="update">
<span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
</button>
</form>
{{end}}
</div>
</div>
{{end}}

{{if and (or $.IsRepoAdmin (not $notAllOverridableChecksOk)) (or (not .RequireSigned) .WillSign)}}
{{if .AllowMerge}}
{{$prUnit := .Repository.MustGetUnit $.UnitTypePullRequests}}
{{$approvers := .Issue.PullRequest.GetApprovers}}
Expand Down Expand Up @@ -300,6 +325,7 @@
</div>
</div>
{{else}}
<div class="ui divider"></div>
<div class="item text red">
{{svg "octicon-x" 16}}
{{$.i18n.Tr "repo.pulls.no_merge_desc"}}
Expand All @@ -310,32 +336,13 @@
</div>
{{end}}
{{else}}
<div class="ui divider"></div>
<div class="item text grey">
{{svg "octicon-info" 16}}
{{$.i18n.Tr "repo.pulls.no_merge_access"}}
</div>
{{end}}
{{end}}
{{if gt .Issue.PullRequest.CommitsBehind 0}}
<div class="ui very compact branch-update grid">
<div class="row">
<div class="item text gray eleven wide left floated column">
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
{{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
</div>
{{if .UpdateAllowed}}
<div class="item text five wide right floated column">
<form action="{{.Link}}/update" method="post">
{{.CsrfTokenHtml}}
<button class="ui button" data-do="update">
<span class="item text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
</button>
</form>
</div>
{{end}}
</div>
</div>
{{end}}
{{else}}
{{/* Merge conflict without specific file. Suggest manual merge, only if all reviews and status checks OK. */}}
{{if .IsBlockedByApprovals}}
Expand Down Expand Up @@ -374,6 +381,21 @@
</div>
{{end}}
{{end}}

{{if and (gt .Issue.PullRequest.CommitsBehind 0) (not .Issue.IsClosed) (not .Issue.PullRequest.IsChecking) (not .IsPullFilesConflicted) (not .IsPullRequestBroken) (not $canAutoMerge)}}
<div class="item text grey">
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
{{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
{{if .UpdateAllowed}}
<form action="{{.Link}}/update" method="post" class="ui floating right">
{{.CsrfTokenHtml}}
<button class="ui compact button" data-do="update">
<span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
</button>
</form>
{{end}}
</div>
{{end}}
</div>
</div>
</div>
13 changes: 11 additions & 2 deletions web_src/less/_repository.less
Original file line number Diff line number Diff line change
Expand Up @@ -995,8 +995,17 @@
> .merge-section {
background-color: #f7f7f7;

.item + .item {
padding-top: .5rem;
.item {
padding: .25rem 0;
}

.item-section {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0;
margin-top: -.25rem;
margin-bottom: -.25rem;
}

.divider {
Expand Down