The node view is now composed entirely of widgets that register
themselves using the plug-in registry.  This will allow future
plug-ins to add themselves at any point in the view.

Paired-with: Jesse Wolfe <[email protected]>
Signed-off-by: Paul Berry <[email protected]>
---
Local-branch: maint/next/refactor_node_view
 app/views/nodes/_activity.html.haml            |    8 ++
 app/views/nodes/_description.html.haml         |    2 +
 app/views/nodes/_inspections.html.haml         |   26 +++++++
 app/views/nodes/_inventory_service.html.haml   |    9 ++
 app/views/nodes/_node_classification.html.haml |    6 ++
 app/views/nodes/_reports.html.haml             |   35 +++++++++
 app/views/nodes/show.html.haml                 |   95 +-----------------------
 config/environment.rb                          |    2 +
 lib/core_callbacks.rb                          |   23 ++++++
 9 files changed, 113 insertions(+), 93 deletions(-)
 create mode 100644 app/views/nodes/_activity.html.haml
 create mode 100644 app/views/nodes/_description.html.haml
 create mode 100644 app/views/nodes/_inspections.html.haml
 create mode 100644 app/views/nodes/_inventory_service.html.haml
 create mode 100644 app/views/nodes/_node_classification.html.haml
 create mode 100644 app/views/nodes/_reports.html.haml
 create mode 100644 lib/core_callbacks.rb

