Skip to content

Commit 14be462

Browse files
Refactor initRepoBranchTagSelector to use new init framework (#33776)
Make "initRepoBranchTagSelector" to use new init framework and fix the abused "js-branch-tag-selector" styles --------- Co-authored-by: wxiaoguang <[email protected]>
1 parent ad204f9 commit 14be462

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

templates/repo/branch_dropdown.tmpl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414

1515
Search "repo/branch_dropdown" in the template directory to find all occurrences.
1616
*/}}
17-
<div class="js-branch-tag-selector {{if .ContainerClasses}}{{.ContainerClasses}}{{end}}"
17+
<div class="{{if .ContainerClasses}}{{.ContainerClasses}}{{end}}"
18+
data-global-init="initRepoBranchTagSelector"
1819
data-text-release-compare="{{ctx.Locale.Tr "repo.release.compare"}}"
1920
data-text-branches="{{ctx.Locale.Tr "repo.branches"}}"
2021
data-text-tags="{{ctx.Locale.Tr "repo.tags"}}"

templates/repo/release/list.tmpl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
{{$compareTarget = $release.Sha1}}
2222
{{end}}
2323
{{template "repo/branch_dropdown" dict
24+
"ContainerClasses" "release-branch-tag-selector"
2425
"Repository" $.Repository
2526
"ShowTabTags" true
2627
"DropdownFixedText" (ctx.Locale.Tr "repo.release.compare")

web_src/css/repo/release-tag.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
display: flex;
4646
align-items: center;
4747
}
48-
#release-list .js-branch-tag-selector {
48+
#release-list .release-branch-tag-selector {
4949
margin-left: auto;
5050
}
5151
#release-list .branch-selector-dropdown .menu { /* open menu to left */

web_src/js/features/repo-legacy.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import {registerGlobalInitFunc} from '../modules/observer.ts';
12
import {
23
initRepoCommentFormAndSidebar,
34
initRepoIssueBranchSelect, initRepoIssueCodeCommentCancel, initRepoIssueCommentDelete,
@@ -20,10 +21,10 @@ import {initRepoNew} from './repo-new.ts';
2021
import {createApp} from 'vue';
2122
import RepoBranchTagSelector from '../components/RepoBranchTagSelector.vue';
2223

23-
function initRepoBranchTagSelector(selector: string) {
24-
for (const elRoot of document.querySelectorAll(selector)) {
24+
function initRepoBranchTagSelector() {
25+
registerGlobalInitFunc('initRepoBranchTagSelector', async (elRoot: HTMLInputElement) => {
2526
createApp(RepoBranchTagSelector, {elRoot}).mount(elRoot);
26-
}
27+
});
2728
}
2829

2930
export function initBranchSelectorTabs() {
@@ -42,7 +43,7 @@ export function initRepository() {
4243
const pageContent = document.querySelector('.page-content.repository');
4344
if (!pageContent) return;
4445

45-
initRepoBranchTagSelector('.js-branch-tag-selector');
46+
initRepoBranchTagSelector();
4647
initRepoCommentFormAndSidebar();
4748

4849
// Labels

0 commit comments

Comments
 (0)