The case where Dashboard contains no nodes is an unfortunately common case;
every new Dashboard installation comes in such a state.  Prior to this change,
the user experience was that they could not actually view Dashboard in their
browser before at least one node had reported in.

This change replaces the index page with a more informative message when
Dashboard is not aware of any nodes.

Reviewed-By: Jacob Helwig

Signed-off-by: Pieter van de Bruggen <[email protected]>
---
Local-branch: tickets/next/7560
 app/views/pages/home.html.haml    |   30 +++++++++++++++++-------------
 spec/helpers/pages_helper_spec.rb |   17 +++++++++++++++++
 2 files changed, 34 insertions(+), 13 deletions(-)

diff --git a/app/views/pages/home.html.haml b/app/views/pages/home.html.haml
index b1f8e4f..19fc5f5 100644
--- a/app/views/pages/home.html.haml
+++ b/app/views/pages/home.html.haml
@@ -3,17 +3,21 @@
   .header
     %h2 Dashboard
   .item
-    .section
-      %table.node_summary
-        - [ { :title => 'Unresponsive', :nodes => @unresponsive_nodes },
-            { :title => 'Failed',       :nodes => @failed_nodes },
-            { :title => 'Pending',      :nodes => @pending_nodes },
-            { :title => 'Compliant',    :nodes => @compliant_nodes },
-            { :title => 'Total Nodes',  :nodes => @nodes } ].each do |section|
-          = render 'node_summary_row', section
+    - if @nodes.empty?
+      .section
+        %p There are no nodes known by Dashboard.
+    - else
+      .section
+        %table.node_summary
+          - [ { :title => 'Unresponsive', :nodes => @unresponsive_nodes },
+              { :title => 'Failed',       :nodes => @failed_nodes },
+              { :title => 'Pending',      :nodes => @pending_nodes },
+              { :title => 'Compliant',    :nodes => @compliant_nodes },
+              { :title => 'Total Nodes',  :nodes => @nodes } ].each do 
|section|
+            = render 'node_summary_row', section
 
-    .section
-      = render 'statuses/run_failure', :nodes => @nodes
-    .section
-      %h3 Recently-reported nodes
-      = render 'nodes/nodes', :nodes => @recently_reported_nodes, :more_link 
=> nodes_path(:page => 2)
+      .section
+        = render 'statuses/run_failure', :nodes => @nodes
+      .section
+        %h3 Recently-reported nodes
+        = render 'nodes/nodes', :nodes => @recently_reported_nodes, :more_link 
=> nodes_path(:page => 2)
diff --git a/spec/helpers/pages_helper_spec.rb 
b/spec/helpers/pages_helper_spec.rb
index 688618c..ec3523e 100644
--- a/spec/helpers/pages_helper_spec.rb
+++ b/spec/helpers/pages_helper_spec.rb
@@ -8,4 +8,21 @@ describe PagesHelper do
     included_modules.should include(PagesHelper)
   end
 
+  describe '#percentage' do
+    before :each do
+      helper.instance_variable_set(:@nodes, @nodes = [])
+    end
+
+    describe 'with values in @nodes' do
+      before :each do
+        @nodes.push(*%w[ a b c d e f g h i j ])
+      end
+
+      it 'should report the ratio of given list length to @nodes' do
+        helper.percentage(%w[ a b c d e ]).should == 50
+        helper.percentage(%w[ a b c z ]).should == 40
+      end
+    end
+  end
+
 end
-- 
1.7.5.1

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to