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.

137 lines
2.7 KiB

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package models
  5. // UnitType is Unit's Type
  6. type UnitType int
  7. // Enumerate all the unit types
  8. const (
  9. UnitTypeCode UnitType = iota + 1 // 1 code
  10. UnitTypeIssues // 2 issues
  11. UnitTypePullRequests // 3 PRs
  12. UnitTypeCommits // 4 Commits
  13. UnitTypeReleases // 5 Releases
  14. UnitTypeWiki // 6 Wiki
  15. UnitTypeSettings // 7 Settings
  16. UnitTypeExternalWiki // 8 ExternalWiki
  17. UnitTypeExternalTracker // 9 ExternalTracker
  18. )
  19. // Unit is a tab page of one repository
  20. type Unit struct {
  21. Type UnitType
  22. NameKey string
  23. URI string
  24. DescKey string
  25. Idx int
  26. }
  27. // Enumerate all the units
  28. var (
  29. UnitCode = Unit{
  30. UnitTypeCode,
  31. "repo.code",
  32. "/",
  33. "repo.code_desc",
  34. 0,
  35. }
  36. UnitIssues = Unit{
  37. UnitTypeIssues,
  38. "repo.issues",
  39. "/issues",
  40. "repo.issues_desc",
  41. 1,
  42. }
  43. UnitExternalTracker = Unit{
  44. UnitTypeExternalTracker,
  45. "repo.issues",
  46. "/issues",
  47. "repo.issues_desc",
  48. 1,
  49. }
  50. UnitPullRequests = Unit{
  51. UnitTypePullRequests,
  52. "repo.pulls",
  53. "/pulls",
  54. "repo.pulls_desc",
  55. 2,
  56. }
  57. UnitCommits = Unit{
  58. UnitTypeCommits,
  59. "repo.commits",
  60. "/commits/master",
  61. "repo.commits_desc",
  62. 3,
  63. }
  64. UnitReleases = Unit{
  65. UnitTypeReleases,
  66. "repo.releases",
  67. "/releases",
  68. "repo.releases_desc",
  69. 4,
  70. }
  71. UnitWiki = Unit{
  72. UnitTypeWiki,
  73. "repo.wiki",
  74. "/wiki",
  75. "repo.wiki_desc",
  76. 5,
  77. }
  78. UnitExternalWiki = Unit{
  79. UnitTypeExternalWiki,
  80. "repo.wiki",
  81. "/wiki",
  82. "repo.wiki_desc",
  83. 5,
  84. }
  85. UnitSettings = Unit{
  86. UnitTypeSettings,
  87. "repo.settings",
  88. "/settings",
  89. "repo.settings_desc",
  90. 6,
  91. }
  92. // defaultRepoUnits contains all the default unit types
  93. defaultRepoUnits = []UnitType{
  94. UnitTypeCode,
  95. UnitTypeIssues,
  96. UnitTypePullRequests,
  97. UnitTypeCommits,
  98. UnitTypeReleases,
  99. UnitTypeWiki,
  100. UnitTypeSettings,
  101. }
  102. // MustRepoUnits contains the units could be disabled currently
  103. MustRepoUnits = []UnitType{
  104. UnitTypeCode,
  105. UnitTypeCommits,
  106. UnitTypeReleases,
  107. UnitTypeSettings,
  108. }
  109. // Units contains all the units
  110. Units = map[UnitType]Unit{
  111. UnitTypeCode: UnitCode,
  112. UnitTypeIssues: UnitIssues,
  113. UnitTypeExternalTracker: UnitExternalTracker,
  114. UnitTypePullRequests: UnitPullRequests,
  115. UnitTypeCommits: UnitCommits,
  116. UnitTypeReleases: UnitReleases,
  117. UnitTypeWiki: UnitWiki,
  118. UnitTypeExternalWiki: UnitExternalWiki,
  119. UnitTypeSettings: UnitSettings,
  120. }
  121. )