From 7bb7ba1b5b70eb9ad984eaeeabecc1dcc2a26eb9 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Fri, 27 Dec 2024 03:49:50 +0900 Subject: Add `show more` organizations icon in user's profile (#32986) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- routers/web/shared/user/header.go | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'routers/web/shared') 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) -- cgit v1.2.3