mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-08-28 21:36:05 +02:00
Repository level enable package or disable (#19323)
This commit is contained in:
parent
6a969681cd
commit
d4834071da
14 changed files with 65 additions and 4 deletions
|
@ -102,3 +102,6 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
|
||||||
|
|
||||||
[lfs]
|
[lfs]
|
||||||
PATH = integrations/gitea-integration-mssql/data/lfs
|
PATH = integrations/gitea-integration-mssql/data/lfs
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
ENABLED = true
|
||||||
|
|
|
@ -118,3 +118,6 @@ DISABLE_GIT_HOOKS = false
|
||||||
INSTALL_LOCK = true
|
INSTALL_LOCK = true
|
||||||
SECRET_KEY = 9pCviYTWSb
|
SECRET_KEY = 9pCviYTWSb
|
||||||
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.hhSVGOANkaKk3vfCd2jDOIww4pUk0xtg9JRde5UogyQ
|
INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.hhSVGOANkaKk3vfCd2jDOIww4pUk0xtg9JRde5UogyQ
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
ENABLED = true
|
||||||
|
|
|
@ -99,3 +99,6 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
|
||||||
|
|
||||||
[lfs]
|
[lfs]
|
||||||
PATH = integrations/gitea-integration-mysql8/data/lfs
|
PATH = integrations/gitea-integration-mysql8/data/lfs
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
ENABLED = true
|
||||||
|
|
|
@ -103,3 +103,6 @@ INTERNAL_TOKEN = eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYmYiOjE0OTU1NTE2MTh9.h
|
||||||
|
|
||||||
[lfs]
|
[lfs]
|
||||||
PATH = integrations/gitea-integration-pgsql/data/lfs
|
PATH = integrations/gitea-integration-pgsql/data/lfs
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
ENABLED = true
|
||||||
|
|
|
@ -101,3 +101,6 @@ JWT_SECRET = KZb_QLUd4fYVyxetjxC4eZkrBgWM2SndOOWDNtgUUko
|
||||||
|
|
||||||
[lfs]
|
[lfs]
|
||||||
PATH = integrations/gitea-integration-sqlite/data/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)
|
r.Config = new(PullRequestsConfig)
|
||||||
case unit.TypeIssues:
|
case unit.TypeIssues:
|
||||||
r.Config = new(IssuesConfig)
|
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
|
fallthrough
|
||||||
default:
|
default:
|
||||||
r.Config = new(UnitConfig)
|
r.Config = new(UnitConfig)
|
||||||
|
|
|
@ -27,6 +27,7 @@ const (
|
||||||
TypeExternalWiki // 6 ExternalWiki
|
TypeExternalWiki // 6 ExternalWiki
|
||||||
TypeExternalTracker // 7 ExternalTracker
|
TypeExternalTracker // 7 ExternalTracker
|
||||||
TypeProjects // 8 Kanban board
|
TypeProjects // 8 Kanban board
|
||||||
|
TypePackages // 9 Packages
|
||||||
)
|
)
|
||||||
|
|
||||||
// Value returns integer value for unit type
|
// Value returns integer value for unit type
|
||||||
|
@ -52,6 +53,8 @@ func (u Type) String() string {
|
||||||
return "TypeExternalTracker"
|
return "TypeExternalTracker"
|
||||||
case TypeProjects:
|
case TypeProjects:
|
||||||
return "TypeProjects"
|
return "TypeProjects"
|
||||||
|
case TypePackages:
|
||||||
|
return "TypePackages"
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("Unknown Type %d", u)
|
return fmt.Sprintf("Unknown Type %d", u)
|
||||||
}
|
}
|
||||||
|
@ -74,6 +77,7 @@ var (
|
||||||
TypeExternalWiki,
|
TypeExternalWiki,
|
||||||
TypeExternalTracker,
|
TypeExternalTracker,
|
||||||
TypeProjects,
|
TypeProjects,
|
||||||
|
TypePackages,
|
||||||
}
|
}
|
||||||
|
|
||||||
// DefaultRepoUnits contains the default unit types
|
// DefaultRepoUnits contains the default unit types
|
||||||
|
@ -84,6 +88,7 @@ var (
|
||||||
TypeReleases,
|
TypeReleases,
|
||||||
TypeWiki,
|
TypeWiki,
|
||||||
TypeProjects,
|
TypeProjects,
|
||||||
|
TypePackages,
|
||||||
}
|
}
|
||||||
|
|
||||||
// NotAllowedDefaultRepoUnits contains units that can't be default
|
// NotAllowedDefaultRepoUnits contains units that can't be default
|
||||||
|
@ -275,6 +280,15 @@ var (
|
||||||
perm.AccessModeOwner,
|
perm.AccessModeOwner,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
UnitPackages = Unit{
|
||||||
|
TypePackages,
|
||||||
|
"repo.packages",
|
||||||
|
"/packages",
|
||||||
|
"repo.packages.desc",
|
||||||
|
6,
|
||||||
|
perm.AccessModeRead,
|
||||||
|
}
|
||||||
|
|
||||||
// Units contains all the units
|
// Units contains all the units
|
||||||
Units = map[Type]Unit{
|
Units = map[Type]Unit{
|
||||||
TypeCode: UnitCode,
|
TypeCode: UnitCode,
|
||||||
|
@ -285,6 +299,7 @@ var (
|
||||||
TypeWiki: UnitWiki,
|
TypeWiki: UnitWiki,
|
||||||
TypeExternalWiki: UnitExternalWiki,
|
TypeExternalWiki: UnitExternalWiki,
|
||||||
TypeProjects: UnitProjects,
|
TypeProjects: UnitProjects,
|
||||||
|
TypePackages: UnitPackages,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1019,6 +1019,7 @@ func UnitTypes() func(ctx *Context) {
|
||||||
ctx.Data["UnitTypeExternalWiki"] = unit_model.TypeExternalWiki
|
ctx.Data["UnitTypeExternalWiki"] = unit_model.TypeExternalWiki
|
||||||
ctx.Data["UnitTypeExternalTracker"] = unit_model.TypeExternalTracker
|
ctx.Data["UnitTypeExternalTracker"] = unit_model.TypeExternalTracker
|
||||||
ctx.Data["UnitTypeProjects"] = unit_model.TypeProjects
|
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)
|
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
|
// Handle default trustmodel settings
|
||||||
Repository.Signing.DefaultTrustModel = strings.ToLower(strings.TrimSpace(Repository.Signing.DefaultTrustModel))
|
Repository.Signing.DefaultTrustModel = strings.ToLower(strings.TrimSpace(Repository.Signing.DefaultTrustModel))
|
||||||
if Repository.Signing.DefaultTrustModel == "default" {
|
if Repository.Signing.DefaultTrustModel == "default" {
|
||||||
|
|
|
@ -1011,6 +1011,7 @@ tags = Tags
|
||||||
issues = Issues
|
issues = Issues
|
||||||
pulls = Pull Requests
|
pulls = Pull Requests
|
||||||
project_board = Projects
|
project_board = Projects
|
||||||
|
packages = Packages
|
||||||
labels = Labels
|
labels = Labels
|
||||||
org_labels_desc = Organization level labels that can be used with <strong>all repositories</strong> under this organization
|
org_labels_desc = Organization level labels that can be used with <strong>all repositories</strong> under this organization
|
||||||
org_labels_desc_manage = manage
|
org_labels_desc_manage = manage
|
||||||
|
|
|
@ -456,6 +456,15 @@ func SettingsPost(ctx *context.Context) {
|
||||||
deleteUnitTypes = append(deleteUnitTypes, unit_model.TypeProjects)
|
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() {
|
if form.EnablePulls && !unit_model.TypePullRequests.UnitGlobalDisabled() {
|
||||||
units = append(units, repo_model.RepoUnit{
|
units = append(units, repo_model.RepoUnit{
|
||||||
RepoID: repo.ID,
|
RepoID: repo.ID,
|
||||||
|
|
|
@ -143,6 +143,7 @@ type RepoSettingForm struct {
|
||||||
TrackerIssueStyle string
|
TrackerIssueStyle string
|
||||||
EnableCloseIssuesViaCommitInAnyBranch bool
|
EnableCloseIssuesViaCommitInAnyBranch bool
|
||||||
EnableProjects bool
|
EnableProjects bool
|
||||||
|
EnablePackages bool
|
||||||
EnablePulls bool
|
EnablePulls bool
|
||||||
PullsIgnoreWhitespace bool
|
PullsIgnoreWhitespace bool
|
||||||
PullsAllowMerge bool
|
PullsAllowMerge bool
|
||||||
|
|
|
@ -178,9 +178,11 @@
|
||||||
</a>
|
</a>
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
|
{{if .Permission.CanRead $.UnitTypePackages}}
|
||||||
<a href="{{.RepoLink}}/packages" class="{{ if .IsPackagesPage }}active{{end}} item">
|
<a href="{{.RepoLink}}/packages" class="{{ if .IsPackagesPage }}active{{end}} item">
|
||||||
{{svg "octicon-package"}} {{.i18n.Tr "packages.title"}}
|
{{svg "octicon-package"}} {{.i18n.Tr "packages.title"}}
|
||||||
</a>
|
</a>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{ if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects)}}
|
{{ if and (not .UnitProjectsGlobalDisabled) (.Permission.CanRead $.UnitTypeProjects)}}
|
||||||
<a href="{{.RepoLink}}/projects" class="{{ if .IsProjectsPage }}active{{end}} item">
|
<a href="{{.RepoLink}}/projects" class="{{ if .IsProjectsPage }}active{{end}} item">
|
||||||
|
|
|
@ -390,6 +390,19 @@
|
||||||
</div>
|
</div>
|
||||||
</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}}
|
{{if not .IsMirror}}
|
||||||
<div class="ui divider"></div>
|
<div class="ui divider"></div>
|
||||||
{{$pullRequestEnabled := .Repository.UnitEnabled $.UnitTypePullRequests}}
|
{{$pullRequestEnabled := .Repository.UnitEnabled $.UnitTypePullRequests}}
|
||||||
|
|
Loading…
Reference in a new issue