From 8bec3d7736fbd2d9d5d4fe305b60ed631945c53a Mon Sep 17 00:00:00 2001 From: majiayu000 <1835304752@qq.com> Date: Tue, 30 Dec 2025 19:12:14 +0800 Subject: [PATCH] Add pagination, filtering and description display to organization teams page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds: - Pagination support for the teams list using SearchTeam with configurable page size - Search/filter functionality to filter teams by name or description - Display of team descriptions in the team list view - Empty state message when no teams match the search criteria The implementation follows existing patterns used in members.go and other paginated lists in the codebase. Fixes #34482 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 Signed-off-by: majiayu000 <1835304752@qq.com> --- options/locale/locale_en-US.json | 1 + routers/web/org/teams.go | 29 ++++++++++- templates/org/team/teams.tmpl | 86 +++++++++++++++++++++----------- 3 files changed, 84 insertions(+), 32 deletions(-) diff --git a/options/locale/locale_en-US.json b/options/locale/locale_en-US.json index 0fb95606b3..7afee70d1f 100644 --- a/options/locale/locale_en-US.json +++ b/options/locale/locale_en-US.json @@ -2806,6 +2806,7 @@ "org.teams.add_duplicate_users": "User is already a team member.", "org.teams.repos.none": "No repositories could be accessed by this team.", "org.teams.members.none": "No members on this team.", + "org.teams.no_teams": "No teams found.", "org.teams.members.blocked_user": "Cannot add the user because it is blocked by the organization.", "org.teams.specific_repositories": "Specific repositories", "org.teams.specific_repositories_helper": "Members will only have access to repositories explicitly added to the team. Selecting this will not automatically remove repositories already added with All repositories.", diff --git a/routers/web/org/teams.go b/routers/web/org/teams.go index 0ec7cfddc5..b574253de6 100644 --- a/routers/web/org/teams.go +++ b/routers/web/org/teams.go @@ -54,13 +54,38 @@ func Teams(ctx *context.Context) { ctx.Data["Title"] = org.FullName ctx.Data["PageIsOrgTeams"] = true - for _, t := range ctx.Org.Teams { + page := max(ctx.FormInt("page"), 1) + keyword := ctx.FormTrim("q") + + opts := &org_model.SearchTeamOptions{ + Keyword: keyword, + OrgID: org.ID, + IncludeDesc: true, + ListOptions: db.ListOptions{ + Page: page, + PageSize: setting.UI.MembersPagingNum, + }, + } + + teams, total, err := org_model.SearchTeam(ctx, opts) + if err != nil { + ctx.ServerError("SearchTeam", err) + return + } + + for _, t := range teams { if err := t.LoadMembers(ctx); err != nil { ctx.ServerError("GetMembers", err) return } } - ctx.Data["Teams"] = ctx.Org.Teams + + ctx.Data["Teams"] = teams + ctx.Data["Keyword"] = keyword + + pager := context.NewPagination(int(total), setting.UI.MembersPagingNum, page, 5) + pager.AddParamFromRequest(ctx.Req) + ctx.Data["Page"] = pager ctx.HTML(http.StatusOK, tplTeams) } diff --git a/templates/org/team/teams.tmpl b/templates/org/team/teams.tmpl index 50f4f7e97d..4a06889c60 100644 --- a/templates/org/team/teams.tmpl +++ b/templates/org/team/teams.tmpl @@ -3,44 +3,70 @@ {{template "org/header" .}}
{{template "base/alert" .}} - {{if .IsOrganizationOwner}} - -
- {{end}} -
+
+ + + {{if .IsOrganizationOwner}} + {{svg "octicon-plus"}} {{ctx.Locale.Tr "org.create_new_team"}} + {{end}} +
+
+ +
{{range .Teams}} -
-
- {{.Name}} -
- {{ctx.Locale.Tr "view"}} - {{if .IsMember ctx $.SignedUser.ID}} -
- -
- {{else if $.IsOrganizationOwner}} -
- -
+
+
+
+
+ {{svg "octicon-people" 16}} + {{.Name}} +
+
+ {{ctx.Locale.Tr "view"}} + {{if .IsMember ctx $.SignedUser.ID}} +
+ +
+ {{else if $.IsOrganizationOwner}} +
+ +
+ {{end}} +
+
+ {{if .Description}} +
+ {{.Description}} +
+ {{end}} + +
+ {{range .Members}} + {{template "shared/user/avatarlink" dict "user" . "Size" 28}} {{end}}
-
- {{range .Members}} - {{template "shared/user/avatarlink" dict "user" .}} - {{end}} -
- +
+ {{else}} +
+ {{ctx.Locale.Tr "org.teams.no_teams"}}
{{end}}
+ + {{template "base/paginate" .}}