From 1aaa769799c0aea32f3e60f25f3ebd4a92b5287c Mon Sep 17 00:00:00 2001 From: Romain Date: Sun, 3 Oct 2021 15:03:59 +0200 Subject: [PATCH 1/4] Redirect on project after issue created --- routers/web/repo/issue.go | 9 ++++++++- templates/repo/issue/new_form.tmpl | 1 + templates/repo/projects/view.tmpl | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 7498830d94ccc..3737036d07939 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -803,6 +803,9 @@ func NewIssue(ctx *context.Context) { ctx.Data["Project"] = project } + if ctx.FormBool("redirect_on_project") { + ctx.Data["redirect_on_project"] = true + } } RetrieveRepoMetas(ctx, ctx.Repo.Repository, false) @@ -990,7 +993,11 @@ func NewIssuePost(ctx *context.Context) { } log.Trace("Issue created: %d/%d", repo.ID, issue.ID) - ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + fmt.Sprint(issue.Index)) + if ctx.FormBool("redirect_on_project") { + ctx.Redirect(ctx.Repo.RepoLink + "/projects/" + fmt.Sprint(form.ProjectID)) + } else { + ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + fmt.Sprint(issue.Index)) + } } // commentTag returns the CommentTag for a comment in/with the given repo, poster and issue diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl index f208416261c6a..ec86ef490212e 100644 --- a/templates/repo/issue/new_form.tmpl +++ b/templates/repo/issue/new_form.tmpl @@ -236,5 +236,6 @@ {{end}} + diff --git a/templates/repo/projects/view.tmpl b/templates/repo/projects/view.tmpl index 082f4d8eb99e8..4de7afd9eb9f7 100644 --- a/templates/repo/projects/view.tmpl +++ b/templates/repo/projects/view.tmpl @@ -8,7 +8,7 @@
{{if and .CanWriteProjects (not .Repository.IsArchived) .PageIsProjects}} - {{.i18n.Tr "repo.issues.new"}} + {{.i18n.Tr "repo.issues.new"}} {{.i18n.Tr "new_project_board"}} {{end}}
{{if and .CanWriteProjects (not .Repository.IsArchived) .PageIsProjects}} - {{.i18n.Tr "repo.issues.new"}} + {{.i18n.Tr "repo.issues.new"}} {{.i18n.Tr "new_project_board"}} {{end}}
- +
From 6849c8c2ea0384c36b1c0c5e6a5d2cfc983741d6 Mon Sep 17 00:00:00 2001 From: Romain Date: Sun, 3 Oct 2021 20:00:14 +0200 Subject: [PATCH 4/4] Code review - Change variable redirection_after_creation by redirect_after_creation (#17211) --- routers/web/repo/issue.go | 4 ++-- templates/repo/issue/new_form.tmpl | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go index 507097e1e1540..03bdbec80c929 100644 --- a/routers/web/repo/issue.go +++ b/routers/web/repo/issue.go @@ -804,7 +804,7 @@ func NewIssue(ctx *context.Context) { } if len(ctx.Req.URL.Query().Get("project")) > 0 { - ctx.Data["redirection_after_creation"] = "project" + ctx.Data["redirect_after_creation"] = "project" } } @@ -993,7 +993,7 @@ func NewIssuePost(ctx *context.Context) { } log.Trace("Issue created: %d/%d", repo.ID, issue.ID) - if ctx.FormString("redirection_after_creation") == "project" { + if ctx.FormString("redirect_after_creation") == "project" { ctx.Redirect(ctx.Repo.RepoLink + "/projects/" + fmt.Sprint(form.ProjectID)) } else { ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + fmt.Sprint(issue.Index)) diff --git a/templates/repo/issue/new_form.tmpl b/templates/repo/issue/new_form.tmpl index 841e3dc8b12d3..1089c82415ab8 100644 --- a/templates/repo/issue/new_form.tmpl +++ b/templates/repo/issue/new_form.tmpl @@ -236,6 +236,6 @@ {{end}} - +