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
This commit is contained in:
Lunny Xiao 2017-05-18 22:54:24 +08:00 committed by GitHub
parent 5db5e16ab6
commit fd6034aaf2
18 changed files with 366 additions and 113 deletions

View file

@ -20,90 +20,21 @@ const (
UnitTypeExternalTracker // 9 ExternalTracker
)
// Unit is a tab page of one repository
type Unit struct {
Type UnitType
NameKey string
URI string
DescKey string
Idx int
}
// Enumerate all the units
var (
UnitCode = Unit{
// allRepUnitTypes contains all the unit types
allRepUnitTypes = []UnitType{
UnitTypeCode,
"repo.code",
"/",
"repo.code_desc",
0,
}
UnitIssues = Unit{
UnitTypeIssues,
"repo.issues",
"/issues",
"repo.issues_desc",
1,
}
UnitExternalTracker = Unit{
UnitTypeExternalTracker,
"repo.issues",
"/issues",
"repo.issues_desc",
1,
}
UnitPullRequests = Unit{
UnitTypePullRequests,
"repo.pulls",
"/pulls",
"repo.pulls_desc",
2,
}
UnitCommits = Unit{
UnitTypeCommits,
"repo.commits",
"/commits/master",
"repo.commits_desc",
3,
}
UnitReleases = Unit{
UnitTypeReleases,
"repo.releases",
"/releases",
"repo.releases_desc",
4,
}
UnitWiki = Unit{
UnitTypeWiki,
"repo.wiki",
"/wiki",
"repo.wiki_desc",
5,
}
UnitExternalWiki = Unit{
UnitTypeExternalWiki,
"repo.wiki",
"/wiki",
"repo.wiki_desc",
5,
}
UnitSettings = Unit{
UnitTypeSettings,
"repo.settings",
"/settings",
"repo.settings_desc",
6,
UnitTypeExternalWiki,
UnitTypeExternalTracker,
}
// defaultRepoUnits contains all the default unit types
// defaultRepoUnits contains the default unit types
defaultRepoUnits = []UnitType{
UnitTypeCode,
UnitTypeIssues,
@ -121,6 +52,95 @@ var (
UnitTypeReleases,
UnitTypeSettings,
}
)
// Unit is a tab page of one repository
type Unit struct {
Type UnitType
NameKey string
URI string
DescKey string
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",
0,
}
UnitIssues = Unit{
UnitTypeIssues,
"repo.issues",
"/issues",
"repo.issues.desc",
1,
}
UnitExternalTracker = Unit{
UnitTypeExternalTracker,
"repo.ext_issues",
"/issues",
"repo.ext_issues.desc",
1,
}
UnitPullRequests = Unit{
UnitTypePullRequests,
"repo.pulls",
"/pulls",
"repo.pulls.desc",
2,
}
UnitCommits = Unit{
UnitTypeCommits,
"repo.commits",
"/commits/master",
"repo.commits.desc",
3,
}
UnitReleases = Unit{
UnitTypeReleases,
"repo.releases",
"/releases",
"repo.releases.desc",
4,
}
UnitWiki = Unit{
UnitTypeWiki,
"repo.wiki",
"/wiki",
"repo.wiki.desc",
5,
}
UnitExternalWiki = Unit{
UnitTypeExternalWiki,
"repo.ext_wiki",
"/wiki",
"repo.ext_wiki.desc",
5,
}
UnitSettings = Unit{
UnitTypeSettings,
"repo.settings",
"/settings",
"repo.settings.desc",
6,
}
// Units contains all the units
Units = map[UnitType]Unit{