Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Add links to toggle PR WIP status
  • Loading branch information
jpraet committed Feb 13, 2021
commit b66afeb00a1d35d3fa17d2bf0ddafffa5d038afb
4 changes: 3 additions & 1 deletion options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,9 @@ pulls.merged_as = The pull request has been merged as <a rel="nofollow" class="u
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 @@ -516,6 +516,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 @@ -167,9 +167,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 .HasIssuesOrPullsWritePermission}}
{{$.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 (not .IsPullWorkInProgress) .HasIssuesOrPullsWritePermission}}
<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 @@ -906,6 +906,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