diff options
author | Denys Konovalov <kontakt@denyskon.de> | 2024-03-04 03:56:52 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-04 02:56:52 +0000 |
commit | fe6792dff3d167e87b0c4476f7e7a7ce15742855 (patch) | |
tree | 9511f5bdbeba0f94189f9e173f83c116645a37bc /modules | |
parent | 8553b4600e3035b6f6ad6907c37cebd013fa4d64 (diff) | |
download | gitea-fe6792dff3d167e87b0c4476f7e7a7ce15742855.tar.gz gitea-fe6792dff3d167e87b0c4476f7e7a7ce15742855.zip |
Enable/disable owner and repo projects independently (#28805)
Part of #23318
Add menu in repo settings to allow for repo admin to decide not just if
projects are enabled or disabled per repo, but also which kind of
projects (repo-level/owner-level) are enabled. If repo projects
disabled, don't show the projects tab.
![grafik](https://github.com/go-gitea/gitea/assets/47871822/b9b43fb4-824b-47f9-b8e2-12004313647c)
---------
Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/repository/create.go | 6 | ||||
-rw-r--r-- | modules/structs/repo.go | 3 |
2 files changed, 9 insertions, 0 deletions
diff --git a/modules/repository/create.go b/modules/repository/create.go index ca2150b972..f009c0880d 100644 --- a/modules/repository/create.go +++ b/modules/repository/create.go @@ -93,6 +93,12 @@ func CreateRepositoryByExample(ctx context.Context, doer, u *user_model.User, re AllowRebaseUpdate: true, }, }) + } else if tp == unit.TypeProjects { + units = append(units, repo_model.RepoUnit{ + RepoID: repo.ID, + Type: tp, + Config: &repo_model.ProjectsConfig{ProjectsMode: repo_model.ProjectsModeAll}, + }) } else { units = append(units, repo_model.RepoUnit{ RepoID: repo.ID, diff --git a/modules/structs/repo.go b/modules/structs/repo.go index 56d6158bd8..bc8eb0b756 100644 --- a/modules/structs/repo.go +++ b/modules/structs/repo.go @@ -90,6 +90,7 @@ type Repository struct { ExternalWiki *ExternalWiki `json:"external_wiki,omitempty"` HasPullRequests bool `json:"has_pull_requests"` HasProjects bool `json:"has_projects"` + ProjectsMode string `json:"projects_mode"` HasReleases bool `json:"has_releases"` HasPackages bool `json:"has_packages"` HasActions bool `json:"has_actions"` @@ -180,6 +181,8 @@ type EditRepoOption struct { HasPullRequests *bool `json:"has_pull_requests,omitempty"` // either `true` to enable project unit, or `false` to disable them. HasProjects *bool `json:"has_projects,omitempty"` + // `repo` to only allow repo-level projects, `owner` to only allow owner projects, `all` to allow both. + ProjectsMode *string `json:"projects_mode,omitempty" binding:"In(repo,owner,all)"` // either `true` to enable releases unit, or `false` to disable them. HasReleases *bool `json:"has_releases,omitempty"` // either `true` to enable packages unit, or `false` to disable them. |