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

Split org Propfile README to a new tab overview #31373

Merged
merged 27 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d3f415d
split Propfile README to a new tab `overview`
a1012112796 Jun 14, 2024
123a027
Merge remote-tracking branch 'origin/main' into zzc/dev/org_profile_2
a1012112796 Jun 17, 2024
990584f
show repos in overview also
a1012112796 Jun 17, 2024
4ac2564
use new subRoute
a1012112796 Jun 18, 2024
01e8af4
Merge remote-tracking branch 'origin/main' into zzc/dev/org_profile_2
a1012112796 Jun 18, 2024
8f30308
Merge branch 'main' into zzc/dev/org_profile_2
a1012112796 Jul 19, 2024
3ac733c
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 18, 2024
0b29590
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 19, 2024
cd585ae
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 19, 2024
f08e792
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 19, 2024
fb72673
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 19, 2024
af30f38
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 19, 2024
23df60c
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 20, 2024
88754c9
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 20, 2024
4ceeafc
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 21, 2024
a57dddd
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 21, 2024
28d2c48
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 21, 2024
2107808
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 21, 2024
c9e818b
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 22, 2024
f9f7fc4
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 23, 2024
19b0fb2
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 24, 2024
5d79af5
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 25, 2024
0846a35
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 25, 2024
ebc1fc0
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 25, 2024
e32256b
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 26, 2024
e8df8f4
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 26, 2024
52c5052
Merge branch 'main' into zzc/dev/org_profile_2
GiteaBot Aug 27, 2024
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
75 changes: 43 additions & 32 deletions routers/web/org/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import (
"code.gitea.io/gitea/models/organization"
repo_model "code.gitea.io/gitea/models/repo"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/git"
"code.gitea.io/gitea/modules/log"
"code.gitea.io/gitea/modules/markup"
"code.gitea.io/gitea/modules/markup/markdown"
Expand Down Expand Up @@ -42,6 +41,14 @@ func Home(ctx *context.Context) {
return
}

home(ctx, false)
}

func Repositories(ctx *context.Context) {
home(ctx, true)
}

