pull-requests: use close logic next to merge.

- close and merge are both pr closing actions and should be groupped together
- refresh checks also will change the approved/declined status
This commit is contained in:
Marcin Kuzminski 2019-10-08 13:31:34 +02:00
parent a86f0089a2
commit b50f97b262
3 changed files with 25 additions and 28 deletions

View file

@ -1795,6 +1795,10 @@ BIN_FILENODE = 7
margin-bottom: 20px;
}
.pull-request-merge-refresh {
margin: 2px 7px;
}
.pull-request-merge ul {
padding: 0px 0px;
}

View file

@ -52,30 +52,34 @@
<div>
${h.secure_form(h.route_path('pullrequest_merge', repo_name=c.repo_name, pull_request_id=c.pull_request.pull_request_id), id='merge_pull_request_form', request=request)}
<% merge_disabled = ' disabled' if c.pr_merge_possible is False else '' %>
<a class="btn" href="#" onclick="refreshMergeChecks(); return false;">${_('refresh checks')}</a>
<input type="submit" id="merge_pull_request" value="${_('Merge Pull Request')}" class="btn${merge_disabled}"${merge_disabled}>
% if c.allowed_to_close:
## close PR action, injected later next to COMMENT button
% if c.pull_request_review_status == c.REVIEW_STATUS_APPROVED:
<a id="close-pull-request-action" class="btn btn-approved-status" href="#close-as-approved" onclick="closePullRequest('${c.REVIEW_STATUS_APPROVED}'); return false;">
${_('Close with status {}').format(h.commit_status_lbl(c.REVIEW_STATUS_APPROVED))}
</a>
% else:
<a id="close-pull-request-action" class="btn btn-rejected-status" href="#close-as-rejected" onclick="closePullRequest('${c.REVIEW_STATUS_REJECTED}'); return false;">
${_('Close with status {}').format(h.commit_status_lbl(c.REVIEW_STATUS_REJECTED))}
</a>
% endif
% endif
<input type="submit" id="merge_pull_request" value="${_('Merge and close Pull Request')}" class="btn${merge_disabled}"${merge_disabled}>
${h.end_form()}
<div class="pull-request-merge-refresh">
<a href="#refreshChecks" onclick="refreshMergeChecks(); return false;">${_('refresh checks')}</a>
</div>
</div>
% elif c.rhodecode_user.username != h.DEFAULT_USER:
<a class="btn" href="#" onclick="refreshMergeChecks(); return false;">${_('refresh checks')}</a>
<input type="submit" value="${_('Merge Pull Request')}" class="btn disabled" disabled="disabled" title="${_('You are not allowed to merge this pull request.')}">
<input type="submit" value="${_('Merge and close Pull Request')}" class="btn disabled" disabled="disabled" title="${_('You are not allowed to merge this pull request.')}">
% else:
<input type="submit" value="${_('Login to Merge this Pull Request')}" class="btn disabled" disabled="disabled">
% endif
</div>
% if c.allowed_to_close:
## close PR action, injected later next to COMMENT button
<div id="close-pull-request-action" style="display: none">
% if c.pull_request_review_status == c.REVIEW_STATUS_APPROVED:
<a class="btn btn-approved-status" href="#close-as-approved" onclick="closePullRequest('${c.REVIEW_STATUS_APPROVED}'); return false;">
${_('Close with status {}').format(h.commit_status_lbl(c.REVIEW_STATUS_APPROVED))}
</a>
% else:
<a class="btn btn-rejected-status" href="#close-as-rejected" onclick="closePullRequest('${c.REVIEW_STATUS_REJECTED}'); return false;">
${_('Close with status {}').format(h.commit_status_lbl(c.REVIEW_STATUS_REJECTED))}
</a>
% endif
</div>
% endif
</div>

View file

@ -692,19 +692,10 @@
$('.pull-request-merge').css('opacity', 1);
$('.action-buttons-extra').css('opacity', 1);
injectCloseAction();
}
);
};
injectCloseAction = function() {
var closeAction = $('#close-pull-request-action').html();
var $actionButtons = $('.action-buttons-extra');
// clear the action before
$actionButtons.html("");
$actionButtons.html(closeAction);
};
closePullRequest = function (status) {
// inject closing flag
$('.action-buttons-extra').append('<input type="hidden" class="close-pr-input" id="close_pull_request" value="1">');
@ -800,8 +791,6 @@
window.commentFormGlobalSubmitSuccessCallback = function(){
refreshMergeChecks();
};
// initial injection
injectCloseAction();
ReviewerAutoComplete('#user');