Skip to content

Commit

Permalink
Redirect on project after issue created (go-gitea#17211)
Browse files Browse the repository at this point in the history
close go-gitea#17011

If user create an issue with button in project view, after issue is created the user is redirect to project view.
  • Loading branch information
romdum authored and Stelios Malathouras committed Oct 15, 2021
1 parent 7ba66c9 commit 282729f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion routers/web/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -236,5 +236,6 @@
{{end}}
</div>
</div>
<input type="hidden" name="redirect_after_creation" value="{{.redirect_after_creation}}">
</div>
</form>

0 comments on commit 282729f

Please sign in to comment.