From 89fc8aa1a6a3ec70c11a5d10bf7670926b686a95 Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Thu, 15 Jan 2015 14:37:14 +0100 Subject: [PATCH] SONAR-5820/SONAR-5987 Add some activation details --- ...g-rules-workspace-list-item-activation.hbs | 29 ++++++ .../coding-rules-workspace-list-item.hbs | 90 +++++++++++++++---- .../src/main/js/coding-rules/controller.js | 7 +- .../src/main/js/coding-rules/models/rules.js | 9 +- .../coding-rules/workspace-list-item-view.js | 10 ++- .../src/main/less/components/rules.less | 32 +++++-- 6 files changed, 148 insertions(+), 29 deletions(-) create mode 100644 server/sonar-web/src/main/hbs/coding-rules/_coding-rules-workspace-list-item-activation.hbs 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 index 00000000000..84f89974491 --- /dev/null +++ b/server/sonar-web/src/main/hbs/coding-rules/_coding-rules-workspace-list-item-activation.hbs @@ -0,0 +1,29 @@ +{{#each activeProfiles}} + {{severityIcon severity}} + + {{#eq inherit 'OVERRIDES'}} + + {{/eq}} + {{#eq inherit 'INHERITED'}} + + {{/eq}} + + {{#if ../canWrite}} +
+ {{#unless isTemplate}} + + {{/unless}} + {{#if parent}} + {{#eq inherit 'OVERRIDES'}} + + {{/eq}} + {{else}} + + {{/if}} +
+ {{/if}} +{{/each}} diff --git a/server/sonar-web/src/main/hbs/coding-rules/coding-rules-workspace-list-item.hbs b/server/sonar-web/src/main/hbs/coding-rules/coding-rules-workspace-list-item.hbs index c93bc24c471..d5641452773 100644 --- a/server/sonar-web/src/main/hbs/coding-rules/coding-rules-workspace-list-item.hbs +++ b/server/sonar-web/src/main/hbs/coding-rules/coding-rules-workspace-list-item.hbs @@ -1,19 +1,71 @@ -
-
- {{name}} -
-
- {{#notEq status 'READY'}} - {{status}} -     - {{/notEq}} - {{langName}} - {{#notEmpty tags}} -     - - {{#each tags}} - {{this}} - {{/each}} - {{/notEmpty}} -
-
+ + + {{#if activeProfile}} + {{#if activeProfile.severity}} + + {{/if}} + {{/if}} + + + + + + {{#if activeProfile}} + {{#if canWrite}} + + {{/if}} + {{/if}} + +
+ {{severityIcon activeProfile.severity}} + {{#eq activeProfile.inherit 'OVERRIDES'}} + + {{/eq}} + {{#eq activeProfile.inherit 'INHERITED'}} + + {{/eq}} + +
+ {{name}} +
+
+
+ {{#notEq status 'READY'}} + {{status}} +     + {{/notEq}} + {{langName}} + {{#notEmpty tags}} +     + + {{#each tags}} + {{this}} + {{/each}} + {{/notEmpty}} +
+
+
+ {{#if activeProfile.severity}} + {{#unless activeProfile.isTemplate}} + + {{/unless}} + {{#if activeProfile.parent}} + {{#eq activeProfile.inherit 'OVERRIDES'}} + + {{/eq}} + {{else}} + + {{/if}} + {{else}} + + {{/if}} +
+
diff --git a/server/sonar-web/src/main/js/coding-rules/controller.js b/server/sonar-web/src/main/js/coding-rules/controller.js index 5bbdabe234f..f32b51332a6 100644 --- a/server/sonar-web/src/main/js/coding-rules/controller.js +++ b/server/sonar-web/src/main/js/coding-rules/controller.js @@ -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 }; diff --git a/server/sonar-web/src/main/js/coding-rules/models/rules.js b/server/sonar-web/src/main/js/coding-rules/models/rules.js index d0cc24411e6..e6d92e6135e 100644 --- a/server/sonar-web/src/main/js/coding-rules/models/rules.js +++ b/server/sonar-web/src/main/js/coding-rules/models/rules.js @@ -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 () { diff --git a/server/sonar-web/src/main/js/coding-rules/workspace-list-item-view.js b/server/sonar-web/src/main/js/coding-rules/workspace-list-item-view.js index f7cd1120f15..02627c69f24 100644 --- a/server/sonar-web/src/main/js/coding-rules/workspace-list-item-view.js +++ b/server/sonar-web/src/main/js/coding-rules/workspace-list-item-view.js @@ -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 }); } }); diff --git a/server/sonar-web/src/main/less/components/rules.less b/server/sonar-web/src/main/less/components/rules.less index 681f54f1b96..c4314d0c84c 100644 --- a/server/sonar-web/src/main/less/components/rules.less +++ b/server/sonar-web/src/main/less/components/rules.less @@ -26,21 +26,30 @@ 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; @@ -58,6 +67,15 @@ } } +.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; -- 2.39.5