Skip to content

Commit 8c0b45b

Browse files
committed
add
1 parent 145b583 commit 8c0b45b

File tree

7 files changed

+34
-1
lines changed

7 files changed

+34
-1
lines changed

custom/conf/app.example.ini

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,9 @@ LEVEL = Info
13351335
;; Number of repos that are displayed on one page
13361336
;REPO_PAGING_NUM = 15
13371337

1338+
;; Number of orgs that are displayed on profile page
1339+
;ORG_PAGING_NUM = 15
1340+
13381341
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13391342
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
13401343
;[ui.meta]

modules/setting/ui.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ var UI = struct {
6363
} `ini:"ui.admin"`
6464
User struct {
6565
RepoPagingNum int
66+
OrgPagingNum int
6667
} `ini:"ui.user"`
6768
Meta struct {
6869
Author string
@@ -127,8 +128,10 @@ var UI = struct {
127128
},
128129
User: struct {
129130
RepoPagingNum int
131+
OrgPagingNum int
130132
}{
131133
RepoPagingNum: 15,
134+
OrgPagingNum: 15,
132135
},
133136
Meta: struct {
134137
Author string

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -649,6 +649,7 @@ joined_on = Joined on %s
649649
repositories = Repositories
650650
activity = Public Activity
651651
followers = Followers
652+
show_more = Show More
652653
starred = Starred Repositories
653654
watched = Watched Repositories
654655
code = Code

routers/web/shared/user/header.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,20 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) {
5858
}
5959

6060
showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID)
61-
orgs, err := db.Find[organization.Organization](ctx, organization.FindOrgOptions{
61+
orgs, count, err := db.FindAndCount[organization.Organization](ctx, organization.FindOrgOptions{
6262
UserID: ctx.ContextUser.ID,
6363
IncludePrivate: showPrivate,
64+
ListOptions: db.ListOptions{
65+
Page: 1,
66+
PageSize: setting.UI.User.OrgPagingNum,
67+
},
6468
})
6569
if err != nil {
6670
ctx.ServerError("FindOrgs", err)
6771
return
6872
}
6973
ctx.Data["Orgs"] = orgs
74+
ctx.Data["ShowMoreOrgs"] = int(count) > setting.UI.User.OrgPagingNum
7075
ctx.Data["HasOrgsVisible"] = organization.HasOrgsVisible(ctx, orgs, ctx.Doer)
7176

7277
badges, _, err := user_model.GetUserBadges(ctx, ctx.ContextUser)

routers/web/user/profile.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212

1313
activities_model "code.gitea.io/gitea/models/activities"
1414
"code.gitea.io/gitea/models/db"
15+
"code.gitea.io/gitea/models/organization"
1516
"code.gitea.io/gitea/models/renderhelper"
1617
repo_model "code.gitea.io/gitea/models/repo"
1718
user_model "code.gitea.io/gitea/models/user"
@@ -256,6 +257,21 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDb
256257
ctx.Data["ProfileReadme"] = profileContent
257258
}
258259
}
260+
case "organizations":
261+
orgs, count, err := db.FindAndCount[organization.Organization](ctx, organization.FindOrgOptions{
262+
UserID: ctx.ContextUser.ID,
263+
IncludePrivate: showPrivate,
264+
ListOptions: db.ListOptions{
265+
Page: page,
266+
PageSize: pagingNum,
267+
},
268+
})
269+
if err != nil {
270+
ctx.ServerError("GetUserOrganizations", err)
271+
return
272+
}
273+
ctx.Data["Cards"] = orgs
274+
total = int(count)
259275
default: // default to "repositories"
260276
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
261277
ListOptions: db.ListOptions{

templates/shared/user/profile_big_avatar.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@
9292
</li>
9393
{{end}}
9494
{{end}}
95+
{{if .ShowMoreOrgs}}
96+
<li><a style href="{{.ContextUser.HomeLink}}?tab=organizations" data-tooltip-content="{{ctx.Locale.Tr "user.show_more"}}">{{svg "octicon-kebab-horizontal" 28 "dropdown icon"}}</a></li>
97+
{{end}}
9598
</ul>
9699
</li>
97100
{{end}}

templates/user/profile.tmpl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
{{template "repo/user_cards" .}}
2828
{{else if eq .TabName "overview"}}
2929
<div id="readme_profile" class="markup">{{.ProfileReadme}}</div>
30+
{{else if eq .TabName "organizations"}}
31+
{{template "repo/user_cards" .}}
3032
{{else}}
3133
{{template "shared/repo_search" .}}
3234
{{template "explore/repo_list" .}}

0 commit comments

Comments
 (0)