0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-22 23:33:15 -05:00

Use dynamic package type list (#22263)

Replace the hardcoded list with the dynamic list.
This commit is contained in:
KN4CK3R 2022-12-29 00:31:54 +01:00 committed by GitHub
parent ca67c5a8a7
commit 309e86a9bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 24 deletions

View file

@ -62,6 +62,7 @@ func Packages(ctx *context.Context) {
ctx.Data["PageIsAdminPackages"] = true ctx.Data["PageIsAdminPackages"] = true
ctx.Data["Query"] = query ctx.Data["Query"] = query
ctx.Data["PackageType"] = packageType ctx.Data["PackageType"] = packageType
ctx.Data["AvailableTypes"] = packages_model.TypeList
ctx.Data["SortType"] = sort ctx.Data["SortType"] = sort
ctx.Data["PackageDescriptors"] = pds ctx.Data["PackageDescriptors"] = pds
ctx.Data["Total"] = total ctx.Data["Total"] = total

View file

@ -61,6 +61,7 @@ func Packages(ctx *context.Context) {
ctx.Data["ContextUser"] = ctx.ContextUser ctx.Data["ContextUser"] = ctx.ContextUser
ctx.Data["Query"] = query ctx.Data["Query"] = query
ctx.Data["PackageType"] = packageType ctx.Data["PackageType"] = packageType
ctx.Data["AvailableTypes"] = packages.TypeList
ctx.Data["HasPackages"] = hasPackages ctx.Data["HasPackages"] = hasPackages
if ctx.Repo != nil { if ctx.Repo != nil {
ctx.Data["CanWritePackages"] = ctx.IsUserRepoWriter([]unit.Type{unit.TypePackages}) || ctx.IsUserSiteAdmin() ctx.Data["CanWritePackages"] = ctx.IsUserRepoWriter([]unit.Type{unit.TypePackages}) || ctx.IsUserSiteAdmin()

View file

@ -89,6 +89,7 @@ func ListPackages(ctx *context.Context) {
ctx.Data["ContextUser"] = ctx.ContextUser ctx.Data["ContextUser"] = ctx.ContextUser
ctx.Data["Query"] = query ctx.Data["Query"] = query
ctx.Data["PackageType"] = packageType ctx.Data["PackageType"] = packageType
ctx.Data["AvailableTypes"] = packages_model.TypeList
ctx.Data["HasPackages"] = hasPackages ctx.Data["HasPackages"] = hasPackages
ctx.Data["PackageDescriptors"] = pds ctx.Data["PackageDescriptors"] = pds
ctx.Data["Total"] = total ctx.Data["Total"] = total

View file

@ -13,18 +13,9 @@
<select class="ui dropdown" name="type"> <select class="ui dropdown" name="type">
<option value="">{{.locale.Tr "packages.filter.type"}}</option> <option value="">{{.locale.Tr "packages.filter.type"}}</option>
<option value="all">{{.locale.Tr "packages.filter.type.all"}}</option> <option value="all">{{.locale.Tr "packages.filter.type.all"}}</option>
<option value="composer" {{if eq .PackageType "composer"}}selected="selected"{{end}}>Composer</option> {{range $type := .AvailableTypes}}
<option value="conan" {{if eq .PackageType "conan"}}selected="selected"{{end}}>Conan</option> <option{{if eq $.PackageType $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
<option value="container" {{if eq .PackageType "container"}}selected="selected"{{end}}>Container</option> {{end}}
<option value="generic" {{if eq .PackageType "generic"}}selected="selected"{{end}}>Generic</option>
<option value="helm" {{if eq .PackageType "helm"}}selected="selected"{{end}}>Helm</option>
<option value="maven" {{if eq .PackageType "maven"}}selected="selected"{{end}}>Maven</option>
<option value="npm" {{if eq .PackageType "npm"}}selected="selected"{{end}}>npm</option>
<option value="nuget" {{if eq .PackageType "nuget"}}selected="selected"{{end}}>NuGet</option>
<option value="pub" {{if eq .PackageType "pub"}}selected="selected"{{end}}>Pub</option>
<option value="pypi" {{if eq .PackageType "pypi"}}selected="selected"{{end}}>PyPi</option>
<option value="rubygems" {{if eq .PackageType "rubygems"}}selected="selected"{{end}}>RubyGems</option>
<option value="vagrant" {{if eq .PackageType "vagrant"}}selected="selected"{{end}}>Vagrant</option>
</select> </select>
<button class="ui primary button">{{.locale.Tr "explore.search"}}</button> <button class="ui primary button">{{.locale.Tr "explore.search"}}</button>
</div> </div>

View file

@ -6,18 +6,9 @@
<select class="ui dropdown" name="type"> <select class="ui dropdown" name="type">
<option value="">{{.locale.Tr "packages.filter.type"}}</option> <option value="">{{.locale.Tr "packages.filter.type"}}</option>
<option value="all">{{.locale.Tr "packages.filter.type.all"}}</option> <option value="all">{{.locale.Tr "packages.filter.type.all"}}</option>
<option value="composer" {{if eq .PackageType "composer"}}selected="selected"{{end}}>Composer</option> {{range $type := .AvailableTypes}}
<option value="conan" {{if eq .PackageType "conan"}}selected="selected"{{end}}>Conan</option> <option{{if eq $.PackageType $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
<option value="container" {{if eq .PackageType "container"}}selected="selected"{{end}}>Container</option> {{end}}
<option value="generic" {{if eq .PackageType "generic"}}selected="selected"{{end}}>Generic</option>
<option value="helm" {{if eq .PackageType "helm"}}selected="selected"{{end}}>Helm</option>
<option value="maven" {{if eq .PackageType "maven"}}selected="selected"{{end}}>Maven</option>
<option value="npm" {{if eq .PackageType "npm"}}selected="selected"{{end}}>npm</option>
<option value="nuget" {{if eq .PackageType "nuget"}}selected="selected"{{end}}>NuGet</option>
<option value="pub" {{if eq .PackageType "pub"}}selected="selected"{{end}}>Pub</option>
<option value="pypi" {{if eq .PackageType "pypi"}}selected="selected"{{end}}>PyPi</option>
<option value="rubygems" {{if eq .PackageType "rubygems"}}selected="selected"{{end}}>RubyGems</option>
<option value="vagrant" {{if eq .PackageType "vagrant"}}selected="selected"{{end}}>Vagrant</option>
</select> </select>
<button class="ui primary button">{{.locale.Tr "explore.search"}}</button> <button class="ui primary button">{{.locale.Tr "explore.search"}}</button>
</div> </div>