<% title _("Host Groups") %>

<% title_actions display_link_if_authorized(_("New Host Group"), hash_for_new_hostgroup_path), help_path %>

<table class="table table-bordered table-striped">
  <thead>
    <tr>
      <th><%= sort :label, :as => _('Hostgroup|Name') %></th>
      <th><%= sort :hosts_count, :as => _('Hosts'), :default => "DESC" %></th>
      <th><%= _('Hosts including sub-groups') %></th>
      <th><%= _('Actions') %></th>
    </tr>
  </thead>
  <tbody>
    <% @hostgroups.each do |hostgroup| %>
      <tr>
        <td>
          <%= label_with_link(hostgroup, 150, authorizer) %>
        </td>
        <td>
          <%= link_to hostgroup.hosts_count, hosts_path(:search => "hostgroup_fullname = #{hostgroup.title}") %>
        </td>
        <td>
          <%= link_to hostgroup.children_hosts_count, hosts_path(:search => "parent_hostgroup = #{hostgroup.title}") %>
        </td>
        <td>
          <%= action_buttons(
                      display_link_if_authorized(_('Nest'),    hash_for_nest_hostgroup_path(:id => hostgroup)),
                      display_link_if_authorized(_('Clone'),   hash_for_clone_hostgroup_path(:id => hostgroup)),
                      display_delete_if_authorized(hash_for_hostgroup_path(:id => hostgroup).merge(:auth_object => hostgroup, :authorizer => authorizer), :data => { :confirm => warning_message(hostgroup) })) %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>

<%= will_paginate_with_info @hostgroups %>
