<div class="container">
  <h1 class='page-header'>Packages</h1>
  <div class="row">
    <div class="col-md-3">
      <div class="panel panel-default">
        <div class="panel-heading panel-heading-browse">
          <h2>Browse</h2>
        </div>
        <ul class="list-inline">

          <% @package_prefixes.each do |prefix| %>
            <li><h5><a href="/packages/<%= prefix %>/"><%= prefix %></a></h5></li>
          <% end %>
          <% if @package_prefixes.empty? %>
            <li><em>(no data yet)</em></li>
          <% end %>

        </ul>
      </div>
    </div>

    <div class="col-md-9">
      <% @repository.search('^' + (@prefix || '-')).tap do |packages| %>
        <table class="table" style="text-align: left">
          <tr>
            <td><b>Package</b></td>
            <td><b>Status</b></td>
          </tr>
          <% packages.each do |package| %>
            <tr>
              <td><a href="/packages/<%= @prefix %>/<%= package.name %>"><%= package.name %></a></td>
              <% if package.failures.any? %>
                <td>
                  <% package.failures.each do |s| %>
                    <a class='<%= s.extended_status %>' href='<%= "/packages/#{@prefix}/#{package.name}/#{s.suite}/#{s.architecture}"%>'>
                      <%= s.version %> <%= s.status.upcase %> <%= s.suite %>/<%= s.architecture %> <%= s.failmsg && '(%s)' % s.failmsg %>
                    </a>
                  <% end %>
                </td>
              <% else %>
                <td><div class='pass'>Passing everywhere</div></td>
              <% end %>
            </tr>
          <% end %>
        </table>
      <% end %>
    </div>
  </div>
</div>
