mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 02:08:36 +00:00
Add team option to grant rights for all organization repositories (#8688)
* Add field IsAllRepositories to team
* Add AllRepositories to team UI
* Manage team with access to all repositories
* Add field IsAllRepositories to team API
* put backticks around table/column names
* rename IsAllRepositories to IncludesAllRepositories
* do not reload slice if already loaded
* add repo to teams with access to all repositories when changing repo owner
* improve tests for teams with access to all repositories
* Merge branch 'master'
* Change code for adding all repositories
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* fmt after merge
* Change code in API EditTeam similar to EditTeamPost web interface
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* Clarify that all repositories will be added
Signed-off-by: David Svantesson <davidsvantesson@gmail.com>
* All repositories option under Permissions headline
* New setting group 'Repository access'
* Move check IncludeAllRepositories to removeRepository.
* Revert "Move check IncludeAllRepositories to removeRepository." and add comment instead.
This reverts commit 753b7d205b
.
* Clarify help text what options do.
This commit is contained in:
committed by
Lauris BH
parent
0109229928
commit
72aa5a20ec
@@ -1,4 +1,5 @@
|
||||
// Copyright 2014 The Gogs Authors. All rights reserved.
|
||||
// Copyright 2019 The Gitea Authors. All rights reserved.
|
||||
// Use of this source code is governed by a MIT-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
@@ -180,12 +181,14 @@ func NewTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
|
||||
ctx.Data["PageIsOrgTeams"] = true
|
||||
ctx.Data["PageIsOrgTeamsNew"] = true
|
||||
ctx.Data["Units"] = models.Units
|
||||
var includesAllRepositories = (form.RepoAccess == "all")
|
||||
|
||||
t := &models.Team{
|
||||
OrgID: ctx.Org.Organization.ID,
|
||||
Name: form.TeamName,
|
||||
Description: form.Description,
|
||||
Authorize: models.ParseAccessMode(form.Permission),
|
||||
OrgID: ctx.Org.Organization.ID,
|
||||
Name: form.TeamName,
|
||||
Description: form.Description,
|
||||
Authorize: models.ParseAccessMode(form.Permission),
|
||||
IncludesAllRepositories: includesAllRepositories,
|
||||
}
|
||||
|
||||
if t.Authorize < models.AccessModeOwner {
|
||||
@@ -268,6 +271,8 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
|
||||
ctx.Data["Units"] = models.Units
|
||||
|
||||
isAuthChanged := false
|
||||
isIncludeAllChanged := false
|
||||
var includesAllRepositories = (form.RepoAccess == "all")
|
||||
if !t.IsOwnerTeam() {
|
||||
// Validate permission level.
|
||||
auth := models.ParseAccessMode(form.Permission)
|
||||
@@ -277,6 +282,11 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
|
||||
isAuthChanged = true
|
||||
t.Authorize = auth
|
||||
}
|
||||
|
||||
if t.IncludesAllRepositories != includesAllRepositories {
|
||||
isIncludeAllChanged = true
|
||||
t.IncludesAllRepositories = includesAllRepositories
|
||||
}
|
||||
}
|
||||
t.Description = form.Description
|
||||
if t.Authorize < models.AccessModeOwner {
|
||||
@@ -305,7 +315,7 @@ func EditTeamPost(ctx *context.Context, form auth.CreateTeamForm) {
|
||||
return
|
||||
}
|
||||
|
||||
if err := models.UpdateTeam(t, isAuthChanged); err != nil {
|
||||
if err := models.UpdateTeam(t, isAuthChanged, isIncludeAllChanged); err != nil {
|
||||
ctx.Data["Err_TeamName"] = true
|
||||
switch {
|
||||
case models.IsErrTeamAlreadyExist(err):
|
||||
|
Reference in New Issue
Block a user