]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-5820/SONAR-5987 Add some activation details
authorStas Vilchik <vilchiks@gmail.com>
Thu, 15 Jan 2015 13:37:14 +0000 (14:37 +0100)
committerStas Vilchik <vilchiks@gmail.com>
Mon, 19 Jan 2015 09:02:32 +0000 (10:02 +0100)
server/sonar-web/src/main/hbs/coding-rules/_coding-rules-workspace-list-item-activation.hbs [new file with mode: 0644]
server/sonar-web/src/main/hbs/coding-rules/coding-rules-workspace-list-item.hbs
server/sonar-web/src/main/js/coding-rules/controller.js
server/sonar-web/src/main/js/coding-rules/models/rules.js
server/sonar-web/src/main/js/coding-rules/workspace-list-item-view.js
server/sonar-web/src/main/less/components/rules.less

diff --git a/server/sonar-web/src/main/hbs/coding-rules/_coding-rules-workspace-list-item-activation.hbs b/server/sonar-web/src/main/hbs/coding-rules/_coding-rules-workspace-list-item-activation.hbs
new file mode 100644 (file)
index 0000000..84f8997
--- /dev/null
@@ -0,0 +1,29 @@
+{{#each activeProfiles}}
+  {{severityIcon severity}}
+
+  {{#eq inherit 'OVERRIDES'}}
+    <i class="icon-inheritance" title="{{tp 'coding_rules.overrides' name parent.name}}"></i>
+  {{/eq}}
+  {{#eq inherit 'INHERITED'}}
+    <i class="icon-inheritance" title="{{tp 'coding_rules.inherits' name parent.name}}"></i>
+  {{/eq}}
+
+  {{#if ../canWrite}}
+    <div class="button-group">
+      {{#unless isTemplate}}
+        <button class="coding-rules-detail-quality-profile-change">{{t 'change_verb'}}</button>
+      {{/unless}}
+      {{#if parent}}
+        {{#eq inherit 'OVERRIDES'}}
+          <button class="coding-rules-detail-quality-profile-revert button-red">
+            {{t 'coding_rules.revert_to_parent_definition'}}
+          </button>
+        {{/eq}}
+      {{else}}
+        <button class="coding-rules-detail-quality-profile-deactivate button-red">
+          {{t 'coding_rules.deactivate'}}
+        </button>
+      {{/if}}
+    </div>
+  {{/if}}
+{{/each}}
index c93bc24c471778c66d0d51b9a7f80e5a8fdb3c11..d5641452773bebe78ec2088e03800709620056e1 100644 (file)
@@ -1,19 +1,71 @@
-<div class="coding-rule-inner">
-  <div class="coding-rule-title">
-    <a class="js-rule link-no-underline">{{name}}</a>
-  </div>
-  <div class="coding-rule-meta">
-    {{#notEq status 'READY'}}
-      {{status}}
-      &nbsp;&nbsp;&nbsp;
-    {{/notEq}}
-    <a class="js-lang link-no-underline" data-lang="{{lang}}">{{langName}}</a>
-    {{#notEmpty tags}}
-      &nbsp;&nbsp;&nbsp;
-      <i class="icon-tags"></i>
-      {{#each tags}}
-        <a class="js-tag link-no-underline" data-tag="{{this}}">{{this}}</a>
-      {{/each}}
-    {{/notEmpty}}
-  </div>
-</div>
+<table class="coding-rule-table">
+  <tr>
+    {{#if activeProfile}}
+      {{#if activeProfile.severity}}
+        <td class="coding-rule-table-meta-cell coding-rule-activation">
+          {{severityIcon activeProfile.severity}}
+          {{#eq activeProfile.inherit 'OVERRIDES'}}
+            <i class="icon-inheritance"
+               title="{{tp 'coding_rules.overrides' activeProfile.name activeProfile.parent.name}}"></i>
+          {{/eq}}
+          {{#eq activeProfile.inherit 'INHERITED'}}
+            <i class="icon-inheritance"
+               title="{{tp 'coding_rules.inherits' activeProfile.name activeProfile.parent.name}}"></i>
+          {{/eq}}
+        </td>
+      {{/if}}
+    {{/if}}
+
+    <td>
+      <div class="coding-rule-title">
+        <a class="js-rule link-no-underline">{{name}}</a>
+      </div>
+    </td>
+
+    <td class="coding-rule-table-meta-cell">
+      <div class="coding-rule-meta">
+        {{#notEq status 'READY'}}
+          {{status}}
+          &nbsp;&nbsp;&nbsp;
+        {{/notEq}}
+        <a class="js-lang link-no-underline" data-lang="{{lang}}">{{langName}}</a>
+        {{#notEmpty tags}}
+          &nbsp;&nbsp;&nbsp;
+          <i class="icon-tags"></i>
+          {{#each tags}}
+            <a class="js-tag link-no-underline" data-tag="{{this}}">{{this}}</a>
+          {{/each}}
+        {{/notEmpty}}
+      </div>
+    </td>
+
+    {{#if activeProfile}}
+      {{#if canWrite}}
+        <td class="coding-rule-table-meta-cell coding-rule-activation-actions">
+          <div class="button-group">
+            {{#if activeProfile.severity}}
+              {{#unless activeProfile.isTemplate}}
+                <button class="coding-rules-detail-quality-profile-change">{{t 'change_verb'}}</button>
+              {{/unless}}
+              {{#if activeProfile.parent}}
+                {{#eq activeProfile.inherit 'OVERRIDES'}}
+                  <button class="coding-rules-detail-quality-profile-revert button-red">
+                    {{t 'coding_rules.revert_to_parent_definition'}}
+                  </button>
+                {{/eq}}
+              {{else}}
+                <button class="coding-rules-detail-quality-profile-deactivate button-red">
+                  {{t 'coding_rules.deactivate'}}
+                </button>
+              {{/if}}
+            {{else}}
+              <button class="coding-rules-detail-quality-profile-activate">
+                {{t 'coding_rules.activate'}}
+              </button>
+            {{/if}}
+          </div>
+        </td>
+      {{/if}}
+    {{/if}}
+  </tr>
+</table>
index 5bbdabe234f6da5fe81f701812be064b9eda066a..f32b51332a661d25e26ee466b81defe3eb0a7734 100644 (file)
@@ -15,11 +15,16 @@ define([
 
 
     _searchParameters: function () {
+      var fields = this.ruleFields.slice(),
+          profile = this.app.state.get('query').qprofile;
+      if (profile != null) {
+        fields.push('actives');
+      }
       return {
         p: this.app.state.get('page'),
         ps: this.pageSize,
         facets: this._facetsFromServer().join(),
-        f: this.ruleFields.join(),
+        f: fields.join(),
         s: 'name',
         asc: true
       };
index d0cc24411e6d1b03a6df60ade5d5c8df321b398a..e6d92e6135e84571b8f9cc00419fc6143b059a07 100644 (file)
@@ -6,7 +6,14 @@ define([
     model: Rule,
 
     parseRules: function (r) {
-      return r.rules;
+      var rules = r.rules;
+      if (r.actives != null) {
+        rules = rules.map(function (rule) {
+          var profiles = r.actives[rule.key];
+          return _.extend(rule, { activeProfiles: profiles });
+        });
+      }
+      return rules;
     },
 
     setIndex: function () {
index f7cd1120f15d4728b37d1fb05a8c540d4f90d28e..02627c69f243a70cc02031ef1bd07628247d93c5 100644 (file)
@@ -25,8 +25,16 @@ define([
     },
 
     serializeData: function () {
+      var activeProfiles = this.model.get('activeProfiles'),
+          activeProfile = _.isArray(activeProfiles) && activeProfiles.length === 1 ? activeProfiles[0] : null,
+          selectedProfile = this.options.app.state.get('query').qprofile;
+      if (selectedProfile != null && activeProfile == null) {
+        activeProfile = selectedProfile;
+      }
       return _.extend(WorkspaceListItemView.prototype.serializeData.apply(this, arguments), {
-        tags: _.union(this.model.get('sysTags'), this.model.get('tags'))
+        tags: _.union(this.model.get('sysTags'), this.model.get('tags')),
+        canWrite: this.options.app.canWrite,
+        activeProfile: activeProfile
       });
     }
   });
index 681f54f1b96fe012b32314c5169b2816b4a0e578..c4314d0c84cddb7fc054b984968091e06e8646d3 100644 (file)
   border-top-color: transparent;
 }
 
-.coding-rule-inner {
-  .justify;
-  margin-bottom: -16px;
+.coding-rule-table {
+  width: 100%;
+
+  td {
+    vertical-align: top;
+  }
+}
+
+.coding-rule-table + .coding-rule-table {
+  margin-top: 5px;
+}
+
+.coding-rule-table-meta-cell {
+  width: 1px;
+  white-space: nowrap;
 }
 
 .coding-rule-title {
-  display: inline-block;
-  vertical-align: baseline;
   line-height: @lineHeight;
   font-size: @baseFontSize;
 }
 
 .coding-rule-meta {
-  display: inline-block;
-  vertical-align: baseline;
+  padding-left: 30px;
   line-height: @lineHeight;
   font-size: @smallFontSize;
 
   }
 }
 
+.coding-rule-activation {
+  width: 40px;
+  line-height: @lineHeight;
+}
+
+.coding-rule-activation-actions {
+  padding-left: 20px;
+}
+
 .coding-rule-section > div {
   max-width: 1020px;
   margin: 0 -10px;