From 62afc0a727610aba6462f51b040032dcdb8c9a36 Mon Sep 17 00:00:00 2001 From: Giteabot Date: Mon, 27 Mar 2023 09:42:47 -0400 Subject: [PATCH] Redirect to project again after editing it (#23326) (#23739) Backport #23326 by @yp05327 A part of https://github.com/go-gitea/gitea/pull/22865 We have edit buttons in projects list page and project view page. But after user edit a project, it will always redirect to the projects list page. Co-authored-by: yp05327 <576951401@qq.com> --- routers/web/org/projects.go | 7 ++++++- routers/web/repo/projects.go | 7 ++++++- templates/projects/new.tmpl | 1 + templates/projects/view.tmpl | 2 +- templates/repo/projects/new.tmpl | 1 + templates/repo/projects/view.tmpl | 2 +- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go index 8db42689d8..c9d63fec5d 100644 --- a/routers/web/org/projects.go +++ b/routers/web/org/projects.go @@ -234,6 +234,7 @@ func EditProject(ctx *context.Context) { ctx.Data["title"] = p.Title ctx.Data["content"] = p.Description + ctx.Data["redirect"] = ctx.FormString("redirect") ctx.HTML(http.StatusOK, tplProjectsNew) } @@ -274,7 +275,11 @@ func EditProjectPost(ctx *context.Context) { } ctx.Flash.Success(ctx.Tr("repo.projects.edit_success", p.Title)) - ctx.Redirect(ctx.Repo.RepoLink + "/projects") + if ctx.FormString("redirect") == "project" { + ctx.Redirect(p.Link()) + } else { + ctx.Redirect(ctx.ContextUser.HomeLink() + "/-/projects") + } } // ViewProject renders the project board for a project diff --git a/routers/web/repo/projects.go b/routers/web/repo/projects.go index 521256584a..e15f548a38 100644 --- a/routers/web/repo/projects.go +++ b/routers/web/repo/projects.go @@ -235,6 +235,7 @@ func EditProject(ctx *context.Context) { ctx.Data["title"] = p.Title ctx.Data["content"] = p.Description ctx.Data["card_type"] = p.CardType + ctx.Data["redirect"] = ctx.FormString("redirect") ctx.HTML(http.StatusOK, tplProjectsNew) } @@ -275,7 +276,11 @@ func EditProjectPost(ctx *context.Context) { } ctx.Flash.Success(ctx.Tr("repo.projects.edit_success", p.Title)) - ctx.Redirect(ctx.Repo.RepoLink + "/projects") + if ctx.FormString("redirect") == "project" { + ctx.Redirect(p.Link()) + } else { + ctx.Redirect(ctx.Repo.RepoLink + "/projects") + } } // ViewProject renders the project board for a project diff --git a/templates/projects/new.tmpl b/templates/projects/new.tmpl index 19bf503692..85ceddec60 100644 --- a/templates/projects/new.tmpl +++ b/templates/projects/new.tmpl @@ -21,6 +21,7 @@
{{.CsrfTokenHtml}}
+
diff --git a/templates/projects/view.tmpl b/templates/projects/view.tmpl index 00e5c9038c..c815ec4f6a 100644 --- a/templates/projects/view.tmpl +++ b/templates/projects/view.tmpl @@ -46,7 +46,7 @@ {{if $.CanWriteProjects}}