my-gitea-templates/templates/repo/ branch_dropdown.tmpl
74 lines
3.8 KiB

  1. <div class="fitted item choose reference">
  2. {{ $showCommitCount := and (.Repository.UnitEnabled $.UnitTypeCode) (not .IsBareRepo)}}
  3. <div class="ui floating filter dropdown custom" data-can-create-branch="{{.CanCreateBranch}}" data-no-results="{{.i18n.Tr "repo.pulls.no_results"}}">
  4. <div class="ui basic {{if $showCommitCount}}labeled button{{else}}buttons{{end}}">
  5. <div class="ui basic button" @click="menuVisible = !menuVisible" @keyup.enter="menuVisible = !menuVisible">
  6. <span class="text">
  7. <i class="octicon octicon-git-branch"></i>
  8. {{if .IsViewBranch}}{{.i18n.Tr "repo.branch"}}{{else}}{{.i18n.Tr "repo.tree"}}{{end}}:
  9. <strong>{{if .IsViewBranch}}{{.BranchName}}{{else}}{{ShortSha .BranchName}}{{end}}</strong>
  10. </span>
  11. <i class="dropdown icon"></i>
  12. </div>
  13. {{if $showCommitCount}}
  14. <div class="ui basic label">
  15. <a href="{{.RepoLink}}/commits{{if .IsViewBranch}}/branch{{else if .IsViewTag}}/tag{{else if .IsViewCommit}}/commit{{end}}/{{EscapePound .BranchName}}"><i class="octicon octicon-history"></i> <b>{{.CommitsCount}}</b> {{.i18n.Tr (TrN .i18n.Lang .CommitsCount "repo.commit" "repo.commits") }}</a>
  16. </div>
  17. {{end}}
  18. </div>
  19. <div class="data" style="display: none" data-mode="{{if .IsViewTag}}tags{{else}}branches{{end}}">
  20. {{range .Branches}}
  21. <div class="item branch {{if eq $.BranchName .}}selected{{end}}" data-url="{{$.RepoLink}}/{{if $.PageIsCommits}}commits{{else}}src{{end}}/branch/{{EscapePound .}}{{if $.TreePath}}/{{EscapePound $.TreePath}}{{end}}">{{.}}</div>
  22. {{end}}
  23. {{range .Tags}}
  24. <div class="item tag {{if eq $.BranchName .}}selected{{end}}" data-url="{{$.RepoLink}}/{{if $.PageIsCommits}}commits{{else}}src{{end}}/tag/{{EscapePound .}}{{if $.TreePath}}/{{EscapePound $.TreePath}}{{end}}">{{.}}</div>
  25. {{end}}
  26. </div>
  27. <div class="menu transition" :class="{visible: menuVisible}" v-if="menuVisible" v-cloak>
  28. <div class="ui icon search input">
  29. <i class="filter icon"></i>
  30. <input name="search" ref="searchField" v-model="searchTerm" @keydown="keydown($event)" placeholder="{{.i18n.Tr "repo.filter_branch_and_tag"}}...">
  31. </div>
  32. <div class="header branch-tag-choice">
  33. <div class="ui grid">
  34. <div class="two column row">
  35. <a class="reference column" href="#" @click="mode = 'branches'; focusSearchField()">
  36. <span class="text" :class="{black: mode == 'branches'}">
  37. <i class="octicon octicon-git-branch"></i> {{.i18n.Tr "repo.branches"}}
  38. </span>
  39. </a>
  40. <a class="reference column" href="#" @click="mode = 'tags'; focusSearchField()">
  41. <span class="text" :class="{black: mode == 'tags'}">
  42. <i class="reference tags icon"></i> {{.i18n.Tr "repo.tags"}}
  43. </span>
  44. </a>
  45. </div>
  46. </div>
  47. </div>
  48. <div class="scrolling menu" ref="scrollContainer">
  49. <div v-for="(item, index) in filteredItems" :key="item.name" class="item" :class="{selected: item.selected, active: active == index}" @click="selectItem(item)" :ref="'listItem' + index">${ item.name }</div>
  50. <div class="item" v-if="showCreateNewBranch" :class="{active: active == filteredItems.length}" :ref="'listItem' + filteredItems.length">
  51. <a href="#" @click="createNewBranch()">
  52. <div>
  53. <i class="octicon octicon-git-branch"></i>
  54. {{.i18n.Tr "repo.branch.create_branch" `${ searchTerm }` | Safe}}
  55. </div>
  56. <div class="text small">
  57. {{if .IsViewBranch}}
  58. {{.i18n.Tr "repo.branch.create_from" .BranchName}}
  59. {{else}}
  60. {{.i18n.Tr "repo.branch.create_from" (ShortSha .BranchName)}}
  61. {{end}}
  62. </div>
  63. </a>
  64. <form ref="newBranchForm" action="{{.RepoLink}}/branches/_new/{{EscapePound .BranchNameSubURL}}" method="post">
  65. {{.CsrfTokenHtml}}
  66. <input type="hidden" name="new_branch_name" v-model="searchTerm">
  67. </form>
  68. </div>
  69. </div>
  70. <div class="message" v-if="showNoResults">${ noResults }</div>
  71. </div>
  72. </div>
  73. </div>