my-gitea-templates/templates/repo/ branch_dropdown.tmpl
66 lines
3.3 KiB

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