summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb14
1 files changed, 8 insertions, 6 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb
index e262a6c3850..7336c98a363 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/admin_dashboards_controller.rb
@@ -57,14 +57,16 @@ class AdminDashboardsController < ApplicationController
def remove
verify_post_request
- if @actives.size<=1
+
+ to_be_removed = ActiveDashboard.find(params[:id])
+ not_found unless to_be_removed
+
+ remaining_defaults = @actives.select { |a| (a.global? == to_be_removed.global? && a.id != to_be_removed.id) }
+ if remaining_defaults.size == 0
flash[:error]='At least one dashboard must be defined as default.'
else
- active=@actives.find { |a| a.id==params[:id].to_i }
- if active
- active.destroy
- flash[:notice]='Dashboard removed from default dashboards.'
- end
+ to_be_removed.destroy
+ flash[:notice]='Dashboard removed from default dashboards.'
end
redirect_to :action => 'index'