Skip to content

Commit 167914c

Browse files
authored
Redirect on project after issue created (#17211)
close #17011 If user create an issue with button in project view, after issue is created the user is redirect to project view.
1 parent 987152b commit 167914c

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

routers/web/repo/issue.go

+8-1
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,9 @@ func NewIssue(ctx *context.Context) {
803803
ctx.Data["Project"] = project
804804
}
805805

806+
if len(ctx.Req.URL.Query().Get("project")) > 0 {
807+
ctx.Data["redirect_after_creation"] = "project"
808+
}
806809
}
807810

808811
RetrieveRepoMetas(ctx, ctx.Repo.Repository, false)
@@ -990,7 +993,11 @@ func NewIssuePost(ctx *context.Context) {
990993
}
991994

992995
log.Trace("Issue created: %d/%d", repo.ID, issue.ID)
993-
ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + fmt.Sprint(issue.Index))
996+
if ctx.FormString("redirect_after_creation") == "project" {
997+
ctx.Redirect(ctx.Repo.RepoLink + "/projects/" + fmt.Sprint(form.ProjectID))
998+
} else {
999+
ctx.Redirect(ctx.Repo.RepoLink + "/issues/" + fmt.Sprint(issue.Index))
1000+
}
9941001
}
9951002

9961003
// commentTag returns the CommentTag for a comment in/with the given repo, poster and issue

templates/repo/issue/new_form.tmpl

+1
Original file line numberDiff line numberDiff line change
@@ -236,5 +236,6 @@
236236
{{end}}
237237
</div>
238238
</div>
239+
<input type="hidden" name="redirect_after_creation" value="{{.redirect_after_creation}}">
239240
</div>
240241
</form>

0 commit comments

Comments
 (0)