##// END OF EJS Templates
pull-requests: wait for all dynamic checks before enabling opening a PR.
marcink -
r1276:7a9c1981 default
parent child Browse files
Show More
@@ -107,6 +107,7 b''
107 107 <div class="reviewers-title block-right">
108 108 <div class="pr-details-title">
109 109 ${_('Pull request reviewers')}
110 <span class="calculate-reviewers"> - ${_('loading...')}</span>
110 111 </div>
111 112 </div>
112 113 <div id="reviewers" class="block-right pr-details-content reviewers">
@@ -247,16 +248,33 b''
247 248 query.callback({results: data.results});
248 249 };
249 250
250 var prButtonLock = function(lockEnabled, msg) {
251
252 var prButtonLockChecks = {
253 'compare': false,
254 'reviewers': false
255 };
256
257 var prButtonLock = function(lockEnabled, msg, scope) {
258 scope = scope || 'all';
259 if (scope == 'all'){
260 prButtonLockChecks['compare'] = !lockEnabled;
261 prButtonLockChecks['reviewers'] = !lockEnabled;
262 } else if (scope == 'compare') {
263 prButtonLockChecks['compare'] = !lockEnabled;
264 } else if (scope == 'reviewers'){
265 prButtonLockChecks['reviewers'] = !lockEnabled;
266 }
267 var checksMeet = prButtonLockChecks.compare && prButtonLockChecks.reviewers;
251 268 if (lockEnabled) {
252 269 $('#save').attr('disabled', 'disabled');
253 270 }
254 else {
271 else if (checksMeet) {
255 272 $('#save').removeAttr('disabled');
256 273 }
257 274
258 $('#pr_open_message').html(msg);
259
275 if (msg) {
276 $('#pr_open_message').html(msg);
277 }
260 278 };
261 279
262 280 var loadRepoRefDiffPreview = function() {
@@ -284,7 +302,7 b''
284 302 var url = pyroutes.url('compare_url', url_data);
285 303
286 304 // lock PR button, so we cannot send PR before it's calculated
287 prButtonLock(true, "${_('Loading compare ...')}");
305 prButtonLock(true, "${_('Loading compare ...')}", 'compare');
288 306
289 307 if (loadRepoRefDiffPreview._currentRequest) {
290 308 loadRepoRefDiffPreview._currentRequest.abort();
@@ -340,10 +358,10 b''
340 358
341 359 if (commitElements.length) {
342 360 var commitsLink = '<a href="#pull_request_overview"><strong>{0}</strong></a>'.format(commitElements.length);
343 prButtonLock(false, msg.replace('__COMMITS__', commitsLink));
361 prButtonLock(false, msg.replace('__COMMITS__', commitsLink), 'compare');
344 362 }
345 363 else {
346 prButtonLock(true, "${_('There are no commits to merge.')}");
364 prButtonLock(true, "${_('There are no commits to merge.')}", 'compare');
347 365 }
348 366
349 367
@@ -391,7 +409,7 b''
391 409 var globalDefaults = {
392 410 dropdownAutoWidth: true,
393 411 containerCssClass: "drop-menu",
394 dropdownCssClass: "drop-menu-dropdown",
412 dropdownCssClass: "drop-menu-dropdown"
395 413 };
396 414
397 415 var initSelect2 = function(defaultOptions) {
@@ -422,7 +440,7 b''
422 440 element.select2('val', defaultSourceRepo);
423 441 if (readOnly === true) {
424 442 element.select2('readonly', true);
425 };
443 }
426 444 }
427 445 };
428 446 };
@@ -519,6 +537,9 b''
519 537 if (loadDefaultReviewers._currentRequest) {
520 538 loadDefaultReviewers._currentRequest.abort();
521 539 }
540 $('.calculate-reviewers').show();
541 prButtonLock(true, null, 'reviewers');
542
522 543 var url = pyroutes.url('repo_default_reviewers_data', {'repo_name': targetRepoName});
523 544
524 545 var sourceRepo = $sourceRepo.eq(0).val();
@@ -531,7 +552,7 b''
531 552 url += '&target_ref=' + targetRef[2];
532 553
533 554 loadDefaultReviewers._currentRequest = $.get(url)
534 .done(function(data) {
555 .done(function(data) {
535 556 loadDefaultReviewers._currentRequest = null;
536 557
537 558 // reset && add the reviewer based on selected repo
@@ -543,9 +564,12 b''
543 564 reviewer.lastname, reviewer.username,
544 565 reviewer.gravatar_link, reviewer.reasons);
545 566 }
546 });
567 $('.calculate-reviewers').hide();
568 prButtonLock(false, null, 'reviewers');
569 });
547 570 };
548 prButtonLock(true, "${_('Please select origin and destination')}");
571
572 prButtonLock(true, "${_('Please select origin and destination')}", 'all');
549 573
550 574 // auto-load on init, the target refs select2
551 575 calculateContainerWidth();
@@ -555,12 +579,12 b''
555 579 $(this).removeClass('autogenerated-title');
556 580 });
557 581
558 %if c.default_source_ref:
582 % if c.default_source_ref:
559 583 // in case we have a pre-selected value, use it now
560 584 $sourceRef.select2('val', '${c.default_source_ref}');
561 585 loadRepoRefDiffPreview();
562 586 loadDefaultReviewers();
563 %endif
587 % endif
564 588
565 589 ReviewerAutoComplete('user');
566 590 });
General Comments 0
You need to be logged in to leave comments. Login now