aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-server/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'sonar-server/src/main')
-rw-r--r--sonar-server/src/main/coffee/coding-rules/views/coding-rules-custom-rule-creation-view.coffee43
-rw-r--r--sonar-server/src/main/hbs/coding-rules/coding-rules-custom-rule-creation.hbs1
-rw-r--r--sonar-server/src/main/hbs/coding-rules/coding-rules-custom-rule-reactivation.hbs7
-rw-r--r--sonar-server/src/main/less/style.less9
4 files changed, 56 insertions, 4 deletions
diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-custom-rule-creation-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-custom-rule-creation-view.coffee
index 04be236be47..26321af5804 100644
--- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-custom-rule-creation-view.coffee
+++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-custom-rule-creation-view.coffee
@@ -19,6 +19,8 @@ define [
customRuleCreationStatus: '#coding-rules-custom-rule-creation-status'
customRuleCreationParameters: '[name]'
customRuleCreationCreate: '#coding-rules-custom-rule-creation-create'
+ customRuleCreationReactivate: '#coding-rules-custom-rule-creation-reactivate'
+ modalFoot: '.modal-foot'
events:
@@ -32,6 +34,7 @@ define [
'click #coding-rules-custom-rule-creation-cancel': 'hide'
'click @ui.customRuleCreationCreate': 'create'
+ 'click @ui.customRuleCreationReactivate': 'reactivate'
generateKey: ->
@@ -42,6 +45,8 @@ define [
flagKey: ->
@keyModifiedByUser = true
+ # Cannot use @ui.customRuleCreationReactivate.hide() directly since it was not there at initial render
+ jQuery(@ui.customRuleCreationReactivate.selector).hide()
create: ->
@@ -60,24 +65,54 @@ define [
else
postData.template_key = @templateRule.get 'key'
postData.custom_key = @ui.customRuleCreationKey.val()
+ postData.prevent_reactivation = true
params = @ui.customRuleCreationParameters.map(->
key: jQuery(@).prop('name'), value: jQuery(@).val() || jQuery(@).prop('placeholder') || '').get()
postData.params = (params.map (param) -> param.key + '=' + param.value).join(';')
+ @sendRequest(action, postData)
- origFooter = @$('.modal-foot').html()
- @$('.modal-foot').html '<i class="spinner"></i>'
+
+ reactivate: ->
+ postData =
+ name: @existingRule.name
+ html_description: @existingRule.htmlDesc
+ severity: @existingRule.severity
+ status: @existingRule.status
+ template_key: @existingRule.templateKey
+ custom_key: @ui.customRuleCreationKey.val()
+ prevent_reactivation: false
+
+ params = @existingRule.params
+ postData.params = (params.map (param) -> param.key + '=' + param.defaultValue).join(';')
+
+ @sendRequest('create', postData)
+
+
+ sendRequest: (action, postData) ->
+ @$('.modal-error').hide()
+ @$('.modal-warning').hide()
+
+ origFooter = @ui.modalFoot.html()
+ @ui.modalFoot.html '<i class="spinner"></i>'
jQuery.ajax
type: 'POST'
url: "#{baseUrl}/api/rules/" + action
data: postData
+ error: () ->
.done (r) =>
@options.app.showRule r.rule.key
@hide()
- .fail =>
- @$('.modal-foot').html origFooter
+ .fail (jqXHR, textStatus, errorThrown) =>
+ if jqXHR.status == 409
+ @existingRule = jqXHR.responseJSON.rule
+ @$('.modal-warning').show()
+ @ui.modalFoot.html Templates['coding-rules-custom-rule-reactivation'](@)
+ else
+ jQuery.ajaxSettings.error(jqXHR, textStatus, errorThrown)
+ @ui.modalFoot.html origFooter
onRender: ->
diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-custom-rule-creation.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-custom-rule-creation.hbs
index 57a9182ff70..ebc66880c45 100644
--- a/sonar-server/src/main/hbs/coding-rules/coding-rules-custom-rule-creation.hbs
+++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-custom-rule-creation.hbs
@@ -9,6 +9,7 @@
<div class="modal-body">
<div class="modal-error"></div>
+ <div class="modal-warning">{{t 'coding_rules.reactivate.help'}}</div>
<table>
<tr class="property">
diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-custom-rule-reactivation.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-custom-rule-reactivation.hbs
new file mode 100644
index 00000000000..2de07a6a814
--- /dev/null
+++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-custom-rule-reactivation.hbs
@@ -0,0 +1,7 @@
+<button id="coding-rules-custom-rule-creation-reactivate">
+ {{t 'coding_rules.reactivate'}}
+</button>
+<button id="coding-rules-custom-rule-creation-create">
+ {{#if change}}{{t 'save'}}{{else}}{{t 'create'}}{{/if}}
+</button>
+<a id="coding-rules-custom-rule-creation-cancel" class="action">{{t 'cancel'}}</a>
diff --git a/sonar-server/src/main/less/style.less b/sonar-server/src/main/less/style.less
index 33c298fe662..317c2c1b291 100644
--- a/sonar-server/src/main/less/style.less
+++ b/sonar-server/src/main/less/style.less
@@ -2545,6 +2545,15 @@ ul.modal-head-metadata li {
display: none;
}
+.modal-warning {
+ border: solid 1px #FFD324;
+ background-color: #FFF6BF;
+ color: #514721;
+ margin: 0 0 4px;
+ padding: 4px;
+ display: none;
+}
+
textarea.width100 {
width: 100%;
-webkit-box-sizing: border-box; /* Safari/Chrome, other WebKit */