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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. <div class="header-wrapper">
  2. {{with .Repository}}
  3. <div class="ui container">
  4. <div class="repo-header">
  5. <div class="repo-title-wrap df fc">
  6. <div class="repo-title">
  7. {{$avatar := (repoAvatar . 32 "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="mx-2">/</div>
  15. <a href="{{$.RepoLink}}">{{.Name}}</a>
  16. {{if $.EnableFeed}}
  17. <a href="{{$.RepoLink}}.rss"><i class="ui grey icon tooltip ml-3" data-content="{{$.locale.Tr "rss_feed"}}" data-position="top center">{{svg "octicon-rss" 18}}</i></a>
  18. {{end}}
  19. <div class="labels df ac fw">
  20. {{if .IsTemplate}}
  21. {{if .IsPrivate}}
  22. <span class="ui basic label">{{$.locale.Tr "repo.desc.private_template"}}</span>
  23. {{else}}
  24. {{if .Owner.Visibility.IsPrivate}}
  25. <span class="ui basic label">{{$.locale.Tr "repo.desc.internal_template"}}</span>
  26. {{end}}
  27. {{end}}
  28. {{else}}
  29. {{if .IsPrivate}}
  30. <span class="ui basic label">{{$.locale.Tr "repo.desc.private"}}</span>
  31. {{else}}
  32. {{if .Owner.Visibility.IsPrivate}}
  33. <span class="ui basic label">{{$.locale.Tr "repo.desc.internal"}}</span>
  34. {{end}}
  35. {{end}}
  36. {{end}}
  37. {{if .IsArchived}}
  38. <span class="ui basic label">{{$.locale.Tr "repo.desc.archived"}}</span>
  39. {{end}}
  40. </div>
  41. </div>
  42. {{if $.IsPullMirror}}
  43. {{$address := MirrorRemoteAddress $.Context . $.Mirror.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 class="ui tooltip" data-content="{{if $.CanUserAcceptTransfer}}{{$.locale.Tr "repo.transfer.accept_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{$.locale.Tr "repo.transfer.no_permission_to_accept"}}{{end}}" data-position="bottom center">
  55. <button type="submit" class="ui button {{if $.CanUserAcceptTransfer}}green {{end}} ok inverted 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 class="ui tooltip" data-content="{{if $.CanUserAcceptTransfer}}{{$.locale.Tr "repo.transfer.reject_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{$.locale.Tr "repo.transfer.no_permission_to_reject"}}{{end}}" data-position="bottom center">
  63. <button type="submit" class="ui button {{if $.CanUserAcceptTransfer}}red {{end}}ok inverted 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}} tooltip{{end}}"{{if not $.IsSigned}} data-content="{{$.locale.Tr "repo.watch_guest_user"}}" data-position="top center"{{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}} tooltip{{end}}"{{if not $.IsSigned}} data-content="{{$.locale.Tr "repo.star_guest_user"}}" data-position="top center"{{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. tooltip disabled
  97. {{end}}"
  98. {{if not $.IsSigned}}
  99. data-content="{{$.locale.Tr "repo.fork_guest_user"}}"
  100. {{else if and (not $.CanSignedUserFork) (eq (len $.UserAndOrgForks) 0)}}
  101. data-content="{{$.locale.Tr "repo.fork_from_self"}}"
  102. {{end}}
  103. data-position="top center">
  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. {{svg "octicon-x" 16 "close inside"}}
  122. <div class="header">
  123. {{$.locale.Tr "repo.already_forked" .Name}}
  124. </div>
  125. <div class="content tl">
  126. <div class="ui list">
  127. {{range $.UserAndOrgForks}}
  128. <div class="ui item py-3">
  129. <a href="{{.Link}}">
  130. {{svg "octicon-repo-forked" 16 "mr-3"}}{{.FullName}}
  131. </a>
  132. </div>
  133. {{end}}
  134. </div>
  135. {{if $.CanSignedUserFork}}
  136. <div class="ui divider"></div>
  137. <a href="{{AppSubUrl}}/repo/fork/{{.ID}}">
  138. {{$.locale.Tr "repo.fork_to_different_account"}}
  139. </a>
  140. {{end}}
  141. </div>
  142. </div>
  143. <a class="ui basic label" href="{{.Link}}/forks">
  144. {{CountFmt .NumForks}}
  145. </a>
  146. </div>
  147. {{end}}
  148. </div>
  149. {{end}}
  150. </div><!-- end grid -->
  151. </div><!-- end container -->
  152. {{end}}
  153. <div class="ui tabs container">
  154. {{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}}
  155. <div class="ui tabular stackable menu navbar">
  156. {{if .Permission.CanRead $.UnitTypeCode}}
  157. <a class="{{if .PageIsViewCode}}active {{end}}item" href="{{.RepoLink}}{{if (ne .BranchName .Repository.DefaultBranch)}}/src/{{.BranchNameSubURL}}{{end}}">
  158. {{svg "octicon-code"}} {{.locale.Tr "repo.code"}}
  159. </a>
  160. {{end}}
  161. {{if .Permission.CanRead $.UnitTypeIssues}}
  162. <a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoLink}}/issues">
  163. {{svg "octicon-issue-opened"}} {{.locale.Tr "repo.issues"}}
  164. {{if .Repository.NumOpenIssues}}
  165. <span class="ui primary small label">{{CountFmt .Repository.NumOpenIssues}}</span>
  166. {{end}}
  167. </a>
  168. {{end}}
  169. {{if .Permission.CanRead $.UnitTypeExternalTracker}}
  170. <a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer">
  171. {{svg "octicon-link-external"}} {{.locale.Tr "repo.issues"}} </span>
  172. </a>
  173. {{end}}
  174. {{if and .Repository.CanEnablePulls (.Permission.CanRead $.UnitTypePullRequests)}}
  175. <a class="{{if .PageIsPullList}}active {{end}}item" href="{{.RepoLink}}/pulls">
  176. {{svg "octicon-git-pull-request"}} {{.locale.Tr "repo.pulls"}}
  177. {{if .Repository.NumOpenPulls}}
  178. <span class="ui primary small label">{{CountFmt .Repository.NumOpenPulls}}</span>
  179. {{end}}
  180. </a>
  181. {{end}}
  182. {{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead $.UnitTypeActions)}}
  183. <a class="{{if .PageIsActions}}active {{end}}item" href="{{.RepoLink}}/actions">
  184. {{svg "octicon-play"}} {{.locale.Tr "actions.actions"}}
  185. {{if .Repository.NumOpenActionRuns}}
  186. <span class="ui primary small label">{{CountFmt .Repository.NumOpenActionRuns}}</span>
  187. {{end}}
  188. </a>
  189. {{end}}
  190. {{if .Permission.CanRead $.UnitTypePackages}}
  191. <a href="{{.RepoLink}}/packages" class="{{if .IsPackagesPage}}active {{end}}item">
  192. {{svg "octicon-package"}} {{.locale.Tr "packages.title"}}
  193. </a>
  194. {{end}}
  195. {{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects)}}
  196. <a href="{{.RepoLink}}/projects" class="{{if .IsProjectsPage}}active {{end}}item">
  197. {{svg "octicon-project"}} {{.locale.Tr "repo.project_board"}}
  198. {{if .Repository.NumOpenProjects}}
  199. <span class="ui primary small label">{{CountFmt .Repository.NumOpenProjects}}</span>
  200. {{end}}
  201. </a>
  202. {{end}}
  203. {{if and (.Permission.CanRead $.UnitTypeReleases) (not .IsEmptyRepo)}}
  204. <a class="{{if .PageIsReleaseList}}active {{end}}item" href="{{.RepoLink}}/releases">
  205. {{svg "octicon-tag"}} {{.locale.Tr "repo.releases"}}
  206. {{if .NumReleases}}
  207. <span class="ui primary small label">{{CountFmt .NumReleases}}</span>
  208. {{end}}
  209. </a>
  210. {{end}}
  211. {{if or (.Permission.CanRead $.UnitTypeWiki) (.Permission.CanRead $.UnitTypeExternalWiki)}}
  212. <a class="{{if .PageIsWiki}}active {{end}}item" href="{{.RepoLink}}/wiki" {{if and (.Permission.CanRead $.UnitTypeExternalWiki) (not (HasPrefix ((.Repository.MustGetUnit $.Context $.UnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL) (.Repository.HTMLURL)))}} target="_blank" rel="noopener noreferrer" {{end}}>
  213. {{svg "octicon-book"}} {{.locale.Tr "repo.wiki"}}
  214. </a>
  215. {{end}}
  216. {{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
  217. <a class="{{if .PageIsActivity}}active {{end}}item" href="{{.RepoLink}}/activity">
  218. {{svg "octicon-pulse"}} {{.locale.Tr "repo.activity"}}
  219. </a>
  220. {{end}}
  221. {{template "custom/extra_tabs" .}}
  222. {{if .Permission.IsAdmin}}
  223. <div class="right menu">
  224. <a class="{{if .PageIsSettings}}active {{end}}item" href="{{.RepoLink}}/settings">
  225. {{svg "octicon-tools"}} {{.locale.Tr "repo.settings"}}
  226. </a>
  227. </div>
  228. {{end}}
  229. </div>
  230. {{else if .Permission.IsAdmin}}
  231. <div class="ui tabular stackable menu navbar">
  232. <div class="right menu">
  233. <a class="{{if .PageIsSettings}}active {{end}}item" href="{{.RepoLink}}/settings">
  234. {{svg "octicon-tools"}} {{.locale.Tr "repo.settings"}}
  235. </a>
  236. </div>
  237. </div>
  238. {{end}}
  239. </div>
  240. <div class="ui tabs divider"></div>
  241. </div>