Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix missing items in organization menu #33928

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all 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
7 changes: 7 additions & 0 deletions routers/web/org/projects.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ func Projects(ctx *context.Context) {

pager := context.NewPagination(int(total), setting.UI.IssuePagingNum, page, numPages)
pager.AddParamFromRequest(ctx.Req)

_, err = shared_user.PrepareOrgHeader(ctx)
if err != nil {
ctx.ServerError("PrepareOrgHeader", err)
return
}

ctx.Data["Page"] = pager

ctx.Data["CanWriteProjects"] = canWriteProjects(ctx)
Expand Down
8 changes: 8 additions & 0 deletions routers/web/org/worktime.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"code.gitea.io/gitea/models/organization"
"code.gitea.io/gitea/modules/templates"
shared_user "code.gitea.io/gitea/routers/web/shared/user"
"code.gitea.io/gitea/services/context"
)

Expand Down Expand Up @@ -69,6 +70,13 @@ func Worktime(ctx *context.Context) {
ctx.ServerError("GetWorktime", err)
return
}

_, err = shared_user.PrepareOrgHeader(ctx)
if err != nil {
ctx.ServerError("PrepareOrgHeader", err)
return
}

ctx.Data["WorktimeSumResult"] = worktimeSumResult
ctx.HTML(http.StatusOK, tplByRepos)
}
7 changes: 7 additions & 0 deletions routers/web/user/code.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ func CodeSearch(ctx *context.Context) {
ctx.ServerError("LoadHeaderCount", err)
return
}
if ctx.ContextUser.IsOrganization() {
_, err := shared_user.PrepareOrgHeader(ctx)
if err != nil {
ctx.ServerError("PrepareOrgHeader", err)
return
}
}
Copy link
Contributor

@wxiaoguang wxiaoguang Mar 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now the logic seems strange:

image

Ideally, maybe there should be a shared_user.PrepareOwnerHeader, and in it prepare for user or for org by user type?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wxiaoguang I will attempt to refactor this section and extract more common code.


ctx.Data["IsPackageEnabled"] = setting.Packages.Enabled
ctx.Data["Title"] = ctx.Tr("explore.code")
Expand Down
13 changes: 12 additions & 1 deletion routers/web/user/package.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ func ListPackages(ctx *context.Context) {
ctx.Data["IsOrganizationMember"] = false
ctx.Data["IsOrganizationOwner"] = false
}
_, err := shared_user.PrepareOrgHeader(ctx)
if err != nil {
ctx.ServerError("PrepareOrgHeader", err)
return
}
}

pager := context.NewPagination(int(total), setting.UI.PackagesPagingNum, page, 5)
Expand Down Expand Up @@ -428,7 +433,13 @@ func PackageSettings(ctx *context.Context) {
ctx.ServerError("LoadHeaderCount", err)
return
}

if ctx.ContextUser.IsOrganization() {
_, err = shared_user.PrepareOrgHeader(ctx)
if err != nil {
ctx.ServerError("PrepareOrgHeader", err)
return
}
}
ctx.HTML(http.StatusOK, tplPackagesSettings)
}

Expand Down