loading up the forgejo repo on tangled to test page performance
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Redirect from `{repo}/issues/new` to `{repo}/issues/new/choose` when blank issues are disabled (#26813)

You can currently visit `{repo}/issues/new` and create a blank issue,
even if it's disabled. This PR fixes this,

Fixes https://codeberg.org/forgejo/forgejo/issues/1356

Co-authored-by: Giteabot <teabot@gitea.io>

authored by

JakobDev
Giteabot
and committed by
GitHub
3cae50e8 d5703d4a

+9 -1
+9 -1
routers/web/repo/issue.go
··· 902 902 903 903 // NewIssue render creating issue page 904 904 func NewIssue(ctx *context.Context) { 905 + issueConfig, _ := issue_service.GetTemplateConfigFromDefaultBranch(ctx.Repo.Repository, ctx.Repo.GitRepo) 906 + hasTemplates := issue_service.HasTemplatesOrContactLinks(ctx.Repo.Repository, ctx.Repo.GitRepo) 907 + if !issueConfig.BlankIssuesEnabled && hasTemplates { 908 + // The "issues/new" and "issues/new/choose" share the same query parameters "project" and "milestone", if blank issues are disabled, just redirect to the "issues/choose" page with these parameters. 909 + ctx.Redirect(fmt.Sprintf("%s/issues/new/choose?%s", ctx.Repo.Repository.Link(), ctx.Req.URL.RawQuery), http.StatusSeeOther) 910 + return 911 + } 912 + 905 913 ctx.Data["Title"] = ctx.Tr("repo.issues.new") 906 914 ctx.Data["PageIsIssueList"] = true 907 - ctx.Data["NewIssueChooseTemplate"] = issue_service.HasTemplatesOrContactLinks(ctx.Repo.Repository, ctx.Repo.GitRepo) 915 + ctx.Data["NewIssueChooseTemplate"] = hasTemplates 908 916 ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes 909 917 title := ctx.FormString("title") 910 918 ctx.Data["TitleQuery"] = title