##// 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 <div class="reviewers-title block-right">
107 <div class="reviewers-title block-right">
108 <div class="pr-details-title">
108 <div class="pr-details-title">
109 ${_('Pull request reviewers')}
109 ${_('Pull request reviewers')}
110 <span class="calculate-reviewers"> - ${_('loading...')}</span>
110 </div>
111 </div>
111 </div>
112 </div>
112 <div id="reviewers" class="block-right pr-details-content reviewers">
113 <div id="reviewers" class="block-right pr-details-content reviewers">
@@ -247,16 +248,33 b''
247 query.callback({results: data.results});
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 if (lockEnabled) {
268 if (lockEnabled) {
252 $('#save').attr('disabled', 'disabled');
269 $('#save').attr('disabled', 'disabled');
253 }
270 }
254 else {
271 else if (checksMeet) {
255 $('#save').removeAttr('disabled');
272 $('#save').removeAttr('disabled');
256 }
273 }
257
274
258 $('#pr_open_message').html(msg);
275 if (msg) {
259
276 $('#pr_open_message').html(msg);
277 }
260 };
278 };
261
279
262 var loadRepoRefDiffPreview = function() {
280 var loadRepoRefDiffPreview = function() {
@@ -284,7 +302,7 b''
284 var url = pyroutes.url('compare_url', url_data);
302 var url = pyroutes.url('compare_url', url_data);
285
303
286 // lock PR button, so we cannot send PR before it's calculated
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 if (loadRepoRefDiffPreview._currentRequest) {
307 if (loadRepoRefDiffPreview._currentRequest) {
290 loadRepoRefDiffPreview._currentRequest.abort();
308 loadRepoRefDiffPreview._currentRequest.abort();
@@ -340,10 +358,10 b''
340
358
341 if (commitElements.length) {
359 if (commitElements.length) {
342 var commitsLink = '<a href="#pull_request_overview"><strong>{0}</strong></a>'.format(commitElements.length);
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 else {
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 var globalDefaults = {
409 var globalDefaults = {
392 dropdownAutoWidth: true,
410 dropdownAutoWidth: true,
393 containerCssClass: "drop-menu",
411 containerCssClass: "drop-menu",
394 dropdownCssClass: "drop-menu-dropdown",
412 dropdownCssClass: "drop-menu-dropdown"
395 };
413 };
396
414
397 var initSelect2 = function(defaultOptions) {
415 var initSelect2 = function(defaultOptions) {
@@ -422,7 +440,7 b''
422 element.select2('val', defaultSourceRepo);
440 element.select2('val', defaultSourceRepo);
423 if (readOnly === true) {
441 if (readOnly === true) {
424 element.select2('readonly', true);
442 element.select2('readonly', true);
425 };
443 }
426 }
444 }
427 };
445 };
428 };
446 };
@@ -519,6 +537,9 b''
519 if (loadDefaultReviewers._currentRequest) {
537 if (loadDefaultReviewers._currentRequest) {
520 loadDefaultReviewers._currentRequest.abort();
538 loadDefaultReviewers._currentRequest.abort();
521 }
539 }
540 $('.calculate-reviewers').show();
541 prButtonLock(true, null, 'reviewers');
542
522 var url = pyroutes.url('repo_default_reviewers_data', {'repo_name': targetRepoName});
543 var url = pyroutes.url('repo_default_reviewers_data', {'repo_name': targetRepoName});
523
544
524 var sourceRepo = $sourceRepo.eq(0).val();
545 var sourceRepo = $sourceRepo.eq(0).val();
@@ -531,7 +552,7 b''
531 url += '&target_ref=' + targetRef[2];
552 url += '&target_ref=' + targetRef[2];
532
553
533 loadDefaultReviewers._currentRequest = $.get(url)
554 loadDefaultReviewers._currentRequest = $.get(url)
534 .done(function(data) {
555 .done(function(data) {
535 loadDefaultReviewers._currentRequest = null;
556 loadDefaultReviewers._currentRequest = null;
536
557
537 // reset && add the reviewer based on selected repo
558 // reset && add the reviewer based on selected repo
@@ -543,9 +564,12 b''
543 reviewer.lastname, reviewer.username,
564 reviewer.lastname, reviewer.username,
544 reviewer.gravatar_link, reviewer.reasons);
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 // auto-load on init, the target refs select2
574 // auto-load on init, the target refs select2
551 calculateContainerWidth();
575 calculateContainerWidth();
@@ -555,12 +579,12 b''
555 $(this).removeClass('autogenerated-title');
579 $(this).removeClass('autogenerated-title');
556 });
580 });
557
581
558 %if c.default_source_ref:
582 % if c.default_source_ref:
559 // in case we have a pre-selected value, use it now
583 // in case we have a pre-selected value, use it now
560 $sourceRef.select2('val', '${c.default_source_ref}');
584 $sourceRef.select2('val', '${c.default_source_ref}');
561 loadRepoRefDiffPreview();
585 loadRepoRefDiffPreview();
562 loadDefaultReviewers();
586 loadDefaultReviewers();
563 %endif
587 % endif
564
588
565 ReviewerAutoComplete('user');
589 ReviewerAutoComplete('user');
566 });
590 });
General Comments 0
You need to be logged in to leave comments. Login now