summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--models/repo_unit.go18
-rw-r--r--templates/repo/issue/view_content/pull.tmpl34
2 files changed, 36 insertions, 16 deletions
diff --git a/models/repo_unit.go b/models/repo_unit.go
index d4c74515f7..b208276d9d 100644
--- a/models/repo_unit.go
+++ b/models/repo_unit.go
@@ -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 {
diff --git a/templates/repo/issue/view_content/pull.tmpl b/templates/repo/issue/view_content/pull.tmpl
index 347b3b15d3..f7870d60d2 100644
--- a/templates/repo/issue/view_content/pull.tmpl
+++ b/templates/repo/issue/view_content/pull.tmpl
@@ -335,23 +335,25 @@
{{end}}
</span>
</button>
- <div class="ui dropdown icon button">
- {{svg "octicon-triangle-down" 14 "dropdown icon"}}
- <div class="menu">
- {{if $prUnit.PullRequestsConfig.AllowMerge}}
- <div class="item{{if eq .MergeStyle "merge"}} active selected{{end}}" data-do="merge">{{$.i18n.Tr "repo.pulls.merge_pull_request"}}</div>
- {{end}}
- {{if $prUnit.PullRequestsConfig.AllowRebase}}
- <div class="item{{if eq .MergeStyle "rebase"}} active selected{{end}}" data-do="rebase">{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}</div>
- {{end}}
- {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
- <div class="item{{if eq .MergeStyle "rebase-merge"}} active selected{{end}}" data-do="rebase-merge">{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}</div>
- {{end}}
- {{if $prUnit.PullRequestsConfig.AllowSquash}}
- <div class="item{{if eq .MergeStyle "squash"}} active selected{{end}}" data-do="squash">{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}</div>
- {{end}}
+ {{if gt $prUnit.PullRequestsConfig.AllowedMergeStyleCount 1}}
+ <div class="ui dropdown icon button">
+ {{svg "octicon-triangle-down" 14 "dropdown icon"}}
+ <div class="menu">
+ {{if $prUnit.PullRequestsConfig.AllowMerge}}
+ <div class="item{{if eq .MergeStyle "merge"}} active selected{{end}}" data-do="merge">{{$.i18n.Tr "repo.pulls.merge_pull_request"}}</div>
+ {{end}}
+ {{if $prUnit.PullRequestsConfig.AllowRebase}}
+ <div class="item{{if eq .MergeStyle "rebase"}} active selected{{end}}" data-do="rebase">{{$.i18n.Tr "repo.pulls.rebase_merge_pull_request"}}</div>
+ {{end}}
+ {{if $prUnit.PullRequestsConfig.AllowRebaseMerge}}
+ <div class="item{{if eq .MergeStyle "rebase-merge"}} active selected{{end}}" data-do="rebase-merge">{{$.i18n.Tr "repo.pulls.rebase_merge_commit_pull_request"}}</div>
+ {{end}}
+ {{if $prUnit.PullRequestsConfig.AllowSquash}}
+ <div class="item{{if eq .MergeStyle "squash"}} active selected{{end}}" data-do="squash">{{$.i18n.Tr "repo.pulls.squash_merge_pull_request"}}</div>
+ {{end}}
+ </div>
</div>
- </div>
+ {{end}}
</div>
{{else}}
<div class="ui divider"></div>