From 99e3b54a11d97f5240a5d737a23129821ef8db5f Mon Sep 17 00:00:00 2001 From: Stas Vilchik Date: Wed, 25 Jan 2017 16:06:26 +0100 Subject: [PATCH] SONAR-7931 Show hierarchy of profiles in rule activation --- .../rule/profile-activation-view.js | 9 +++++++- .../rule/coding-rules-profile-activation.hbs | 23 +++++++++++-------- .../main/js/apps/quality-profiles/utils.js | 13 ++++++++--- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js index 5c4e92d10c9..70fe0cd6a4d 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js +++ b/server/sonar-web/src/main/js/apps/coding-rules/rule/profile-activation-view.js @@ -22,6 +22,7 @@ import Backbone from 'backbone'; import ModalForm from '../../../components/common/modal-form'; import Template from '../templates/rule/coding-rules-profile-activation.hbs'; import { csvEscape } from '../../../helpers/csv'; +import { sortProfiles } from '../../quality-profiles/utils'; export default ModalForm.extend({ template: Template, @@ -144,12 +145,18 @@ export default ModalForm.extend({ const availableProfiles = this.getAvailableQualityProfiles(this.options.rule.get('lang')); const contextProfile = this.options.app.state.get('query').qprofile; + // decrease depth by 1, so the top level starts at 0 + const profilesWithDepth = sortProfiles(availableProfiles).map(profile => ({ + ...profile, + depth: profile.depth - 1 + })); + return { ...ModalForm.prototype.serializeData.apply(this, arguments), params, contextProfile, change: this.model && this.model.has('severity'), - qualityProfiles: availableProfiles, + qualityProfiles: profilesWithDepth, severities: ['BLOCKER', 'CRITICAL', 'MAJOR', 'MINOR', 'INFO'], saveEnabled: availableProfiles.length > 0 || (this.model && this.model.get('qProfile')), isCustomRule: (this.model && this.model.has('templateKey')) || this.options.rule.has('templateKey') diff --git a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs index 7a7a2d9a3a8..e7b30dbbf09 100644 --- a/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs +++ b/server/sonar-web/src/main/js/apps/coding-rules/templates/rule/coding-rules-profile-activation.hbs @@ -23,7 +23,9 @@ {{else}} {{/any}} @@ -37,8 +39,9 @@ {{#if isCustomRule}} -