Skip to content

Commit

Permalink
use configurable WIP prefixes in javascript and default to first one …
Browse files Browse the repository at this point in the history
…in templates
  • Loading branch information
JulienTant committed Aug 1, 2018
1 parent 195b413 commit eaadddd
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -829,7 +829,7 @@ pulls.tab_files = Files Changed
pulls.reopen_to_merge = Please reopen this pull request to perform a merge.
pulls.merged = Merged
pulls.has_merged = The pull request has been merged.
pulls.title_wip_desc = '<a href="#">Start the title with <strong>WIP:</strong></a> to prevent the pull request from being merged accidentally.'
pulls.title_wip_desc = '<a href="#">Start the title with <strong>%s</strong></a> to prevent the pull request from being merged accidentally.'
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"
pulls.data_broken = This pull request is broken due to missing fork information.
pulls.is_checking = "Merge conflict checking is in progress. Try again in few moments."
Expand Down
12 changes: 10 additions & 2 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1564,8 +1564,16 @@ function initWipTitle() {
var $issueTitle = $("#issue_title");
var value = $issueTitle.val().trim().toUpperCase();

if (!value.startsWith("WIP:") && !value.startsWith("[WIP]")) {
$issueTitle.val("WIP: " + $issueTitle.val());
var addPrefix = true;
for (var i in wipPrefixes) {
if (value.startsWith(wipPrefixes[i].toUpperCase())) {
addPrefix = false;
break;
}
}

if (addPrefix) {
$issueTitle.val(wipPrefixes[0] + " " + $issueTitle.val());
}
});
}
Expand Down
2 changes: 2 additions & 0 deletions routers/repo/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ func NewIssue(ctx *context.Context) {
ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireSimpleMDE"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
setTemplateIfExists(ctx, issueTemplateKey, IssueTemplateCandidates)
renderAttachmentSettings(ctx)

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

var (
Expand Down
2 changes: 2 additions & 0 deletions routers/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -744,6 +744,7 @@ func CompareAndPullRequest(ctx *context.Context) {
ctx.Data["IsDiffCompare"] = true
ctx.Data["RequireHighlightJS"] = true
ctx.Data["RequireTribute"] = true
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
setTemplateIfExists(ctx, pullRequestTemplateKey, pullRequestTemplateCandidates)
renderAttachmentSettings(ctx)

Expand Down Expand Up @@ -787,6 +788,7 @@ func CompareAndPullRequestPost(ctx *context.Context, form auth.CreateIssueForm)
ctx.Data["PageIsComparePull"] = true
ctx.Data["IsDiffCompare"] = true
ctx.Data["RequireHighlightJS"] = true
ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes
renderAttachmentSettings(ctx)

var (
Expand Down
6 changes: 5 additions & 1 deletion templates/repo/issue/new_form.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="field">
<input name="title" id="issue_title" placeholder="{{.i18n.Tr "repo.milestones.title"}}" value="{{.title}}" tabindex="3" autofocus required>
{{if .PageIsComparePull}}
<span class="title_wip_desc">{{.i18n.Tr "repo.pulls.title_wip_desc" | Safe}}</span>
<span class="title_wip_desc">{{.i18n.Tr "repo.pulls.title_wip_desc" (index .PullRequestWorkInProgressPrefixes 0) | Safe}}</span>
{{end}}
</div>
{{template "repo/issue/comment_tab" .}}
Expand Down Expand Up @@ -153,3 +153,7 @@
</div>
</div>
</form>
{{if .PageIsComparePull}}
<script>window.workInProgressPrefixes = {{.PullRequestWorkInProgressPrefixes}}</script>
{{end}}

0 comments on commit eaadddd

Please sign in to comment.