From 820b5195acb7167cd06296a923451be0b9a03d78 Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Mon, 6 Mar 2023 07:40:52 +0000 Subject: [PATCH 1/2] redirect to origin page after edit a project --- routers/web/org/projects.go | 7 ++++++- routers/web/repo/projects.go | 7 ++++++- templates/projects/new.tmpl | 1 + templates/repo/projects/new.tmpl | 1 + 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/routers/web/org/projects.go b/routers/web/org/projects.go index 6449d12de105a..9c631871b457d 100644 --- a/routers/web/org/projects.go +++ b/routers/web/org/projects.go @@ -233,6 +233,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) } @@ -273,7 +274,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 967b81c608516..29bd59c7a3b3e 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 c96f948dedfd6..826869ac5daac 100644 --- a/templates/projects/new.tmpl +++ b/templates/projects/new.tmpl @@ -21,6 +21,7 @@
{{.CsrfTokenHtml}}
+
diff --git a/templates/repo/projects/new.tmpl b/templates/repo/projects/new.tmpl index b65601c158905..b53a47dc58e69 100644 --- a/templates/repo/projects/new.tmpl +++ b/templates/repo/projects/new.tmpl @@ -24,6 +24,7 @@ {{.CsrfTokenHtml}}
+
From 712be70dbc343743c389e59ad27a69edcba5398a Mon Sep 17 00:00:00 2001 From: yp05327 <576951401@qq.com> Date: Thu, 9 Mar 2023 07:04:52 +0000 Subject: [PATCH 2/2] add redirect in view page --- templates/projects/view.tmpl | 2 +- templates/repo/projects/view.tmpl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/projects/view.tmpl b/templates/projects/view.tmpl index 14a876d8fd943..474b22a2f14ca 100644 --- a/templates/projects/view.tmpl +++ b/templates/projects/view.tmpl @@ -46,7 +46,7 @@ {{if or $.CanWriteIssues $.CanWritePulls}}