Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add links to toggle WIP status #14677

Merged
merged 21 commits into from
May 27, 2021
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
5 changes: 3 additions & 2 deletions options/locale/locale_en-US.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1317,8 +1317,9 @@ 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.
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.still_in_progress = Still in progress?
pulls.add_prefix = `Add <strong>%s</strong> prefix`
silverwind marked this conversation as resolved.
Show resolved Hide resolved
pulls.remove_prefix = Remove the <strong>%s</strong> prefix
silverwind marked this conversation as resolved.
Show resolved Hide resolved
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
58 changes: 34 additions & 24 deletions templates/repo/issue/view_content/pull.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
{{avatar .User}}
</a>
{{end}}
<span class="text grey">
<span>
{{if .User}}
<a href="{{.User.HomeLink}}">{{.User.GetDisplayName}}</a>
{{else if .Team}}
Expand All @@ -34,12 +34,12 @@
</div>
<div class="review-item-right">
{{if .Review.Stale}}
<span class="ui poping up type-icon text grey" data-content="{{$.i18n.Tr "repo.issues.is_stale"}}">
<span class="ui poping up type-icon" data-content="{{$.i18n.Tr "repo.issues.is_stale"}}">
<i class="octicon icon fa-hourglass-end"></i>
</span>
{{end}}
{{if (and $.Permission.IsAdmin (or (eq .Review.Type 1) (eq .Review.Type 3)) (not $.Issue.IsClosed))}}
<a href="#" class="ui grey poping up icon dismiss-review-btn" data-review-id="dismiss-review-{{.Review.ID}}" data-content="{{$.i18n.Tr "repo.issues.dismiss_review"}}">
<a href="#" class="ui muted poping up icon dismiss-review-btn" data-review-id="dismiss-review-{{.Review.ID}}" data-content="{{$.i18n.Tr "repo.issues.dismiss_review"}}">
{{svg "octicon-x" 16}}
</a>
<div class="ui small modal" id="dismiss-review-modal">
Expand Down Expand Up @@ -172,20 +172,26 @@
{{$.i18n.Tr "repo.pulls.data_broken"}}
</div>
{{else if .IsPullWorkInProgress}}
<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" }}
{{if or .HasIssuesOrPullsWritePermission .IsIssuePoster}}
{{$.i18n.Tr "repo.pulls.remove_wip_prefix" (.WorkInProgressPrefix|Escape) | Safe}}
{{end}}
<div class="item toggle-wip df ac sb" data-title="{{.Issue.Title}}" data-wip-prefix="{{(.WorkInProgressPrefix|Escape)}}" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/title">
<div>
<i class="icon icon-octicon">{{svg "octicon-x"}}</i>
{{$.i18n.Tr "repo.pulls.cannot_merge_work_in_progress" }}
</div>
<div>
{{if or .HasIssuesOrPullsWritePermission .IsIssuePoster}}
<button class="ui compact button">
{{$.i18n.Tr "repo.pulls.remove_prefix" (.WorkInProgressPrefix|Escape) | Safe}}
</button>
{{end}}
</div>
</div>
{{else if .Issue.PullRequest.IsChecking}}
<div class="item">
<i class="icon icon-octicon">{{svg "octicon-sync"}}</i>
{{$.i18n.Tr "repo.pulls.is_checking"}}
</div>
{{else if .Issue.PullRequest.IsEmpty}}
<div class="item text grey">
<div class="item">
<i class="icon icon-octicon">{{svg "octicon-alert" 16}}</i>
{{$.i18n.Tr "repo.pulls.is_empty"}}
</div>
Expand Down Expand Up @@ -446,14 +452,14 @@
{{svg "octicon-x"}}
{{$.i18n.Tr "repo.pulls.no_merge_desc"}}
</div>
<div class="item text grey">
<div class="item">
{{svg "octicon-info"}}
{{$.i18n.Tr "repo.pulls.no_merge_helper"}}
</div>
{{end}}
{{else}}
<div class="ui divider"></div>
<div class="item text grey">
<div class="item">
{{svg "octicon-info"}}
{{$.i18n.Tr "repo.pulls.no_merge_access"}}
</div>
Expand Down Expand Up @@ -506,25 +512,29 @@
{{svg "octicon-x"}}
{{$.i18n.Tr "repo.pulls.cannot_auto_merge_desc"}}
</div>
<div class="item text grey">
<div class="item">
{{svg "octicon-info"}}
{{$.i18n.Tr "repo.pulls.cannot_auto_merge_helper"}}
</div>
{{end}}
{{end}}

{{if and (gt .Issue.PullRequest.CommitsBehind 0) (not .Issue.IsClosed) (not .Issue.PullRequest.IsChecking) (not .IsPullFilesConflicted) (not .IsPullRequestBroken) (not $canAutoMerge)}}
<div class="item text grey">
<i class="icon icon-octicon">{{svg "octicon-alert"}}</i>
{{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
{{if .UpdateAllowed}}
<form action="{{.Link}}/update" method="post" class="ui floating right">
{{.CsrfTokenHtml}}
<button class="ui compact button" data-do="update">
<span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
</button>
</form>
{{end}}
<div class="item df ac sb">
<div>
<i class="icon icon-octicon">{{svg "octicon-alert"}}</i>
{{$.i18n.Tr "repo.pulls.outdated_with_base_branch"}}
</div>
<div>
{{if .UpdateAllowed}}
<form action="{{.Link}}/update" method="post">
{{.CsrfTokenHtml}}
<button class="ui compact button" data-do="update">
<span class="ui text">{{$.i18n.Tr "repo.pulls.update_branch"}}</span>
</button>
</form>
{{end}}
</div>
Copy link
Member

@silverwind silverwind May 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can't provide a screenshot for this right now but it essentially styles the "Update Branch" button the same as in the screenshot for WIP removal. Previously, the button was misaligned because of floating right styling.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a screenshot:

afbeelding

</div>
{{end}}

Expand Down
6 changes: 5 additions & 1 deletion templates/repo/issue/view_content/sidebar.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@
</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>
<div class="toggle-wip" data-title="{{.Issue.Title}}" data-wip-prefix="{{(index .PullRequestWorkInProgressPrefixes 0| Escape)}}" data-update-url="{{$.RepoLink}}/issues/{{.Issue.Index}}/title">
<a class="muted">
{{.i18n.Tr "repo.pulls.still_in_progress"}} {{.i18n.Tr "repo.pulls.add_prefix" (index .PullRequestWorkInProgressPrefixes 0| Escape) | Safe}}
</a>
</div>
{{end}}
<div class="ui divider"></div>
{{end}}
Expand Down
15 changes: 6 additions & 9 deletions web_src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -909,17 +909,14 @@ async function initRepository() {
});

// Toggle WIP
$('.toggle-wip a').on('click', (e) => {
$('.toggle-wip a, .toggle-wip button').on('click', async (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'), {
const {title, wipPrefix, updateUrl} = e.currentTarget.closest('.toggle-wip').dataset;
await $.post(updateUrl, {
_csrf: csrf,
title: newTitle
}).done(reload);
return false;
title: title?.startsWith(wipPrefix) ? title.substr(wipPrefix.length).trim() : `${wipPrefix.trim()} ${title}`,
});
reload();
});

// Issue Comments
Expand Down