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.

header.tmpl 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <div class="header-wrapper">
  2. {{with .Repository}}
  3. <div class="ui container">
  4. <div class="repo-header">
  5. <div class="repo-title-wrap gt-df gt-fc">
  6. <div class="repo-title" role="heading" aria-level="1">
  7. {{$avatar := (repoAvatar . 32 "gt-mr-3")}}
  8. {{if $avatar}}
  9. {{$avatar}}
  10. {{else}}
  11. {{template "repo/icon" .}}
  12. {{end}}
  13. <a href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>
  14. <div class="gt-mx-2">/</div>
  15. <a href="{{$.RepoLink}}">{{.Name}}</a>
  16. <div class="labels gt-df gt-ac gt-fw">
  17. {{if .IsTemplate}}
  18. {{if .IsPrivate}}
  19. <span class="ui basic label">{{$.locale.Tr "repo.desc.private_template"}}</span>
  20. {{else}}
  21. {{if .Owner.Visibility.IsPrivate}}
  22. <span class="ui basic label">{{$.locale.Tr "repo.desc.internal_template"}}</span>
  23. {{end}}
  24. {{end}}
  25. {{else}}
  26. {{if .IsPrivate}}
  27. <span class="ui basic label">{{$.locale.Tr "repo.desc.private"}}</span>
  28. {{else}}
  29. {{if .Owner.Visibility.IsPrivate}}
  30. <span class="ui basic label">{{$.locale.Tr "repo.desc.internal"}}</span>
  31. {{end}}
  32. {{end}}
  33. {{end}}
  34. {{if .IsArchived}}
  35. <span class="ui basic label">{{$.locale.Tr "repo.desc.archived"}}</span>
  36. {{end}}
  37. </div>
  38. {{if $.EnableFeed}}
  39. <a class="rss-icon gt-ml-3" href="{{$.RepoLink}}.rss" data-tooltip-content="{{$.locale.Tr "rss_feed"}}">{{svg "octicon-rss" 18}}</a>
  40. {{end}}
  41. </div>
  42. {{if $.PullMirror}}
  43. {{$address := MirrorRemoteAddress $.Context . $.PullMirror.GetRemoteName false}}
  44. <div class="fork-flag">{{$.locale.Tr "repo.mirror_from"}} <a target="_blank" rel="noopener noreferrer" href="{{$address.Address}}">{{$address.Address}}</a></div>
  45. {{end}}
  46. {{if .IsFork}}<div class="fork-flag">{{$.locale.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{.BaseRepo.FullName}}</a></div>{{end}}
  47. {{if .IsGenerated}}<div class="fork-flag">{{$.locale.Tr "repo.generated_from"}} <a href="{{.TemplateRepo.Link}}">{{.TemplateRepo.FullName}}</a></div>{{end}}
  48. </div>
  49. {{if not (or .IsBeingCreated .IsBroken)}}
  50. <div class="repo-buttons">
  51. {{if $.RepoTransfer}}
  52. <form method="post" action="{{$.RepoLink}}/action/accept_transfer?redirect_to={{$.RepoLink}}">
  53. {{$.CsrfTokenHtml}}
  54. <div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{$.locale.Tr "repo.transfer.accept_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{$.locale.Tr "repo.transfer.no_permission_to_accept"}}{{end}}">
  55. <button type="submit" class="ui basic button {{if $.CanUserAcceptTransfer}}green {{end}} ok small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}>
  56. {{$.locale.Tr "repo.transfer.accept"}}
  57. </button>
  58. </div>
  59. </form>
  60. <form method="post" action="{{$.RepoLink}}/action/reject_transfer?redirect_to={{$.RepoLink}}">
  61. {{$.CsrfTokenHtml}}
  62. <div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{$.locale.Tr "repo.transfer.reject_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{$.locale.Tr "repo.transfer.no_permission_to_reject"}}{{end}}">
  63. <button type="submit" class="ui basic button {{if $.CanUserAcceptTransfer}}red {{end}}ok small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}>
  64. {{$.locale.Tr "repo.transfer.reject"}}
  65. </button>
  66. </div>
  67. </form>
  68. {{end}}
  69. <form method="post" action="{{$.RepoLink}}/action/{{if $.IsWatchingRepo}}un{{end}}watch?redirect_to={{$.Link}}">
  70. {{$.CsrfTokenHtml}}
  71. <div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{$.locale.Tr "repo.watch_guest_user"}}"{{end}}>
  72. <button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}>
  73. {{if $.IsWatchingRepo}}{{svg "octicon-eye-closed" 16}}{{$.locale.Tr "repo.unwatch"}}{{else}}{{svg "octicon-eye"}}{{$.locale.Tr "repo.watch"}}{{end}}
  74. </button>
  75. <a class="ui basic label" href="{{.Link}}/watchers">
  76. {{CountFmt .NumWatches}}
  77. </a>
  78. </div>
  79. </form>
  80. {{if not $.DisableStars}}
  81. <form method="post" action="{{$.RepoLink}}/action/{{if $.IsStaringRepo}}un{{end}}star?redirect_to={{$.Link}}">
  82. {{$.CsrfTokenHtml}}
  83. <div class="ui labeled button" {{if not $.IsSigned}}data-tooltip-content="{{$.locale.Tr "repo.star_guest_user"}}"{{end}}>
  84. <button type="submit" class="ui compact small basic button"{{if not $.IsSigned}} disabled{{end}}>
  85. {{if $.IsStaringRepo}}{{svg "octicon-star-fill"}}{{$.locale.Tr "repo.unstar"}}{{else}}{{svg "octicon-star"}}{{$.locale.Tr "repo.star"}}{{end}}
  86. </button>
  87. <a class="ui basic label" href="{{.Link}}/stars">
  88. {{CountFmt .NumStars}}
  89. </a>
  90. </div>
  91. </form>
  92. {{end}}
  93. {{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
  94. <div class="ui labeled button
  95. {{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0))}}
  96. disabled
  97. {{end}}"
  98. {{if not $.IsSigned}}
  99. data-tooltip-content="{{$.locale.Tr "repo.fork_guest_user"}}"
  100. {{else if and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0)}}
  101. data-tooltip-content="{{$.locale.Tr "repo.fork_from_self"}}"
  102. {{end}}
  103. >
  104. <a class="ui compact{{if $.ShowForkModal}} show-modal{{end}} small basic button"
  105. {{if not $.CanSignedUserFork}}
  106. {{if gt (len $.UserAndOrgForks) 1}}
  107. data-modal="#fork-repo-modal"
  108. {{else if eq (len $.UserAndOrgForks) 1}}
  109. href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}"
  110. {{/*else is not required here, because the button shouldn't link to any site if you can't create a fork*/}}
  111. {{end}}
  112. {{else if eq (len $.UserAndOrgForks) 0}}
  113. href="{{AppSubUrl}}/repo/fork/{{.ID}}"
  114. {{else}}
  115. data-modal="#fork-repo-modal"
  116. {{end}}
  117. >
  118. {{svg "octicon-repo-forked"}}{{$.locale.Tr "repo.fork"}}
  119. </a>
  120. <div class="ui small modal" id="fork-repo-modal">
  121. <div class="header">
  122. {{$.locale.Tr "repo.already_forked" .Name}}
  123. </div>
  124. <div class="content gt-text-left">
  125. <div class="ui list">
  126. {{range $.UserAndOrgForks}}
  127. <div class="ui item gt-py-3">
  128. <a href="{{.Link}}">
  129. {{svg "octicon-repo-forked" 16 "gt-mr-3"}}{{.FullName}}
  130. </a>
  131. </div>
  132. {{end}}
  133. </div>
  134. {{if $.CanSignedUserFork}}
  135. <div class="ui divider"></div>
  136. <a href="{{AppSubUrl}}/repo/fork/{{.ID}}">
  137. {{$.locale.Tr "repo.fork_to_different_account"}}
  138. </a>
  139. {{end}}
  140. </div>
  141. </div>
  142. <a class="ui basic label" href="{{.Link}}/forks">
  143. {{CountFmt .NumForks}}
  144. </a>
  145. </div>
  146. {{end}}
  147. </div>
  148. {{end}}
  149. </div><!-- end grid -->
  150. </div><!-- end container -->
  151. {{end}}
  152. <div class="ui tabs container">
  153. {{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}}
  154. <div class="ui tabular menu navbar gt-overflow-x-auto gt-overflow-y-hidden">
  155. {{if .Permission.CanRead $.UnitTypeCode}}
  156. <a class="{{if .PageIsViewCode}}active {{end}}item" href="{{.RepoLink}}{{if (ne .BranchName .Repository.DefaultBranch)}}/src/{{.BranchNameSubURL}}{{end}}">
  157. {{svg "octicon-code"}} {{.locale.Tr "repo.code"}}
  158. </a>
  159. {{end}}
  160. {{if .Permission.CanRead $.UnitTypeIssues}}
  161. <a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoLink}}/issues">
  162. {{svg "octicon-issue-opened"}} {{.locale.Tr "repo.issues"}}
  163. {{if .Repository.NumOpenIssues}}
  164. <span class="ui small label">{{CountFmt .Repository.NumOpenIssues}}</span>
  165. {{end}}
  166. </a>
  167. {{end}}
  168. {{if .Permission.CanRead $.UnitTypeExternalTracker}}
  169. <a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer">
  170. {{svg "octicon-link-external"}} {{.locale.Tr "repo.issues"}} </span>
  171. </a>
  172. {{end}}
  173. {{if and .Repository.CanEnablePulls (.Permission.CanRead $.UnitTypePullRequests)}}
  174. <a class="{{if .PageIsPullList}}active {{end}}item" href="{{.RepoLink}}/pulls">
  175. {{svg "octicon-git-pull-request"}} {{.locale.Tr "repo.pulls"}}
  176. {{if .Repository.NumOpenPulls}}
  177. <span class="ui small label">{{CountFmt .Repository.NumOpenPulls}}</span>
  178. {{end}}
  179. </a>
  180. {{end}}
  181. {{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}}
  182. <a class="{{if .PageIsActions}}active {{end}}item" href="{{.RepoLink}}/actions">
  183. {{svg "octicon-play"}} {{.locale.Tr "actions.actions"}}
  184. {{if .Repository.NumOpenActionRuns}}
  185. <span class="ui small label">{{CountFmt .Repository.NumOpenActionRuns}}</span>
  186. {{end}}
  187. </a>
  188. {{end}}
  189. {{if .Permission.CanRead $.UnitTypePackages}}
  190. <a href="{{.RepoLink}}/packages" class="{{if .IsPackagesPage}}active {{end}}item">
  191. {{svg "octicon-package"}} {{.locale.Tr "packages.title"}}
  192. </a>
  193. {{end}}
  194. {{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects)}}
  195. <a href="{{.RepoLink}}/projects" class="{{if .IsProjectsPage}}active {{end}}item">
  196. {{svg "octicon-project"}} {{.locale.Tr "repo.project_board"}}
  197. {{if .Repository.NumOpenProjects}}
  198. <span class="ui small label">{{CountFmt .Repository.NumOpenProjects}}</span>
  199. {{end}}
  200. </a>
  201. {{end}}
  202. {{if and (.Permission.CanRead $.UnitTypeReleases) (not .IsEmptyRepo)}}
  203. <a class="{{if or .PageIsReleaseList .PageIsTagList}}active {{end}}item" href="{{.RepoLink}}/releases">
  204. {{svg "octicon-tag"}} {{.locale.Tr "repo.releases"}}
  205. {{if .NumReleases}}
  206. <span class="ui small label">{{CountFmt .NumReleases}}</span>
  207. {{end}}
  208. </a>
  209. {{end}}
  210. {{if .Permission.CanRead $.UnitTypeWiki}}
  211. <a class="{{if .PageIsWiki}}active {{end}}item" href="{{.RepoLink}}/wiki">
  212. {{svg "octicon-book"}} {{.locale.Tr "repo.wiki"}}
  213. </a>
  214. {{end}}
  215. {{if .Permission.CanRead $.UnitTypeExternalWiki}}
  216. <a class="item" href="{{(.Repository.MustGetUnit $.Context $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL}}" target="_blank" rel="noopener noreferrer">
  217. {{svg "octicon-link-external"}} {{.locale.Tr "repo.wiki"}}
  218. </a>
  219. {{end}}
  220. {{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
  221. <a class="{{if .PageIsActivity}}active {{end}}item" href="{{.RepoLink}}/activity">
  222. {{svg "octicon-pulse"}} {{.locale.Tr "repo.activity"}}
  223. </a>
  224. {{end}}
  225. {{template "custom/extra_tabs" .}}
  226. {{if .Permission.IsAdmin}}
  227. <a class="{{if .PageIsRepoSettings}}active {{end}}right item" href="{{.RepoLink}}/settings">
  228. {{svg "octicon-tools"}} {{.locale.Tr "repo.settings"}}
  229. </a>
  230. {{end}}
  231. </div>
  232. {{else if .Permission.IsAdmin}}
  233. <div class="ui tabular menu navbar gt-overflow-x-auto gt-overflow-y-hidden">
  234. <a class="{{if .PageIsRepoSettings}}active {{end}}right item" href="{{.RepoLink}}/settings">
  235. {{svg "octicon-tools"}} {{.locale.Tr "repo.settings"}}
  236. </a>
  237. </div>
  238. {{end}}
  239. </div>
  240. <div class="ui tabs divider"></div>
  241. </div>