]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 Replace browser confirm dialogs with custom ones
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Mon, 30 Jun 2014 09:43:10 +0000 (11:43 +0200)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Mon, 30 Jun 2014 09:48:12 +0000 (11:48 +0200)
sonar-core/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-custom-rule-view.coffee
sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee
sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee

index 0e99bdfbadc7d1f48205478c9bb77586ef934bc9..4bbaadf924fb8fdd4a646c1da83c2cb30156ecdd 100644 (file)
@@ -1714,6 +1714,7 @@ coding_rules.custom_rules=Custom Rules
 coding_rules.extend_description=Extend Description
 coding_rules.deactivate_in=Deactivate In
 coding_rules.deactivate=Deactivate
+coding_rules.deactivate.confirm=Are you sure you want to deactivate this rule in profile {0}?
 coding_rules.deactivate_in_quality_profile=Deactivate In Quality Profile
 coding_rules.deactivate_in_all_quality_profiles=Deactivate In All {0} Profiles
 coding_rules.found=Found
@@ -1739,6 +1740,7 @@ coding_rules.reactivate.help=A rule with the same key has been previously delete
 coding_rules.remove_extended_description.confirm=Are you sure you want to remove the extended description?
 coding_rules.repository=Repository:
 coding_rules.revert_to_parent_definition=Revert to Parent Definition
+coding_rules.revert_to_parent_definition.confirm=This rule will be reverted to the parameters defined in profile {0}. Are you sure?
 coding_rules.rule_template=Rule Template
 coding_rules.rule_template.title=This rule can be used as a template to create custom rules,\nit cannot be activated on a profile
 coding_rules._rules=rules
index 3a8454b78aae9e765802082f92770bf6d13713aa..216704641efe6728dab3fe1354ab68fce8759554 100644 (file)
@@ -18,20 +18,23 @@ define [
       'click @ui.delete': 'delete'
 
     delete: ->
-      if confirm(t 'are_you_sure')
-        origEl = @$el.html()
-        @$el.html '<i class="spinner"></i>'
+      confirmDialog
+        title: t 'delete'
+        html: t 'are_you_sure'
+        yesHandler: =>
+          origEl = @$el.html()
+          @$el.html '<i class="spinner"></i>'
 
-        jQuery.ajax
-          type: 'POST'
-          url: "#{baseUrl}/api/rules/delete"
-          data:
-            key: @model.get 'key'
-        .done =>
-          templateKey = @options.templateKey or @options.templateRule.get 'key'
-          @options.app.showRule templateKey
-        .fail =>
-          @$el.html origEl
+          jQuery.ajax
+            type: 'POST'
+            url: "#{baseUrl}/api/rules/delete"
+            data:
+              key: @model.get 'key'
+          .done =>
+            templateKey = @options.templateKey or @options.templateRule.get 'key'
+            @options.app.showRule templateKey
+          .fail =>
+            @$el.html origEl
 
     serializeData: ->
       _.extend super,
index 1ec9154d71b32a09bbfbcc66c308d81ae13465aa..7a1544bc9c4af9cb70d1575459ac48fd7fc0b98d 100644 (file)
@@ -34,30 +34,36 @@ define [
 
     revert: ->
       ruleKey = @options.rule.get('key')
-      if confirm t 'are_you_sure'
-        that = @
-        jQuery.ajax
-          type: 'POST'
-          url: "#{baseUrl}/api/qualityprofiles/activate_rule"
-          data:
+      confirmDialog
+        title: t 'coding_rules.revert_to_parent_definition'
+        html: tp 'coding_rules.revert_to_parent_definition.confirm', @getParent().name
+        yesHandler: =>
+          jQuery.ajax
+            type: 'POST'
+            url: "#{baseUrl}/api/qualityprofiles/activate_rule"
+            data:
               profile_key: @model.get('qProfile')
               rule_key: ruleKey
               reset: true
-        .done =>
-          @options.app.showRule ruleKey
+          .done =>
+            @options.app.showRule ruleKey
 
 
     deactivate: ->
       ruleKey = @options.rule.get('key')
-      if confirm t 'are_you_sure'
-        jQuery.ajax
-          type: 'POST'
-          url: "#{baseUrl}/api/qualityprofiles/deactivate_rule"
-          data:
-            profile_key: @model.get('qProfile')
-            rule_key: ruleKey
-        .done =>
-          @options.app.showRule ruleKey
+      myProfile = _.findWhere(@options.app.qualityProfiles, key: @model.get('qProfile'))
+      confirmDialog
+        title: t 'coding_rules.deactivate'
+        html: tp 'coding_rules.deactivate.confirm', myProfile.name
+        yesHandler: =>
+          jQuery.ajax
+            type: 'POST'
+            url: "#{baseUrl}/api/qualityprofiles/deactivate_rule"
+            data:
+              profile_key: @model.get('qProfile')
+              rule_key: ruleKey
+          .done =>
+            @options.app.showRule ruleKey
 
 
     enableUpdate: ->
index 5770275f8b10e743735f8887f2f6a529d4c52fa5..920dd632376b54a0d02d2d624982985951d7d1ff 100644 (file)
@@ -235,9 +235,11 @@ define [
 
 
     removeExtendedDescription: ->
-      if confirm(t 'coding_rules.remove_extended_description.confirm')
-        @ui.extendDescriptionText.val ''
-        @submitExtendDescription()
+      confirmDialog
+        html: t 'coding_rules.remove_extended_description.confirm'
+        yesHandler: =>
+          @ui.extendDescriptionText.val ''
+          @submitExtendDescription()
 
 
     activateQualityProfile: ->
@@ -261,16 +263,19 @@ define [
 
 
     deleteCustomRule: ->
-      if confirm(t 'are_you_sure')
-        jQuery.ajax
-          type: 'POST'
-          url: "#{baseUrl}/api/rules/delete"
-          data:
-            key: @model.get 'key'
-        .done =>
-          @options.app.fetchFirstPage()
-        .fail =>
-          @options.app.showRule @model.get('key')
+      confirmDialog
+        title: t 'delete'
+        html: t 'are_you_sure'
+        yesHandler: =>
+          jQuery.ajax
+            type: 'POST'
+            url: "#{baseUrl}/api/rules/delete"
+            data:
+              key: @model.get 'key'
+          .done =>
+            @options.app.fetchFirstPage()
+          .fail =>
+            @options.app.showRule @model.get('key')
 
 
     serializeData: ->