mirror of
https://github.com/go-gitea/gitea
synced 2024-11-25 20:42:57 +01:00
Add option to define refs in issue templates (#17842)
Adds a markdown header option `ref` that allows you to set the ref the issue should belong.
This commit is contained in:
parent
4bbbf35654
commit
4cbc865d83
5 changed files with 14 additions and 5 deletions
|
@ -69,6 +69,7 @@ Inside the directory can be multiple issue templates with the form
|
||||||
name: "Template Name"
|
name: "Template Name"
|
||||||
about: "This template is for testing!"
|
about: "This template is for testing!"
|
||||||
title: "[TEST] "
|
title: "[TEST] "
|
||||||
|
ref: "main"
|
||||||
labels:
|
labels:
|
||||||
|
|
||||||
- bug
|
- bug
|
||||||
|
@ -82,4 +83,4 @@ This is the template!
|
||||||
In the above example, when a user is presented with the list of issues they can submit, this would show as `Template Name` with the description
|
In the above example, when a user is presented with the list of issues they can submit, this would show as `Template Name` with the description
|
||||||
`This template is for testing!`. When submitting an issue with the above example, the issue title would be pre-populated with
|
`This template is for testing!`. When submitting an issue with the above example, the issue title would be pre-populated with
|
||||||
`[TEST] ` while the issue body would be pre-populated with `This is the template!`. The issue would also be assigned two labels,
|
`[TEST] ` while the issue body would be pre-populated with `This is the template!`. The issue would also be assigned two labels,
|
||||||
`bug` and `help needed`.
|
`bug` and `help needed`, and the issue will have a reference to `main`.
|
||||||
|
|
|
@ -127,6 +127,7 @@ type IssueTemplate struct {
|
||||||
Title string `json:"title" yaml:"title"`
|
Title string `json:"title" yaml:"title"`
|
||||||
About string `json:"about" yaml:"about"`
|
About string `json:"about" yaml:"about"`
|
||||||
Labels []string `json:"labels" yaml:"labels"`
|
Labels []string `json:"labels" yaml:"labels"`
|
||||||
|
Ref string `json:"ref" yaml:"ref"`
|
||||||
Content string `json:"content" yaml:"-"`
|
Content string `json:"content" yaml:"-"`
|
||||||
FileName string `json:"file_name" yaml:"-"`
|
FileName string `json:"file_name" yaml:"-"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -776,6 +776,8 @@ func setTemplateIfExists(ctx *context.Context, ctxDataKey string, possibleDirs [
|
||||||
}
|
}
|
||||||
ctx.Data["HasSelectedLabel"] = len(labelIDs) > 0
|
ctx.Data["HasSelectedLabel"] = len(labelIDs) > 0
|
||||||
ctx.Data["label_ids"] = strings.Join(labelIDs, ",")
|
ctx.Data["label_ids"] = strings.Join(labelIDs, ",")
|
||||||
|
ctx.Data["Reference"] = meta.Ref
|
||||||
|
ctx.Data["RefEndName"] = git.RefEndName(meta.Ref)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1635,6 +1637,7 @@ func ViewIssue(ctx *context.Context) {
|
||||||
ctx.Data["Participants"] = participants
|
ctx.Data["Participants"] = participants
|
||||||
ctx.Data["NumParticipants"] = len(participants)
|
ctx.Data["NumParticipants"] = len(participants)
|
||||||
ctx.Data["Issue"] = issue
|
ctx.Data["Issue"] = issue
|
||||||
|
ctx.Data["Reference"] = issue.Ref
|
||||||
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + url.QueryEscape(ctx.Data["Link"].(string))
|
ctx.Data["SignInLink"] = setting.AppSubURL + "/user/login?redirect_to=" + url.QueryEscape(ctx.Data["Link"].(string))
|
||||||
ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.User.ID)
|
ctx.Data["IsIssuePoster"] = ctx.IsSigned && issue.IsPoster(ctx.User.ID)
|
||||||
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
|
ctx.Data["HasIssuesOrPullsWritePermission"] = ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{{if and (not .Issue.IsPull) (not .PageIsComparePull)}}
|
{{if and (not .Issue.IsPull) (not .PageIsComparePull)}}
|
||||||
<input id="ref_selector" name="ref" type="hidden" value="{{.Issue.Ref}}">
|
<input id="ref_selector" name="ref" type="hidden" value="{{.Reference}}">
|
||||||
<input id="editing_mode" name="edit_mode" type="hidden" value="{{(or .IsIssueWriter .HasIssuesOrPullsWritePermission)}}">
|
<input id="editing_mode" name="edit_mode" type="hidden" value="{{(or .IsIssueWriter .HasIssuesOrPullsWritePermission)}}">
|
||||||
<form method="POST" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/ref" id="update_issueref_form">
|
<form method="POST" action="{{$.RepoLink}}/issues/{{.Issue.Index}}/ref" id="update_issueref_form">
|
||||||
{{$.CsrfTokenHtml}}
|
{{$.CsrfTokenHtml}}
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
<div class="ui {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} floating filter select-branch dropdown" data-no-results="{{.i18n.Tr "repo.pulls.no_results"}}">
|
<div class="ui {{if not .HasIssuesOrPullsWritePermission}}disabled{{end}} floating filter select-branch dropdown" data-no-results="{{.i18n.Tr "repo.pulls.no_results"}}">
|
||||||
<div class="ui basic small button">
|
<div class="ui basic small button">
|
||||||
<span class="text branch-name">{{if .Issue.Ref}}{{$.RefEndName}}{{else}}{{.i18n.Tr "repo.issues.no_ref"}}{{end}}</span>
|
<span class="text branch-name">{{if .Reference}}{{$.RefEndName}}{{else}}{{.i18n.Tr "repo.issues.no_ref"}}{{end}}</span>
|
||||||
{{if .HasIssuesOrPullsWritePermission}}{{svg "octicon-triangle-down" 14 "dropdown icon"}}{{end}}
|
{{if .HasIssuesOrPullsWritePermission}}{{svg "octicon-triangle-down" 14 "dropdown icon"}}{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div class="menu">
|
<div class="menu">
|
||||||
|
@ -32,7 +32,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="branch-list" class="scrolling menu reference-list-menu {{if not .Issue}}new-issue{{end}}">
|
<div id="branch-list" class="scrolling menu reference-list-menu {{if not .Issue}}new-issue{{end}}">
|
||||||
{{if .Issue.Ref}}
|
{{if .Reference}}
|
||||||
<div class="item text small" data-id="" data-id-selector="#ref_selector"><strong><a href="#">{{$.i18n.Tr "repo.clear_ref"}}</a></strong></div>
|
<div class="item text small" data-id="" data-id-selector="#ref_selector"><strong><a href="#">{{$.i18n.Tr "repo.clear_ref"}}</a></strong></div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{range .Branches}}
|
{{range .Branches}}
|
||||||
|
@ -40,7 +40,7 @@
|
||||||
{{end}}
|
{{end}}
|
||||||
</div>
|
</div>
|
||||||
<div id="tag-list" class="scrolling menu reference-list-menu {{if not .Issue}}new-issue{{end}}" style="display: none">
|
<div id="tag-list" class="scrolling menu reference-list-menu {{if not .Issue}}new-issue{{end}}" style="display: none">
|
||||||
{{if .Issue.Ref}}
|
{{if .Reference}}
|
||||||
<div class="item text small" data-id="" data-id-selector="#ref_selector"><strong><a href="#">{{.i18n.Tr "repo.clear_ref"}}</a></strong></div>
|
<div class="item text small" data-id="" data-id-selector="#ref_selector"><strong><a href="#">{{.i18n.Tr "repo.clear_ref"}}</a></strong></div>
|
||||||
{{end}}
|
{{end}}
|
||||||
{{range .Tags}}
|
{{range .Tags}}
|
||||||
|
|
|
@ -15578,6 +15578,10 @@
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Name"
|
"x-go-name": "Name"
|
||||||
},
|
},
|
||||||
|
"ref": {
|
||||||
|
"type": "string",
|
||||||
|
"x-go-name": "Ref"
|
||||||
|
},
|
||||||
"title": {
|
"title": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "Title"
|
"x-go-name": "Title"
|
||||||
|
|
Loading…
Reference in a new issue