Skip to content

Commit eaadddd

Browse files
committed
use configurable WIP prefixes in javascript and default to first one in templates
1 parent 195b413 commit eaadddd

File tree

5 files changed

+20
-4
lines changed

5 files changed

+20
-4
lines changed

options/locale/locale_en-US.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ pulls.tab_files = Files Changed
829829
pulls.reopen_to_merge = Please reopen this pull request to perform a merge.
830830
pulls.merged = Merged
831831
pulls.has_merged = The pull request has been merged.
832-
pulls.title_wip_desc = '<a href="#">Start the title with <strong>WIP:</strong></a> to prevent the pull request from being merged accidentally.'
832+
pulls.title_wip_desc = '<a href="#">Start the title with <strong>%s</strong></a> to prevent the pull request from being merged accidentally.'
833833
pulls.cannot_merge_work_in_progress = "This pull request is marked as a work in progress. Remove the <strong>%s</strong> prefix from the title when it's ready"
834834
pulls.data_broken = This pull request is broken due to missing fork information.
835835
pulls.is_checking = "Merge conflict checking is in progress. Try again in few moments."

public/js/index.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,16 @@ function initWipTitle() {
15641564
var $issueTitle = $("#issue_title");
15651565
var value = $issueTitle.val().trim().toUpperCase();
15661566

1567-
if (!value.startsWith("WIP:") && !value.startsWith("[WIP]")) {
1568-
$issueTitle.val("WIP: " + $issueTitle.val());
1567+
var addPrefix = true;
1568+
for (var i in wipPrefixes) {
1569+
if (value.startsWith(wipPrefixes[i].toUpperCase())) {
1570+
addPrefix = false;
1571+
break;
1572+
}
1573+
}
1574+
1575+
if (addPrefix) {
1576+
$issueTitle.val(wipPrefixes[0] + " " + $issueTitle.val());
15691577
}
15701578
});
15711579
}

routers/repo/issue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,7 @@ func NewIssue(ctx *context.Context) {
356356
ctx.Data["RequireHighlightJS"] = true
357357
ctx.Data["RequireSimpleMDE"] = true
358358
ctx.Data["RequireTribute"] = true
359+
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
359360
setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates)
360361
renderAttachmentSettings(ctx)
361362

@@ -449,6 +450,7 @@ func NewIssuePost(ctx *context.Context, form auth.CreateIssueForm) {
449450
ctx.Data["RequireHighlightJS"] = true
450451
ctx.Data["RequireSimpleMDE"] = true
451452
ctx.Data["ReadOnly"] = false
453+
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
452454
renderAttachmentSettings(ctx)
453455

454456
var (

routers/repo/pull.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -744,6 +744,7 @@ func CompareAndPullRequest(ctx *context.Context) {
744744
ctx.Data["IsDiffCompare"] = true
745745
ctx.Data["RequireHighlightJS"] = true
746746
ctx.Data["RequireTribute"] = true
747+
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
747748
setTemplateIfExists(ctx, pullRequestTemplateKey, pullRequestTemplateCandidates)
748749
renderAttachmentSettings(ctx)
749750

@@ -787,6 +788,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm)
787788
ctx.Data["PageIsComparePull"] = true
788789
ctx.Data["IsDiffCompare"] = true
789790
ctx.Data["RequireHighlightJS"] = true
791+
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
790792
renderAttachmentSettings(ctx)
791793

792794
var (

templates/repo/issue/new_form.tmpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<div class="field">
1616
<input name="title" id="issue_title" placeholder="{{.i18n.Tr "repo.milestones.title"}}" value="{{.title}}" tabindex="3" autofocus required>
1717
{{if .PageIsComparePull}}
18-
<span class="title_wip_desc">{{.i18n.Tr "repo.pulls.title_wip_desc" | Safe}}</span>
18+
<span class="title_wip_desc">{{.i18n.Tr "repo.pulls.title_wip_desc" (index .PullRequestWorkInProgressPrefixes 0) | Safe}}</span>
1919
{{end}}
2020
</div>
2121
{{template "repo/issue/comment_tab" .}}
@@ -153,3 +153,7 @@
153153
</div>
154154
</div>
155155
</form>
156+
{{if .PageIsComparePull}}
157+
<script>window.workInProgressPrefixes = {{.PullRequestWorkInProgressPrefixes}}</script>
158+
{{end}}
159+

0 commit comments

Comments
 (0)