]> source.dussan.org Git - gitea.git/commitdiff
Redirect on project after issue created (#17211)
authorRomain <romdum@users.noreply.github.com>
Tue, 5 Oct 2021 19:21:52 +0000 (21:21 +0200)
committerGitHub <noreply@github.com>
Tue, 5 Oct 2021 19:21:52 +0000 (21:21 +0200)
close #17011

If user create an issue with button in project view, after issue is created the user is redirect to project view.

routers/web/repo/issue.go
templates/repo/issue/new_form.tmpl

index 7498830d94ccc20145bfc057254d1db17b7d6bc4..03bdbec80c9297936f29bb000ab87d53cab92208 100644 (file)
@@ -803,6 +803,9 @@ func NewIssue(ctx *context.Context) {
                        ctx.Data["Project"] = project
                }
 
+               if len(ctx.Req.URL.Query().Get("project")) > 0 {
+                       ctx.Data["redirect_after_creation"] = "project"
+               }
        }
 
        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.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))
+       }
 }
 
 // commentTag returns the CommentTag for a comment in/with the given repo, poster and issue
index f208416261c6a81adea40da4156db46e3bd3914c..1089c82415ab8c50fb82edeca8335a3c2d79f8cb 100644 (file)
                                        {{end}}
                                </div>
                </div>
+               <input type="hidden" name="redirect_after_creation" value="{{.redirect_after_creation}}">
        </div>
 </form>