func home(ctx *context.Context, viewRepositories bool) {
org := ctx.Org.Organization

ctx.Data["PageIsUserProfile"] = true
Expand Down Expand Up @@ -101,10 +108,34 @@ func Home(ctx *context.Context) {
private := ctx.FormOptionalBool("private")
ctx.Data["IsPrivate"] = private

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

opts := &organization.FindOrgMembersOpts{
OrgID: org.ID,
PublicOnly: ctx.Org.PublicMemberOnly,
ListOptions: db.ListOptions{Page: 1, PageSize: 25},
}
members, _, err := organization.FindOrgMembers(ctx, opts)
if err != nil {
ctx.ServerError("FindOrgMembers", err)
return
}
ctx.Data["Members"] = members
ctx.Data["Teams"] = ctx.Org.Teams
ctx.Data["DisableNewPullMirrors"] = setting.Mirror.DisableNewPull
ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0

if !prepareOrgProfileReadme(ctx, viewRepositories) {
ctx.Data["PageIsViewRepositories"] = true
}

var (
repos []*repo_model.Repository
count int64
err error
)
repos, count, err = repo_model.SearchRepository(ctx, &repo_model.SearchRepoOptions{
ListOptions: db.ListOptions{
Expand All @@ -129,29 +160,8 @@ func Home(ctx *context.Context) {
return
}

opts := &organization.FindOrgMembersOpts{
OrgID: org.ID,
PublicOnly: ctx.Org.PublicMemberOnly,
ListOptions: db.ListOptions{Page: 1, PageSize: 25},
}
members, _, err := organization.FindOrgMembers(ctx, opts)
if err != nil {
ctx.ServerError("FindOrgMembers", err)
return
}

ctx.Data["Repos"] = repos
ctx.Data["Total"] = count
ctx.Data["Members"] = members
ctx.Data["Teams"] = ctx.Org.Teams
ctx.Data["DisableNewPullMirrors"] = setting.Mirror.DisableNewPull
ctx.Data["PageIsViewRepositories"] = true

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

pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5)
pager.SetDefaultParams(ctx)
Expand All @@ -173,18 +183,16 @@ func Home(ctx *context.Context) {
}
ctx.Data["Page"] = pager

ctx.Data["ShowMemberAndTeamTab"] = ctx.Org.IsMember || len(members) > 0

profileDbRepo, profileGitRepo, profileReadmeBlob, profileClose := shared_user.FindUserProfileReadme(ctx, ctx.Doer)
defer profileClose()
prepareOrgProfileReadme(ctx, profileGitRepo, profileDbRepo, profileReadmeBlob)

ctx.HTML(http.StatusOK, tplOrgHome)
}

func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repository, profileDbRepo *repo_model.Repository, profileReadme *git.Blob) {
if profileGitRepo == nil || profileReadme == nil {
return
func prepareOrgProfileReadme(ctx *context.Context, viewRepositories bool) bool {
profileDbRepo, profileGitRepo, profileReadme, profileClose := shared_user.FindUserProfileReadme(ctx, ctx.Doer)
defer profileClose()
ctx.Data["HasProfileReadme"] = profileReadme != nil

if profileGitRepo == nil || profileReadme == nil || viewRepositories {
return false
}

if bytes, err := profileReadme.GetBlobContent(setting.UI.MaxDisplayFileSize); err != nil {
Expand All @@ -206,4 +214,7 @@ func prepareOrgProfileReadme(ctx *context.Context, profileGitRepo *git.Repositor
ctx.Data["ProfileReadme"] = profileContent
}
}

ctx.Data["PageIsViewOverview"] = true
return true
}
4 changes: 2 additions & 2 deletions routers/web/org/members.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ func Members(ctx *context.Context) {
return
}

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

Expand Down
4 changes: 2 additions & 2 deletions routers/web/org/teams.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ func Teams(ctx *context.Context) {
}
ctx.Data["Teams"] = ctx.Org.Teams

err := shared_user.LoadHeaderCount(ctx)
err := shared_user.RenderOrgHeader(ctx)
if err != nil {
ctx.ServerError("LoadHeaderCount", err)
ctx.ServerError("RenderOrgHeader", err)
return
}

Expand Down
12 changes: 12 additions & 0 deletions routers/web/shared/user/header.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,3 +162,15 @@ func LoadHeaderCount(ctx *context.Context) error {

return nil
}

func RenderOrgHeader(ctx *context.Context) error {
if err := LoadHeaderCount(ctx); err != nil {
return err
}

_, _, profileReadmeBlob, profileClose := FindUserProfileReadme(ctx, ctx.Doer)
defer profileClose()
ctx.Data["HasProfileReadme"] = profileReadmeBlob != nil

return nil
}
2 changes: 2 additions & 0 deletions routers/web/web.go
Original file line number Diff line number Diff line change
Expand Up @@ -995,6 +995,8 @@ func registerRoutes(m *web.Router) {
}, context.PackageAssignment(), reqPackageAccess(perm.AccessModeRead))
}

m.Get("/repositories", org.Repositories)

m.Group("/projects", func() {
m.Group("", func() {
m.Get("", org.Projects)
Expand Down
7 changes: 6 additions & 1 deletion templates/org/menu.tmpl
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<div class="ui container">
<overflow-menu class="ui secondary pointing tabular borderless menu tw-mb-4">
<div class="overflow-menu-items">
<a class="{{if .PageIsViewRepositories}}active {{end}}item" href="{{$.Org.HomeLink}}">
{{if .HasProfileReadme}}
<a class="{{if .PageIsViewOverview}}active {{end}}item" href="{{$.Org.HomeLink}}">
{{svg "octicon-info"}} {{ctx.Locale.Tr "user.overview"}}
</a>
{{end}}
<a class="{{if .PageIsViewRepositories}}active {{end}}item" href="{{$.Org.HomeLink}}{{if .HasProfileReadme}}/-/repositories{{end}}">
{{svg "octicon-repo"}} {{ctx.Locale.Tr "user.repositories"}}
{{if .RepoCount}}
<div class="ui small label">{{.RepoCount}}</div>
Expand Down