Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1335,6 +1335,9 @@ LEVEL = Info
;; Number of repos that are displayed on one page
;REPO_PAGING_NUM = 15

;; Number of orgs that are displayed on profile page
;ORG_PAGING_NUM = 15

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;[ui.meta]
Expand Down
3 changes: 3 additions & 0 deletions modules/setting/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ var UI = struct {
} `ini:"ui.admin"`
User struct {
RepoPagingNum int
OrgPagingNum int
} `ini:"ui.user"`
Meta struct {
Author string
Expand Down Expand Up @@ -127,8 +128,10 @@ var UI = struct {
},
User: struct {
RepoPagingNum int
OrgPagingNum int
}{
RepoPagingNum: 15,
OrgPagingNum: 15,
},
Meta: struct {
Author string
Expand Down
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,7 @@ joined_on = Joined on %s
repositories = Repositories
activity = Public Activity
followers = Followers
show_more = Show More
starred = Starred Repositories
watched = Watched Repositories
code = Code
Expand Down
7 changes: 6 additions & 1 deletion routers/web/shared/user/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,20 @@ func PrepareContextForProfileBigAvatar(ctx *context.Context) {
}

showPrivate := ctx.IsSigned && (ctx.Doer.IsAdmin || ctx.Doer.ID == ctx.ContextUser.ID)
orgs, err := db.Find[organization.Organization](ctx, organization.FindOrgOptions{
orgs, count, err := db.FindAndCount[organization.Organization](ctx, organization.FindOrgOptions{
UserID: ctx.ContextUser.ID,
IncludePrivate: showPrivate,
ListOptions: db.ListOptions{
Page: 1,
PageSize: setting.UI.User.OrgPagingNum,
},
})
if err != nil {
ctx.ServerError("FindOrgs", err)
return
}
ctx.Data["Orgs"] = orgs
ctx.Data["ShowMoreOrgs"] = int(count) > setting.UI.User.OrgPagingNum
ctx.Data["HasOrgsVisible"] = organization.HasOrgsVisible(ctx, orgs, ctx.Doer)

badges, _, err := user_model.GetUserBadges(ctx, ctx.ContextUser)
Expand Down
16 changes: 16 additions & 0 deletions routers/web/user/profile.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

activities_model "code.gitea.io/gitea/models/activities"
"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/models/renderhelper"
repo_model "code.gitea.io/gitea/models/repo"
user_model "code.gitea.io/gitea/models/user"
Expand Down Expand Up @@ -256,6 +257,21 @@ func prepareUserProfileTabData(ctx *context.Context, showPrivate bool, profileDb
ctx.Data["ProfileReadme"] = profileContent
}
}
case "organizations":
orgs, count, err := db.FindAndCount[organization.Organization](ctx, organization.FindOrgOptions{
UserID: ctx.ContextUser.ID,
IncludePrivate: showPrivate,
ListOptions: db.ListOptions{
Page: page,
PageSize: pagingNum,
},
})
if err != nil {
ctx.ServerError("GetUserOrganizations", err)
return
}
ctx.Data["Cards"] = orgs
total = int(count)
default: // default to "repositories"
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
Expand Down
3 changes: 3 additions & 0 deletions templates/shared/user/profile_big_avatar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
</li>
{{end}}
{{end}}
{{if .ShowMoreOrgs}}
<li><a class="tw-align-center" href="{{.ContextUser.HomeLink}}?tab=organizations" data-tooltip-content="{{ctx.Locale.Tr "user.show_more"}}">{{svg "octicon-kebab-horizontal" 28 "icon tw-p-1"}}</a></li>
{{end}}
</ul>
</li>
{{end}}
Expand Down
2 changes: 2 additions & 0 deletions templates/user/profile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
{{template "repo/user_cards" .}}
{{else if eq .TabName "overview"}}
<div id="readme_profile" class="markup">{{.ProfileReadme}}</div>
{{else if eq .TabName "organizations"}}
{{template "repo/user_cards" .}}
{{else}}
{{template "shared/repo_search" .}}
{{template "explore/repo_list" .}}
Expand Down
Loading