Don't show a dropdown menu when only 1 merge option is available (#13660) (#13670)

This commit is contained in:
Jimmy Praet 2020-11-22 14:58:12 +01:00 committed by GitHub
parent de1e4b2da9
commit 2791cc139e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 36 additions and 16 deletions

View File

@ -113,6 +113,24 @@ func (cfg *PullRequestsConfig) IsMergeStyleAllowed(mergeStyle MergeStyle) bool {
mergeStyle == MergeStyleSquash && cfg.AllowSquash
}
// AllowedMergeStyleCount returns the total count of allowed merge styles for the PullRequestsConfig
func (cfg *PullRequestsConfig) AllowedMergeStyleCount() int {
count := 0
if cfg.AllowMerge {
count++
}
if cfg.AllowRebase {
count++
}
if cfg.AllowRebaseMerge {
count++
}
if cfg.AllowSquash {
count++
}
return count
}
// BeforeSet is invoked from XORM before setting the value of a field of this object.
func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) {
switch colName {

View File

@ -335,6 +335,7 @@
{{end}}
</span>
</button>
{{if gt $prUnit.PullRequestsConfig.AllowedMergeStyleCount 1}}
<div class="ui dropdown icon button">
{{svg "octicon-triangle-down" 14 "dropdown icon"}}
<div class="menu">
@ -352,6 +353,7 @@
{{end}}
</div>
</div>
{{end}}
</div>
{{else}}
<div class="ui divider"></div>