aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStas Vilchik <vilchiks@gmail.com>2014-03-18 16:22:27 +0600
committerStas Vilchik <vilchiks@gmail.com>2014-03-18 16:22:39 +0600
commitd4cc5ad93f1043e9f992be95dc5b1b1e056ea7c7 (patch)
tree17a17a904d405f9b7c042dc1fa9d453122a46910
parent7c6ffbab1b4038b2a5e5c01acb5b3bc96c7db9a9 (diff)
downloadsonarqube-d4cc5ad93f1043e9f992be95dc5b1b1e056ea7c7.tar.gz
sonarqube-d4cc5ad93f1043e9f992be95dc5b1b1e056ea7c7.zip
SONAR-5007 Display quality profiles on which a rule is activated and related actions
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb1
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_quality_profile_template.hbs.erb38
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_template.hbs.erb3
-rw-r--r--sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_quality_profile_activation_template.hbs.erb51
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee7
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/app.js7
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee40
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js42
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.coffee50
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.js56
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee11
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js11
-rw-r--r--sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee79
-rw-r--r--sonar-server/src/main/webapp/stylesheets/coding-rules.css9
-rw-r--r--sonar-server/src/main/webapp/stylesheets/coding-rules.less8
15 files changed, 392 insertions, 21 deletions
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb
index 4755ba39bfb..e71ff6b5080 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb
@@ -17,5 +17,6 @@
<%= render :partial => '/coding_rules/templates/coding_rules_list_empty_template.hbs' -%>
<%= render :partial => '/coding_rules/templates/coding_rules_detail_template.hbs' -%>
<%= render :partial => '/coding_rules/templates/coding_rules_detail_quality_profile_template.hbs' -%>
+<%= render :partial => '/coding_rules/templates/coding_rules_quality_profile_activation_template.hbs' -%>
<%= render :partial => '/coding_rules/templates/coding_rules_facets_item_template.hbs' -%>
<%= render :partial => '/coding_rules/templates/coding_rules_bulk_change_template.hbs' -%>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_quality_profile_template.hbs.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_quality_profile_template.hbs.erb
index 61127eefde7..b5d4295ccfa 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_quality_profile_template.hbs.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_quality_profile_template.hbs.erb
@@ -38,6 +38,44 @@
{{/each}}
</ul>
+ <div class="coding-rules-detail-quality-profile-note">
+ {{#if note}}
+ <blockquote class="rule-desc">
+ <cite>
+ <b>{{note.username}}</b> ({{note.fCreationDate}}) &nbsp;|&nbsp;
+ <a class="coding-rules-detail-quality-profile-note-edit link-action">{{t 'edit'}}</a>&nbsp;
+ <a class="coding-rules-detail-quality-profile-note-delete link-action">{{t 'delete'}}</a>
+ </cite>
+ {{{note.html}}}
+ </blockquote>
+ {{else}}
+ <a class="coding-rules-detail-quality-profile-note-add link-action">{{t 'coding_rules.add_note'}}</a>
+ {{/if}}
+ </div>
+
+ <div class="coding-rules-detail-quality-profile-note-form admin">
+ <table class="width100 table">
+ <tbody>
+ <tr>
+ <td class="width100" colspan="2">
+ <textarea class="coding-rules-detail-quality-profile-note-text" rows="4" style="width: 100%;">{{#if note}}{{note.raw}}{{/if}}</textarea>
+ </td>
+ </tr>
+ <tr>
+ <td>
+ <button class="coding-rules-detail-quality-profile-note-submit">
+ {{#if note}}{{t 'update'}}{{else}}{{t 'coding_rules.add_note'}}{{/if}}
+ </button>
+ <a class="coding-rules-detail-quality-profile-note-cancel action">{{t 'cancel'}}</a>
+ </td>
+ <td class="right">
+ <%= render :partial => 'markdown/tips' -%>
+ </td>
+ </tr>
+ </tbody>
+ </table>
+ </div>
+
<div class="button-group coding-rules-detail-quality-profile-actions">
<button>{{t 'update'}}</button>
{{#if parent}}
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_template.hbs.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_template.hbs.erb
index 2b6c9651cec..09447f2c00e 100644
--- a/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_template.hbs.erb
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_template.hbs.erb
@@ -80,5 +80,8 @@
<h3 class="coding-rules-detail-title">{{t 'coding_rules.quality_profiles'}}</h3>
+ <div class="button-group coding-rules-detail-quality-profiles-activation">
+ <button id="coding-rules-quality-profile-activate">{{t 'coding_rules.activate_quality_profile'}}</button>
+ </div>
<div id="coding-rules-detail-quality-profiles"></div>
</script>
diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_quality_profile_activation_template.hbs.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_quality_profile_activation_template.hbs.erb
new file mode 100644
index 00000000000..7e82a148084
--- /dev/null
+++ b/sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_quality_profile_activation_template.hbs.erb
@@ -0,0 +1,51 @@
+<script id="coding-rules-quality-profile-activation-template" type="text/x-handlebars-template">
+ <form>
+ <div class="modal-head">
+ <h2>{{t 'coding_rules.activate_quality_profile'}}</h2>
+ </div>
+
+ <div class="modal-body">
+ <div class="modal-error"></div>
+
+ <table>
+ <tr class="property">
+ <th><h3>{{t 'coding_rules.quality_profile'}}</h3></th>
+ <td>
+ <select id="coding-rules-quality-profile-activation-select">
+ {{#each qualityProfiles}}
+ <option value="{{key}}">{{name}}</option>
+ {{/each}}
+ </select>
+ </td>
+ </tr>
+ <tr class="property">
+ <th><h3>{{t 'severity'}}</h3></th>
+ <td>
+ <select id="coding-rules-quality-profile-activation-severity">
+ {{#each severities}}
+ <option value="{{this}}">{{t 'severity' this}}</option>
+ {{/each}}
+ </select>
+ </td>
+ </tr>
+ {{#each parameters}}
+ <tr class="property">
+ <th><h3>{{key}}</h3></th>
+ <td>
+ <input type="text" {{#if default}}value="{{default}}"{{/if}}>
+ <div class="note">{{description}}</div>
+ {{#if extra}}
+ <div class="note">{{extra}}</div>
+ {{/if}}
+ </td>
+ </tr>
+ {{/each}}
+ </table>
+ </div>
+
+ <div class="modal-foot">
+ <button id="coding-rules-quality-profile-activation-activate">{{t 'coding_rules.activate'}}</button>
+ <a id="coding-rules-quality-profile-activation-cancel" class="action">{{t 'cancel'}}</a>
+ </div>
+ </form>
+</script>
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee
index 0915eb9dfa4..a930804acc0 100644
--- a/sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee
@@ -29,6 +29,7 @@ requirejs [
'coding-rules/views/filter-bar-view',
'coding-rules/views/coding-rules-list-view',
'coding-rules/views/coding-rules-bulk-change-view',
+ 'coding-rules/views/coding-rules-quality-profile-activation-view',
# filters
'navigator/filters/base-filters',
@@ -51,6 +52,7 @@ requirejs [
CodingRulesFilterBarView,
CodingRulesListView,
CodingRulesBulkChangeView,
+ CodingRulesQualityProfileActivationView,
# filters
BaseFilters,
@@ -181,6 +183,11 @@ requirejs [
@codingRulesBulkChangeView = new CodingRulesBulkChangeView app: @
+ # Construct quality profile activation view
+ App.addInitializer ->
+ @codingRulesQualityProfileActivationView = new CodingRulesQualityProfileActivationView app: @
+
+
# Define filters
App.addInitializer ->
@filters = new BaseFilters.Filters
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/app.js b/sonar-server/src/main/webapp/javascripts/coding-rules/app.js
index 4ca54b9f583..37d534fbd60 100644
--- a/sonar-server/src/main/webapp/javascripts/coding-rules/app.js
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/app.js
@@ -22,7 +22,7 @@
}
});
- requirejs(['backbone', 'backbone.marionette', 'coding-rules/layout', 'coding-rules/router', 'coding-rules/views/header-view', 'coding-rules/views/actions-view', 'coding-rules/views/filter-bar-view', 'coding-rules/views/coding-rules-list-view', 'coding-rules/views/coding-rules-bulk-change-view', 'navigator/filters/base-filters', 'navigator/filters/choice-filters', 'navigator/filters/string-filters', 'navigator/filters/date-filter-view', 'coding-rules/views/filters/quality-profile-filter-view', 'coding-rules/views/filters/inheritance-filter-view', 'coding-rules/mockjax'], function(Backbone, Marionette, CodingRulesLayout, CodingRulesRouter, CodingRulesHeaderView, CodingRulesActionsView, CodingRulesFilterBarView, CodingRulesListView, CodingRulesBulkChangeView, BaseFilters, ChoiceFilters, StringFilterView, DateFilterView, QualityProfileFilterView, InheritanceFilterView) {
+ requirejs(['backbone', 'backbone.marionette', 'coding-rules/layout', 'coding-rules/router', 'coding-rules/views/header-view', 'coding-rules/views/actions-view', 'coding-rules/views/filter-bar-view', 'coding-rules/views/coding-rules-list-view', 'coding-rules/views/coding-rules-bulk-change-view', 'coding-rules/views/coding-rules-quality-profile-activation-view', 'navigator/filters/base-filters', 'navigator/filters/choice-filters', 'navigator/filters/string-filters', 'navigator/filters/date-filter-view', 'coding-rules/views/filters/quality-profile-filter-view', 'coding-rules/views/filters/inheritance-filter-view', 'coding-rules/mockjax'], function(Backbone, Marionette, CodingRulesLayout, CodingRulesRouter, CodingRulesHeaderView, CodingRulesActionsView, CodingRulesFilterBarView, CodingRulesListView, CodingRulesBulkChangeView, CodingRulesQualityProfileActivationView, BaseFilters, ChoiceFilters, StringFilterView, DateFilterView, QualityProfileFilterView, InheritanceFilterView) {
var App, appXHR;
jQuery.ajaxSetup({
error: function(jqXHR) {
@@ -153,6 +153,11 @@
});
});
App.addInitializer(function() {
+ return this.codingRulesQualityProfileActivationView = new CodingRulesQualityProfileActivationView({
+ app: this
+ });
+ });
+ App.addInitializer(function() {
this.filters = new BaseFilters.Filters;
this.filters.add(new BaseFilters.Filter({
name: t('coding_rules.filters.name'),
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee
index 09e73d0bb2e..d052e6dd829 100644
--- a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee
@@ -9,9 +9,9 @@ define ['jquery.mockjax'], ->
responseText: JSON.stringify
qualityprofiles: [
{ key: 'sonarway', name: 'Sonar Way', parent: null },
- { key: 'qp1', name: 'Quality Profile 1', parent: 'sonarway' },
- { key: 'qp2', name: 'Quality Profile 2', parent: 'sonarway' },
- { key: 'qp3', name: 'Quality Profile 3', parent: null },
+ { key: 'qualityprofile1', name: 'Quality Profile 1', parent: 'sonarway' },
+ { key: 'qualityprofile2', name: 'Quality Profile 2', parent: 'sonarway' },
+ { key: 'qualityprofile3', name: 'Quality Profile 3', parent: null },
]
languages:
java: 'Java'
@@ -49,7 +49,9 @@ define ['jquery.mockjax'], ->
'bulk_change': 'Bulk Change'
'cancel': 'Cancel'
'change': 'Change'
+ 'delete': 'Delete'
'done': 'Done'
+ 'edit': 'Edit'
'moreCriteria': '+ More Criteria'
'search_verb': 'Search'
'severity': 'Severity'
@@ -61,7 +63,9 @@ define ['jquery.mockjax'], ->
'severity.MINOR': 'Minor'
'severity.INFO': 'Info'
+ 'coding_rules.activate': 'Activate'
'coding_rules.activate_quality_profile': 'Activate Quality Profile'
+ 'coding_rules.add_note': 'Add Note'
'coding_rules.available_since': 'Available Since'
'coding_rules.bulk_change': 'Bulk Change'
'coding_rules.extend_description': 'Extend Description'
@@ -78,6 +82,7 @@ define ['jquery.mockjax'], ->
'coding_rules.parameters': 'Parameters'
'coding_rules.parameters.default_value': 'Default Value:'
'coding_rules.quality_profiles': 'Quality Profiles'
+ 'coding_rules.quality_profile': 'Quality Profile'
'coding_rules.repository': 'Repository:'
'coding_rules.revert_to_parent_definition': 'Revert to Parent Definition'
'coding_rules._rules': 'rule(s)'
@@ -161,8 +166,8 @@ define ['jquery.mockjax'], ->
repository: 'squid'
key: 'S1190'
parameters: [
- { key: 'someParameterName', type: 'INT', default: '', description: 'Some parameter description' }
- { key: 'boolParameter', type: 'BOOL', default: true, description: 'Bool parameter description' }
+ { key: 'someParameter', type: 'INT', default: 4, description: 'Some parameter description' }
+ { key: 'boolParameter', type: 'BOOL', description: 'Bool parameter description' }
]
description: '''
<p>
@@ -196,7 +201,7 @@ define ['jquery.mockjax'], ->
canDeactivate: true
canUpdate: true
parameters: [
- { key: 'max', value: 8 }
+ { key: 'someParameter', value: 8 }
]
},
{
@@ -206,9 +211,14 @@ define ['jquery.mockjax'], ->
canDeactivate: false
canUpdate: false
parameters: [
- { key: 'max', value: 6 }
+ { key: 'someParameter', value: 6 }
]
inherits: 'sonarway'
+ note:
+ username: 'Admin Admin'
+ html: '''<p>This note is here <b>only for test purposes</b>.</p>'''
+ raw: '''This note is here *only for test purposes*.'''
+ fCreationDate: 'less than a minute'
}
]
@@ -232,6 +242,22 @@ define ['jquery.mockjax'], ->
url: "#{baseUrl}/api/codingrules/set_tags"
+ # POST /api/codingrules/activate
+ jQuery.mockjax
+ url: "#{baseUrl}/api/codingrules/activate"
+
+
+ # POST /api/codingrules/note
+ jQuery.mockjax
+ url: "#{baseUrl}/api/codingrules/note"
+ responseText: JSON.stringify
+ note:
+ username: 'Admin Admin'
+ html: '''<p>This note is here <b>only for test purposes</b>.</p>'''
+ raw: '''This note is here *only for test purposes*.'''
+ fCreationDate: 'less than a minute'
+
+
# GET /api/qualityprofiles/list
jQuery.mockjax
url: "#{baseUrl}/api/qualityprofiles/list"
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js
index 469a4841a34..6d86976882b 100644
--- a/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js
@@ -12,15 +12,15 @@
name: 'Sonar Way',
parent: null
}, {
- key: 'qp1',
+ key: 'qualityprofile1',
name: 'Quality Profile 1',
parent: 'sonarway'
}, {
- key: 'qp2',
+ key: 'qualityprofile2',
name: 'Quality Profile 2',
parent: 'sonarway'
}, {
- key: 'qp3',
+ key: 'qualityprofile3',
name: 'Quality Profile 3',
parent: null
}
@@ -65,7 +65,9 @@
'bulk_change': 'Bulk Change',
'cancel': 'Cancel',
'change': 'Change',
+ 'delete': 'Delete',
'done': 'Done',
+ 'edit': 'Edit',
'moreCriteria': '+ More Criteria',
'search_verb': 'Search',
'severity': 'Severity',
@@ -75,7 +77,9 @@
'severity.MAJOR': 'Major',
'severity.MINOR': 'Minor',
'severity.INFO': 'Info',
+ 'coding_rules.activate': 'Activate',
'coding_rules.activate_quality_profile': 'Activate Quality Profile',
+ 'coding_rules.add_note': 'Add Note',
'coding_rules.available_since': 'Available Since',
'coding_rules.bulk_change': 'Bulk Change',
'coding_rules.extend_description': 'Extend Description',
@@ -92,6 +96,7 @@
'coding_rules.parameters': 'Parameters',
'coding_rules.parameters.default_value': 'Default Value:',
'coding_rules.quality_profiles': 'Quality Profiles',
+ 'coding_rules.quality_profile': 'Quality Profile',
'coding_rules.repository': 'Repository:',
'coding_rules.revert_to_parent_definition': 'Revert to Parent Definition',
'coding_rules._rules': 'rule(s)',
@@ -169,14 +174,13 @@
key: 'S1190',
parameters: [
{
- key: 'someParameterName',
+ key: 'someParameter',
type: 'INT',
- "default": '',
+ "default": 4,
description: 'Some parameter description'
}, {
key: 'boolParameter',
type: 'BOOL',
- "default": true,
description: 'Bool parameter description'
}
],
@@ -192,7 +196,7 @@
canUpdate: true,
parameters: [
{
- key: 'max',
+ key: 'someParameter',
value: 8
}
]
@@ -204,11 +208,17 @@
canUpdate: false,
parameters: [
{
- key: 'max',
+ key: 'someParameter',
value: 6
}
],
- inherits: 'sonarway'
+ inherits: 'sonarway',
+ note: {
+ username: 'Admin Admin',
+ html: '<p>This note is here <b>only for test purposes</b>.</p>',
+ raw: 'This note is here *only for test purposes*.',
+ fCreationDate: 'less than a minute'
+ }
}
]
}
@@ -228,6 +238,20 @@
url: "" + baseUrl + "/api/codingrules/set_tags"
});
jQuery.mockjax({
+ url: "" + baseUrl + "/api/codingrules/activate"
+ });
+ jQuery.mockjax({
+ url: "" + baseUrl + "/api/codingrules/note",
+ responseText: JSON.stringify({
+ note: {
+ username: 'Admin Admin',
+ html: '<p>This note is here <b>only for test purposes</b>.</p>',
+ raw: 'This note is here *only for test purposes*.',
+ fCreationDate: 'less than a minute'
+ }
+ })
+ });
+ jQuery.mockjax({
url: "" + baseUrl + "/api/qualityprofiles/list",
responseText: JSON.stringify({
more: false,
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.coffee
index 3b4dd7ae888..289c209d2c0 100644
--- a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.coffee
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.coffee
@@ -13,8 +13,58 @@ define [
ui:
severitySelect: '.coding-rules-detail-quality-profile-severity'
+ note: '.coding-rules-detail-quality-profile-note'
+ noteForm: '.coding-rules-detail-quality-profile-note-form'
+ noteText: '.coding-rules-detail-quality-profile-note-text'
+ noteAdd: '.coding-rules-detail-quality-profile-note-add'
+ noteEdit: '.coding-rules-detail-quality-profile-note-edit'
+ noteDelete: '.coding-rules-detail-quality-profile-note-delete'
+ noteCancel: '.coding-rules-detail-quality-profile-note-cancel'
+ noteSubmit: '.coding-rules-detail-quality-profile-note-submit'
+
+
+ events:
+ 'click @ui.noteAdd': 'editNote'
+ 'click @ui.noteEdit': 'editNote'
+ 'click @ui.noteDelete': 'deleteNote'
+ 'click @ui.noteCancel': 'cancelNote'
+ 'click @ui.noteSubmit': 'submitNote'
+
+
+ editNote: ->
+ @ui.note.hide()
+ @ui.noteForm.show()
+ @ui.noteText.focus()
+
+
+ deleteNote: ->
+ @ui.noteText.val ''
+ @submitNote().done =>
+ @model.unset 'note'
+ @render()
+
+
+ cancelNote: ->
+ @ui.note.show()
+ @ui.noteForm.hide()
+
+
+ submitNote: ->
+ @ui.note.html '<i class="spinner"></i>'
+ @ui.noteForm.html '<i class="spinner"></i>'
+ jQuery.ajax
+ type: 'POST'
+ url: "#{baseUrl}/api/codingrules/note"
+ dataType: 'json'
+ data: text: @ui.noteText.val()
+ .done (r) =>
+ @model.set 'note', r.note
+ @render()
+
onRender: ->
+ @ui.noteForm.hide()
+
format = (state) ->
return state.text unless state.id
"<i class='icon-severity-#{state.id.toLowerCase()}'></i> #{state.text}"
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.js b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.js
index 4020695f3c7..4cb28435c39 100644
--- a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.js
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.js
@@ -18,11 +18,65 @@
CodingRulesDetailQualityProfilesView.prototype.template = getTemplate('#coding-rules-detail-quality-profile-template');
CodingRulesDetailQualityProfilesView.prototype.ui = {
- severitySelect: '.coding-rules-detail-quality-profile-severity'
+ severitySelect: '.coding-rules-detail-quality-profile-severity',
+ note: '.coding-rules-detail-quality-profile-note',
+ noteForm: '.coding-rules-detail-quality-profile-note-form',
+ noteText: '.coding-rules-detail-quality-profile-note-text',
+ noteAdd: '.coding-rules-detail-quality-profile-note-add',
+ noteEdit: '.coding-rules-detail-quality-profile-note-edit',
+ noteDelete: '.coding-rules-detail-quality-profile-note-delete',
+ noteCancel: '.coding-rules-detail-quality-profile-note-cancel',
+ noteSubmit: '.coding-rules-detail-quality-profile-note-submit'
+ };
+
+ CodingRulesDetailQualityProfilesView.prototype.events = {
+ 'click @ui.noteAdd': 'editNote',
+ 'click @ui.noteEdit': 'editNote',
+ 'click @ui.noteDelete': 'deleteNote',
+ 'click @ui.noteCancel': 'cancelNote',
+ 'click @ui.noteSubmit': 'submitNote'
+ };
+
+ CodingRulesDetailQualityProfilesView.prototype.editNote = function() {
+ this.ui.note.hide();
+ this.ui.noteForm.show();
+ return this.ui.noteText.focus();
+ };
+
+ CodingRulesDetailQualityProfilesView.prototype.deleteNote = function() {
+ var _this = this;
+ this.ui.noteText.val('');
+ return this.submitNote().done(function() {
+ _this.model.unset('note');
+ return _this.render();
+ });
+ };
+
+ CodingRulesDetailQualityProfilesView.prototype.cancelNote = function() {
+ this.ui.note.show();
+ return this.ui.noteForm.hide();
+ };
+
+ CodingRulesDetailQualityProfilesView.prototype.submitNote = function() {
+ var _this = this;
+ this.ui.note.html('<i class="spinner"></i>');
+ this.ui.noteForm.html('<i class="spinner"></i>');
+ return jQuery.ajax({
+ type: 'POST',
+ url: "" + baseUrl + "/api/codingrules/note",
+ dataType: 'json',
+ data: {
+ text: this.ui.noteText.val()
+ }
+ }).done(function(r) {
+ _this.model.set('note', r.note);
+ return _this.render();
+ });
};
CodingRulesDetailQualityProfilesView.prototype.onRender = function() {
var format;
+ this.ui.noteForm.hide();
format = function(state) {
if (!state.id) {
return state.text;
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee
index 919eee0c6ce..01e4cca5d40 100644
--- a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee
@@ -32,6 +32,8 @@ define [
extendDescriptionSpinner: '#coding-rules-detail-extend-description-spinner'
cancelExtendDescription: '#coding-rules-detail-extend-description-cancel'
+ qualityProfileActivate: '#coding-rules-quality-profile-activate'
+
events:
'click @ui.tagsChange': 'changeTags'
@@ -41,6 +43,8 @@ define [
'click @ui.cancelExtendDescription': 'hideExtendDescriptionForm'
'click @ui.extendDescriptionSubmit': 'submitExtendDescription'
+ 'click @ui.qualityProfileActivate': 'activateQualityProfile'
+
initialize: (options) ->
@qualityProfilesView = new CodingRulesDetailQualityProfilesView
@@ -99,4 +103,9 @@ define [
data: text: @ui.extendDescriptionText.val()
.done (r) =>
@model.set extra: r.extra, extraRaw: r.extraRaw
- @render() \ No newline at end of file
+ @render()
+
+
+ activateQualityProfile: ->
+ @options.app.codingRulesQualityProfileActivationView.model = @model
+ @options.app.codingRulesQualityProfileActivationView.show() \ No newline at end of file
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js
index a62422642b7..5649c0b1dfa 100644
--- a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js
@@ -31,7 +31,8 @@
extendDescriptionSubmit: '#coding-rules-detail-extend-description-submit',
extendDescriptionText: '#coding-rules-detail-extend-description-text',
extendDescriptionSpinner: '#coding-rules-detail-extend-description-spinner',
- cancelExtendDescription: '#coding-rules-detail-extend-description-cancel'
+ cancelExtendDescription: '#coding-rules-detail-extend-description-cancel',
+ qualityProfileActivate: '#coding-rules-quality-profile-activate'
};
CodingRulesDetailView.prototype.events = {
@@ -39,7 +40,8 @@
'click @ui.tagsEditDone': 'editDone',
'click @ui.extendDescriptionLink': 'showExtendDescriptionForm',
'click @ui.cancelExtendDescription': 'hideExtendDescriptionForm',
- 'click @ui.extendDescriptionSubmit': 'submitExtendDescription'
+ 'click @ui.extendDescriptionSubmit': 'submitExtendDescription',
+ 'click @ui.qualityProfileActivate': 'activateQualityProfile'
};
CodingRulesDetailView.prototype.initialize = function(options) {
@@ -116,6 +118,11 @@
});
};
+ CodingRulesDetailView.prototype.activateQualityProfile = function() {
+ this.options.app.codingRulesQualityProfileActivationView.model = this.model;
+ return this.options.app.codingRulesQualityProfileActivationView.show();
+ };
+
return CodingRulesDetailView;
})(Marionette.Layout);
diff --git a/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
new file mode 100644
index 00000000000..d85a41e3294
--- /dev/null
+++ b/sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee
@@ -0,0 +1,79 @@
+define [
+ 'backbone.marionette',
+ 'common/handlebars-extensions'
+], (
+ Marionette
+) ->
+
+ class CodingRulesQualityProfileActivationView extends Marionette.ItemView
+ className: 'modal'
+ template: getTemplate '#coding-rules-quality-profile-activation-template'
+
+
+ ui:
+ qualityProfileSelect: '#coding-rules-quality-profile-activation-select'
+ qualityProfileSeverity: '#coding-rules-quality-profile-activation-severity'
+ qualityProfileActivate: '#coding-rules-quality-profile-activation-activate'
+
+
+ events:
+ 'click #coding-rules-quality-profile-activation-cancel': 'hide'
+ 'click @ui.qualityProfileActivate': 'activate'
+
+
+ activate: ->
+ @$('.modal-foot').html '<i class="spinner"></i>'
+ jQuery.ajax
+ type: 'POST'
+ url: "#{baseUrl}/api/codingrules/activate"
+ data: id: 1
+ .done =>
+ jQuery('.navigator-results-list .active').click()
+ @hide()
+
+
+ onRender: ->
+ @$el.dialog
+ dialogClass: 'no-close',
+ width: '600px',
+ draggable: false,
+ autoOpen: false,
+ modal: true,
+ minHeight: 50,
+ resizable: false,
+ title: null
+
+ @ui.qualityProfileSelect.select2
+ width: '250px'
+ minimumResultsForSearch: 5
+
+ format = (state) ->
+ return state.text unless state.id
+ "<i class='icon-severity-#{state.id.toLowerCase()}'></i> #{state.text}"
+
+ @ui.qualityProfileSeverity.val @model.get 'severity'
+ @ui.qualityProfileSeverity.select2
+ width: '250px'
+ minimumResultsForSearch: 999
+ formatResult: format
+ formatSelection: format
+
+
+ show: ->
+ @render()
+ @$el.dialog 'open'
+
+
+ hide: ->
+ @$el.dialog 'close'
+
+
+ getAvailableQualityProfiles: ->
+ _.reject @options.app.qualityProfiles, (profile) =>
+ _.findWhere @model.get('qualityProfiles'), key: profile.key
+
+
+ serializeData: ->
+ _.extend super,
+ qualityProfiles: @getAvailableQualityProfiles()
+ severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO']
diff --git a/sonar-server/src/main/webapp/stylesheets/coding-rules.css b/sonar-server/src/main/webapp/stylesheets/coding-rules.css
index eea426560a6..7e2e846532d 100644
--- a/sonar-server/src/main/webapp/stylesheets/coding-rules.css
+++ b/sonar-server/src/main/webapp/stylesheets/coding-rules.css
@@ -23,6 +23,7 @@
font-weight: bold;
}
.coding-rules-detail-title {
+ display: inline-block;
text-transform: uppercase;
}
.coding-rules-detail-status {
@@ -106,6 +107,9 @@
.coding-rules-detail-quality-profile-actions {
padding: 5px;
}
+.coding-rules-detail-quality-profile-parameters {
+ padding: 0 5px;
+}
.coding-rules-detail-quality-profile-parameters .coding-rules-detail-parameter-name,
.coding-rules-detail-quality-profile-parameters .coding-rules-detail-parameter-description {
vertical-align: middle;
@@ -115,10 +119,15 @@
}
.coding-rules-detail-quality-profile-inheritance {
margin: 10px 0;
+ padding: 0 5px;
}
.coding-rules-detail-quality-profile-inheritance strong {
font-weight: bold;
}
+.coding-rules-detail-quality-profile-note {
+ margin: 10px 0;
+ padding: 0 5px;
+}
.coding-rules-detail-quality-profiles-activation {
margin-top: -3px;
margin-left: 10px;
diff --git a/sonar-server/src/main/webapp/stylesheets/coding-rules.less b/sonar-server/src/main/webapp/stylesheets/coding-rules.less
index 31da7ea9b5b..6a3358b90aa 100644
--- a/sonar-server/src/main/webapp/stylesheets/coding-rules.less
+++ b/sonar-server/src/main/webapp/stylesheets/coding-rules.less
@@ -25,6 +25,7 @@
}
.coding-rules-detail-title {
+ display: inline-block;
text-transform: uppercase;
}
@@ -134,6 +135,7 @@
}
.coding-rules-detail-quality-profile-parameters {
+ padding: 0 @navigatorPadding / 2;
.coding-rules-detail-parameter-name,
.coding-rules-detail-parameter-description {
@@ -147,10 +149,16 @@
.coding-rules-detail-quality-profile-inheritance {
margin: @navigatorPadding 0;
+ padding: 0 @navigatorPadding / 2;
strong { font-weight: bold; }
}
+.coding-rules-detail-quality-profile-note {
+ margin: @navigatorPadding 0;
+ padding: 0 @navigatorPadding / 2;
+}
+
.coding-rules-detail-quality-profiles-activation {
margin-top: -3px;
margin-left: @navigatorPadding;