Add missing badges in user profile for /projects and /packages (#24232)

- Implement fix for user and organization page
- Add necessary ctx.Data

When switching tabs on `user profile page` the badges are shown for
`/gitea_user?tab=stars`, `/gitea_user?tab=activity` and missing under
`gitea_user/-/projects` and `gitea_user/-/packages`

This was added for users and organizations.

Before:

![image](https://user-images.githubusercontent.com/72307968/233338877-f795fae3-b65a-4ea1-8784-dd2b0cd6618f.png)
After:

![image](https://user-images.githubusercontent.com/72307968/233339012-90adb6c4-4de2-432e-ae49-69611eb7aec3.png)

Co-authored-by: silverwind <me@silverwind.io>
Co-authored-by: Giteabot <teabot@gitea.io>
This commit is contained in:
Jakob 2023-04-23 03:32:40 +02:00 committed by GitHub
parent 30ea09c277
commit 136d7492ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 3 deletions

View File

@ -62,6 +62,7 @@ func Members(ctx *context.Context) {
} }
ctx.Data["Page"] = pager ctx.Data["Page"] = pager
ctx.Data["Members"] = members ctx.Data["Members"] = members
ctx.Data["ContextUser"] = ctx.ContextUser
ctx.Data["MembersIsPublicMember"] = membersIsPublic ctx.Data["MembersIsPublicMember"] = membersIsPublic
ctx.Data["MembersIsUserOrgOwner"] = organization.IsUserOrgOwner(members, org.ID) ctx.Data["MembersIsUserOrgOwner"] = organization.IsUserOrgOwner(members, org.ID)
ctx.Data["MembersTwoFaStatus"] = members.GetTwoFaStatus() ctx.Data["MembersTwoFaStatus"] = members.GetTwoFaStatus()

View File

@ -56,6 +56,7 @@ func Teams(ctx *context.Context) {
} }
} }
ctx.Data["Teams"] = ctx.Org.Teams ctx.Data["Teams"] = ctx.Org.Teams
ctx.Data["ContextUser"] = ctx.ContextUser
ctx.HTML(http.StatusOK, tplTeams) ctx.HTML(http.StatusOK, tplTeams)
} }

View File

@ -20,6 +20,9 @@
<div class="ui secondary stackable pointing menu"> <div class="ui secondary stackable pointing menu">
<a class="item" href="{{.ContextUser.HomeLink}}"> <a class="item" href="{{.ContextUser.HomeLink}}">
{{svg "octicon-repo"}} {{.locale.Tr "user.repositories"}} {{svg "octicon-repo"}} {{.locale.Tr "user.repositories"}}
{{if .ContextUser.NumRepos}}
<div class="ui small label">{{.ContextUser.NumRepos}}</div>
{{end}}
</a> </a>
{{if and .IsProjectEnabled (or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadProjects))}} {{if and .IsProjectEnabled (or .ContextUser.IsIndividual (and .ContextUser.IsOrganization .CanReadProjects))}}
<a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if .PageIsViewProjects}}active {{end}}item"> <a href="{{.ContextUser.HomeLink}}/-/projects" class="{{if .PageIsViewProjects}}active {{end}}item">
@ -42,13 +45,13 @@
<a class="item" href="{{$.OrgLink}}/members"> <a class="item" href="{{$.OrgLink}}/members">
{{svg "octicon-person"}}&nbsp;{{$.locale.Tr "org.members"}} {{svg "octicon-person"}}&nbsp;{{$.locale.Tr "org.members"}}
{{if .NumMembers}} {{if .NumMembers}}
<div class="ui primary label">{{.NumMembers}}</div> <div class="ui small label">{{.NumMembers}}</div>
{{end}} {{end}}
</a> </a>
<a class="item" href="{{$.OrgLink}}/teams"> <a class="item" href="{{$.OrgLink}}/teams">
{{svg "octicon-people"}}&nbsp;{{$.locale.Tr "org.teams"}} {{svg "octicon-people"}}&nbsp;{{$.locale.Tr "org.teams"}}
{{if .NumTeams}} {{if .NumTeams}}
<div class="ui primary label">{{.NumTeams}}</div> <div class="ui small label">{{.NumTeams}}</div>
{{end}} {{end}}
</a> </a>
{{end}} {{end}}
@ -68,7 +71,7 @@
<a class='{{if eq .TabName "stars"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=stars"> <a class='{{if eq .TabName "stars"}}active {{end}}item' href="{{.ContextUser.HomeLink}}?tab=stars">
{{svg "octicon-star"}} {{.locale.Tr "user.starred"}} {{svg "octicon-star"}} {{.locale.Tr "user.starred"}}
{{if .ContextUser.NumStars}} {{if .ContextUser.NumStars}}
<div class="ui primary label">{{.ContextUser.NumStars}}</div> <div class="ui small label">{{.ContextUser.NumStars}}</div>
{{end}} {{end}}
</a> </a>
{{else}} {{else}}