my-gitea-templates/templates/repo/ branch_dropdown.tmpl
84 lines
4.2 KiB

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