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 7
7
"code.gitea.io/gitea/models/db"
8
8
"code.gitea.io/gitea/models/organization"
9
9
access_model "code.gitea.io/gitea/models/perm/access"
10
+ project_model "code.gitea.io/gitea/models/project"
10
11
repo_model "code.gitea.io/gitea/models/repo"
11
12
"code.gitea.io/gitea/models/unit"
12
13
user_model "code.gitea.io/gitea/models/user"
@@ -134,5 +135,21 @@ func LoadHeaderCount(ctx *context.Context) error {
134
135
}
135
136
ctx .Data ["RepoCount" ] = repoCount
136
137
138
+ var projectType project_model.Type
139
+ if ctx .ContextUser .IsOrganization () {
140
+ projectType = project_model .TypeOrganization
141
+ } else {
142
+ projectType = project_model .TypeIndividual
143
+ }
144
+ projectCount , err := project_model .CountProjects (ctx , project_model.SearchOptions {
145
+ OwnerID : ctx .ContextUser .ID ,
146
+ IsClosed : util .OptionalBoolOf (false ),
147
+ Type : projectType ,
148
+ })
149
+ if err != nil {
150
+ return err
151
+ }
152
+ ctx .Data ["ProjectCount" ] = projectCount
153
+
137
154
return nil
138
155
}
Original file line number Diff line number Diff line change 9
9
{{if .CanReadProjects}}
10
10
<a class="{{if .PageIsViewProjects}}active {{end}}item" href="{{$.Org.HomeLink}}/-/projects">
11
11
{{svg "octicon-project-symlink"}} {{ctx.Locale.Tr "user.projects"}}
12
+ {{if .ProjectCount}}
13
+ <div class="ui small label">{{.ProjectCount}}</div>
14
+ {{end}}
12
15
</a>
13
16
{{end}}
14
17
{{if and .IsPackageEnabled .CanReadPackages}}
Original file line number Diff line number Diff line change 13
13
{{if or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadProjects)}}
14
14
<a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if .PageIsViewProjects}}active {{end}}item">
15
15
{{svg "octicon-project-symlink"}} {{ctx.Locale.Tr "user.projects"}}
16
+ {{if .ProjectCount}}
17
+ <div class="ui small label">{{.ProjectCount}}</div>
18
+ {{end}}
16
19
</a>
17
20
{{end}}
18
21
{{if and .IsPackageEnabled (or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadPackages))}}
You can’t perform that action at this time.
0 commit comments