Add pagination and search box to org teams list (#37245)
- Add pagination and keyword search to the teams list page - 5 teams shown at most in the overview page Fixes: #34482 Fixes: #36602 Fixes: #37084 Signed-off-by: silverwind <me@silverwind.io> Co-authored-by: Animesh Kumar <83393501+kmranimesh@users.noreply.github.com> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Claude (Opus 4.7) <noreply@anthropic.com> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
@@ -174,23 +174,12 @@ func OrgAssignment(orgAssignmentOpts OrgAssignmentOptions) func(ctx *Context) {
|
||||
}
|
||||
|
||||
// Team.
|
||||
shouldSeeAllTeams, err := UserShouldSeeAllOrgTeams(ctx)
|
||||
if err != nil {
|
||||
ctx.ServerError("UserShouldSeeAllOrgTeams", err)
|
||||
return
|
||||
}
|
||||
if ctx.Org.IsMember {
|
||||
shouldSeeAllTeams := false
|
||||
if ctx.Org.IsOwner {
|
||||
shouldSeeAllTeams = true
|
||||
} else {
|
||||
teams, err := org.GetUserTeams(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
ctx.ServerError("GetUserTeams", err)
|
||||
return
|
||||
}
|
||||
for _, team := range teams {
|
||||
if team.IncludesAllRepositories && team.HasAdminAccess() {
|
||||
shouldSeeAllTeams = true
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if shouldSeeAllTeams {
|
||||
ctx.Org.Teams, err = org.LoadTeams(ctx)
|
||||
if err != nil {
|
||||
@@ -255,3 +244,25 @@ func OrgAssignment(orgAssignmentOpts OrgAssignmentOptions) func(ctx *Context) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// UserShouldSeeAllOrgTeams tells if a user has permission to view all teams in the org.
|
||||
func UserShouldSeeAllOrgTeams(ctx *Context) (bool, error) {
|
||||
if !ctx.Org.IsMember {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if ctx.Org.IsOwner {
|
||||
return true, nil
|
||||
}
|
||||
|
||||
teams, err := ctx.Org.Organization.GetUserTeams(ctx, ctx.Doer.ID)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
for _, team := range teams {
|
||||
if team.IncludesAllRepositories && team.HasAdminAccess() {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
return false, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user