mirror of
https://github.com/go-gitea/gitea
synced 2024-12-23 01:04:36 +01:00
Fix incorrect default branch label while switching between branches (#27053)
Fix #27008
This commit is contained in:
parent
b32998b3f5
commit
076eca8158
2 changed files with 9 additions and 9 deletions
|
@ -3,12 +3,12 @@
|
||||||
* ContainerClasses
|
* ContainerClasses
|
||||||
* (TODO: search "branch_dropdown" in the template direcotry)
|
* (TODO: search "branch_dropdown" in the template direcotry)
|
||||||
*/}}
|
*/}}
|
||||||
{{$defaultBranch := $.root.BranchName}}
|
{{$defaultSelectedRefName := $.root.BranchName}}
|
||||||
{{if and .root.IsViewTag (not .noTag)}}
|
{{if and .root.IsViewTag (not .noTag)}}
|
||||||
{{$defaultBranch = .root.TagName}}
|
{{$defaultSelectedRefName = .root.TagName}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if eq $defaultBranch ""}}
|
{{if eq $defaultSelectedRefName ""}}
|
||||||
{{$defaultBranch = $.root.Repository.DefaultBranch}}
|
{{$defaultSelectedRefName = $.root.Repository.DefaultBranch}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{$type := ""}}
|
{{$type := ""}}
|
||||||
|
@ -45,7 +45,8 @@
|
||||||
'tagName': {{.root.TagName}},
|
'tagName': {{.root.TagName}},
|
||||||
'branchName': {{.root.BranchName}},
|
'branchName': {{.root.BranchName}},
|
||||||
'noTag': {{.noTag}},
|
'noTag': {{.noTag}},
|
||||||
'defaultBranch': {{$defaultBranch}},
|
'defaultSelectedRefName': {{$defaultSelectedRefName}},
|
||||||
|
'repoDefaultBranch': {{.root.Repository.DefaultBranch}},
|
||||||
'enableFeed': {{.root.EnableFeed}},
|
'enableFeed': {{.root.EnableFeed}},
|
||||||
'rssURLPrefix': '{{$.root.RepoLink}}/rss/branch/',
|
'rssURLPrefix': '{{$.root.RepoLink}}/rss/branch/',
|
||||||
'branchURLPrefix': '{{if .branchURLPrefix}}{{.branchURLPrefix}}{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{end}}',
|
'branchURLPrefix': '{{if .branchURLPrefix}}{{.branchURLPrefix}}{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{end}}',
|
||||||
|
|
|
@ -190,16 +190,15 @@ const sfc = {
|
||||||
}
|
}
|
||||||
this.isLoading = true;
|
this.isLoading = true;
|
||||||
try {
|
try {
|
||||||
// the "data.defaultBranch" is ambiguous, it could be "branch name" or "tag name"
|
|
||||||
const reqUrl = `${this.repoLink}/${this.mode}/list`;
|
const reqUrl = `${this.repoLink}/${this.mode}/list`;
|
||||||
const resp = await fetch(reqUrl);
|
const resp = await fetch(reqUrl);
|
||||||
const {results} = await resp.json();
|
const {results} = await resp.json();
|
||||||
for (const result of results) {
|
for (const result of results) {
|
||||||
let selected = false;
|
let selected = false;
|
||||||
if (this.mode === 'branches') {
|
if (this.mode === 'branches') {
|
||||||
selected = result === this.defaultBranch;
|
selected = result === this.defaultSelectedRefName;
|
||||||
} else {
|
} else {
|
||||||
selected = result === (this.release ? this.release.tagName : this.defaultBranch);
|
selected = result === (this.release ? this.release.tagName : this.defaultSelectedRefName);
|
||||||
}
|
}
|
||||||
this.items.push({name: result, url: pathEscapeSegments(result), branch: this.mode === 'branches', tag: this.mode === 'tags', selected});
|
this.items.push({name: result, url: pathEscapeSegments(result), branch: this.mode === 'branches', tag: this.mode === 'tags', selected});
|
||||||
}
|
}
|
||||||
|
@ -276,7 +275,7 @@ export default sfc; // activate IDE's Vue plugin
|
||||||
<div class="loading-indicator is-loading" v-if="isLoading"/>
|
<div class="loading-indicator is-loading" v-if="isLoading"/>
|
||||||
<div v-for="(item, index) in filteredItems" :key="item.name" class="item" :class="{selected: item.selected, active: active === index}" @click="selectItem(item)" :ref="'listItem' + index">
|
<div v-for="(item, index) in filteredItems" :key="item.name" class="item" :class="{selected: item.selected, active: active === index}" @click="selectItem(item)" :ref="'listItem' + index">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
<div class="ui label" v-if="item.name===defaultBranch && mode === 'branches'">
|
<div class="ui label" v-if="item.name===repoDefaultBranch && mode === 'branches'">
|
||||||
{{ textDefaultBranchLabel }}
|
{{ textDefaultBranchLabel }}
|
||||||
</div>
|
</div>
|
||||||
<a v-show="enableFeed && mode === 'branches'" role="button" class="rss-icon gt-float-right" :href="rssURLPrefix + item.url" target="_blank" @click.stop>
|
<a v-show="enableFeed && mode === 'branches'" role="button" class="rss-icon gt-float-right" :href="rssURLPrefix + item.url" target="_blank" @click.stop>
|
||||||
|
|
Loading…
Reference in a new issue