]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5135 Add confirmation for all bulk actions
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 11 Jun 2014 10:14:22 +0000 (12:14 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Wed, 11 Jun 2014 10:14:29 +0000 (12:14 +0200)
sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee
sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee
sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs
sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs
sonar-server/src/main/less/style.less

index 40d1eca0fb2e646b86a7edd19a46831d60ad43c6..865a7435546de826227b1e6017da0b28b1e18c2f 100644 (file)
@@ -18,14 +18,7 @@ define [
     doAction: (e) ->
       action = jQuery(e.currentTarget).data 'action'
       param = jQuery(e.currentTarget).data 'param'
-      unless param
-        @options.app.codingRulesBulkChangeView.show action
-      else
-        query = @options.app.getQuery()
-        _.extend query,
-          profile_key: param
-          wsAction: action
-        @options.app.codingRulesBulkChangeView.bulkChange query
+      @options.app.codingRulesBulkChangeView.show action, param
 
 
     onRender: ->
index 302fad6bec2428f9d9ae1657253cbbf77e77a36a..5c85d827d1c811d2936153c8031795d7f77054c4 100644 (file)
@@ -43,8 +43,9 @@ define [
         escapeMarkup: (m) -> m
 
 
-    show: (action) ->
+    show: (action, param = null) ->
       @action = action
+      @profile = param
       @render()
       @$el.dialog 'open'
 
@@ -59,12 +60,12 @@ define [
       if @action == 'activate' || @action == 'deactivate'
         _.extend query,
           wsAction: @action
-          profile_key: @$('#coding-rules-bulk-change-profile').val()
+          profile_key: @$('#coding-rules-bulk-change-profile').val() or @profile
 
       if @action == 'change-severity'
         _.extend query,
           wsAction: 'activate'
-          profile_key: @options.app.getQualityProfile()
+          profile_key: @profile
           activation_severity: @$('#coding-rules-bulk-change-severity').val()
 
       query
@@ -73,17 +74,24 @@ define [
     bulkChange: (query) ->
       wsAction = query.wsAction
       query = _.omit(query, 'wsAction')
+
+      origFooter = @$('.modal-foot').html()
+      @$('.modal-foot').html '<i class="spinner"></i>'
+
       jQuery.ajax
         type: 'POST'
         url: "#{baseUrl}/api/qualityprofiles/#{wsAction}_rules"
         data: query
       .done =>
         @options.app.fetchFirstPage(true)
+        @hide()
+      .fail =>
+        @$('.modal-foot').html origFooter
 
 
     onSubmit: (e) ->
       e.preventDefault()
-      @bulkChange(@prepareQuery()).done => @hide()
+      @bulkChange(@prepareQuery())
 
 
     getAvailableQualityProfiles: ->
@@ -101,7 +109,7 @@ define [
       paging: @options.app.codingRules.paging
       qualityProfiles: @options.app.qualityProfiles
 
-      qualityProfile: @options.app.getQualityProfile()
+      qualityProfile: @profile
       qualityProfileName: @options.app.qualityProfileFilter.view.renderValue()
 
       availableQualityProfiles: @getAvailableQualityProfiles()
index f8b52caec95ec419e69c2dd7c90e38030a744a76..6b7a82cd3a5b5e38ee4a08bb5ffad40afc4147d3 100644 (file)
@@ -36,7 +36,9 @@ define [
           profileKey = @model.get('key')
       severity = @ui.qualityProfileSeverity.val()
 
+      origFooter = @$('.modal-foot').html()
       @$('.modal-foot').html '<i class="spinner"></i>'
+
       ruleKey = @rule.get('key')
       jQuery.ajax
         type: 'POST'
@@ -49,6 +51,8 @@ define [
       .done =>
           @options.app.showRule ruleKey
           @hide()
+      .fail =>
+          @$('.modal-foot').html origFooter
 
 
     onRender: ->
index 372c3a1a8ea7418800fede4420d50cc102a8532f..f0fd7ea9316a5dd2bdfec9c109bfc9523aadbd3a 100644 (file)
@@ -33,7 +33,7 @@
 {{! severity }}
 
 {{#eq activation 'true'}}
-  <a class="coding-rules-bulk-change-dropdown-link" data-action="change-severity">
+  <a class="coding-rules-bulk-change-dropdown-link" data-action="change-severity" data-param="{{qualityProfile}}">
     {{t 'coding_rules.change_severity_in'}} <strong>{{qualityProfileName}}</strong>
   </a>
 {{/eq}}
index dcfbf2a21a7dfb56be30420ac51d4d65024b8647..837ca64225cebad7cc453608eeb8e70c8f597050 100644 (file)
@@ -1,38 +1,41 @@
 <form>
   <div class="modal-head">
     {{#eq action 'activate'}}
-      <h2>{{t 'coding_rules.activate_in_quality_profile'}} ({{paging.fTotal}} {{t 'coding_rules._rules'}})</h2>
+      <h2>{{t 'coding_rules.activate_in_quality_profile'}} ({{paging.total}} {{t 'coding_rules._rules'}})</h2>
     {{/eq}}
     {{#eq action 'deactivate'}}
-      <h2>{{t 'coding_rules.deactivate_in_quality_profile'}} ({{paging.fTotal}} {{t 'coding_rules._rules'}})</h2>
+      <h2>{{t 'coding_rules.deactivate_in_quality_profile'}} ({{paging.total}} {{t 'coding_rules._rules'}})</h2>
     {{/eq}}
     {{#eq action 'change-severity'}}
-      <h2>{{t 'coding_rules.change_severity'}} ({{paging.fTotal}} {{t 'coding_rules._rules'}})</h2>
+      <h2>{{t 'coding_rules.change_severity'}} ({{paging.total}} {{t 'coding_rules._rules'}})</h2>
     {{/eq}}
   </div>
 
   <div class="modal-body">
     <div class="modal-error"></div>
 
-    {{#notEq action 'change-severity'}}
     <div class="modal-field">
-      <label for="coding-rules-bulk-change-activate-on">
+      <h3><label for="coding-rules-bulk-change-profile">
+        {{#eq action 'change-severity'}}{{t 'coding_rules.change_severity_in'}}{{/eq}}
         {{#eq action 'activate'}}{{t 'coding_rules.activate_in'}}{{/eq}}
         {{#eq action 'deactivate'}}{{t 'coding_rules.deactivate_in'}}{{/eq}}
-      </label>
+      </label></h3>
+      {{#if qualityProfile}}
+        <h3 class="readonly-field">{{qualityProfileName}}</h3>
+      {{else}}
         <select id="coding-rules-bulk-change-profile">
           {{#each availableQualityProfiles}}
             <option value="{{key}}">{{name}}</option>
           {{/each}}
         </select>
-      </div>
-    {{/notEq}}
+      {{/if}}
+    </div>
 
 
     {{#eq action 'change-severity'}}
       {{#if qualityProfile}}
         <div class="modal-field">
-          <label for="coding-rules-bulk-change-severity">{{t 'coding_rules.change_severity'}}</label>
+          <h3><label for="coding-rules-bulk-change-severity">{{t 'severity'}}</label></h3>
           <select id="coding-rules-bulk-change-severity">
             {{#each severities}}
               <option value="{{this}}">{{t 'severity' this}}</option>
index 21a0b79706614df3af9401e1ad54eb25fc06cf38..0f5f917c7580fe6224d5afb64da6888e0db37970 100644 (file)
@@ -2496,6 +2496,11 @@ ul.modal-head-metadata li {
   }
 }
 
+.readonly-field {
+  padding-top: 5px;
+  line-height: 1;
+}
+
 .modal-field input {
   margin-right: 5px;
   margin-bottom: 10px;