aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2022-12-29 00:31:54 +0100
committerGitHub <noreply@github.com>2022-12-29 00:31:54 +0100
commit309e86a9bf305e807ead2854fa757c4d704dcfce (patch)
tree4239e0a07647f732e7810e443a9dfafa6743824f
parentca67c5a8a72f3d26bb0808ba7a63cd4875cd5229 (diff)
downloadgitea-309e86a9bf305e807ead2854fa757c4d704dcfce.tar.gz
gitea-309e86a9bf305e807ead2854fa757c4d704dcfce.zip
Use dynamic package type list (#22263)
Replace the hardcoded list with the dynamic list.
-rw-r--r--routers/web/admin/packages.go1
-rw-r--r--routers/web/repo/packages.go1
-rw-r--r--routers/web/user/package.go1
-rw-r--r--templates/admin/packages/list.tmpl15
-rw-r--r--templates/package/shared/list.tmpl15
5 files changed, 9 insertions, 24 deletions
diff --git a/routers/web/admin/packages.go b/routers/web/admin/packages.go
index 80cec51275..7c6d1ed840 100644
--- a/routers/web/admin/packages.go
+++ b/routers/web/admin/packages.go
@@ -62,6 +62,7 @@ func Packages(ctx *context.Context) {
ctx.Data["PageIsAdminPackages"] = true
ctx.Data["Query"] = query
ctx.Data["PackageType"] = packageType
+ ctx.Data["AvailableTypes"] = packages_model.TypeList
ctx.Data["SortType"] = sort
ctx.Data["PackageDescriptors"] = pds
ctx.Data["Total"] = total
diff --git a/routers/web/repo/packages.go b/routers/web/repo/packages.go
index 83324711da..6ad2f71b5c 100644
--- a/routers/web/repo/packages.go
+++ b/routers/web/repo/packages.go
@@ -61,6 +61,7 @@ func Packages(ctx *context.Context) {
ctx.Data["ContextUser"] = ctx.ContextUser
ctx.Data["Query"] = query
ctx.Data["PackageType"] = packageType
+ ctx.Data["AvailableTypes"] = packages.TypeList
ctx.Data["HasPackages"] = hasPackages
if ctx.Repo != nil {
ctx.Data["CanWritePackages"] = ctx.IsUserRepoWriter([]unit.Type{unit.TypePackages}) || ctx.IsUserSiteAdmin()
diff --git a/routers/web/user/package.go b/routers/web/user/package.go
index 3782f46b42..c0aba7583f 100644
--- a/routers/web/user/package.go
+++ b/routers/web/user/package.go
@@ -89,6 +89,7 @@ func ListPackages(ctx *context.Context) {
ctx.Data["ContextUser"] = ctx.ContextUser
ctx.Data["Query"] = query
ctx.Data["PackageType"] = packageType
+ ctx.Data["AvailableTypes"] = packages_model.TypeList
ctx.Data["HasPackages"] = hasPackages
ctx.Data["PackageDescriptors"] = pds
ctx.Data["Total"] = total
diff --git a/templates/admin/packages/list.tmpl b/templates/admin/packages/list.tmpl
index 3aab2873c6..c39f5fc128 100644
--- a/templates/admin/packages/list.tmpl
+++ b/templates/admin/packages/list.tmpl
@@ -13,18 +13,9 @@
<select class="ui dropdown" name="type">
<option value="">{{.locale.Tr "packages.filter.type"}}</option>
<option value="all">{{.locale.Tr "packages.filter.type.all"}}</option>
- <option value="composer" {{if eq .PackageType "composer"}}selected="selected"{{end}}>Composer</option>
- <option value="conan" {{if eq .PackageType "conan"}}selected="selected"{{end}}>Conan</option>
- <option value="container" {{if eq .PackageType "container"}}selected="selected"{{end}}>Container</option>
- <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>
+ {{range $type := .AvailableTypes}}
+ <option{{if eq $.PackageType $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
+ {{end}}
</select>
<button class="ui primary button">{{.locale.Tr "explore.search"}}</button>
</div>
diff --git a/templates/package/shared/list.tmpl b/templates/package/shared/list.tmpl
index 37c47cef33..ec2e88c854 100644
--- a/templates/package/shared/list.tmpl
+++ b/templates/package/shared/list.tmpl
@@ -6,18 +6,9 @@
<select class="ui dropdown" name="type">
<option value="">{{.locale.Tr "packages.filter.type"}}</option>
<option value="all">{{.locale.Tr "packages.filter.type.all"}}</option>
- <option value="composer" {{if eq .PackageType "composer"}}selected="selected"{{end}}>Composer</option>
- <option value="conan" {{if eq .PackageType "conan"}}selected="selected"{{end}}>Conan</option>
- <option value="container" {{if eq .PackageType "container"}}selected="selected"{{end}}>Container</option>
- <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>
+ {{range $type := .AvailableTypes}}
+ <option{{if eq $.PackageType $type}} selected="selected"{{end}} value="{{$type}}">{{$type.Name}}</option>
+ {{end}}
</select>
<button class="ui primary button">{{.locale.Tr "explore.search"}}</button>
</div>