aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulien Lancelot <julien.lancelot@sonarsource.com>2015-02-11 17:11:29 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-02-11 17:49:37 +0100
commitbbfa49753a730cc57831f7de548f5e3625d8a7e4 (patch)
tree8573223cf863ed671c8c50faec0f357e6b5bbb8e
parentbe75d03041402ee68c17b1f9781f7d4839a885b3 (diff)
downloadsonarqube-bbfa49753a730cc57831f7de548f5e3625d8a7e4.tar.gz
sonarqube-bbfa49753a730cc57831f7de548f5e3625d8a7e4.zip
SONAR-6132 Dashboard is failing on removed components
-rw-r--r--server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb45
1 files changed, 31 insertions, 14 deletions
diff --git a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
index 5d4a6cf741e..7c6fdc34a30 100644
--- a/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
+++ b/server/sonar-web/src/main/webapp/WEB-INF/app/controllers/dashboard_controller.rb
@@ -25,22 +25,27 @@ class DashboardController < ApplicationController
def index
load_resource()
-
- if !@resource || @resource.display_dashboard?
- load_dashboard()
- load_authorized_widget_definitions()
- else
- # display the layout of the parent without the sidebar, usually the directory, but display the file viewers
- @hide_sidebar = true
- @file = @resource
- @project = @snapshot.parent.project
- @metric=params[:metric]
- render :action => 'no_dashboard'
+ if !@resource || @resource.display_dashboard?
+ redirect_if_bad_component()
+ load_dashboard()
+ load_authorized_widget_definitions()
+ else
+ if !@resource || !@snapshot
+ redirect_if_bad_component()
+ else
+ # display the layout of the parent without the sidebar, usually the directory, but display the file viewers
+ @hide_sidebar = true
+ @file = @resource
+ @project = @snapshot.parent.project
+ @metric=params[:metric]
+ render :action => 'no_dashboard'
+ end
end
end
def configure
load_resource()
+ redirect_if_bad_component()
load_dashboard()
@category=params[:category]
@@ -136,6 +141,7 @@ class DashboardController < ApplicationController
def widget_definitions
@category=params[:category]
load_resource()
+ # redirect_if_bad_component()
load_dashboard()
load_widget_definitions(@category)
render :partial => 'widget_definitions', :locals => {:category => @category}
@@ -183,12 +189,12 @@ class DashboardController < ApplicationController
def load_resource
if params[:id]
- @resource=Project.by_key(params[:id])
- return project_not_found unless @resource
+ @resource = Project.by_key(params[:id])
+ return unless @resource
@resource=@resource.permanent_resource
@snapshot=@resource.last_snapshot
- return project_not_analyzed unless @snapshot
+ return unless @snapshot
access_denied unless has_role?(:user, @resource)
@@ -196,6 +202,17 @@ class DashboardController < ApplicationController
end
end
+ def redirect_if_bad_component
+ if params[:id]
+ unless @resource
+ return project_not_found
+ end
+ unless @snapshot
+ project_not_analyzed
+ end
+ end
+ end
+
def project_not_found
flash[:error] = message('dashboard.project_not_found')
redirect_to :action => :index