Skip to content

Commit b05907e

Browse files
committed
fix canCreateBranch/disableCreateBranch
1 parent 703dfd3 commit b05907e

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

templates/repo/branch_dropdown.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
'showBranchesInDropdown': {{$showBranchesInDropdown}},
1717
'searchFieldPlaceholder': '{{if $.noTag}}{{.root.locale.Tr "repo.pulls.filter_branch"}}{{else if $showBranchesInDropdown}}{{.root.locale.Tr "repo.filter_branch_and_tag"}}{{else}}{{.root.locale.Tr "repo.find_tag"}}{{end}}...',
1818
'branchForm': {{$.branchForm}},
19-
'canCreateBranch': {{if .canCreateBranch}}{{.canCreateBranch}}{{else}}{{.root.CanCreateBranch}}{{end}},
19+
'disableCreateBranch': {{if .disableCreateBranch}}{{.disableCreateBranch}}{{else}}{{not .root.CanCreateBranch}}{{end}},
2020
'setAction': {{.setAction}},
2121
'submitForm': {{.submitForm}},
2222
'viewType': {{$type}},

templates/repo/commit_page.tmpl

+4-4
Original file line numberDiff line numberDiff line change
@@ -52,24 +52,24 @@
5252
data-modal-cherry-pick-type="revert"
5353
data-modal-cherry-pick-header="{{$.locale.Tr "repo.commit.revert-header" (ShortSha .CommitID)}}"
5454
data-modal-cherry-pick-content="{{$.locale.Tr "repo.commit.revert-content"}}"
55-
data-modal-cherry-pick-submit="{{.locale.Tr "repo.commit.revert"}}">{{.locale.Tr "repo.commit.revert"}}</a></div>
55+
data-modal-cherry-pick-submit="{{.locale.Tr "repo.commit.revert"}}">{{.locale.Tr "repo.commit.revert"}}</div>
5656
<div class="item cherry-pick-button show-modal"
5757
data-modal="#cherry-pick-modal"
5858
data-modal-cherry-pick-type="cherry-pick"
5959
data-modal-cherry-pick-header="{{$.locale.Tr "repo.commit.cherry-pick-header" (ShortSha .CommitID)}}"
6060
data-modal-cherry-pick-content="{{$.locale.Tr "repo.commit.cherry-pick-content"}}"
61-
data-modal-cherry-pick-submit="{{.locale.Tr "repo.commit.cherry-pick"}}">{{.locale.Tr "repo.commit.cherry-pick"}}</a></div>
61+
data-modal-cherry-pick-submit="{{.locale.Tr "repo.commit.cherry-pick"}}">{{.locale.Tr "repo.commit.cherry-pick"}}</div>
6262
<div class="ui basic modal" id="cherry-pick-modal">
6363
<div class="ui icon header">
6464
<span id="cherry-pick-header"></span>
6565
</div>
6666
<div class="content center">
6767
<p id="cherry-pick-content" class="branch-dropdown"></p>
6868
{{template "repo/branch_dropdown" dict "root" .
69-
"noTag" "true" "canCreateBranch" "false"
69+
"noTag" true "disableCreateBranch" true
7070
"branchForm" "branch-dropdown-form"
7171
"branchURLPrefix" (printf "%s/_cherrypick/%s/" $.RepoLink .CommitID) "branchURLSuffix" ""
72-
"setAction" "true" "submitForm" "true"}}
72+
"setAction" true "submitForm" true}}
7373
<form method="GET" action="{{$.RepoLink}}/_cherrypick/{{.CommitID}}/{{if $.BranchName}}{{PathEscapeSegments $.BranchName}}{{else}}{{PathEscapeSegments $.Repository.DefaultBranch}}{{end}}" id="branch-dropdown-form">
7474
<input type="hidden" name="ref" value="{{if $.BranchName}}{{$.BranchName}}{{else}}{{$.Repository.DefaultBranch}}{{end}}">
7575
<input type="hidden" name="refType" value="branch">

web_src/js/components/RepoBranchTagDropdown.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ export function initRepoBranchTagDropdown(selector) {
2121
...window.config.pageData.branchDropdownDataList[dropdownIndex],
2222
};
2323

24-
if (data.showBranchesInDropdown) {
24+
// the "data.defaultBranch" is ambiguous, it could be "branch name" or "tag name"
25+
26+
if (data.showBranchesInDropdown && data.branches) {
2527
for (const branch of data.branches) {
2628
data.items.push({name: branch, url: branch, branch: true, tag: false, selected: branch === data.defaultBranch});
2729
}
2830
}
29-
if (!data.noTag) {
31+
if (!data.noTag && data.tags) {
3032
for (const tag of data.tags) {
3133
if (data.release) {
3234
data.items.push({name: tag, url: tag, branch: false, tag: true, selected: tag === data.release.tagName});
@@ -56,7 +58,7 @@ export function initRepoBranchTagDropdown(selector) {
5658
return this.filteredItems.length === 0 && !this.showCreateNewBranch;
5759
},
5860
showCreateNewBranch() {
59-
if (!this.canCreateBranch || !this.searchTerm) {
61+
if (this.disableCreateBranch || !this.searchTerm) {
6062
return false;
6163
}
6264

0 commit comments

Comments
 (0)