This commit is contained in:
Lunny Xiao 2024-10-30 15:34:13 -07:00
parent c2ff613582
commit c0edbd4d67
No known key found for this signature in database
GPG Key ID: C3B7C91B632F738A
3 changed files with 9 additions and 4 deletions

View File

@ -255,7 +255,7 @@ func UpdateTeam(ctx context.Context, t *organization.Team, updateCols ...string)
}
// update units for team
if len(t.Units) > 0 {
if slices.Contains(updateCols, "units") {
for _, unit := range t.Units {
unit.TeamID = t.ID
}

View File

@ -320,10 +320,15 @@ func EditTeam(ctx *context.APIContext) {
}
}
isAdmin := team.AccessMode == perm.AccessModeAdmin
if form.Permission != "" && form.Permission == "admin" {
isAdmin = true
}
if err := org_service.UpdateTeam(ctx, team, org_service.UpdateTeamOptions{
TeamName: teamName,
Description: description,
IsAdmin: form.Permission == "admin",
IsAdmin: isAdmin,
IncludesAllRepositories: includeAllRepos,
CanCreateOrgRepo: canCreateOrgRepo,
UnitPerms: unitPerms,

View File

@ -25,10 +25,10 @@ type UpdateTeamOptions struct {
func UpdateTeam(ctx context.Context, team *org_model.Team, opts UpdateTeamOptions) error {
var changedCols []string
var newAccessMode perm.AccessMode
newAccessMode := team.AccessMode
if opts.IsAdmin {
newAccessMode = perm.AccessModeAdmin
} else {
} else if len(opts.UnitPerms) > 0 {
// if newAccessMode is less than admin accessmode, then it should be general accessmode,
// so we should calculate the minial accessmode from units accessmodes.
newAccessMode = unit_model.MinUnitAccessMode(opts.UnitPerms)