aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKN4CK3R <admin@oldschoolhack.me>2023-06-29 19:01:14 +0200
committerGitHub <noreply@github.com>2023-06-29 17:01:14 +0000
commitcf2356062fd13c51c9ccc86df96e0ac6cd764f28 (patch)
treef260bca8c1e4a25ac254134fa2b0674dad7abd18
parente882398c5acb99db555553acc2da89db73713710 (diff)
downloadgitea-cf2356062fd13c51c9ccc86df96e0ac6cd764f28.tar.gz
gitea-cf2356062fd13c51c9ccc86df96e0ac6cd764f28.zip
Redirect to package after version deletion (#25594)
Related #25559 Current behaviour: 1. Deletion of a package version 2. Redirect to the owners package list New behaviour: 1. Deletion of a package version 2.1. If there are more versions available, redirect to the package again 2.2. If there are no versions available, redirect to the owners package list
-rw-r--r--routers/web/user/package.go8
-rw-r--r--templates/package/view.tmpl20
2 files changed, 16 insertions, 12 deletions
diff --git a/routers/web/user/package.go b/routers/web/user/package.go
index 81a26da827..20141914b6 100644
--- a/routers/web/user/package.go
+++ b/routers/web/user/package.go
@@ -420,7 +420,13 @@ func PackageSettingsPost(ctx *context.Context) {
ctx.Flash.Success(ctx.Tr("packages.settings.delete.success"))
}
- ctx.Redirect(ctx.Package.Owner.HomeLink() + "/-/packages")
+ redirectURL := ctx.Package.Owner.HomeLink() + "/-/packages"
+ // redirect to the package if there are still versions available
+ if has, _ := packages_model.ExistVersion(ctx, &packages_model.PackageSearchOptions{PackageID: ctx.Package.Descriptor.Package.ID}); has {
+ redirectURL = ctx.Package.Descriptor.PackageWebLink()
+ }
+
+ ctx.Redirect(redirectURL)
return
}
}
diff --git a/templates/package/view.tmpl b/templates/package/view.tmpl
index 1e7d13285e..6064db1b4c 100644
--- a/templates/package/view.tmpl
+++ b/templates/package/view.tmpl
@@ -84,19 +84,17 @@
{{end}}
</div>
{{end}}
- {{if .LatestVersions}}
- <div class="divider"></div>
- <strong>{{.locale.Tr "packages.versions"}} ({{.TotalVersionCount}})</strong>
- <a class="ui right" href="{{$.PackageDescriptor.PackageWebLink}}/versions">{{.locale.Tr "packages.versions.view_all"}}</a>
- <div class="ui relaxed list">
- {{range .LatestVersions}}
- <div class="item gt-df">
- <a class="gt-f1" href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .LowerVersion}}">{{.Version}}</a>
- <span class="text small">{{DateTime "short" .CreatedUnix}}</span>
- </div>
- {{end}}
+ <div class="divider"></div>
+ <strong>{{.locale.Tr "packages.versions"}} ({{.TotalVersionCount}})</strong>
+ <a class="ui right" href="{{$.PackageDescriptor.PackageWebLink}}/versions">{{.locale.Tr "packages.versions.view_all"}}</a>
+ <div class="ui relaxed list">
+ {{range .LatestVersions}}
+ <div class="item gt-df">
+ <a class="gt-f1" href="{{$.PackageDescriptor.PackageWebLink}}/{{PathEscape .LowerVersion}}">{{.Version}}</a>
+ <span class="text small">{{DateTime "short" .CreatedUnix}}</span>
</div>
{{end}}
+ </div>
{{if or .CanWritePackages .HasRepositoryAccess}}
<div class="divider"></div>
<div class="ui relaxed list">