Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions integrations/pull_merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,8 @@ func TestCantMergeWorkInProgress(t *testing.T) {
text := strings.TrimSpace(htmlDoc.doc.Find(".merge-section > .item").Last().Text())
assert.NotEmpty(t, text, "Can't find WIP text")

// remove <strong /> from lang
expected := i18n.Tr("en", "repo.pulls.cannot_merge_work_in_progress", "[wip]")
replacer := strings.NewReplacer("<strong>", "", "</strong>", "")
assert.Equal(t, replacer.Replace(expected), text, "Unable to find WIP text")
assert.Contains(t, text, i18n.Tr("en", "repo.pulls.cannot_merge_work_in_progress"), "Unable to find WIP text")
assert.Contains(t, text, "[wip]", "Unable to find WIP text")
})
}

Expand Down
4 changes: 3 additions & 1 deletion options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,9 @@ pulls.manually_merged_as = The pull request has been manually merged as <a rel="
pulls.is_closed = The pull request has been closed.
pulls.has_merged = The pull request has been merged.
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.cannot_merge_work_in_progress = This pull request is marked as a work in progress.
pulls.remove_wip_prefix = `<a href="#">Remove the <strong>%s</strong> prefix</a> from the title when it's ready`
pulls.add_wip_prefix = `Still in progress? <a href="#">Add <strong>%s</strong> prefix</a>`
pulls.data_broken = This pull request is broken due to missing fork information.
pulls.files_conflicted = This pull request has changes conflicting with the target branch.
pulls.is_checking = "Merge conflict checking is in progress. Try again in few moments."
Expand Down
2 changes: 2 additions & 0 deletions routers/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,8 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
return nil
}

ctx.Data["PullRequestWorkInProgressPrefixes"] = setting.Repository.PullRequest.WorkInProgressPrefixes

if pull.IsWorkInProgress() {
ctx.Data["IsPullWorkInProgress"] = true
ctx.Data["WorkInProgressPrefix"] = pull.GetWorkInProgressPrefix()
Expand Down
7 changes: 5 additions & 2 deletions templates/repo/issue/view_content/pull.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -172,9 +172,12 @@
{{$.i18n.Tr "repo.pulls.data_broken"}}
</div>
{{else if .IsPullWorkInProgress}}
<div class="item">
<div class="item toggle-wip" data-title="{{.Issue.Title}}" data-wip-prefix="{{(.WorkInProgressPrefix|Escape)}}" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/title">
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
{{$.i18n.Tr "repo.pulls.cannot_merge_work_in_progress" (.WorkInProgressPrefix|Escape) | Str2html}}
{{$.i18n.Tr "repo.pulls.cannot_merge_work_in_progress" }}
{{if or .HasIssuesOrPullsWritePermission .IsIssuePoster}}
{{$.i18n.Tr "repo.pulls.remove_wip_prefix" (.WorkInProgressPrefix|Escape) | Safe}}
{{end}}
</div>
{{else if .Issue.PullRequest.IsChecking}}
<div class="item">
Expand Down
3 changes: 3 additions & 0 deletions templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
{{end}}
</div>
</div>
{{if and (or .HasIssuesOrPullsWritePermission .IsIssuePoster) (not .HasMerged) (not .Issue.IsClosed) (not .IsPullWorkInProgress)}}
<div class="toggle-wip" data-title="{{.Issue.Title}}" data-wip-prefix="{{(index .PullRequestWorkInProgressPrefixes 0| Escape)}}" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/title">{{.i18n.Tr "repo.pulls.add_wip_prefix" (index .PullRequestWorkInProgressPrefixes 0| Escape) | Safe}}</div>
{{end}}
<div class="ui divider"></div>
{{end}}

Expand Down
14 changes: 14 additions & 0 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,20 @@ async function initRepository() {
return false;
});

// Toggle WIP
$('.toggle-wip a').on('click', (e) => {
e.preventDefault();
const $toggle = $(e.target).closest('div');
const title = $toggle.data('title');
const prefix = $toggle.data('wip-prefix');
const newTitle = title.startsWith(prefix) ? title.substr(prefix.length).trim() : `${prefix.trim()} ${title}`;
$.post($toggle.data('update-url'), {
_csrf: csrf,
title: newTitle
}).done(reload);
return false;
});

// Issue Comments
initIssueComments();

Expand Down