aboutsummaryrefslogtreecommitdiffstats
path: root/routers/web/shared
diff options
context:
space:
mode:
authoryp05327 <576951401@qq.com>2024-12-27 03:49:50 +0900
committerGitHub <noreply@github.com>2024-12-27 02:49:50 +0800
commit7bb7ba1b5b70eb9ad984eaeeabecc1dcc2a26eb9 (patch)
treede08464d806d2a968d69a9b7eb8feaa1083e18c1 /routers/web/shared
parent550abdbc2443209d6b2f4801c6e3c180b48d73bb (diff)
downloadgitea-7bb7ba1b5b70eb9ad984eaeeabecc1dcc2a26eb9.tar.gz
gitea-7bb7ba1b5b70eb9ad984eaeeabecc1dcc2a26eb9.zip
Add `show more` organizations icon in user's profile (#32986)
Close #32952 # ⚠️ Doc update is required ![image](https://github.com/user-attachments/assets/296c5109-8fc1-43ea-b7dc-e79919cc1f9a) ![image](https://github.com/user-attachments/assets/d30980f6-22e4-4b97-9143-c750dc399da6) ------ ⚠️This PR refuses to be cherry-picked by any forked projects without any mentions. --------- Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers/web/shared')
-rw-r--r--routers/web/shared/user/header.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/routers/web/shared/user/header.go b/routers/web/shared/user/header.go
index 4cb0592b4b..d388d2b5d9 100644
--- a/routers/web/shared/user/header.go
+++ b/routers/web/shared/user/header.go
@@ -61,11 +61,20 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) {
orgs, err := db.Find[organization.Organization](ctx, organization.FindOrgOptions{
UserID: ctx.ContextUser.ID,
IncludePrivate: showPrivate,
+ ListOptions: db.ListOptions{
+ Page: 1,
+ // query one more results (without a separate counting) to see whether we need to add the "show more orgs" link
+ PageSize: setting.UI.User.OrgPagingNum + 1,
+ },
})
if err != nil {
ctx.ServerError("FindOrgs", err)
return
}
+ if len(orgs) > setting.UI.User.OrgPagingNum {
+ orgs = orgs[:setting.UI.User.OrgPagingNum]
+ ctx.Data["ShowMoreOrgs"] = true
+ }
ctx.Data["Orgs"] = orgs
ctx.Data["HasOrgsVisible"] = organization.HasOrgsVisible(ctx, orgs, ctx.Doer)