mirror of https://github.com/go-gitea/gitea.git
Repository level enable package or disable (#19323)
This commit is contained in:
parent
6a969681cd
commit
d4834071da
|
@ -102,3 +102,6 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
|
|||
|
||||
[lfs]
|
||||
PATH = integrations/gitea-integration-mssql/data/lfs
|
||||
|
||||
[packages]
|
||||
ENABLED = true
|
||||
|
|
|
@ -118,3 +118,6 @@ DISABLE_GIT_HOOKS = false
|
|||
INSTALL_LOCK = true
|
||||
SECRET_KEY = 9pCviYTWSb
|
||||
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.hhSVGOANkaKk3vfCd2jDOIww4pUk0xtg9JRde5UogyQ
|
||||
|
||||
[packages]
|
||||
ENABLED = true
|
||||
|
|
|
@ -99,3 +99,6 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
|
|||
|
||||
[lfs]
|
||||
PATH = integrations/gitea-integration-mysql8/data/lfs
|
||||
|
||||
[packages]
|
||||
ENABLED = true
|
||||
|
|
|
@ -103,3 +103,6 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
|
|||
|
||||
[lfs]
|
||||
PATH = integrations/gitea-integration-pgsql/data/lfs
|
||||
|
||||
[packages]
|
||||
ENABLED = true
|
||||
|
|
|
@ -101,3 +101,6 @@ JWT_SECRET = KZb_QLUd4fYVyxetjxC4eZkrBgWM2SndOOWDNtgUUko
|
|||
|
||||
[lfs]
|
||||
PATH = integrations/gitea-integration-sqlite/data/lfs
|
||||
|
||||
[packages]
|
||||
ENABLED = true
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -1019,6 +1019,7 @@ func UnitTypes() func(ctx *Context) {
|
|||
ctx.Data["UnitTypeExternalWiki"] = unit_model.TypeExternalWiki
|
||||
ctx.Data["UnitTypeExternalTracker"] = unit_model.TypeExternalTracker
|
||||
ctx.Data["UnitTypeProjects"] = unit_model.TypeProjects
|
||||
ctx.Data["UnitTypePackages"] = unit_model.TypePackages
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -295,6 +295,10 @@ func newRepository() {
|
|||
log.Fatal("Failed to map Repository.PullRequest settings: %v", err)
|
||||
}
|
||||
|
||||
if !Cfg.Section("packages").Key("ENABLED").MustBool(false) {
|
||||
Repository.DisabledRepoUnits = append(Repository.DisabledRepoUnits, "repo.packages")
|
||||
}
|
||||
|
||||
// Handle default trustmodel settings
|
||||
Repository.Signing.DefaultTrustModel = strings.ToLower(strings.TrimSpace(Repository.Signing.DefaultTrustModel))
|
||||
if Repository.Signing.DefaultTrustModel == "default" {
|
||||
|
|
|
@ -1011,6 +1011,7 @@ tags = Tags
|
|||
issues = Issues
|
||||
pulls = Pull Requests
|
||||
project_board = Projects
|
||||
packages = Packages
|
||||
labels = Labels
|
||||
org_labels_desc = Organization level labels that can be used with <strong>all repositories</strong> under this organization
|
||||
org_labels_desc_manage = manage
|
||||
|
|
|
@ -456,6 +456,15 @@ func SettingsPost(ctx *context.Context) {
|
|||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeProjects)
|
||||
}
|
||||
|
||||
if form.EnablePackages && !unit_model.TypeProjects.UnitGlobalDisabled() {
|
||||
units = append(units, repo_model.RepoUnit{
|
||||
RepoID: repo.ID,
|
||||
Type: unit_model.TypePackages,
|
||||
})
|
||||
} else if !unit_model.TypePackages.UnitGlobalDisabled() {
|
||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypePackages)
|
||||
}
|
||||
|
||||
if form.EnablePulls && !unit_model.TypePullRequests.UnitGlobalDisabled() {
|
||||
units = append(units, repo_model.RepoUnit{
|
||||
RepoID: repo.ID,
|
||||
|
|
|
@ -143,6 +143,7 @@ type RepoSettingForm struct {
|
|||
TrackerIssueStyle string
|
||||
EnableCloseIssuesViaCommitInAnyBranch bool
|
||||
EnableProjects bool
|
||||
EnablePackages bool
|
||||
EnablePulls bool
|
||||
PullsIgnoreWhitespace bool
|
||||
PullsAllowMerge bool
|
||||
|
|
|
@ -178,9 +178,11 @@
|
|||
</a>
|
||||
{{end}}
|
||||
|
||||
<a href="{{.RepoLink}}/packages" class="{{ if .IsPackagesPage }}active{{end}} item">
|
||||
{{svg "octicon-package"}} {{.i18n.Tr "packages.title"}}
|
||||
</a>
|
||||
{{if .Permission.CanRead $.UnitTypePackages}}
|
||||
<a href="{{.RepoLink}}/packages" class="{{ if .IsPackagesPage }}active{{end}} item">
|
||||
{{svg "octicon-package"}} {{.i18n.Tr "packages.title"}}
|
||||
</a>
|
||||
{{end}}
|
||||
|
||||
{{ if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects)}}
|
||||
<a href="{{.RepoLink}}/projects" class="{{ if .IsProjectsPage }}active{{end}} item">
|
||||
|
|
|
@ -390,6 +390,19 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
{{$isPackagesEnabled := .Repository.UnitEnabled $.UnitTypePackages}}
|
||||
<div class="inline field">
|
||||
<label>{{.i18n.Tr "repo.packages"}}</label>
|
||||
{{if .UnitTypePackages.UnitGlobalDisabled}}
|
||||
<div class="ui checkbox tooltip disabled" data-content="{{.i18n.Tr "repo.unit_disabled"}}">
|
||||
{{else}}
|
||||
<div class="ui checkbox">
|
||||
{{end}}
|
||||
<input class="enable-system" name="enable_packages" type="checkbox" {{if $isPackagesEnabled}}checked{{end}}>
|
||||
<label>{{.i18n.Tr "repo.settings.packages_desc"}}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{if not .IsMirror}}
|
||||
<div class="ui divider"></div>
|
||||
{{$pullRequestEnabled := .Repository.UnitEnabled $.UnitTypePullRequests}}
|
||||
|
|
Loading…
Reference in New Issue