##// 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
275 if (msg) {
258 $('#pr_open_message').html(msg);
276 $('#pr_open_message').html(msg);
259
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();
@@ -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 }
567 $('.calculate-reviewers').hide();
568 prButtonLock(false, null, 'reviewers');
546 });
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();
General Comments 0
You need to be logged in to leave comments. Login now