From fd6034aaf23af1ce03bcba0babcbe7675ce093ee Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 18 May 2017 22:54:24 +0800 Subject: 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 --- models/unit.go | 80 ++++++++++++++++++++++++++++++++++++---------------------- 1 file changed, 50 insertions(+), 30 deletions(-) (limited to 'models/unit.go') 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, -- cgit v1.2.3