]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5007 Display quality profiles on which a rule is activated and related actions
authorStas Vilchik <vilchiks@gmail.com>
Tue, 18 Mar 2014 10:22:27 +0000 (16:22 +0600)
committerStas Vilchik <vilchiks@gmail.com>
Tue, 18 Mar 2014 10:22:39 +0000 (16:22 +0600)
15 files changed:
sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/index.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_quality_profile_template.hbs.erb
sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_detail_template.hbs.erb
sonar-server/src/main/webapp/WEB-INF/app/views/coding_rules/templates/_coding_rules_quality_profile_activation_template.hbs.erb [new file with mode: 0644]
sonar-server/src/main/webapp/javascripts/coding-rules/app.coffee
sonar-server/src/main/webapp/javascripts/coding-rules/app.js
sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.coffee
sonar-server/src/main/webapp/javascripts/coding-rules/mockjax.js
sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.coffee
sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-quality-profile-view.js
sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.coffee
sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-detail-view.js
sonar-server/src/main/webapp/javascripts/coding-rules/views/coding-rules-quality-profile-activation-view.coffee [new file with mode: 0644]
sonar-server/src/main/webapp/stylesheets/coding-rules.css
sonar-server/src/main/webapp/stylesheets/coding-rules.less

index 4755ba39bfbf715a601cf2e6bd93602cf1615e4d..e71ff6b5080e44ff788fbb2a306ae8c876defce5 100644 (file)
@@ -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' -%>
index 61127eefde7a97a6d2ff0ef0515c60f126690951..b5d4295ccfad3d9c7bc5b1bdd2508f44f5bb8b7e 100644 (file)
     {{/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}}
index 2b6c9651cecbaa967f5ecbfc47163b580ee0b6a0..09447f2c00e10b6d66b540df1c0729f5ec429040 100644 (file)
@@ -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 (file)
index 0000000..7e82a14
--- /dev/null
@@ -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>
index 0915eb9dfa47ef3ae13d62df005aba283b97c746..a930804acc0612870ac091d7c502f1e2e0e7c689 100644 (file)
@@ -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
index 4ca54b9f5834d9f92208351e3cadb12bf72471b6..37d534fbd60b83ea44897c647d2ecf69ef196ebb 100644 (file)
@@ -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) {
         app: this
       });
     });
+    App.addInitializer(function() {
+      return this.codingRulesQualityProfileActivationView = new CodingRulesQualityProfileActivationView({
+        app: this
+      });
+    });
     App.addInitializer(function() {
       this.filters = new BaseFilters.Filters;
       this.filters.add(new BaseFilters.Filter({
index 09e73d0bb2e0c05251cac398277cd23713e9f384..d052e6dd8294dffad8ecab769b51afc142a03fe6 100644 (file)
@@ -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"
index 469a4841a34136398c9bd4fcb92bf94f276b5a65..6d86976882b252000e19f5a7d01e0e645683e7d8 100644 (file)
             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)',
           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'
             }
           ],
               canUpdate: true,
               parameters: [
                 {
-                  key: 'max',
+                  key: 'someParameter',
                   value: 8
                 }
               ]
               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'
+              }
             }
           ]
         }
     jQuery.mockjax({
       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({
index 3b4dd7ae88879c36a62e3dbc34f6282b89fd6c52..289c209d2c0a45bd19c600779f96675187c210b4 100644 (file)
@@ -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}"
index 4020695f3c79c6c7bdcac1674e6b844a68025653..4cb28435c398afbb5ac26c0e7f7f1fb81bb9cf14 100644 (file)
       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;
index 919eee0c6ce42bc3858731e4f01e8abef12c246d..01e4cca5d403efae580e709eedc81e90e2412705 100644 (file)
@@ -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
index a62422642b71525b02611150b0c5fa147215074f..5649c0b1dfac0adfc7f421edca6365785db6df40 100644 (file)
@@ -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) {
         });
       };
 
+      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 (file)
index 0000000..d85a41e
--- /dev/null
@@ -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']
index eea426560a6e1fd0503e631501946f2347b4cd50..7e2e846532d3794977b9729f4069679cfd9dae69 100644 (file)
@@ -23,6 +23,7 @@
   font-weight: bold;
 }
 .coding-rules-detail-title {
+  display: inline-block;
   text-transform: uppercase;
 }
 .coding-rules-detail-status {
 .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;
 }
 .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;
index 31da7ea9b5b6c44623ef2e6834fd67e42e62323c..6a3358b90aab233e68b787b7d58b05aea8593d6e 100644 (file)
@@ -25,6 +25,7 @@
 }
 
 .coding-rules-detail-title {
+  display: inline-block;
   text-transform: uppercase;
 }
 
 }
 
 .coding-rules-detail-quality-profile-parameters {
+  padding: 0 @navigatorPadding / 2;
 
   .coding-rules-detail-parameter-name,
   .coding-rules-detail-parameter-description {
 
 .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;