summaryrefslogtreecommitdiffstats
path: root/models/unit.go
diff options
context:
space:
mode:
Diffstat (limited to 'models/unit.go')
-rw-r--r--models/unit.go80
1 files changed, 50 insertions, 30 deletions
diff --git a/models/unit.go b/models/unit.go
index 54bb928ba7..48ef1620eb 100644
--- a/models/unit.go
+++ b/models/unit.go
@@ -20,6 +20,40 @@ const (
UnitTypeExternalTracker // 9 ExternalTracker
)
+var (
+ // allRepUnitTypes contains all the unit types
+ allRepUnitTypes = []UnitType{
+ UnitTypeCode,
+ UnitTypeIssues,
+ UnitTypePullRequests,
+ UnitTypeCommits,
+ UnitTypeReleases,
+ UnitTypeWiki,
+ UnitTypeSettings,
+ UnitTypeExternalWiki,
+ UnitTypeExternalTracker,
+ }
+
+ // defaultRepoUnits contains the default unit types
+ defaultRepoUnits = []UnitType{
+ UnitTypeCode,
+ UnitTypeIssues,
+ UnitTypePullRequests,
+ UnitTypeCommits,
+ UnitTypeReleases,
+ UnitTypeWiki,
+ UnitTypeSettings,
+ }
+
+ // MustRepoUnits contains the units could be disabled currently
+ MustRepoUnits = []UnitType{
+ UnitTypeCode,
+ UnitTypeCommits,
+ UnitTypeReleases,
+ UnitTypeSettings,
+ }
+)
+
// Unit is a tab page of one repository
type Unit struct {
Type UnitType
@@ -29,13 +63,18 @@ type Unit struct {
Idx int
}
+// CanDisable returns if this unit could be disabled.
+func (u *Unit) CanDisable() bool {
+ return u.Type != UnitTypeSettings
+}
+
// Enumerate all the units
var (
UnitCode = Unit{
UnitTypeCode,
"repo.code",
"/",
- "repo.code_desc",
+ "repo.code.desc",
0,
}
@@ -43,15 +82,15 @@ var (
UnitTypeIssues,
"repo.issues",
"/issues",
- "repo.issues_desc",
+ "repo.issues.desc",
1,
}
UnitExternalTracker = Unit{
UnitTypeExternalTracker,
- "repo.issues",
+ "repo.ext_issues",
"/issues",
- "repo.issues_desc",
+ "repo.ext_issues.desc",
1,
}
@@ -59,7 +98,7 @@ var (
UnitTypePullRequests,
"repo.pulls",
"/pulls",
- "repo.pulls_desc",
+ "repo.pulls.desc",
2,
}
@@ -67,7 +106,7 @@ var (
UnitTypeCommits,
"repo.commits",
"/commits/master",
- "repo.commits_desc",
+ "repo.commits.desc",
3,
}
@@ -75,7 +114,7 @@ var (
UnitTypeReleases,
"repo.releases",
"/releases",
- "repo.releases_desc",
+ "repo.releases.desc",
4,
}
@@ -83,15 +122,15 @@ var (
UnitTypeWiki,
"repo.wiki",
"/wiki",
- "repo.wiki_desc",
+ "repo.wiki.desc",
5,
}
UnitExternalWiki = Unit{
UnitTypeExternalWiki,
- "repo.wiki",
+ "repo.ext_wiki",
"/wiki",
- "repo.wiki_desc",
+ "repo.ext_wiki.desc",
5,
}
@@ -99,29 +138,10 @@ var (
UnitTypeSettings,
"repo.settings",
"/settings",
- "repo.settings_desc",
+ "repo.settings.desc",
6,
}
- // defaultRepoUnits contains all the default unit types
- defaultRepoUnits = []UnitType{
- UnitTypeCode,
- UnitTypeIssues,
- UnitTypePullRequests,
- UnitTypeCommits,
- UnitTypeReleases,
- UnitTypeWiki,
- UnitTypeSettings,
- }
-
- // MustRepoUnits contains the units could be disabled currently
- MustRepoUnits = []UnitType{
- UnitTypeCode,
- UnitTypeCommits,
- UnitTypeReleases,
- UnitTypeSettings,
- }
-
// Units contains all the units
Units = map[UnitType]Unit{
UnitTypeCode: UnitCode,