diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2017-05-18 22:54:24 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-18 22:54:24 +0800 |
commit | fd6034aaf23af1ce03bcba0babcbe7675ce093ee (patch) | |
tree | 9720f416facdef02a76bd56ca50669cc1f17eb88 /models/unit.go | |
parent | 5db5e16ab61f25f21cb17ee4895679b9830641a5 (diff) | |
download | gitea-fd6034aaf23af1ce03bcba0babcbe7675ce093ee.tar.gz gitea-fd6034aaf23af1ce03bcba0babcbe7675ce093ee.zip |
Add units to team (#947)
* add units to team
* fix lint
* finish team setting backend
* finished permission controll on routes
* fix import blank line
* add unit check on ssh/http pull and push and fix test failed
* fix fixtures data
* remove unused code
Diffstat (limited to 'models/unit.go')
-rw-r--r-- | models/unit.go | 80 |
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, |