Repository level enable package or disable (#19323)

This commit is contained in:
Lunny Xiao 2022-05-08 23:51:50 +08:00 committed by GitHub
parent 6a969681cd
commit d4834071da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 65 additions and 4 deletions

View file

@ -181,7 +181,7 @@ func (r *RepoUnit) BeforeSet(colName string, val xorm.Cell) {
r.Config = new(PullRequestsConfig)
case unit.TypeIssues:
r.Config = new(IssuesConfig)
case unit.TypeCode, unit.TypeReleases, unit.TypeWiki, unit.TypeProjects:
case unit.TypeCode, unit.TypeReleases, unit.TypeWiki, unit.TypeProjects, unit.TypePackages:
fallthrough
default:
r.Config = new(UnitConfig)

View file

@ -27,6 +27,7 @@ const (
TypeExternalWiki // 6 ExternalWiki
TypeExternalTracker // 7 ExternalTracker
TypeProjects // 8 Kanban board
TypePackages // 9 Packages
)
// Value returns integer value for unit type
@ -52,6 +53,8 @@ func (u Type) String() string {
return "TypeExternalTracker"
case TypeProjects:
return "TypeProjects"
case TypePackages:
return "TypePackages"
}
return fmt.Sprintf("Unknown Type %d", u)
}
@ -74,6 +77,7 @@ var (
TypeExternalWiki,
TypeExternalTracker,
TypeProjects,
TypePackages,
}
// DefaultRepoUnits contains the default unit types
@ -84,6 +88,7 @@ var (
TypeReleases,
TypeWiki,
TypeProjects,
TypePackages,
}
// NotAllowedDefaultRepoUnits contains units that can't be default
@ -275,6 +280,15 @@ var (
perm.AccessModeOwner,
}
UnitPackages = Unit{
TypePackages,
"repo.packages",
"/packages",
"repo.packages.desc",
6,
perm.AccessModeRead,
}
// Units contains all the units
Units = map[Type]Unit{
TypeCode: UnitCode,
@ -285,6 +299,7 @@ var (
TypeWiki: UnitWiki,
TypeExternalWiki: UnitExternalWiki,
TypeProjects: UnitProjects,
TypePackages: UnitPackages,
}
)