diff options
author | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-22 23:25:28 +0000 |
---|---|---|
committer | simonbrandhof <simon.brandhof@gmail.com> | 2010-12-22 23:25:28 +0000 |
commit | 1b9e5dbd00d8c13328a3add55e734f6fc9044c2c (patch) | |
tree | cdf8f35f115c2f30ead2da513c8e6dc6945a722c /sonar-server | |
parent | a88064602dbaa52f991c2c5c02b6fef16ff1ed69 (diff) | |
download | sonarqube-1b9e5dbd00d8c13328a3add55e734f6fc9044c2c.tar.gz sonarqube-1b9e5dbd00d8c13328a3add55e734f6fc9044c2c.zip |
do not display the delete button on profiles inherited by other profiles
Diffstat (limited to 'sonar-server')
5 files changed, 8 insertions, 5 deletions
diff --git a/sonar-server/src/main/java/org/sonar/server/startup/DeleteDeprecatedMeasures.java b/sonar-server/src/main/java/org/sonar/server/startup/DeleteDeprecatedMeasures.java index 42f23331663..eed02cc31b4 100644 --- a/sonar-server/src/main/java/org/sonar/server/startup/DeleteDeprecatedMeasures.java +++ b/sonar-server/src/main/java/org/sonar/server/startup/DeleteDeprecatedMeasures.java @@ -19,7 +19,6 @@ */ package org.sonar.server.startup; -import org.slf4j.LoggerFactory; import org.sonar.api.database.DatabaseSession; import org.sonar.api.database.model.MeasureModel; import org.sonar.api.platform.ServerUpgradeStatus; @@ -52,7 +51,7 @@ public final class DeleteDeprecatedMeasures { } boolean mustDoPurge() { - return status.isUpgraded() && status.getInitialDbVersion()<=162; + return status.isUpgraded() && status.getInitialDbVersion() <= 162; } void doPurge() { diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb index fcd05e004fd..9ab8bb3d366 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/profiles_controller.rb @@ -93,7 +93,7 @@ class ProfilesController < ApplicationController # def delete @profile = Profile.find(params[:id]) - if @profile && !@profile.provided? && !@profile.default_profile? + if @profile && @profile.deletable? java_facade.deleteProfile(@profile.id) flash[:notice]="Profile '#{@profile.name}' is deleted." end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb index 956e93a7f3d..1c32e082704 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/models/profile.rb @@ -100,6 +100,10 @@ class Profile < ActiveRecord::Base @active_hash_by_rule_id end + def deletable? + !provided? && !default_profile? && children.empty? + end + def inherited? parent_name.present? end diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb index d402cf272b5..0c75209fe57 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/index.html.erb @@ -137,7 +137,7 @@ </td> <td> - <% if (!(profile.provided?) && !(profile.default_profile?)) %> + <% if profile.deletable? %> <%= button_to "Delete", { :action => 'delete', :id => profile.id }, :class => 'action', :id => "delete_#{u profile.key}", :confirm => "Are you sure that you want to delete the profile '#{profile.name}' ?", diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb index 7d3e1c04da9..50c95d98ec0 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/profiles/inheritance.html.erb @@ -29,7 +29,7 @@ <td valign="top" width="300"> <div class="admin"> <% if @profile.provided? %> - <p>This profile can not be changed.</p> + <p>This profile can not be edited.</p> <% else %> <h3>Set parent:</h3> |