]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5573 Make it possible to bulk (de)activate rules in several profiles at once
authorStas Vilchik <vilchiks@gmail.com>
Wed, 7 Jan 2015 09:07:11 +0000 (10:07 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Wed, 7 Jan 2015 09:12:18 +0000 (10:12 +0100)
server/sonar-web/src/main/hbs/coding-rules/coding-rules-bulk-change-modal.hbs
server/sonar-web/src/main/js/coding-rules/bulk-change-modal-view.js
server/sonar-web/src/main/less/ui.less
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 0ad2c90b68453ffccc53c8c19c032ca6226d7d70..28130ae5c8afd8bc48f7dee121c65dafb2a97e46 100644 (file)
@@ -23,7 +23,7 @@
           {{qualityProfileName}}{{#notEq action 'change-severity'}} — {{t 'are_you_sure'}}{{/notEq}}
         </h3>
       {{else}}
-        <select id="coding-rules-bulk-change-profile">
+        <select id="coding-rules-bulk-change-profile" multiple>
           {{#each availableQualityProfiles}}
             <option value="{{key}}">{{name}} - {{language}}</option>
           {{/each}}
index 93755794b3a3225172cc6e136471612a3bbb7147..f9d3a2839a99d7f78ce0d35f9c9603fdbf7a4ffc 100644 (file)
@@ -14,14 +14,18 @@ define([
       });
     },
 
-    showSuccessMessage: function (succeeded) {
-      var message = tp('coding_rules.bulk_change.success', succeeded);
-      this.ui.messagesContainer.html('<div class="message-notice">' + message + '</div>');
+    showSuccessMessage: function (profile, succeeded) {
+      var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }),
+          profileName = profileBase != null ? profileBase.name : profile,
+          message = tp('coding_rules.bulk_change.success', profileName, succeeded);
+      this.ui.messagesContainer.append('<div class="message-notice">' + message + '</div>');
     },
 
-    showWarnMessage: function (succeeded, failed) {
-      var message = tp('coding_rules.bulk_change.warning', succeeded, failed);
-      this.ui.messagesContainer.html('<div class="message-alert">' + message + '</div>');
+    showWarnMessage: function (profile, succeeded, failed) {
+      var profileBase = _.findWhere(this.options.app.qualityProfiles, { key: profile }),
+          profileName = profileBase != null ? profileBase.name : profile,
+          message = tp('coding_rules.bulk_change.warning', profileName, succeeded, failed);
+      this.ui.messagesContainer.append('<div class="message-alert">' + message + '</div>');
     },
 
     onRender: function () {
@@ -37,16 +41,20 @@ define([
       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,
-            profile_key: this.$('#coding-rules-bulk-change-profile').val() || this.options.param
+          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);
+              }
+            });
           });
-      $.post(url, options).done(function (r) {
-        if (r.failed) {
-          that.showWarnMessage(r.succeeded, r.failed);
-        } else {
-          that.showSuccessMessage(r.succeeded, r.failed);
-        }
+      this.ui.messagesContainer.empty();
+      $.when.apply($, requests).done(function () {
         that.$(that.ui.codingRulesSubmitBulkChange.selector).hide();
         window.process.finishBackgroundProcess(p);
       }).fail(function () {
index d0b840b128cee5b276d086ac77c5f2d86bbd42b0..5081ad535c1994325085d8579f029b23dcd2cdb8 100644 (file)
@@ -348,6 +348,18 @@ input[type=button] {
   color: #fff;
 }
 
+.message-notice + .message-notice,
+.message-notice + .message-alert,
+.message-notice + .message-error,
+.message-alert + .message-notice,
+.message-alert + .message-alert,
+.message-alert + .message-error,
+.message-error + .message-notice,
+.message-error + .message-alert,
+.message-error + .message-error {
+  margin-top: 5px;
+}
+
 
 
 /*
index 2736aef044b94f91aa93c0a523e38410a1c370ec..764a0571b117fb85f0094d3b0994c6165e57ada3 100644 (file)
@@ -1769,8 +1769,8 @@ coding_rules.add_note=Add Note
 coding_rules.add_tags=Add Tags
 coding_rules.available_since=Available Since
 coding_rules.bulk_change=Bulk Change
-coding_rules.bulk_change.success={0} rule(s) changed
-coding_rules.bulk_change.warning={0} rule(s) changed, {1} rule(s) ignored
+coding_rules.bulk_change.success={1} rule(s) changed in profile {0}
+coding_rules.bulk_change.warning={1} rule(s) changed, {2} rule(s) ignored in profile {0}
 coding_rules.change_severity=Change Severity
 coding_rules.change_severity_in=Change Severity In
 coding_rules.change_details=Change Details of Quality Profile