From: David Gageot Date: Wed, 16 May 2012 13:58:58 +0000 (+0200) Subject: SONAR-3482 Prevent removing a filter which is used by a widget X-Git-Tag: 3.1~183 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ed577004fe47daa335abcdd2287231400fb0dcb4;p=sonarqube.git SONAR-3482 Prevent removing a filter which is used by a widget --- diff --git a/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb b/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb index 7d08bc89a95..d5097476165 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb +++ b/sonar-server/src/main/webapp/WEB-INF/app/controllers/filters_controller.rb @@ -104,8 +104,12 @@ class FiltersController < ApplicationController access_denied unless @filter.authorized_to_edit?(self) if @filter - @filter.destroy - flash[:notice]='Filter deleted' + if WidgetProperty.find(:first, :conditions => { :kee => 'filter', :text_value => @filter.id.to_s}) + flash[:error]='The filter is used in at least one dashboard. It cannot be deleted' + else + @filter.destroy + flash[:notice]='Filter deleted' + end end redirect_to :action => 'manage'