Skip to content

Commit c0edbd4

Browse files
committed
Fix test
1 parent c2ff613 commit c0edbd4

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

models/org_team.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ func UpdateTeam(ctx context.Context, t *organization.Team, updateCols ...string)
255255
}
256256

257257
// update units for team
258-
if len(t.Units) > 0 {
258+
if slices.Contains(updateCols, "units") {
259259
for _, unit := range t.Units {
260260
unit.TeamID = t.ID
261261
}

routers/api/v1/org/team.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,10 +320,15 @@ func EditTeam(ctx *context.APIContext) {
320320
}
321321
}
322322

323+
isAdmin := team.AccessMode == perm.AccessModeAdmin
324+
if form.Permission != "" && form.Permission == "admin" {
325+
isAdmin = true
326+
}
327+
323328
if err := org_service.UpdateTeam(ctx, team, org_service.UpdateTeamOptions{
324329
TeamName: teamName,
325330
Description: description,
326-
IsAdmin: form.Permission == "admin",
331+
IsAdmin: isAdmin,
327332
IncludesAllRepositories: includeAllRepos,
328333
CanCreateOrgRepo: canCreateOrgRepo,
329334
UnitPerms: unitPerms,

services/org/team.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ type UpdateTeamOptions struct {
2525
func UpdateTeam(ctx context.Context, team *org_model.Team, opts UpdateTeamOptions) error {
2626
var changedCols []string
2727

28-
var newAccessMode perm.AccessMode
28+
newAccessMode := team.AccessMode
2929
if opts.IsAdmin {
3030
newAccessMode = perm.AccessModeAdmin
31-
} else {
31+
} else if len(opts.UnitPerms) > 0 {
3232
// if newAccessMode is less than admin accessmode, then it should be general accessmode,
3333
// so we should calculate the minial accessmode from units accessmodes.
3434
newAccessMode = unit_model.MinUnitAccessMode(opts.UnitPerms)

0 commit comments

Comments
 (0)