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.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {{/* Attributes:
  2. * root
  3. * ContainerClasses
  4. * (TODO: search "branch_dropdown" in the template direcotry)
  5. */}}
  6. {{$defaultBranch := $.root.BranchName}}
  7. {{if and .root.IsViewTag (not .noTag)}}
  8. {{$defaultBranch = .root.TagName}}
  9. {{end}}
  10. {{if eq $defaultBranch ""}}
  11. {{$defaultBranch = $.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': {{.root.locale.Tr "repo.release.compare"}},
  25. 'textCreateTag': {{.root.locale.Tr "repo.tag.create_tag"}},
  26. 'textCreateBranch': {{.root.locale.Tr "repo.branch.create_branch"}},
  27. 'textCreateBranchFrom': {{.root.locale.Tr "repo.branch.create_from"}},
  28. 'textBranches': {{.root.locale.Tr "repo.branches"}},
  29. 'textTags': {{.root.locale.Tr "repo.tags"}},
  30. 'mode': '{{if or .root.IsViewTag .isTag}}tags{{else}}branches{{end}}',
  31. 'showBranchesInDropdown': {{$showBranchesInDropdown}},
  32. 'searchFieldPlaceholder': '{{if $.noTag}}{{.root.locale.Tr "repo.pulls.filter_branch"}}{{else if $showBranchesInDropdown}}{{.root.locale.Tr "repo.filter_branch_and_tag"}}{{else}}{{.root.locale.Tr "repo.find_tag"}}{{end}}...',
  33. 'branchForm': {{$.branchForm}},
  34. 'disableCreateBranch': {{if .disableCreateBranch}}{{.disableCreateBranch}}{{else}}{{not .root.CanCreateBranch}}{{end}},
  35. 'setAction': {{.setAction}},
  36. 'submitForm': {{.submitForm}},
  37. 'viewType': {{$type}},
  38. 'refName': {{if and .root.IsViewTag (not .noTag)}}{{.root.TagName}}{{else if .root.IsViewBranch}}{{.root.BranchName}}{{else}}{{ShortSha .root.CommitID}}{{end}},
  39. 'commitIdShort': {{ShortSha .root.CommitID}},
  40. 'tagName': {{.root.TagName}},
  41. 'branchName': {{.root.BranchName}},
  42. 'noTag': {{.noTag}},
  43. 'defaultBranch': {{$defaultBranch}},
  44. 'enableFeed': {{.root.EnableFeed}},
  45. 'rssURLPrefix': '{{$.root.RepoLink}}/rss/branch/',
  46. 'branchURLPrefix': '{{if .branchURLPrefix}}{{.branchURLPrefix}}{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/branch/{{end}}',
  47. 'branchURLSuffix': '{{if .branchURLSuffix}}{{.branchURLSuffix}}{{else}}{{if $.root.TreePath}}/{{PathEscapeSegments $.root.TreePath}}{{end}}{{end}}',
  48. 'tagURLPrefix': '{{if .tagURLPrefix}}{{.tagURLPrefix}}{{else if .release}}{{$.root.RepoLink}}/compare/{{else}}{{$.root.RepoLink}}/{{if $.root.PageIsCommits}}commits{{else}}src{{end}}/tag/{{end}}',
  49. '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}}',
  50. 'repoLink': {{.root.RepoLink}},
  51. 'treePath': {{.root.TreePath}},
  52. 'branchNameSubURL': {{.root.BranchNameSubURL}},
  53. 'noResults': {{.root.locale.Tr "repo.pulls.no_results"}},
  54. };
  55. {{if .release}}
  56. data.release = {
  57. 'tagName': {{.release.TagName}},
  58. };
  59. {{end}}
  60. window.config.pageData.branchDropdownDataList = window.config.pageData.branchDropdownDataList || [];
  61. window.config.pageData.branchDropdownDataList.push(data);
  62. </script>
  63. <div class="js-branch-tag-selector {{if .ContainerClasses}}{{.ContainerClasses}}{{end}}">
  64. {{/* show dummy elements before Vue componment is mounted, this code must match the code in BranchTagSelector.vue */}}
  65. <div class="ui dropdown custom">
  66. <button class="branch-dropdown-button gt-ellipsis ui basic small compact button gt-df gt-m-0">
  67. <span class="text gt-df gt-ac gt-mr-2">
  68. {{if .release}}
  69. {{.root.locale.Tr "repo.release.compare"}}
  70. {{else}}
  71. {{if eq $type "tag"}}
  72. {{svg "octicon-tag"}}
  73. {{else}}
  74. {{svg "octicon-git-branch"}}
  75. {{end}}
  76. <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>
  77. {{end}}
  78. </span>
  79. {{svg "octicon-triangle-down" 14 "dropdown icon"}}
  80. </button>
  81. </div>
  82. </div>