]> source.dussan.org Git - sonarqube.git/commitdiff
Confirmation modal windows
authorStas Vilchik <vilchiks@gmail.com>
Thu, 10 Apr 2014 08:48:55 +0000 (14:48 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Thu, 10 Apr 2014 08:48:55 +0000 (14:48 +0600)
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/Gruntfile.coffee
sonar-server/src/main/coffee/common/dialogs.coffee [new file with mode: 0644]
sonar-server/src/main/coffee/quality-gate/views/quality-gate-detail-condition-view.coffee
sonar-server/src/main/coffee/quality-gate/views/quality-gate-detail-header-view.coffee
sonar-server/src/main/java/org/sonar/server/qualitygate/ws/QgateAppHandler.java

index 8f699f7c755b1d2f4693f1bbcfd4febf66a14b03..e190b1da8d9dc8a40ba33a0bc58922969abb5882 100644 (file)
@@ -1640,11 +1640,13 @@ quality_profiles.copy_new_name=New name
 quality_gates.noQualityGates=No Quality Gates
 quality_gates.create=Create Quality Gate
 quality_gates.rename=Rename Quality Gate
+quality_gates.delete=Delete Quality Gate
 quality_gates.copy=Copy Quality Gate
 quality_gates.conditions=Conditions
 quality_gates.projects=Projects
 quality_gates.add_condition=Add Condition
 quality_gates.no_conditions=No Conditions
+quality_gates.delete_condition=Delete Condition
 quality_gates.introduction=Only project measures are checked against thresholds. Sub-projects, directories and files are ignored.
 quality_gates.health_icons=Project health icons represent:
 quality_gates.projects_for_default=Every project not specifically associated to a quality gate will be associated to this one by default.
index ffcc8519dc597e3965cde2636217502627034d49..88c18c563699d80c566da2d6fb1b1de397f4cdff 100644 (file)
@@ -75,6 +75,7 @@ module.exports = (grunt) ->
             '<%= pkg.assets %>js/top-search.js'
             '<%= pkg.assets %>js/sortable.js'
             '<%= pkg.assets %>js/common/inputs.js'
+            '<%= pkg.assets %>js/common/dialogs.js'
             '<%= pkg.assets %>js/application.js'
             '<%= pkg.assets %>js/dashboard.js'
             '<%= pkg.assets %>js/duplication.js'
@@ -108,6 +109,7 @@ module.exports = (grunt) ->
             '<%= pkg.assets %>js/top-search.js'
             '<%= pkg.assets %>js/sortable.js'
             '<%= pkg.assets %>js/common/inputs.js'
+            '<%= pkg.assets %>js/common/dialogs.js'
             '<%= pkg.assets %>js/application.js'
             '<%= pkg.assets %>js/dashboard.js'
             '<%= pkg.assets %>js/duplication.js'
diff --git a/sonar-server/src/main/coffee/common/dialogs.coffee b/sonar-server/src/main/coffee/common/dialogs.coffee
new file mode 100644 (file)
index 0000000..0ae1c01
--- /dev/null
@@ -0,0 +1,38 @@
+$ = jQuery
+
+window.confirmDialog = (options) ->
+  settings = _.extend window.confirmDialog.defaults, options
+  dialog = $ """
+             <div>
+               <div class='modal-head'><h2>#{settings.title}</h2></div>
+               <div class='modal-body'>#{settings.html}</div>
+               <div class='modal-foot'>
+                 <button data-confirm='yes'>#{settings.yesLabel}</button>
+                 <a data-confirm='no' class='action'>#{settings.noLabel}</a>
+               </div>
+             </div>
+             """
+
+  $('[data-confirm=yes]', dialog).on 'click', ->
+    dialog.dialog 'close'
+    settings.yesHandler()
+    settings.always()
+  $('[data-confirm=no]', dialog).on 'click', ->
+    dialog.dialog 'close'
+    settings.noHandler()
+    settings.always()
+
+  dialog.dialog
+    modal: true
+    minHeight: null
+    width: 540
+
+
+window.confirmDialog.defaults =
+  title: 'Confirmation'
+  html: ''
+  yesLabel: 'Yes'
+  noLabel: 'Cancel'
+  yesHandler: ->
+  noHandler: ->
+  always: ->
\ No newline at end of file
index e928b169b2580a68dfbd93107af484acb5bbdf84..6535003e0fca6fb8551473b6e3b0cae18edfe32d 100644 (file)
@@ -23,11 +23,12 @@ define [
       errorInput: '[name=error]'
       actionsBox: '.quality-gate-condition-actions'
       updateButton: '.update-condition'
+      deleteButton: '.delete-condition'
 
 
     events:
       'click @ui.updateButton': 'saveCondition'
-      'click .delete-condition': 'deleteCondition'
+      'click @ui.deleteButton': 'deleteCondition'
       'click .add-condition': 'saveCondition'
       'click .cancel-add-condition': 'cancelAddCondition'
       'keyup :input': 'enableUpdate'
@@ -94,12 +95,16 @@ define [
 
 
     deleteCondition: ->
-      if confirm t('quality_gates.delete_condition.confirm.message')
-        @showSpinner()
-        @model.delete().done =>
-          @options.collectionView.collection.remove @model
-          @options.collectionView.updateConditions()
-          @close()
+      confirmDialog
+        title: t 'quality_gates.delete_condition'
+        html: t('quality_gates.delete_condition.confirm.message')
+        yesHandler: =>
+          @showSpinner()
+          @model.delete().done =>
+            @options.collectionView.collection.remove @model
+            @options.collectionView.updateConditions()
+            @close()
+        always: => @ui.deleteButton.blur()
 
 
     cancelAddCondition: ->
index fc23e91c4793937c71a4b5692d6f639a0426d7a2..24fbf33f65793c2a481e1f2ee236435257bec799 100644 (file)
@@ -45,18 +45,19 @@ define [
 
     deleteQualityGate: ->
       message = if @model.get 'default' then 'quality_gates.delete.confirm.default' else 'quality_gates.delete.confirm.message'
-      if confirm t(message).replace('{0}', @model.get 'name')
-        @showSpinner()
-        jQuery.ajax
-          type: 'POST'
-          url: "#{baseUrl}/api/qualitygates/destroy"
-          data: id: @model.id
-        .always =>
-          @hideSpinner()
-        .done =>
-          @options.app.deleteQualityGate @model.id
-      else
-        @ui.deleteButton.blur()
+      message = tp message, @model.get('name')
+      confirmDialog
+        title: t 'quality_gates.delete'
+        html: message
+        yesHandler: =>
+          @showSpinner()
+          jQuery.ajax
+            type: 'POST'
+            url: "#{baseUrl}/api/qualitygates/destroy"
+            data: id: @model.id
+          .always => @hideSpinner()
+          .done => @options.app.deleteQualityGate @model.id
+        always: => @ui.deleteButton.blur()
 
 
     changeDefault: (set) ->
index ea7765f7921e25144402ebe407bcfbfb28011345..bef4810027320b1f928638fd09014fa1357e53e6 100644 (file)
@@ -54,9 +54,11 @@ public class QgateAppHandler implements RequestHandler {
       "quality_gates.conditions",
       "quality_gates.copy",
       "quality_gates.create",
+      "quality_gates.delete",
       "quality_gates.health_icons",
       "quality_gates.introduction",
       "quality_gates.no_conditions",
+      "quality_gates.delete_condition",
       "quality_gates.noQualityGates",
       "quality_gates.operator.LT",
       "quality_gates.operator.GT",