Added the history for how groups, classes, and parameters were inherited to the views for nodes and groups. Also separated those sections into their own partial templates, to simplify the main view templates and to collect similar functionality.
Signed-off-by: Nick Lewis <[email protected]> --- app/views/node_groups/show.html.haml | 33 +++++++++++++++---------------- app/views/nodes/show.html.haml | 30 ++-------------------------- app/views/shared/_classes.html.haml | 15 ++++++++++++++ app/views/shared/_groups.html.haml | 15 ++++++++++++++ app/views/shared/_parameters.html.haml | 25 ++++++++++++++++++++++++ 5 files changed, 74 insertions(+), 44 deletions(-) create mode 100644 app/views/shared/_classes.html.haml create mode 100644 app/views/shared/_groups.html.haml create mode 100644 app/views/shared/_parameters.html.haml diff --git a/app/views/node_groups/show.html.haml b/app/views/node_groups/show.html.haml index 9b7f084..4f7ba7b 100644 --- a/app/views/node_groups/show.html.haml +++ b/app/views/node_groups/show.html.haml @@ -9,26 +9,25 @@ %li= link_to 'Destroy', @node_group, :confirm => 'Are you sure?', :method => :delete, :class => "delete button" .item - .section - %h3 Parameters - - unless @node_group.parameters.blank? - = inspector_table @node_group.parameters.to_hash - - else - = describe_no_matches_as 'No parameters' - - .section.half - %h3 Inherited groups - - unless @node_group.node_groups.blank? - = inspector_table @node_group.node_groups, :name, false, :link => true - - else - = describe_no_matches_as 'No groups' + = render 'shared/parameters', :resource => @node_group + = render 'shared/groups', :resource => @node_group + = render 'shared/classes', :resource => @node_group .section.half - %h3 Classes - - unless @node_group.node_classes.blank? - = inspector_table @node_group.node_classes, :name, false, :link => true + %h3 Derived groups + - unless resource.node_group_child_list.empty? + %table.inspector + %thead + %tr + %th.key Name + %tbody + - resource.node_group_child_list.each do |group,parents| + %tr + %td.key + %strong= link_to(group.name,group) + = " via #{parents.map{|p| link_to(p.name,p)}.to_sentence}" unless parents.include?(resource) - else - = describe_no_matches_as 'No classes' + = describe_no_matches_as 'No child groups' .item - if @node_group.nodes.present? diff --git a/app/views/nodes/show.html.haml b/app/views/nodes/show.html.haml index f630c70..10bc3c0 100644 --- a/app/views/nodes/show.html.haml +++ b/app/views/nodes/show.html.haml @@ -12,33 +12,9 @@ - unless @node.description.blank? .description= simple_format h(@node.description) - -# Conflicting parameters are okay here, since we just want to warn - - if @node.compiled_parameters(true).present? - - if @node.errors.on(:parameters) - %p.error - %strong Warning: - The following parameters have multiple conflicting values: - = [[email protected](:parameters)].join(", ") - = inspector_table @node.compiled_parameters(true), :key, :value, :link => false, :caption => 'Parameters' - - - .section.half - %h3 Groups - - unless @node.node_groups.empty? - = inspector_table @node.node_groups, :name, false, :link => true - - else - = describe_no_matches_for :groups - - .section.half - %h3 Classes - - unless @node.node_classes.empty? - = inspector_table @node.node_classes, :name, false, :link => true - - else - = describe_no_matches_for :classes - - - unless @node.inherited_classes.empty? - = inspector_table @node.inherited_classes, :name, false, :link => true, :caption => 'Inherited Classes' - + = render 'shared/parameters', :resource => @node + = render 'shared/groups', :resource => @node + = render 'shared/classes', :resource => @node %br.clear diff --git a/app/views/shared/_classes.html.haml b/app/views/shared/_classes.html.haml new file mode 100644 index 0000000..ffce6c8 --- /dev/null +++ b/app/views/shared/_classes.html.haml @@ -0,0 +1,15 @@ +.section.half + %h3 Classes + - unless resource.node_class_list.empty? + %table.inspector + %thead + %tr + %th.key Name + %tbody + - resource.node_class_list.each do |node_class,parents| + %tr + %td.key + %strong= link_to(node_class.name,node_class) + = " via #{parents.map{|p| link_to(p.name,p)}.to_sentence}" unless parents.include?(resource) + - else + = describe_no_matches_as 'No classes' diff --git a/app/views/shared/_groups.html.haml b/app/views/shared/_groups.html.haml new file mode 100644 index 0000000..99e2b11 --- /dev/null +++ b/app/views/shared/_groups.html.haml @@ -0,0 +1,15 @@ +.section.half + %h3 Groups + - unless resource.node_group_list.empty? + %table.inspector + %thead + %tr + %th.key Name + %tbody + - resource.node_group_list.each do |group,parents| + %tr + %td.key + %strong= link_to(group.name,group) + = " via #{parents.map{|p| link_to(p.name,p)}.to_sentence}" unless parents.include?(resource) + - else + = describe_no_matches_as 'No groups' diff --git a/app/views/shared/_parameters.html.haml b/app/views/shared/_parameters.html.haml new file mode 100644 index 0000000..51e8c19 --- /dev/null +++ b/app/views/shared/_parameters.html.haml @@ -0,0 +1,25 @@ +.section + %h3 Parameters + - # Conflicting parameters are okay here, since we just want to warn + - unless resource.compiled_parameters(true).empty? + - if resource.errors.on(:parameters) + %p.error + %strong Warning: + The following parameters have multiple conflicting values: + = [*resource.errors.on(:parameters)].join(", ") + %table.inspector + %thead + %tr + %th.key Key + %th.value{:colspan => 2} Value + %tbody + - resource.compiled_parameters(true).each do |key,value_sources_pair| + - value,sources = value_sources_pair + %tr + %td.key{:style => ("background-color: pink;" if sources.size > 1)} + %tt= key + %td.value + %tt= value + = " from #{sources.map{|source| link_to(source.name,node_group_path(source.id))}.to_sentence}" unless sources == Set[resource] + - else + = describe_no_matches_as 'No parameters' -- 1.7.2.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.
