]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-3590 Show clean message when the widget fails to render.
authorFabrice Bellingard <bellingard@gmail.com>
Wed, 11 Jul 2012 14:31:42 +0000 (16:31 +0200)
committerFabrice Bellingard <bellingard@gmail.com>
Thu, 12 Jul 2012 08:33:31 +0000 (10:33 +0200)
plugins/sonar-l10n-en-plugin/src/main/resources/org/sonar/l10n/core.properties
sonar-server/src/main/webapp/WEB-INF/app/helpers/dashboard_helper.rb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_configure_widget.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/dashboard/_widget.html.erb
sonar-server/src/main/webapp/WEB-INF/app/views/widget/index.html.erb

index e6020ecbdccd9eb2b049d436d1c9414514e371ac..12ce94eb15d1d39fb92f3361484aec226229e615 100644 (file)
@@ -607,6 +607,7 @@ search.duration=({0} seconds)
 #------------------------------------------------------------------------------
 
 widgets.more=More
+widget.error_occurred_please_read_logs=An error occurred while trying to display the widget "{0}". Please contact the administrator.
 
 widget.alerts.name=Alerts
 widget.alerts.description=Display current alerts on the project.
index 1461413d9364ee4d84957165e4094206e953de70..803c7f16fb91d122e22feede8ee94dfdcd52c08d 100644 (file)
@@ -120,7 +120,7 @@ module DashboardHelper
   end
 
   def widget_body(widget)
-    widget_body=""
+    widget_body=nil
 
     if widget.configured
       begin
index 3d7e81f9795d87bd1926e403c69d9d5bca18b728..6482380aef85e7cd261d583e8ddc76292d187e3f 100644 (file)
@@ -1,5 +1,8 @@
-<% switch_to_widget_resource(widget) %>
-<% widget_body=widget_body(widget) %>
+<% 
+  switch_to_widget_resource(widget)
+  widget_body=widget_body(widget) 
+  default_layout=(widget.layout=='DEFAULT')
+%>
 
 <div class="widget-header">
   <div class="widget-actions">
   </style>
   <![endif]-->
   <div class="transparent"></div>
-  <% if widget_body.include? '<' %>
+  <% if !widget_body %>
+    <div class="block">
+      <% if default_layout %>
+      <div class="widget">   
+        <span class="empty_widget"><%= message('widget.error_occurred_please_read_logs', :params => widget.name) -%></span>
+        <div class="clear"></div>
+      </div>
+      <% else %>
+        <span class="empty_widget"><%= message('widget.error_occurred_please_read_logs', :params => widget.name) -%></span>
+      <% end %>
+    </div>
+  <% elsif widget_body.include? '<' %>
     <%
-       default_layout=(widget.layout=='DEFAULT')
+       
        if default_layout
     %>
       <div class="widget">
index e7ae2a5ce94646e6da8116e80e8f841acdeb68c5..c39863f4b6e93492435961a02ee0afeaf7d08d2c 100644 (file)
@@ -1,12 +1,27 @@
-<% switch_to_widget_resource(widget) %>
-<% widget_body=widget_body(widget) %>
+<% 
+  switch_to_widget_resource(widget)
+  widget_body=widget_body(widget)
+  default_layout=(widget.java_definition.getWidgetLayout().name()=='DEFAULT')
+%>
 
-<% if widget_body.include?('<') %>
+<% if !widget_body %>
+
+  <div class="block">
+   <% if default_layout %>
+     <div class="widget">   
+       <span class="empty_widget"><%= message('widget.error_occurred_please_read_logs', :params => widget.name) -%></span>
+       <div class="clear"></div>
+     </div>
+   <% else %>
+     <span class="empty_widget"><%= message('widget.error_occurred_please_read_logs', :params => widget.name) -%></span>
+   <% end %>
+  </div>
+
+<% elsif widget_body.include?('<') %>
   <div class="block" id="block_<%= widget.id -%>">
     <%= render :partial => 'widget_title', :locals => {:widget => widget} -%>
 
     <div class="<%= h widget.key -%>" style="height:100%;">
-      <% default_layout=(widget.java_definition.getWidgetLayout().name()=='DEFAULT') %>
       <% if default_layout %>
         <div class="widget">
           <%= widget_body -%>
index 04ff9d1a63ca8f7c51ace411504ba001e1b9b749..68f6685d3498c29bdc23339aaaf21508889df30f 100644 (file)
@@ -1,29 +1,39 @@
 <div id="block_1" class="block" style="width: <%= @widget_width -%>">
   <div class="<%= @widget_definition.getId() %>" style="height:100%;">
     <%
+       widget_body=nil
        begin
          widget_body=render :inline => @widget_definition.getTarget().getTemplate(), :locals => {:widget_properties => @widget.properties_as_hash, :widget => @widget, :dashboard_configuration => @dashboard_configuration}
        rescue => error
          logger.error(message('dashboard.cannot_render_widget_x', :params => [@widget_definition.getId(), error]), error)
-         widget_body=""
        end
-
-       if widget_body.include?('<')
+       default_layout=(@widget_definition.getWidgetLayout().name()=='DEFAULT')
     %>
-      <%
-         default_layout=(@widget_definition.getWidgetLayout().name()=='DEFAULT')
-         if default_layout
-      %>
-        <div class="widget">
-      <% end %>
-      <%= widget_body -%>
-      <% if default_layout %>
+
+<% if !widget_body %>
+
+   <% if default_layout %>
+     <div class="widget">   
+       <span class="empty_widget"><%= message('widget.error_occurred_please_read_logs', :params => @widget.key) -%></span>
+       <div class="clear"></div>
+     </div>
+   <% else %>
+     <span class="empty_widget"><%= message('widget.error_occurred_please_read_logs', :params => @widget.key) -%></span>
+   <% end %>
+
+<% 
+   elsif widget_body.include?('<') 
+%>
+   <% if default_layout %>
+     <div class="widget">
+        <%= widget_body -%>
         <div class="clear"></div>
-        </div>
-      <% end %>
-    <%
-       end
-    %>
+      </div>
+   <% else %>
+     <%= widget_body -%>
+   <% end %>
+<% end %>
+
     <div style="clear: both;"></div>
   </div>
 </div>
\ No newline at end of file