You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

branch_dropdown.tmpl 4.3KB

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