aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-06-11 12:14:22 +0200
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-06-11 12:14:29 +0200
commitca373f36b8517d938c0a9c8d27d484c33ab988f5 (patch)
tree6c317b5a1c94f019b9a07d9c7668507fe27ab783
parent4e45f2184c5f55f81e69e544a1cee25c0b765f9b (diff)
downloadsonarqube-ca373f36b8517d938c0a9c8d27d484c33ab988f5.tar.gz
sonarqube-ca373f36b8517d938c0a9c8d27d484c33ab988f5.zip
SONAR-5135 Add confirmation for all bulk actions
-rw-r--r--sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee9
-rw-r--r--sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee18
-rw-r--r--sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee4
-rw-r--r--sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs2
-rw-r--r--sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs21
-rw-r--r--sonar-server/src/main/less/style.less5
6 files changed, 36 insertions, 23 deletions
diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee
index 40d1eca0fb2..865a7435546 100644
--- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee
+++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-dropdown-view.coffee
@@ -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: ->
diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee
index 302fad6bec2..5c85d827d1c 100644
--- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee
+++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-bulk-change-view.coffee
@@ -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()
diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
index f8b52caec95..6b7a82cd3a5 100644
--- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
+++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
@@ -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: ->
diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs
index 372c3a1a8ea..f0fd7ea9316 100644
--- a/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs
+++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change-dropdown.hbs
@@ -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}}
diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs
index dcfbf2a21a7..837ca64225c 100644
--- a/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs
+++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-bulk-change.hbs
@@ -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>
diff --git a/sonar-server/src/main/less/style.less b/sonar-server/src/main/less/style.less
index 21a0b797066..0f5f917c758 100644
--- a/sonar-server/src/main/less/style.less
+++ b/sonar-server/src/main/less/style.less
@@ -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;