aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authorzeripath <art27@cantab.net>2022-03-22 19:54:24 +0000
committerGitHub <noreply@github.com>2022-03-22 19:54:24 +0000
commitd2c165811a1bad081b2e99ca580e3bdbb18171f0 (patch)
tree25b9381bd920f347e4c2cce095741c3b0c8be780 /routers
parent461068cfa14bce6c1d6e24a6dc84b7ea0ac60080 (diff)
downloadgitea-d2c165811a1bad081b2e99ca580e3bdbb18171f0.tar.gz
gitea-d2c165811a1bad081b2e99ca580e3bdbb18171f0.zip
Use the new/choose link for New Issue on project page (#19172)
Extend issues/new/choose to pass the project id and change New Issue link on project page to use new/choose Fix #19170 Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/issue.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/routers/web/repo/issue.go b/routers/web/repo/issue.go
index e51631a721..adf7e93eac 100644
--- a/routers/web/repo/issue.go
+++ b/routers/web/repo/issue.go
@@ -843,12 +843,19 @@ func NewIssue(ctx *context.Context) {
func NewIssueChooseTemplate(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
ctx.Data["PageIsIssueList"] = true
- ctx.Data["milestone"] = ctx.FormInt64("milestone")
issueTemplates := ctx.IssueTemplatesFromDefaultBranch()
- ctx.Data["NewIssueChooseTemplate"] = len(issueTemplates) > 0
ctx.Data["IssueTemplates"] = issueTemplates
+ if len(issueTemplates) == 0 {
+ // The "issues/new" and "issues/new/choose" share the same query parameters "project" and "milestone", if no template here, just redirect to the "issues/new" page with these parameters.
+ ctx.Redirect(fmt.Sprintf("%s/issues/new?%s", ctx.Repo.Repository.HTMLURL(), ctx.Req.URL.RawQuery), http.StatusSeeOther)
+ return
+ }
+
+ ctx.Data["milestone"] = ctx.FormInt64("milestone")
+ ctx.Data["project"] = ctx.FormInt64("project")
+
ctx.HTML(http.StatusOK, tplIssueChoose)
}