11{{/* Attributes:
2- * root
3- * ContainerClasses
4- * (TODO: search "branch_dropdown" in the template directory)
5- */}}
6- {{$defaultSelectedRefName := $.root.BranchName}}
7- {{if and .root.IsViewTag (not .noTag)}}
8- {{$defaultSelectedRefName = .root.TagName}}
2+ * root
3+ * ContainerClasses
4+ * (TODO: search "branch_dropdown" in the template directory)
5+ */}}
6+ {{$defaultSelectedRefName := $.root.BranchName}}
7+ {{if and .root.IsViewTag (not .noTag)}}
8+ {{$defaultSelectedRefName = .root.TagName}}
9+ {{end}}
10+ {{if eq $defaultSelectedRefName ""}}
11+ {{$defaultSelectedRefName = $.root.Repository.DefaultBranch}}
12+ {{end}}
13+
14+ {{$type := ""}}
15+ {{if and .root.IsViewTag (not .noTag)}}
16+ {{$type = "tag"}}
17+ {{else if .root.IsViewBranch}}
18+ {{$type = "branch"}}
19+ {{else}}
20+ {{$type = "tree"}}
21+ {{end}}
22+
23+ {{$showBranchesInDropdown := not .root.HideBranchesInDropdown}}
24+
25+ <script type="module">
26+ const data = {
27+ 'textReleaseCompare': {{ctx.Locale.Tr "repo.release.compare"}},
28+ 'textCreateTag': {{ctx.Locale.Tr "repo.tag.create_tag"}},
29+ 'textCreateBranch': {{ctx.Locale.Tr "repo.branch.create_branch"}},
30+ 'textCreateBranchFrom': {{ctx.Locale.Tr "repo.branch.create_from"}},
31+ 'textBranches': {{ctx.Locale.Tr "repo.branches"}},
32+ 'textTags': {{ctx.Locale.Tr "repo.tags"}},
33+ 'textDefaultBranchLabel': {{ctx.Locale.Tr "repo.default_branch_label"}},
34+
35+ 'mode': '{{if or .root.IsViewTag .isTag}}tags{{else}}branches{{end}}',
36+ 'showBranchesInDropdown': {{$showBranchesInDropdown}},
37+ 'searchFieldPlaceholder': '{{if $.noTag}}{{ctx.Locale.Tr "repo.pulls.filter_branch"}}{{else if $showBranchesInDropdown}}{{ctx.Locale.Tr "repo.filter_branch_and_tag"}}{{else}}{{ctx.Locale.Tr "repo.find_tag"}}{{end}}...',
38+ 'branchForm': {{$.branchForm}},
39+ 'disableCreateBranch': {{if .disableCreateBranch}}{{.disableCreateBranch}}{{else}}{{not .root.CanCreateBranch}}{{end}},
40+ 'setAction': {{.setAction}},
41+ 'submitForm': {{.submitForm}},
42+ 'viewType': {{$type}},
43+ 'refName': {{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}},
44+ 'commitIdShort': {{ShortSha .root.CommitID}},
45+ 'tagName': {{.root.TagName}},
46+ 'branchName': {{.root.BranchName}},
47+ 'noTag': {{.noTag}},
48+ 'defaultSelectedRefName': {{$defaultSelectedRefName}},
49+ 'repoDefaultBranch': {{.root.Repository.DefaultBranch}},
50+ 'enableFeed': {{.root.EnableFeed}},
51+ 'rssURLPrefix': '{{$.root.RepoLink}}/rss/branch/',
52+ 'branchURLPrefix': '{{if .branchURLPrefix}}{{.branchURLPrefix}}{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{end}}',
53+ 'branchURLSuffix': '{{if .branchURLSuffix}}{{.branchURLSuffix}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}',
54+ 'tagURLPrefix': '{{if .tagURLPrefix}}{{.tagURLPrefix}}{{else if .release}}{{$.root.RepoLink}}/compare/{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/tag/{{end}}',
55+ 'tagURLSuffix': '{{if .tagURLSuffix}}{{.tagURLSuffix}}{{else if .release}}...{{if .release.IsDraft}}{{PathEscapeSegments .release.Target}}{{else}}{{if .release.TagName}}{{PathEscapeSegments .release.TagName}}{{else}}{{PathEscapeSegments .release.Sha1}}{{end}}{{end}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}',
56+ 'repoLink': {{.root.RepoLink}},
57+ 'treePath': {{.root.TreePath}},
58+ 'branchNameSubURL': {{.root.BranchNameSubURL}},
59+ 'noResults': {{ctx.Locale.Tr "repo.pulls.no_results"}},
60+ };
61+ {{if .release}}
62+ data.release = {
63+ 'tagName': {{.release.TagName}},
64+ };
965 {{end}}
10- {{if eq $defaultSelectedRefName ""}}
11- {{$defaultSelectedRefName = $.root.Repository.DefaultBranch}}
12- {{end}}
13-
14- {{$type := ""}}
15- {{if and .root.IsViewTag (not .noTag)}}
16- {{$type = "tag"}}
17- {{else if .root.IsViewBranch}}
18- {{$type = "branch"}}
19- {{else}}
20- {{$type = "tree"}}
21- {{end}}
22-
23- {{$showBranchesInDropdown := not .root.HideBranchesInDropdown}}
24-
25- <script type="module">
26- const data = {
27- 'textReleaseCompare': {{ctx.Locale.Tr "repo.release.compare"}},
28- 'textCreateTag': {{ctx.Locale.Tr "repo.tag.create_tag"}},
29- 'textCreateBranch': {{ctx.Locale.Tr "repo.branch.create_branch"}},
30- 'textCreateBranchFrom': {{ctx.Locale.Tr "repo.branch.create_from"}},
31- 'textBranches': {{ctx.Locale.Tr "repo.branches"}},
32- 'textTags': {{ctx.Locale.Tr "repo.tags"}},
33- 'textDefaultBranchLabel': {{ctx.Locale.Tr "repo.default_branch_label"}},
34-
35- 'mode': '{{if or .root.IsViewTag .isTag}}tags{{else}}branches{{end}}',
36- 'showBranchesInDropdown': {{$showBranchesInDropdown}},
37- 'searchFieldPlaceholder': '{{if $.noTag}}{{ctx.Locale.Tr "repo.pulls.filter_branch"}}{{else if $showBranchesInDropdown}}{{ctx.Locale.Tr "repo.filter_branch_and_tag"}}{{else}}{{ctx.Locale.Tr "repo.find_tag"}}{{end}}...',
38- 'branchForm': {{$.branchForm}},
39- 'disableCreateBranch': {{if .disableCreateBranch}}{{.disableCreateBranch}}{{else}}{{not .root.CanCreateBranch}}{{end}},
40- 'setAction': {{.setAction}},
41- 'submitForm': {{.submitForm}},
42- 'viewType': {{$type}},
43- 'refName': {{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}},
44- 'commitIdShort': {{ShortSha .root.CommitID}},
45- 'tagName': {{.root.TagName}},
46- 'branchName': {{.root.BranchName}},
47- 'noTag': {{.noTag}},
48- 'defaultSelectedRefName': {{$defaultSelectedRefName}},
49- 'repoDefaultBranch': {{.root.Repository.DefaultBranch}},
50- 'enableFeed': {{.root.EnableFeed}},
51- 'rssURLPrefix': '{{$.root.RepoLink}}/rss/branch/',
52- 'branchURLPrefix': '{{if .branchURLPrefix}}{{.branchURLPrefix}}{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{end}}',
53- 'branchURLSuffix': '{{if .branchURLSuffix}}{{.branchURLSuffix}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}',
54- 'tagURLPrefix': '{{if .tagURLPrefix}}{{.tagURLPrefix}}{{else if .release}}{{$.root.RepoLink}}/compare/{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/tag/{{end}}',
55- 'tagURLSuffix': '{{if .tagURLSuffix}}{{.tagURLSuffix}}{{else if .release}}...{{if .release.IsDraft}}{{PathEscapeSegments .release.Target}}{{else}}{{if .release.TagName}}{{PathEscapeSegments .release.TagName}}{{else}}{{PathEscapeSegments .release.Sha1}}{{end}}{{end}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}',
56- 'repoLink': {{.root.RepoLink}},
57- 'treePath': {{.root.TreePath}},
58- 'branchNameSubURL': {{.root.BranchNameSubURL}},
59- 'noResults': {{ctx.Locale.Tr "repo.pulls.no_results"}},
60- };
61- {{if .release}}
62- data.release = {
63- 'tagName': {{.release.TagName}},
64- };
65- {{end}}
66- window.config.pageData.branchDropdownDataList = window.config.pageData.branchDropdownDataList || [];
67- window.config.pageData.branchDropdownDataList.push(data);
68- </script>
69-
70- <div class="js-branch-tag-selector {{if .ContainerClasses}}{{.ContainerClasses}}{{end}}">
71- {{/* show dummy elements before Vue componment is mounted, this code must match the code in BranchTagSelector.vue */}}
72- <div class="ui dropdown custom">
73- <button class="branch-dropdown-button gt-ellipsis ui basic small compact button gt-df gt-m-0">
74- <span class="text gt-df gt-ac gt-mr-2">
75- {{if .release}}
76- {{ctx.Locale.Tr "repo.release.compare"}}
66+ window.config.pageData.branchDropdownDataList = window.config.pageData.branchDropdownDataList || [];
67+ window.config.pageData.branchDropdownDataList.push(data);
68+ </script>
69+
70+ <div class="js-branch-tag-selector {{if .ContainerClasses}}{{.ContainerClasses}}{{end}}">
71+ {{/* show dummy elements before Vue componment is mounted, this code must match the code in BranchTagSelector.vue */}}
72+ <div class="ui dropdown custom">
73+ <button class="branch-dropdown-button gt-ellipsis ui basic small compact button gt-df gt-m-0">
74+ <span class="text gt-df gt-ac gt-mr-2">
75+ {{if .release}}
76+ {{ctx.Locale.Tr "repo.release.compare"}}
77+ {{else}}
78+ {{if eq $type "tag"}}
79+ {{svg "octicon-tag"}}
7780 {{else}}
78- {{if eq $type "tag"}}
79- {{svg "octicon-tag"}}
80- {{else}}
81- {{svg "octicon-git-branch"}}
82- {{end}}
83- <strong ref="dropdownRefName" class="gt-ml-3">{{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}}</strong>
81+ {{svg "octicon-git-branch"}}
8482 {{end}}
85- </span>
86- {{svg "octicon-triangle-down" 14 "dropdown icon"}}
87- </button>
88- </div>
89- </div>
83+ <strong ref="dropdownRefName" class="gt-ml-3">{{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}}</strong>
84+ {{end}}
85+ </span>
86+ {{svg "octicon-triangle-down" 14 "dropdown icon"}}
87+ </button>
88+ </div>
89+ </div>
0 commit comments