Skip to content

Commit

Permalink
Show hint to link package to repo when viewing empty repo package list (
Browse files Browse the repository at this point in the history
  • Loading branch information
noerw authored Jul 27, 2022
1 parent e0f35ea commit 0a32bd5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,7 @@ title = Packages
desc = Manage repository packages.
empty = There are no packages yet.
empty.documentation = For more information on the package registry, see <a target="_blank" rel="noopener noreferrer" href="https://docs.gitea.io/en-us/packages/overview">the documentation</a>.
empty.repo = Did you upload a package, but it's not shown here? Go to <a href="%[1]s">package settings</a> and link it to this repo.
filter.type = Type
filter.type.all = All
filter.no_result = Your filter produced no results.
Expand Down
4 changes: 4 additions & 0 deletions routers/web/repo/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"code.gitea.io/gitea/models/db"
"code.gitea.io/gitea/models/packages"
"code.gitea.io/gitea/models/unit"
"code.gitea.io/gitea/modules/base"
"code.gitea.io/gitea/modules/context"
"code.gitea.io/gitea/modules/setting"
Expand Down Expand Up @@ -60,6 +61,9 @@ func Packages(ctx *context.Context) {
ctx.Data["Query"] = query
ctx.Data["PackageType"] = packageType
ctx.Data["HasPackages"] = hasPackages
if ctx.Repo != nil {
ctx.Data["CanWritePackages"] = ctx.IsUserRepoWriter([]unit.Type{unit.TypePackages}) || ctx.IsUserSiteAdmin()
}
ctx.Data["PackageDescriptors"] = pds
ctx.Data["Total"] = total
ctx.Data["RepositoryAccessMap"] = map[int64]bool{ctx.Repo.Repository.ID: true} // There is only the current repository
Expand Down
4 changes: 4 additions & 0 deletions templates/package/shared/list.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<div class="empty center">
{{svg "octicon-package" 32}}
<h2>{{.i18n.Tr "packages.empty"}}</h2>
{{if and .Repository .CanWritePackages}}
{{$packagesUrl := URLJoin .Owner.HTMLURL "-" "packages" }}
<p>{{.i18n.Tr "packages.empty.repo" $packagesUrl | Safe}}</p>
{{end}}
<p>{{.i18n.Tr "packages.empty.documentation" | Safe}}</p>
</div>
{{else}}
Expand Down

0 comments on commit 0a32bd5

Please sign in to comment.