From: Stas Vilchik Date: Thu, 8 Jan 2015 14:08:16 +0000 (+0100) Subject: SONAR-5573 Make it possible to bulk (de)activate rules in several profiles at once X-Git-Tag: latest-silver-master-#65~290 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d8eb2b69d8af7500d3bda35a99cf00923116798a;p=sonarqube.git SONAR-5573 Make it possible to bulk (de)activate rules in several profiles at once Make the requests sequential --- diff --git a/server/sonar-web/src/main/js/coding-rules/bulk-change-modal-view.js b/server/sonar-web/src/main/js/coding-rules/bulk-change-modal-view.js index f9d3a2839a9..571b97b76d6 100644 --- a/server/sonar-web/src/main/js/coding-rules/bulk-change-modal-view.js +++ b/server/sonar-web/src/main/js/coding-rules/bulk-change-modal-view.js @@ -38,23 +38,30 @@ define([ onFormSubmit: function () { ModalFormView.prototype.onFormSubmit.apply(this, arguments); + var url = baseUrl + '/api/qualityprofiles/' + this.options.action + '_rules', + options = _.extend({}, this.options.app.state.get('query'), { wsAction: this.options.action }), + profiles = this.$('#coding-rules-bulk-change-profile').val() || [this.options.param]; + this.ui.messagesContainer.empty(); + this.sendRequests(url, options, profiles); + }, + + sendRequests: function (url, options, profiles) { var that = this, p = window.process.addBackgroundProcess(), - url = baseUrl + '/api/qualityprofiles/' + this.options.action + '_rules', - options = _.extend({}, this.options.app.state.get('query'), { wsAction: this.options.action }), - profiles = this.$('#coding-rules-bulk-change-profile').val() || [this.options.param], - requests = profiles.map(function (profile) { - var opts = _.extend({}, options, { profile_key: profile }); - return $.post(url, opts).done(function (r) { - if (r.failed) { - that.showWarnMessage(profile, r.succeeded, r.failed); - } else { - that.showSuccessMessage(profile, r.succeeded); - } - }); + looper = $.Deferred().resolve(); + profiles.forEach(function (profile) { + var opts = _.extend({}, options, { profile_key: profile }); + looper = looper.then(function () { + return $.post(url, opts).done(function (r) { + if (r.failed) { + that.showWarnMessage(profile, r.succeeded, r.failed); + } else { + that.showSuccessMessage(profile, r.succeeded); + } }); - this.ui.messagesContainer.empty(); - $.when.apply($, requests).done(function () { + }); + }); + looper.done(function () { that.$(that.ui.codingRulesSubmitBulkChange.selector).hide(); window.process.finishBackgroundProcess(p); }).fail(function () {