diff --git a/app/views/nodes/_activity.html.haml 
b/app/views/nodes/_activity.html.haml
new file mode 100644
index 0000000..e53742b
--- /dev/null
+++ b/app/views/nodes/_activity.html.haml
@@ -0,0 +1,8 @@
+.section
+  %h3 Dashboard activity
+  - unless node.timeline_events.empty?
+    %ol.timeline= render node.timeline_events.recent(10)
+  - else
+    = describe_no_matches_for :activity
+
+%br.clear
diff --git a/app/views/nodes/_description.html.haml 
b/app/views/nodes/_description.html.haml
new file mode 100644
index 0000000..428e710
--- /dev/null
+++ b/app/views/nodes/_description.html.haml
@@ -0,0 +1,2 @@
+- unless node.description.blank?
+  .description= simple_format h(node.description)
diff --git a/app/views/nodes/_inspections.html.haml 
b/app/views/nodes/_inspections.html.haml
new file mode 100644
index 0000000..046479e
--- /dev/null
+++ b/app/views/nodes/_inspections.html.haml
@@ -0,0 +1,26 @@
+- if node.reports.inspections.count > 0
+  .section
+    %h3
+      Recent inspections
+      %span.count== (#{node.reports.inspections.count})
+      - reports_limit = 10
+    %table.inspector
+      %thead
+        %tr
+          %th.status
+          %th Reported at
+          %th Total
+          %th Runtime
+      %tbody
+        - node.reports.inspections.limit(reports_limit).each do |report|
+          %tr
+            = report_status_td(report)
+            %td= link_to report.time, report
+            %td= report.total_resources
+            %td= report.total_time
+      - if node.reports.inspections.count > reports_limit
+        %tfoot
+          %tr
+            %td{:colspan => 5}
+              .actionbar
+                = link_to "More &raquo;", reports_node_path(node, :kind => 
"inspect"), :class => 'button'
diff --git a/app/views/nodes/_inventory_service.html.haml 
b/app/views/nodes/_inventory_service.html.haml
new file mode 100644
index 0000000..21bbc7c
--- /dev/null
+++ b/app/views/nodes/_inventory_service.html.haml
@@ -0,0 +1,9 @@
+- if SETTINGS.experimental_inventory_service
+  .section
+    %h3 Inventory
+    %div#inventory
+      = image_tag "loading.gif"
+      = "Loading node inventory"
+    %script{:type => 'text/javascript'}= load_asynchronously("div#inventory", 
facts_node_path(node))
+
+  %br.clear
diff --git a/app/views/nodes/_node_classification.html.haml 
b/app/views/nodes/_node_classification.html.haml
new file mode 100644
index 0000000..2992338
--- /dev/null
+++ b/app/views/nodes/_node_classification.html.haml
@@ -0,0 +1,6 @@
+- if SETTINGS.use_external_node_classification
+  = render 'shared/parameters', :resource => node
+  = render 'shared/groups', :resource => node
+  = render 'shared/classes', :resource => node
+
+%br.clear
diff --git a/app/views/nodes/_reports.html.haml 
b/app/views/nodes/_reports.html.haml
new file mode 100644
index 0000000..279e6ca
--- /dev/null
+++ b/app/views/nodes/_reports.html.haml
@@ -0,0 +1,35 @@
+- reports = node.reports.applies.limit(30).order('time ASC')
+- unless reports.empty?
+  .section
+    = render 'statuses/run_failure', :node => node
+
+  .section
+    = render 'statuses/run_time', :reports => reports.reverse
+
+  .section
+    %h3
+      Recent reports
+      %span.count== (#{node.reports.applies.count})
+      - reports_limit = 10
+    %table.inspector
+      %thead
+        %tr
+          %th.status
+          %th Reported at
+          %th Total
+          %th Failed
+          %th Runtime
+      %tbody
+        - node.reports.applies.limit(reports_limit).each do |report|
+          %tr
+            = report_status_td(report)
+            %td= link_to report.time, report
+            %td= report.total_resources
+            %td= report.failed_resources
+            %td= report.total_time
+      - if node.reports.applies.count > reports_limit
+        %tfoot
+          %tr
+            %td{:colspan => 5}
+              .actionbar
+                = link_to "More &raquo;", reports_node_path(node, :kind => 
"apply"), :class => 'button'
diff --git a/app/views/nodes/show.html.haml b/app/views/nodes/show.html.haml
index eaea054..e76942c 100644
--- a/app/views/nodes/show.html.haml
+++ b/app/views/nodes/show.html.haml
@@ -15,96 +15,5 @@
           %li= link_to 'Hide', hide_node_path(@node), :class => "hide button", 
:method => :put
         %li= link_to 'Destroy', @node, :confirm => 'Are you sure you wish to 
destroy this node?', :method => :delete, :class => "delete button"
   .item
-    - unless @node.description.blank?
-      .description= simple_format h(@node.description)
-
-    - if SETTINGS.use_external_node_classification
-      = render 'shared/parameters', :resource => @node
-      = render 'shared/groups', :resource => @node
-      = render 'shared/classes', :resource => @node
-
-    %br.clear
-
-    - if SETTINGS.experimental_inventory_service
-      .section
-        %h3 Inventory
-        %div#inventory
-          = image_tag "loading.gif"
-          = "Loading node inventory"
-        %script{:type => 'text/javascript'}= 
load_asynchronously("div#inventory", facts_node_path(@node))
-
-      %br.clear
-
-    - reports = @node.reports.applies.limit(30).order('time ASC')
-    - unless reports.empty?
-      .section
-        = render 'statuses/run_failure', :node => @node
-
-      .section
-        = render 'statuses/run_time', :reports => reports.reverse
-
-      .section
-        %h3
-          Recent reports
-          %span.count== (#{@node.reports.applies.count})
-          - reports_limit = 10
-        %table.inspector
-          %thead
-            %tr
-              %th.status
-              %th Reported at
-              %th Total
-              %th Failed
-              %th Runtime
-          %tbody
-            - @node.reports.applies.limit(reports_limit).each do |report|
-              %tr
-                = report_status_td(report)
-                %td= link_to report.time, report
-                %td= report.total_resources
-                %td= report.failed_resources
-                %td= report.total_time
-          - if @node.reports.applies.count > reports_limit
-            %tfoot
-              %tr
-                %td{:colspan => 5}
-                  .actionbar
-                    = link_to "More &raquo;", reports_node_path(@node, :kind 
=> "apply"), :class => 'button'
-
-    - Registry.each_callback :core, :node_view_widgets do |thing|
-      = thing.call self, @node
-    - if @node.reports.inspections.count > 0
-      .section
-        %h3
-          Recent inspections
-          %span.count== (#{@node.reports.inspections.count})
-          - reports_limit = 10
-        %table.inspector
-          %thead
-            %tr
-              %th.status
-              %th Reported at
-              %th Total
-              %th Runtime
-          %tbody
-            - @node.reports.inspections.limit(reports_limit).each do |report|
-              %tr
-                = report_status_td(report)
-                %td= link_to report.time, report
-                %td= report.total_resources
-                %td= report.total_time
-          - if @node.reports.inspections.count > reports_limit
-            %tfoot
-              %tr
-                %td{:colspan => 5}
-                  .actionbar
-                    = link_to "More &raquo;", reports_node_path(@node, :kind 
=> "inspect"), :class => 'button'
-
-    .section
-      %h3 Dashboard activity
-      - unless @node.timeline_events.empty?
-        %ol.timeline= render @node.timeline_events.recent(10)
-      - else
-        = describe_no_matches_for :activity
-
-    %br.clear
+    - Registry.each_callback :core, :node_view_widgets do |widget|
+      = widget.call self, @node
diff --git a/config/environment.rb b/config/environment.rb
index e0084a5..6163bce 100644
--- a/config/environment.rb
+++ b/config/environment.rb
@@ -9,6 +9,8 @@ require 'active_support'
 
 require 'registry'
 
+require 'core_callbacks'
+
 Rails::Initializer.run do |config|
   config.gem 'rack'
   config.gem 'haml'
diff --git a/lib/core_callbacks.rb b/lib/core_callbacks.rb
new file mode 100644
index 0000000..bb7eda4
--- /dev/null
+++ b/lib/core_callbacks.rb
@@ -0,0 +1,23 @@
+Registry.add_callback :core, :node_view_widgets, "100_description" do 
|view_renderer, node|
+  view_renderer.render 'nodes/description', :node => node
+end
+
+Registry.add_callback :core, :node_view_widgets, "200_node_classification" do 
|view_renderer, node|
+  view_renderer.render 'nodes/node_classification', :node => node
+end
+
+Registry.add_callback :core, :node_view_widgets, "300_inventory_service" do 
|view_renderer, node|
+  view_renderer.render 'nodes/inventory_service', :node => node
+end
+
+Registry.add_callback :core, :node_view_widgets, "400_reports" do 
|view_renderer, node|
+  view_renderer.render 'nodes/reports', :node => node
+end
+
+Registry.add_callback :core, :node_view_widgets, "600_inspections" do 
|view_renderer, node|
+  view_renderer.render 'nodes/inspections', :node => node
+end
+
+Registry.add_callback :core, :node_view_widgets, "700_activity" do 
|view_renderer, node|
+  view_renderer.render 'nodes/activity', :node => node
+end
-- 
1.7.2

-- 
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