Skip to content

Commit c87afd4

Browse files
zeripathwxiaoguang
andcommitted
Use the new/choose link for New Issue on project page (go-gitea#19172)
Backport go-gitea#19172 Extend issues/new/choose to pass the project id and change New Issue link on project page to use new/choose Fix go-gitea#19170 Signed-off-by: Andrew Thornton <[email protected]> Co-authored-by: wxiaoguang <[email protected]>
1 parent 23b8214 commit c87afd4

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

routers/web/repo/issue.go

+9-2
Original file line numberDiff line numberDiff line change
@@ -843,12 +843,19 @@ func NewIssue(ctx *context.Context) {
843843
func NewIssueChooseTemplate(ctx *context.Context) {
844844
ctx.Data["Title"] = ctx.Tr("repo.issues.new")
845845
ctx.Data["PageIsIssueList"] = true
846-
ctx.Data["milestone"] = ctx.FormInt64("milestone")
847846

848847
issueTemplates := ctx.IssueTemplatesFromDefaultBranch()
849-
ctx.Data["NewIssueChooseTemplate"] = len(issueTemplates) > 0
850848
ctx.Data["IssueTemplates"] = issueTemplates
851849

850+
if len(issueTemplates) == 0 {
851+
// 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.
852+
ctx.Redirect(fmt.Sprintf("%s/issues/new?%s", ctx.Repo.Repository.HTMLURL(), ctx.Req.URL.RawQuery), http.StatusSeeOther)
853+
return
854+
}
855+
856+
ctx.Data["milestone"] = ctx.FormInt64("milestone")
857+
ctx.Data["project"] = ctx.FormInt64("project")
858+
852859
ctx.HTML(http.StatusOK, tplIssueChoose)
853860
}
854861

templates/repo/issue/choose.tmpl

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<br/>{{.About | RenderEmojiPlain}}
1515
</div>
1616
<div class="column right aligned">
17-
<a href="{{$.RepoLink}}/issues/new?template={{.FileName}}{{if $.milestone}}&milestone={{$.milestone}}{{end}}" class="ui green button">{{$.i18n.Tr "repo.issues.choose.get_started"}}</a>
17+
<a href="{{$.RepoLink}}/issues/new?template={{.FileName}}{{if $.milestone}}&milestone={{$.milestone}}{{end}}{{if $.project}}&project={{$.project}}{{end}}" class="ui green button">{{$.i18n.Tr "repo.issues.choose.get_started"}}</a>
1818
</div>
1919
</div>
2020
</div>
@@ -26,7 +26,7 @@
2626
<br/>{{.i18n.Tr "repo.issues.choose.blank_about"}}
2727
</div>
2828
<div class="column right aligned">
29-
<a href="{{.RepoLink}}/issues/new{{if .milestone}}?milestone={{.milestone}}{{end}}" class="ui green button">{{$.i18n.Tr "repo.issues.choose.get_started"}}</a>
29+
<a href="{{.RepoLink}}/issues/new?{{if .milestone}}&milestone={{.milestone}}{{end}}{{if $.project}}&project={{$.project}}{{end}}" class="ui green button">{{$.i18n.Tr "repo.issues.choose.get_started"}}</a>
3030
</div>
3131
</div>
3232
</div>

templates/repo/projects/view.tmpl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
</div>
99
<div class="column right aligned">
1010
{{if and .CanWriteProjects (not .Repository.IsArchived)}}
11-
<a class="ui green button show-modal item" href="{{$.RepoLink}}/issues/new?project={{$.Project.ID}}">{{.i18n.Tr "repo.issues.new"}}</a>
11+
<a class="ui green button show-modal item" href="{{$.RepoLink}}/issues/new/choose?project={{$.Project.ID}}">{{.i18n.Tr "repo.issues.new"}}</a>
1212
<a class="ui green button show-modal item" data-modal="#new-board-item">{{.i18n.Tr "new_project_board"}}</a>
1313
{{end}}
1414
<div class="ui small modal new-board-modal" id="new-board-item">

0 commit comments

Comments
 (0)