<div class="grid">
  <%= render Components::Backend::Card.new(title: "oauth programs") do %>
    <div class="table-container">
      <table>
        <thead>
          <tr>
            <th>name</th>
            <th>owner</th>
            <th>scopes</th>
            <th>users</th>
            <th>active</th>
          </tr>
        </thead>
        <tbody>
          <% @programs.each do |program| %>
            <tr>
              <td>
                <%= link_to backend_program_path(program) do %>
                  <b><%= program.name %></b>
                <% end %>
                <% if program.description.present? %>
                  <br><small><%= truncate(program.description, length: 40) %></small>
                <% end %>
              </td>
              <td>
                <% if program.owner_identity.present? %>
                  <%= render Components::UserMention.new(program.owner_identity) %>
                <% else %>
                  <i>HQ</i>
                <% end %>
              </td>
              <td><code><%= program.scopes.presence || "—" %></code></td>
              <td><%= program.identities.distinct.count %></td>
              <td><%= render_checkbox(program.active?) %></td>
            </tr>
          <% end %>
        </tbody>
      </table>
    </div>
    <hr>
    <%= render Components::Backend::Item.new(icon: "+", href: new_backend_program_path) do %>
      <b>new program</b>
    <% end %>
  <% end %>
</div>
