aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-06-17 16:36:22 +0200
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>2014-06-17 16:36:34 +0200
commit64fd25bd31f4ad4e4133568a011d94fa79b6ab3d (patch)
tree8b9fd9f07009199fb016be71652ed3e6f455a9d2
parent33ca7c4577ff97ff2b2b61101124ebdecdf25df3 (diff)
downloadsonarqube-64fd25bd31f4ad4e4133568a011d94fa79b6ab3d.tar.gz
sonarqube-64fd25bd31f4ad4e4133568a011d94fa79b6ab3d.zip
SONAR-5353 SONAR-5358 Allow to deactivate rule templates if they have been activated previously
-rw-r--r--sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-quality-profile-view.coffee1
-rw-r--r--sonar-server/src/main/coffee/coding-rules/views/coding-rules-detail-view.coffee36
-rw-r--r--sonar-server/src/main/hbs/coding-rules/coding-rules-detail-quality-profile.hbs8
-rw-r--r--sonar-server/src/main/hbs/coding-rules/coding-rules-detail.hbs4
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 '<i class="spinner"></i>'
@@ -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}}
<td class="coding-rules-detail-quality-profile-actions">
<div class="button-group">
- <button class="coding-rules-detail-quality-profile-change">{{t 'change_verb'}}</button>
+ {{#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">
@@ -62,13 +64,13 @@
{{/if}}
{{else}}
- {{#if canWrite}}
+ {{#if canWrite}}{{#unless isTemplate}}
<td class="coding-rules-detail-quality-profile-actions">
<div class="button-group">
<button class="coding-rules-detail-quality-profile-activate">{{t 'coding_rules.activate'}}</button>
</div>
</td>
- {{/if}}
+ {{/unless}}{{/if}}
{{/if}}
</tr>
</tbody>
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 @@
<div class="coding-rules-detail-quality-profiles-section">
<h3 class="coding-rules-detail-title">{{t 'coding_rules.quality_profiles'}}</h3>
- {{#if canWrite}}<div class="button-group coding-rules-detail-quality-profiles-activation">
+ {{#if canWrite}}{{#unless isTemplate}}<div class="button-group coding-rules-detail-quality-profiles-activation">
<button id="coding-rules-quality-profile-activate">{{t 'coding_rules.activate'}}</button>
- </div>{{/if}}
+ </div>{{/unless}}{{/if}}
<div id="coding-rules-detail-quality-profiles"></div>
</div>
{{/if}}