|
1 | 1 | {{/* Attributes:
|
2 |
| -* root |
3 | 2 | * 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}} |
| 3 | +* Repository |
| 4 | +* CurrentRefType: eg. "branch", "tag" |
| 5 | +* CurrentRefShortName: eg. "master", "v1.0" |
| 6 | +* CurrentTreePath |
| 7 | +* RefLinkTemplate: redirect to the link when a branch/tag is selected |
| 8 | +* RefFormActionTemplate: change the parent form's action when a branch/tag is selected |
| 9 | +* DropdownFixedText: the text to show in the dropdown (mainly used by "release page"), if empty, the text will be the branch/tag name |
| 10 | +* ShowTabBranches |
| 11 | +* ShowTabTagsTab |
| 12 | +* AllowCreateNewRef |
22 | 13 |
|
23 |
| -{{$showBranchesInDropdown := not .root.HideBranchesInDropdown}} |
| 14 | +Search "repo/branch_dropdown" in the template directory to find all occurrences. |
| 15 | +*/}} |
| 16 | +<div class="js-branch-tag-selector {{if .ContainerClasses}}{{.ContainerClasses}}{{end}}" |
| 17 | + data-text-release-compare="{{ctx.Locale.Tr "repo.release.compare"}}" |
| 18 | + data-text-branches="{{ctx.Locale.Tr "repo.branches"}}" |
| 19 | + data-text-tags="{{ctx.Locale.Tr "repo.tags"}}" |
| 20 | + data-text-filter-branch="{{ctx.Locale.Tr "repo.pulls.filter_branch"}}" |
| 21 | + data-text-filter-tag="{{ctx.Locale.Tr "repo.find_tag"}}" |
| 22 | + data-text-default-branch-label="{{ctx.Locale.Tr "repo.default_branch_label"}}" |
| 23 | + data-text-create-tag="{{ctx.Locale.Tr "repo.tag.create_tag"}}" |
| 24 | + data-text-create-branch="{{ctx.Locale.Tr "repo.branch.create_branch"}}" |
| 25 | + data-text-create-ref-from="{{ctx.Locale.Tr "repo.branch.create_from"}}" |
| 26 | + data-text-no-results="{{ctx.Locale.Tr "no_results_found"}}" |
24 | 27 |
|
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"}}, |
| 28 | + data-current-repo-default-branch="{{.Repository.DefaultBranch}}" |
| 29 | + data-current-repo-link="{{.Repository.Link}}" |
| 30 | + data-current-tree-path="{{.CurrentTreePath}}" |
| 31 | + data-current-ref-type="{{.CurrentRefType}}" |
| 32 | + data-current-ref-short-name="{{.CurrentRefShortName}}" |
34 | 33 |
|
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 "no_results_found"}}, |
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> |
| 34 | + data-ref-link-template="{{.RefLinkTemplate}}" |
| 35 | + data-ref-form-action-template="{{.RefFormActionTemplate}}" |
| 36 | + data-dropdown-fixed-text="{{.DropdownFixedText}}" |
| 37 | + data-show-tab-branches="{{.ShowTabBranches}}" |
| 38 | + data-show-tab-tags="{{.ShowTabTags}}" |
| 39 | + data-allow-create-new-ref="{{.AllowCreateNewRef}}" |
69 | 40 |
|
70 |
| -<div class="js-branch-tag-selector {{if .ContainerClasses}}{{.ContainerClasses}}{{end}}"> |
| 41 | + data-enable-feed="{{ctx.RootData.EnableFeed}}" |
| 42 | +> |
71 | 43 | {{/* show dummy elements before Vue componment is mounted, this code must match the code in BranchTagSelector.vue */}}
|
72 | 44 | <div class="ui dropdown custom branch-selector-dropdown ellipsis-items-nowrap">
|
73 | 45 | <div class="ui button branch-dropdown-button">
|
74 | 46 | <span class="flex-text-block gt-ellipsis">
|
75 |
| - {{if .release}} |
76 |
| - {{ctx.Locale.Tr "repo.release.compare"}} |
77 |
| - {{else}} |
78 |
| - {{if eq $type "tag"}} |
| 47 | + {{if not .DropdownFixedText}} |
| 48 | + {{if .ShowTabTags}} |
79 | 49 | {{svg "octicon-tag"}}
|
80 |
| - {{else}} |
| 50 | + {{else if .ShowTabBranches}} |
81 | 51 | {{svg "octicon-git-branch"}}
|
82 | 52 | {{end}}
|
83 |
| - <strong ref="dropdownRefName" class="tw-ml-2 tw-inline-block gt-ellipsis">{{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}}</strong> |
84 | 53 | {{end}}
|
| 54 | + <strong class="tw-ml-2 tw-inline-block gt-ellipsis">{{Iif .DropdownFixedText .SelectedRefShortName}}</strong> |
85 | 55 | </span>
|
86 | 56 | {{svg "octicon-triangle-down" 14 "dropdown icon"}}
|
87 | 57 | </div>
|
|
0 commit comments