<% title _("Puppet classes") %>

<% title_actions import_proxy_select(hash_for_import_environments_puppetclasses_path), button_group(display_link_if_authorized(_("New Puppet class"), hash_for_new_puppetclass_path)) %>

<table class="table table-bordered table-striped">
  <tr>
    <th><%= sort :name, :as => s_("Puppetclass|Name") %></th>
    <th><%= sort :environment, :as => _("Environments and documentation") %></th>
    <th><%= _('Host group') %></th>
    <th><%= _('Hosts') %></th>
    <th><%= _('Keys') %></th>
    <th></th>
  </tr>
  <% for puppetclass in @puppetclasses %>
    <tr>
      <td><%=link_to_if_authorized h(puppetclass.name), hash_for_edit_puppetclass_path(:id => puppetclass) %></td>
      <td>
        <% puppetclass.environments.uniq.each do |environment| %>
          <%= link_to_function environment, 'show_rdoc(this)', :'data-url' => rdoc_classes_path(environment, puppetclass.name) %>
        <% end %>
      </td>
      <td><%= puppetclass.hostgroups.map {|hg| link_to_if_authorized hg, hash_for_edit_hostgroup_path(:id=>hg)}.to_sentence.html_safe %></td>
      <td> <%= link_to host_counter(puppetclass), hosts_path(:search => "class = #{puppetclass.name}")%></td>
      <td><%= @keys_counter[puppetclass.name] || 0 %> </td>
      <td>
        <%= display_delete_if_authorized hash_for_puppetclass_path(:id => puppetclass), :confirm => _("Delete %s?") % puppetclass.name %>
      </td>
    </tr>
  <% end %>
</table>

<%= page_entries_info @puppetclasses %>
<%= will_paginate @puppetclasses %>
