File tree Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Expand file tree Collapse file tree 3 files changed +23
-0
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ package user
66import (
77 "code.gitea.io/gitea/models/db"
88 "code.gitea.io/gitea/models/organization"
9+ project_model "code.gitea.io/gitea/models/project"
910 repo_model "code.gitea.io/gitea/models/repo"
1011 user_model "code.gitea.io/gitea/models/user"
1112 "code.gitea.io/gitea/modules/context"
@@ -125,5 +126,21 @@ func LoadHeaderCount(ctx *context.Context) error {
125126 }
126127 ctx .Data ["RepoCount" ] = repoCount
127128
129+ var projectType project_model.Type
130+ if ctx .ContextUser .IsOrganization () {
131+ projectType = project_model .TypeOrganization
132+ } else {
133+ projectType = project_model .TypeIndividual
134+ }
135+ projectCount , err := project_model .CountProjects (ctx , project_model.SearchOptions {
136+ OwnerID : ctx .ContextUser .ID ,
137+ IsClosed : util .OptionalBoolOf (false ),
138+ Type : projectType ,
139+ })
140+ if err != nil {
141+ return err
142+ }
143+ ctx .Data ["ProjectCount" ] = projectCount
144+
128145 return nil
129146}
Original file line number Diff line number Diff line change 99 {{if .CanReadProjects}}
1010 <a class="{{if .PageIsViewProjects}}active {{end}}item" href="{{$.Org.HomeLink}}/-/projects">
1111 {{svg "octicon-project-symlink"}} {{ctx.Locale.Tr "user.projects"}}
12+ {{if .ProjectCount}}
13+ <div class="ui small label">{{.ProjectCount}}</div>
14+ {{end}}
1215 </a>
1316 {{end}}
1417 {{if and .IsPackageEnabled .CanReadPackages}}
Original file line number Diff line number Diff line change 1313 {{if or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadProjects)}}
1414 <a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if .PageIsViewProjects}}active {{end}}item">
1515 {{svg "octicon-project-symlink"}} {{ctx.Locale.Tr "user.projects"}}
16+ {{if .ProjectCount}}
17+ <div class="ui small label">{{.ProjectCount}}</div>
18+ {{end}}
1619 </a>
1720 {{end}}
1821 {{if and .IsPackageEnabled (or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadPackages))}}
You can’t perform that action at this time.
0 commit comments