Show More
@@ -968,7 +968,7 b' class TestPullrequestsView(object):' | |||
|
968 | 968 | 'csrf_token': csrf_token}) |
|
969 | 969 | |
|
970 | 970 | assert response.status_int == 200 |
|
971 | assert response.body == 'true' | |
|
971 | assert response.body == '{"response": true, "redirect_url": null}' | |
|
972 | 972 | |
|
973 | 973 | # Make sure that after update, it won't raise 500 errors |
|
974 | 974 | response = self.app.get(route_path( |
@@ -1051,12 +1051,14 b' class RepoPullRequestsView(RepoAppView, ' | |||
|
1051 | 1051 | _ = self.request.translate |
|
1052 | 1052 | |
|
1053 | 1053 | self.load_default_context() |
|
1054 | redirect_url = None | |
|
1054 | 1055 | |
|
1055 | 1056 | if pull_request.is_closed(): |
|
1056 | 1057 | log.debug('update: forbidden because pull request is closed') |
|
1057 | 1058 | msg = _(u'Cannot update closed pull requests.') |
|
1058 | 1059 | h.flash(msg, category='error') |
|
1059 | return True | |
|
1060 | return {'response': True, | |
|
1061 | 'redirect_url': redirect_url} | |
|
1060 | 1062 | |
|
1061 | 1063 | if pull_request.pull_request_state != PullRequest.STATE_CREATED: |
|
1062 | 1064 | log.debug('update: forbidden because pull request is in state %s', |
@@ -1065,13 +1067,15 b' class RepoPullRequestsView(RepoAppView, ' | |||
|
1065 | 1067 | u'Current state is: `{}`').format(PullRequest.STATE_CREATED, |
|
1066 | 1068 | pull_request.pull_request_state) |
|
1067 | 1069 | h.flash(msg, category='error') |
|
1068 | return True | |
|
1070 | return {'response': True, | |
|
1071 | 'redirect_url': redirect_url} | |
|
1069 | 1072 | |
|
1070 | 1073 | # only owner or admin can update it |
|
1071 | 1074 | allowed_to_update = PullRequestModel().check_user_update( |
|
1072 | 1075 | pull_request, self._rhodecode_user) |
|
1073 | 1076 | if allowed_to_update: |
|
1074 | 1077 | controls = peppercorn.parse(self.request.POST.items()) |
|
1078 | force_refresh = str2bool(self.request.POST.get('force_refresh')) | |
|
1075 | 1079 | |
|
1076 | 1080 | if 'review_members' in controls: |
|
1077 | 1081 | self._update_reviewers( |
@@ -1079,11 +1083,18 b' class RepoPullRequestsView(RepoAppView, ' | |||
|
1079 | 1083 | pull_request.reviewer_data) |
|
1080 | 1084 | elif str2bool(self.request.POST.get('update_commits', 'false')): |
|
1081 | 1085 | self._update_commits(pull_request) |
|
1086 | if force_refresh: | |
|
1087 | redirect_url = h.route_path( | |
|
1088 | 'pullrequest_show', repo_name=self.db_repo_name, | |
|
1089 | pull_request_id=pull_request.pull_request_id, | |
|
1090 | _query={"force_refresh": 1}) | |
|
1082 | 1091 | elif str2bool(self.request.POST.get('edit_pull_request', 'false')): |
|
1083 | 1092 | self._edit_pull_request(pull_request) |
|
1084 | 1093 | else: |
|
1085 | 1094 | raise HTTPBadRequest() |
|
1086 | return True | |
|
1095 | ||
|
1096 | return {'response': True, | |
|
1097 | 'redirect_url': redirect_url} | |
|
1087 | 1098 | raise HTTPForbidden() |
|
1088 | 1099 | |
|
1089 | 1100 | def _edit_pull_request(self, pull_request): |
@@ -249,6 +249,54 b' input[type="button"] {' | |||
|
249 | 249 | |
|
250 | 250 | } |
|
251 | 251 | |
|
252 | ||
|
253 | .btn-group-actions { | |
|
254 | position: relative; | |
|
255 | z-index: 100; | |
|
256 | ||
|
257 | &:not(.open) .btn-action-switcher-container { | |
|
258 | display: none; | |
|
259 | } | |
|
260 | } | |
|
261 | ||
|
262 | ||
|
263 | .btn-action-switcher-container{ | |
|
264 | position: absolute; | |
|
265 | top: 30px; | |
|
266 | left: 0px; | |
|
267 | } | |
|
268 | ||
|
269 | .btn-action-switcher { | |
|
270 | display: block; | |
|
271 | position: relative; | |
|
272 | z-index: 300; | |
|
273 | min-width: 240px; | |
|
274 | max-width: 500px; | |
|
275 | margin-top: 4px; | |
|
276 | margin-bottom: 24px; | |
|
277 | font-size: 14px; | |
|
278 | font-weight: 400; | |
|
279 | padding: 8px 0; | |
|
280 | background-color: #fff; | |
|
281 | border: 1px solid @grey4; | |
|
282 | border-radius: 3px; | |
|
283 | box-shadow: @dropdown-shadow; | |
|
284 | ||
|
285 | li { | |
|
286 | display: block; | |
|
287 | text-align: left; | |
|
288 | list-style: none; | |
|
289 | padding: 5px 10px; | |
|
290 | } | |
|
291 | ||
|
292 | li .action-help-block { | |
|
293 | font-size: 10px; | |
|
294 | line-height: normal; | |
|
295 | color: @grey4; | |
|
296 | } | |
|
297 | ||
|
298 | } | |
|
299 | ||
|
252 | 300 | .btn-link { |
|
253 | 301 | background: transparent; |
|
254 | 302 | border: none; |
@@ -343,18 +343,29 b' var _updatePullRequest = function(repo_n' | |||
|
343 | 343 | } else { |
|
344 | 344 | postData.csrf_token = CSRF_TOKEN; |
|
345 | 345 | } |
|
346 | ||
|
346 | 347 | var success = function(o) { |
|
348 | var redirectUrl = o['redirect_url']; | |
|
349 | if (redirectUrl !== undefined && redirectUrl !== null && redirectUrl !== '') { | |
|
350 | window.location = redirectUrl; | |
|
351 | } else { | |
|
347 | 352 | window.location.reload(); |
|
353 | } | |
|
348 | 354 | }; |
|
355 | ||
|
349 | 356 | ajaxPOST(url, postData, success); |
|
350 | 357 | }; |
|
351 | 358 | |
|
352 | 359 | /** |
|
353 | 360 | * PULL REQUEST update commits |
|
354 | 361 | */ |
|
355 | var updateCommits = function(repo_name, pull_request_id) { | |
|
362 | var updateCommits = function(repo_name, pull_request_id, force) { | |
|
356 | 363 | var postData = { |
|
357 |
'update_commits': true |
|
|
364 | 'update_commits': true | |
|
365 | }; | |
|
366 | if (force !== undefined && force === true) { | |
|
367 | postData['force_refresh'] = true | |
|
368 | } | |
|
358 | 369 | _updatePullRequest(repo_name, pull_request_id, postData); |
|
359 | 370 | }; |
|
360 | 371 | |
@@ -549,4 +560,49 b' VersionController = function () {' | |||
|
549 | 560 | return false |
|
550 | 561 | } |
|
551 | 562 | |
|
563 | }; | |
|
564 | ||
|
565 | ||
|
566 | UpdatePrController = function () { | |
|
567 | var self = this; | |
|
568 | this.$updateCommits = $('#update_commits'); | |
|
569 | this.$updateCommitsSwitcher = $('#update_commits_switcher'); | |
|
570 | ||
|
571 | this.lockUpdateButton = function (label) { | |
|
572 | self.$updateCommits.attr('disabled', 'disabled'); | |
|
573 | self.$updateCommitsSwitcher.attr('disabled', 'disabled'); | |
|
574 | ||
|
575 | self.$updateCommits.addClass('disabled'); | |
|
576 | self.$updateCommitsSwitcher.addClass('disabled'); | |
|
577 | ||
|
578 | self.$updateCommits.removeClass('btn-primary'); | |
|
579 | self.$updateCommitsSwitcher.removeClass('btn-primary'); | |
|
580 | ||
|
581 | self.$updateCommits.text(_gettext(label)); | |
|
582 | }; | |
|
583 | ||
|
584 | this.isUpdateLocked = function () { | |
|
585 | return self.$updateCommits.attr('disabled') !== undefined; | |
|
586 | }; | |
|
587 | ||
|
588 | this.updateCommits = function (curNode) { | |
|
589 | if (self.isUpdateLocked()) { | |
|
590 | return | |
|
591 | } | |
|
592 | self.lockUpdateButton(_gettext('Updating...')); | |
|
593 | updateCommits( | |
|
594 | templateContext.repo_name, | |
|
595 | templateContext.pull_request_data.pull_request_id); | |
|
596 | }; | |
|
597 | ||
|
598 | this.forceUpdateCommits = function () { | |
|
599 | if (self.isUpdateLocked()) { | |
|
600 | return | |
|
601 | } | |
|
602 | self.lockUpdateButton(_gettext('Force updating...')); | |
|
603 | var force = true; | |
|
604 | updateCommits( | |
|
605 | templateContext.repo_name, | |
|
606 | templateContext.pull_request_data.pull_request_id, force); | |
|
607 | }; | |
|
552 | 608 | }; No newline at end of file |
@@ -68,8 +68,6 b'' | |||
|
68 | 68 | |
|
69 | 69 | <div class="pull-request-merge-refresh"> |
|
70 | 70 | <a href="#refreshChecks" onclick="refreshMergeChecks(); return false;">${_('refresh checks')}</a> |
|
71 | / | |
|
72 | <a class="tooltip" title="Force refresh of the merge workspace in case current status seems wrong." href="${h.route_path('pullrequest_show', repo_name=c.repo_name, pull_request_id=c.pull_request.pull_request_id,_query={"force_refresh":1})}">forced recheck</a> | |
|
73 | 71 | </div> |
|
74 | 72 | |
|
75 | 73 | </div> |
@@ -405,7 +405,30 b'' | |||
|
405 | 405 | |
|
406 | 406 | <div class="pull-right"> |
|
407 | 407 | % if c.allowed_to_update and not c.pull_request.is_closed(): |
|
408 | <a id="update_commits" class="btn btn-primary no-margin pull-right">${_('Update commits')}</a> | |
|
408 | ||
|
409 | <div class="btn-group btn-group-actions"> | |
|
410 | <a id="update_commits" class="btn btn-primary no-margin" onclick="updateController.updateCommits(this); return false"> | |
|
411 | ${_('Update commits')} | |
|
412 | </a> | |
|
413 | ||
|
414 | <a id="update_commits_switcher" class="btn btn-primary" style="margin-left: -1px" data-toggle="dropdown" aria-pressed="false" role="button"> | |
|
415 | <i class="icon-down"></i> | |
|
416 | </a> | |
|
417 | ||
|
418 | <div class="btn-action-switcher-container" id="update-commits-switcher"> | |
|
419 | <ul class="btn-action-switcher" role="menu"> | |
|
420 | <li> | |
|
421 | <a href="#forceUpdate" onclick="updateController.forceUpdateCommits(this); return false"> | |
|
422 | ${_('Force update commits')} | |
|
423 | </a> | |
|
424 | <div class="action-help-block"> | |
|
425 | ${_('Update commits and force refresh this pull request.')} | |
|
426 | </div> | |
|
427 | </li> | |
|
428 | </ul> | |
|
429 | </div> | |
|
430 | </div> | |
|
431 | ||
|
409 | 432 |
|
|
410 | 433 | <a class="tooltip btn disabled pull-right" disabled="disabled" title="${_('Update is disabled for current view')}">${_('Update commits')}</a> |
|
411 | 434 | % endif |
@@ -584,6 +607,8 b'' | |||
|
584 | 607 | reviewersController = new ReviewersController(); |
|
585 | 608 | commitsController = new CommitsController(); |
|
586 | 609 | |
|
610 | updateController = new UpdatePrController(); | |
|
611 | ||
|
587 | 612 | $(function(){ |
|
588 | 613 | |
|
589 | 614 | // custom code mirror |
@@ -746,17 +771,7 b'' | |||
|
746 | 771 | "${c.repo_name}", "${c.pull_request.pull_request_id}"); |
|
747 | 772 | }); |
|
748 | 773 | |
|
749 | $('#update_commits').on('click', function(e){ | |
|
750 | var isDisabled = !$(e.currentTarget).attr('disabled'); | |
|
751 | $(e.currentTarget).attr('disabled', 'disabled'); | |
|
752 | $(e.currentTarget).addClass('disabled'); | |
|
753 | $(e.currentTarget).removeClass('btn-primary'); | |
|
754 | $(e.currentTarget).text(_gettext('Updating...')); | |
|
755 | if(isDisabled){ | |
|
756 | updateCommits( | |
|
757 | "${c.repo_name}", "${c.pull_request.pull_request_id}"); | |
|
758 | } | |
|
759 | }); | |
|
774 | ||
|
760 | 775 | // fixing issue with caches on firefox |
|
761 | 776 | $('#update_commits').removeAttr("disabled"); |
|
762 | 777 |
General Comments 0
You need to be logged in to leave comments.
Login now