Add missing Tabs on organisation/package view (Frontport #20539) (#20540)

hotfix #20106
This commit is contained in:
6543 2022-07-31 14:32:51 +02:00 committed by GitHub
parent ff9b6fa663
commit 0b12abcfb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 57 additions and 7 deletions

View file

@ -8,6 +8,7 @@ import (
"net/http" "net/http"
"code.gitea.io/gitea/models/db" "code.gitea.io/gitea/models/db"
org_model "code.gitea.io/gitea/models/organization"
packages_model "code.gitea.io/gitea/models/packages" packages_model "code.gitea.io/gitea/models/packages"
container_model "code.gitea.io/gitea/models/packages/container" container_model "code.gitea.io/gitea/models/packages/container"
"code.gitea.io/gitea/models/perm" "code.gitea.io/gitea/models/perm"
@ -93,6 +94,21 @@ func ListPackages(ctx *context.Context) {
ctx.Data["Total"] = total ctx.Data["Total"] = total
ctx.Data["RepositoryAccessMap"] = repositoryAccessMap ctx.Data["RepositoryAccessMap"] = repositoryAccessMap
// TODO: context/org -> HandleOrgAssignment() can not be used
if ctx.ContextUser.IsOrganization() {
org := org_model.OrgFromUser(ctx.ContextUser)
ctx.Data["Org"] = org
ctx.Data["OrgLink"] = ctx.ContextUser.OrganisationLink()
if ctx.Doer != nil {
ctx.Data["IsOrganizationMember"], _ = org_model.IsOrganizationMember(ctx, org.ID, ctx.Doer.ID)
ctx.Data["IsOrganizationOwner"], _ = org_model.IsOrganizationOwner(ctx, org.ID, ctx.Doer.ID)
} else {
ctx.Data["IsOrganizationMember"] = false
ctx.Data["IsOrganizationOwner"] = false
}
}
pager := context.NewPagination(int(total), setting.UI.PackagesPagingNum, page, 5) pager := context.NewPagination(int(total), setting.UI.PackagesPagingNum, page, 5)
pager.AddParam(ctx, "q", "Query") pager.AddParam(ctx, "q", "Query")
pager.AddParam(ctx, "type", "PackageType") pager.AddParam(ctx, "type", "PackageType")

View file

@ -1,14 +1,22 @@
<div class="header-wrapper"> <div class="header-wrapper">
<div class="ui container"> <!-- TODO: make template org and user can share -->
<div class="repo-header"> {{with .ContextUser}}
<div class="repo-title-wrap df fc"> <div class="ui container">
<div class="repo-title"> <div class="ui vertically grid head">
{{avatar .ContextUser 32}} <div class="column">
<a href="{{.ContextUser.HTMLURL}}">{{.ContextUser.Name}}</a> <div class="ui header">
{{avatar . 100}}
<span class="text thin grey"><a href="{{.HomeLink}}">{{.DisplayName}}</a></span>
<span class="org-visibility">
{{if .Visibility.IsLimited}}<div class="ui medium orange horizontal label">{{$.locale.Tr "org.settings.visibility.limited_shortname"}}</div>{{end}}
{{if .Visibility.IsPrivate}}<div class="ui medium red horizontal label">{{$.locale.Tr "org.settings.visibility.private_shortname"}}</div>{{end}}
</span>
</div>
</div> </div>
</div> </div>
</div> </div>
</div> {{end}}
<div class="ui tabs container"> <div class="ui tabs container">
<div class="ui tabular stackable menu navbar"> <div class="ui tabular stackable menu navbar">
<a class="item" href="{{.ContextUser.HomeLink}}"> <a class="item" href="{{.ContextUser.HomeLink}}">
@ -19,6 +27,32 @@
{{svg "octicon-package"}} {{.locale.Tr "packages.title"}} {{svg "octicon-package"}} {{.locale.Tr "packages.title"}}
</a> </a>
{{end}} {{end}}
{{if .ContextUser.IsOrganization}}
{{if .IsOrganizationMember}}
<a class="item" href="{{$.OrgLink}}/members">
{{svg "octicon-organization"}}&nbsp;{{$.locale.Tr "org.people"}}
{{if .NumMembers}}
<div class="ui primary label">{{.NumMembers}}</div>
{{end}}
</a>
<a class="item" href="{{$.OrgLink}}/teams">
{{svg "octicon-people"}}&nbsp;{{$.locale.Tr "org.teams"}}
{{if .NumTeams}}
<div class="ui black label">{{.NumTeams}}</div>
{{end}}
</a>
{{end}}
{{if .IsOrganizationOwner}}
<div class="right menu">
<a class="item" href="{{.OrgLink}}/settings">
{{svg "octicon-tools"}} {{.locale.Tr "repo.settings"}}
</a>
</div>
{{end}}
{{end}}
</div> </div>
</div> </div>
<div class="ui tabs divider"></div> <div class="ui tabs divider"></div>