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.

131 lines
2.5 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. UnitTypeReleases // 4 Releases
  13. UnitTypeWiki // 5 Wiki
  14. UnitTypeExternalWiki // 6 ExternalWiki
  15. UnitTypeExternalTracker // 7 ExternalTracker
  16. )
  17. var (
  18. // allRepUnitTypes contains all the unit types
  19. allRepUnitTypes = []UnitType{
  20. UnitTypeCode,
  21. UnitTypeIssues,
  22. UnitTypePullRequests,
  23. UnitTypeReleases,
  24. UnitTypeWiki,
  25. UnitTypeExternalWiki,
  26. UnitTypeExternalTracker,
  27. }
  28. // defaultRepoUnits contains the default unit types
  29. defaultRepoUnits = []UnitType{
  30. UnitTypeCode,
  31. UnitTypeIssues,
  32. UnitTypePullRequests,
  33. UnitTypeReleases,
  34. UnitTypeWiki,
  35. }
  36. // MustRepoUnits contains the units could not be disabled currently
  37. MustRepoUnits = []UnitType{
  38. UnitTypeCode,
  39. UnitTypeReleases,
  40. }
  41. )
  42. // Unit is a section of one repository
  43. type Unit struct {
  44. Type UnitType
  45. NameKey string
  46. URI string
  47. DescKey string
  48. Idx int
  49. }
  50. // CanDisable returns if this unit could be disabled.
  51. func (u *Unit) CanDisable() bool {
  52. return true
  53. }
  54. // Enumerate all the units
  55. var (
  56. UnitCode = Unit{
  57. UnitTypeCode,
  58. "repo.code",
  59. "/",
  60. "repo.code.desc",
  61. 0,
  62. }
  63. UnitIssues = Unit{
  64. UnitTypeIssues,
  65. "repo.issues",
  66. "/issues",
  67. "repo.issues.desc",
  68. 1,
  69. }
  70. UnitExternalTracker = Unit{
  71. UnitTypeExternalTracker,
  72. "repo.ext_issues",
  73. "/issues",
  74. "repo.ext_issues.desc",
  75. 1,
  76. }
  77. UnitPullRequests = Unit{
  78. UnitTypePullRequests,
  79. "repo.pulls",
  80. "/pulls",
  81. "repo.pulls.desc",
  82. 2,
  83. }
  84. UnitReleases = Unit{
  85. UnitTypeReleases,
  86. "repo.releases",
  87. "/releases",
  88. "repo.releases.desc",
  89. 3,
  90. }
  91. UnitWiki = Unit{
  92. UnitTypeWiki,
  93. "repo.wiki",
  94. "/wiki",
  95. "repo.wiki.desc",
  96. 4,
  97. }
  98. UnitExternalWiki = Unit{
  99. UnitTypeExternalWiki,
  100. "repo.ext_wiki",
  101. "/wiki",
  102. "repo.ext_wiki.desc",
  103. 4,
  104. }
  105. // Units contains all the units
  106. Units = map[UnitType]Unit{
  107. UnitTypeCode: UnitCode,
  108. UnitTypeIssues: UnitIssues,
  109. UnitTypeExternalTracker: UnitExternalTracker,
  110. UnitTypePullRequests: UnitPullRequests,
  111. UnitTypeReleases: UnitReleases,
  112. UnitTypeWiki: UnitWiki,
  113. UnitTypeExternalWiki: UnitExternalWiki,
  114. }
  115. )