gitea源码

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