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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. <div class="secondary-nav">
  2. {{with .Repository}}
  3. <div class="ui container">
  4. <div class="repo-header">
  5. <div class="flex-item tw-items-center">
  6. <div class="flex-item-leading">
  7. {{template "repo/icon" .}}
  8. </div>
  9. <div class="flex-item-main">
  10. <div class="flex-item-title tw-text-18">
  11. <a class="muted tw-font-normal" href="{{.Owner.HomeLink}}">{{.Owner.Name}}</a>/<a class="muted" href="{{$.RepoLink}}">{{.Name}}</a>
  12. </div>
  13. </div>
  14. <div class="flex-item-trailing">
  15. {{if .IsArchived}}
  16. <span class="ui basic label not-mobile">{{ctx.Locale.Tr "repo.desc.archived"}}</span>
  17. <div class="repo-icon only-mobile" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.archived"}}">{{svg "octicon-archive" 18}}</div>
  18. {{end}}
  19. {{if .IsPrivate}}
  20. <span class="ui basic label not-mobile">{{ctx.Locale.Tr "repo.desc.private"}}</span>
  21. <div class="repo-icon only-mobile" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.private"}}">{{svg "octicon-lock" 18}}</div>
  22. {{else}}
  23. {{if .Owner.Visibility.IsPrivate}}
  24. <span class="ui basic label not-mobile">{{ctx.Locale.Tr "repo.desc.internal"}}</span>
  25. <div class="repo-icon only-mobile" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.internal"}}">{{svg "octicon-shield-lock" 18}}</div>
  26. {{end}}
  27. {{end}}
  28. {{if .IsTemplate}}
  29. <span class="ui basic label not-mobile">{{ctx.Locale.Tr "repo.desc.template"}}</span>
  30. <div class="repo-icon only-mobile" data-tooltip-content="{{ctx.Locale.Tr "repo.desc.template"}}">{{svg "octicon-repo-template" 18}}</div>
  31. {{end}}
  32. {{if eq .ObjectFormatName "sha256"}}
  33. <span class="ui basic label">{{ctx.Locale.Tr "repo.desc.sha256"}}</span>
  34. {{end}}
  35. </div>
  36. </div>
  37. {{if not (or .IsBeingCreated .IsBroken)}}
  38. <div class="repo-buttons">
  39. {{if $.RepoTransfer}}
  40. <form method="post" action="{{$.RepoLink}}/action/accept_transfer?redirect_to={{$.RepoLink}}">
  41. {{$.CsrfTokenHtml}}
  42. <div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{ctx.Locale.Tr "repo.transfer.accept_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{ctx.Locale.Tr "repo.transfer.no_permission_to_accept"}}{{end}}">
  43. <button type="submit" class="ui basic button {{if $.CanUserAcceptTransfer}}primary {{end}} ok small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}>
  44. {{ctx.Locale.Tr "repo.transfer.accept"}}
  45. </button>
  46. </div>
  47. </form>
  48. <form method="post" action="{{$.RepoLink}}/action/reject_transfer?redirect_to={{$.RepoLink}}">
  49. {{$.CsrfTokenHtml}}
  50. <div data-tooltip-content="{{if $.CanUserAcceptTransfer}}{{ctx.Locale.Tr "repo.transfer.reject_desc" $.RepoTransfer.Recipient.DisplayName}}{{else}}{{ctx.Locale.Tr "repo.transfer.no_permission_to_reject"}}{{end}}">
  51. <button type="submit" class="ui basic button {{if $.CanUserAcceptTransfer}}red {{end}}ok small"{{if not $.CanUserAcceptTransfer}} disabled{{end}}>
  52. {{ctx.Locale.Tr "repo.transfer.reject"}}
  53. </button>
  54. </div>
  55. </form>
  56. {{end}}
  57. {{if $.EnableFeed}}
  58. {{/* An extra div-element is not necessary here, as this button does not secretly contain two buttons. */}}
  59. <a class="ui compact small basic button" href="{{$.RepoLink}}.rss" data-tooltip-content="{{ctx.Locale.Tr "rss_feed"}}">
  60. {{svg "octicon-rss" 16}}
  61. </a>
  62. {{end}}
  63. {{template "repo/watch_unwatch" $}}
  64. {{if not $.DisableStars}}
  65. {{template "repo/star_unstar" $}}
  66. {{end}}
  67. {{if and (not .IsEmpty) ($.Permission.CanRead ctx.Consts.RepoUnitTypeCode)}}
  68. <div class="ui labeled button
  69. {{if or (not $.IsSigned) (and (not $.CanSignedUserFork) (not $.UserAndOrgForks))}}
  70. disabled
  71. {{end}}"
  72. {{if not $.IsSigned}}
  73. data-tooltip-content="{{ctx.Locale.Tr "repo.fork_guest_user"}}"
  74. {{else if and (not $.CanSignedUserFork) (not $.UserAndOrgForks)}}
  75. data-tooltip-content="{{ctx.Locale.Tr "repo.fork_from_self"}}"
  76. {{end}}
  77. >
  78. <a class="ui compact{{if $.ShowForkModal}} show-modal{{end}} small basic button"
  79. {{if not $.CanSignedUserFork}}
  80. {{if gt (len $.UserAndOrgForks) 1}}
  81. href="#" data-modal="#fork-repo-modal"
  82. {{else if eq (len $.UserAndOrgForks) 1}}
  83. href="{{AppSubUrl}}/{{(index $.UserAndOrgForks 0).FullName}}"
  84. {{/*else is not required here, because the button shouldn't link to any site if you can't create a fork*/}}
  85. {{end}}
  86. {{else if not $.UserAndOrgForks}}
  87. href="{{$.RepoLink}}/fork"
  88. {{else}}
  89. href="#" data-modal="#fork-repo-modal"
  90. {{end}}
  91. >
  92. {{svg "octicon-repo-forked"}}<span class="text not-mobile">{{ctx.Locale.Tr "repo.fork"}}</span>
  93. </a>
  94. <a class="ui basic label" href="{{.Link}}/forks">
  95. {{CountFmt .NumForks}}
  96. </a>
  97. </div>
  98. <div class="ui small modal" id="fork-repo-modal">
  99. <div class="header">
  100. {{ctx.Locale.Tr "repo.already_forked" .Name}}
  101. </div>
  102. <div class="content tw-text-left">
  103. <div class="ui list">
  104. {{range $.UserAndOrgForks}}
  105. <div class="ui item tw-py-2">
  106. <a href="{{.Link}}">{{svg "octicon-repo-forked" 16 "tw-mr-2"}}{{.FullName}}</a>
  107. </div>
  108. {{end}}
  109. </div>
  110. {{if $.CanSignedUserFork}}
  111. <div class="divider"></div>
  112. <a href="{{$.RepoLink}}/fork">{{ctx.Locale.Tr "repo.fork_to_different_account"}}</a>
  113. {{end}}
  114. </div>
  115. </div>
  116. {{end}}
  117. </div>
  118. {{end}}
  119. </div>
  120. {{if $.PullMirror}}
  121. <div class="fork-flag">
  122. {{ctx.Locale.Tr "repo.mirror_from"}}
  123. <a target="_blank" rel="noopener noreferrer" href="{{$.PullMirror.RemoteAddress}}">{{$.PullMirror.RemoteAddress}}</a>
  124. {{if $.PullMirror.UpdatedUnix}}{{ctx.Locale.Tr "repo.mirror_sync"}} {{TimeSinceUnix $.PullMirror.UpdatedUnix ctx.Locale}}{{end}}
  125. </div>
  126. {{end}}
  127. {{if .IsFork}}<div class="fork-flag">{{ctx.Locale.Tr "repo.forked_from"}} <a href="{{.BaseRepo.Link}}">{{.BaseRepo.FullName}}</a></div>{{end}}
  128. {{if .IsGenerated}}<div class="fork-flag">{{ctx.Locale.Tr "repo.generated_from"}} <a href="{{(.TemplateRepo ctx).Link}}">{{(.TemplateRepo ctx).FullName}}</a></div>{{end}}
  129. </div>
  130. {{end}}
  131. <div class="ui container">
  132. <overflow-menu class="ui secondary pointing menu">
  133. {{if not (or .Repository.IsBeingCreated .Repository.IsBroken)}}
  134. <div class="overflow-menu-items">
  135. {{if .Permission.CanRead ctx.Consts.RepoUnitTypeCode}}
  136. <a class="{{if .PageIsViewCode}}active {{end}}item" href="{{.RepoLink}}{{if and (ne .BranchName .Repository.DefaultBranch) (not $.PageIsWiki)}}/src/{{.BranchNameSubURL}}{{end}}">
  137. {{svg "octicon-code"}} {{ctx.Locale.Tr "repo.code"}}
  138. </a>
  139. {{end}}
  140. {{if .Permission.CanRead ctx.Consts.RepoUnitTypeIssues}}
  141. <a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoLink}}/issues">
  142. {{svg "octicon-issue-opened"}} {{ctx.Locale.Tr "repo.issues"}}
  143. {{if .Repository.NumOpenIssues}}
  144. <span class="ui small label">{{CountFmt .Repository.NumOpenIssues}}</span>
  145. {{end}}
  146. </a>
  147. {{end}}
  148. {{if .Permission.CanRead ctx.Consts.RepoUnitTypeExternalTracker}}
  149. <a class="{{if .PageIsIssueList}}active {{end}}item" href="{{.RepoExternalIssuesLink}}" target="_blank" rel="noopener noreferrer">
  150. {{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.issues"}}
  151. </a>
  152. {{end}}
  153. {{if and .Repository.CanEnablePulls (.Permission.CanRead ctx.Consts.RepoUnitTypePullRequests)}}
  154. <a class="{{if .PageIsPullList}}active {{end}}item" href="{{.RepoLink}}/pulls">
  155. {{svg "octicon-git-pull-request"}} {{ctx.Locale.Tr "repo.pulls"}}
  156. {{if .Repository.NumOpenPulls}}
  157. <span class="ui small label">{{CountFmt .Repository.NumOpenPulls}}</span>
  158. {{end}}
  159. </a>
  160. {{end}}
  161. {{if and .EnableActions (not .UnitActionsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeActions)}}
  162. <a class="{{if .PageIsActions}}active {{end}}item" href="{{.RepoLink}}/actions">
  163. {{svg "octicon-play"}} {{ctx.Locale.Tr "actions.actions"}}
  164. {{if .Repository.NumOpenActionRuns}}
  165. <span class="ui small label">{{CountFmt .Repository.NumOpenActionRuns}}</span>
  166. {{end}}
  167. </a>
  168. {{end}}
  169. {{if .Permission.CanRead ctx.Consts.RepoUnitTypePackages}}
  170. <a href="{{.RepoLink}}/packages" class="{{if .IsPackagesPage}}active {{end}}item">
  171. {{svg "octicon-package"}} {{ctx.Locale.Tr "packages.title"}}
  172. </a>
  173. {{end}}
  174. {{$projectsUnit := .Repository.MustGetUnit $.Context ctx.Consts.RepoUnitTypeProjects}}
  175. {{if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead ctx.Consts.RepoUnitTypeProjects) ($projectsUnit.ProjectsConfig.IsProjectsAllowed "repo")}}
  176. <a href="{{.RepoLink}}/projects" class="{{if .IsProjectsPage}}active {{end}}item">
  177. {{svg "octicon-project"}} {{ctx.Locale.Tr "repo.project_board"}}
  178. {{if .Repository.NumOpenProjects}}
  179. <span class="ui small label">{{CountFmt .Repository.NumOpenProjects}}</span>
  180. {{end}}
  181. </a>
  182. {{end}}
  183. {{if and (.Permission.CanRead ctx.Consts.RepoUnitTypeReleases) (not .IsEmptyRepo)}}
  184. <a class="{{if or .PageIsReleaseList .PageIsTagList}}active {{end}}item" href="{{.RepoLink}}/releases">
  185. {{svg "octicon-tag"}} {{ctx.Locale.Tr "repo.releases"}}
  186. {{if .NumReleases}}
  187. <span class="ui small label">{{CountFmt .NumReleases}}</span>
  188. {{end}}
  189. </a>
  190. {{end}}
  191. {{if .Permission.CanRead ctx.Consts.RepoUnitTypeWiki}}
  192. <a class="{{if .PageIsWiki}}active {{end}}item" href="{{.RepoLink}}/wiki">
  193. {{svg "octicon-book"}} {{ctx.Locale.Tr "repo.wiki"}}
  194. </a>
  195. {{end}}
  196. {{if .Permission.CanRead ctx.Consts.RepoUnitTypeExternalWiki}}
  197. <a class="item" href="{{(.Repository.MustGetUnit $.Context ctx.Consts.RepoUnitTypeExternalWiki).ExternalWikiConfig.ExternalWikiURL}}" target="_blank" rel="noopener noreferrer">
  198. {{svg "octicon-link-external"}} {{ctx.Locale.Tr "repo.wiki"}}
  199. </a>
  200. {{end}}
  201. {{if and (.Permission.CanReadAny ctx.Consts.RepoUnitTypePullRequests ctx.Consts.RepoUnitTypeIssues ctx.Consts.RepoUnitTypeReleases) (not .IsEmptyRepo)}}
  202. <a class="{{if .PageIsActivity}}active {{end}}item" href="{{.RepoLink}}/activity">
  203. {{svg "octicon-pulse"}} {{ctx.Locale.Tr "repo.activity"}}
  204. </a>
  205. {{end}}
  206. {{template "custom/extra_tabs" .}}
  207. {{if .Permission.IsAdmin}}
  208. <span class="item-flex-space"></span>
  209. <a class="{{if .PageIsRepoSettings}}active {{end}} item" href="{{.RepoLink}}/settings">
  210. {{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}}
  211. </a>
  212. {{end}}
  213. </div>
  214. {{else if .Permission.IsAdmin}}
  215. <div class="overflow-menu-items">
  216. <a class="{{if .PageIsRepoSettings}}active {{end}} item" href="{{.RepoLink}}/settings">
  217. {{svg "octicon-tools"}} {{ctx.Locale.Tr "repo.settings"}}
  218. </a>
  219. </div>
  220. {{end}}
  221. </overflow-menu>
  222. </div>
  223. <div class="ui tabs divider"></div>
  224. </div>