From 64fd25bd31f4ad4e4133568a011d94fa79b6ab3d Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Lievremont Date: Tue, 17 Jun 2014 16:36:22 +0200 Subject: SONAR-5353 SONAR-5358 Allow to deactivate rule templates if they have been activated previously --- ...coding-rules-detail-quality-profile-view.coffee | 1 + .../views/coding-rules-detail-view.coffee | 36 ++++++++++++++-------- .../coding-rules-detail-quality-profile.hbs | 8 +++-- .../main/hbs/coding-rules/coding-rules-detail.hbs | 4 +-- 4 files changed, 32 insertions(+), 17 deletions(-) diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee index 7330ebd057d..72acb69f14c 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee @@ -90,3 +90,4 @@ define [ parameters: @enhanceParameters() canWrite: @options.app.canWrite templateKey: @options.rule.get 'templateKey' + isTemplate: @options.rule.get 'isTemplate' diff --git a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee index 5f00924ff4e..f06a7468642 100644 --- a/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee +++ b/sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee @@ -68,16 +68,16 @@ define [ if @model.get 'params' @model.set 'params', _.sortBy(@model.get('params'), 'key') - unless @model.get 'isTemplate' - _.map options.actives, (active) => - _.extend active, options.app.getQualityProfileByKey active.qProfile - qualityProfiles = new Backbone.Collection options.actives, - comparator: 'name' - @qualityProfilesView = new CodingRulesDetailQualityProfilesView - app: @options.app - collection: qualityProfiles - rule: @model + _.map options.actives, (active) => + _.extend active, options.app.getQualityProfileByKey active.qProfile + qualityProfiles = new Backbone.Collection options.actives, + comparator: 'name' + @qualityProfilesView = new CodingRulesDetailQualityProfilesView + app: @options.app + collection: qualityProfiles + rule: @model + unless @model.get 'isTemplate' qualityProfileKey = @options.app.getQualityProfile() if qualityProfileKey @@ -98,9 +98,13 @@ define [ if @model.get 'isTemplate' @$(@contextRegion.el).hide() - @$(@qualityProfilesRegion.el).hide() - @$(@customRulesRegion.el).show() + if _.isEmpty(@options.actives) + @$(@qualityProfilesRegion.el).hide() + else + @qualityProfilesRegion.show @qualityProfilesView + + @$(@customRulesRegion.el).show() customRulesOriginal = @$(@customRulesRegion.el).html() @$(@customRulesRegion.el).html '' @@ -247,6 +251,14 @@ define [ repoKey = @model.get 'repo' isManual = (@options.app.manualRepository().key == repoKey) + qualityProfilesVisible = not isManual + if qualityProfilesVisible + if @model.get 'isTemplate' + qualityProfilesVisible = (not _.isEmpty(@options.actives)) + else + qualityProfilesVisible = (@options.app.canWrite or not _.isEmpty(@options.actives)) + + _.extend super, contextQualityProfile: contextQualityProfile contextQualityProfileName: @options.app.qualityProfileFilter.view.renderValue() @@ -255,7 +267,7 @@ define [ repository: _.find(@options.app.repositories, (repo) -> repo.key == repoKey).name isManual: isManual canWrite: @options.app.canWrite - qualityProfilesVisible: not @model.get('isTemplate') and not isManual and (@options.app.canWrite or not _.isEmpty(@options.actives)) + qualityProfilesVisible: qualityProfilesVisible subcharacteristic: (@options.app.characteristics[@model.get 'debtSubChar'] || '').replace ': ', ' > ' createdAt: new Date(@model.get 'createdAt') allTags: _.union @model.get('sysTags'), @model.get('tags') diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-detail-quality-profile.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-detail-quality-profile.hbs index cd8bf9771d3..9f398ea3f2c 100644 --- a/sonar-server/src/main/hbs/coding-rules/coding-rules-detail-quality-profile.hbs +++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-detail-quality-profile.hbs @@ -45,7 +45,9 @@ {{#if canWrite}}
- + {{#unless isTemplate}} + + {{/unless}} {{#if parent}} {{#eq inherit 'OVERRIDES'}}
- {{/if}} + {{/unless}}{{/if}} {{/if}} diff --git a/sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs b/sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs index f49e514f227..8ae18a3a480 100644 --- a/sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs +++ b/sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs @@ -141,9 +141,9 @@

{{t 'coding_rules.quality_profiles'}}

- {{#if canWrite}}
+ {{#if canWrite}}{{#unless isTemplate}}
-
{{/if}} +
{{/unless}}{{/if}}
{{/if}} -- cgit v1.2.3