]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-1643 do not delete the last default dashboard
authorsimonbrandhof <simon.brandhof@gmail.com>
Wed, 3 Nov 2010 12:23:11 +0000 (12:23 +0000)
committersimonbrandhof <simon.brandhof@gmail.com>
Wed, 3 Nov 2010 12:23:11 +0000 (12:23 +0000)
sonar-server/src/main/webapp/WEB-INF/app/controllers/dashboards_controller.rb
sonar-server/src/main/webapp/WEB-INF/app/controllers/project_controller.rb

index a27e5c595dcc009938be947228f06a37455d5099..290a1499dee3fbc0e8f32be1d59e0f70164548db 100644 (file)
@@ -86,14 +86,20 @@ class DashboardsController < ApplicationController
 
   def delete
     dashboard=Dashboard.find(params[:id])
+    default_dashboards=ActiveDashboard.default_dashboards
     if current_user.active_dashboards.size<=1
       flash[:error]='At least one dashboard must be defined'
       redirect_to :action => 'index', :resource => params[:resource]
 
+    elsif default_dashboards.size==1 && default_dashboards[0].dashboard_id==dashboard.id
+      flash[:error]='At least one default dashboard must be defined'
+      redirect_to :action => 'index', :resource => params[:resource]
+
     elsif dashboard.owner?(current_user)
       dashboard.destroy
       flash[:notice]='Dashboard deleted'
       redirect_to :action => 'index', :resource => params[:resource]
+      
     else
       # TODO explicit error
       redirect_to home_path
index 64be4e9ccb7178d24cc76156e8e5f56d4ea31806..11392d5046426f61860f3d03a16a79fd1d08d818 100644 (file)
@@ -24,7 +24,7 @@ class ProjectController < ApplicationController
   SECTION=Navigation::SECTION_RESOURCE
   
   def index
-    redirect_to :overwrite_params => {:controller => :dashboard, :action => 'index', :resource => params[:id], :id => nil 
+    redirect_to :overwrite_params => {:controller => :dashboard, :action => 'index'} 
   end
 
   def show_reviews