18F/identity-dashboard

View on GitHub
app/views/users/index.html.erb

Summary

Maintainability
Test Coverage

<h1 class="usa-display">Users</h1>

<div class="display-flex">
  <%= button_to t('headings.users.new_user'),
    new_user_path,
    method: :get,
    class: 'usa-button'
  %>

  <% if can_delete_unconfirmed_users?(current_user, @users) %>
    <%= button_to t('forms.buttons.remove_unconfirmed_users'),
      remove_unconfirmed_users_path,
      method: :delete,
      class: 'usa-button' %>
  <% end %>
</div>
<table class="usa-table">
  <thead>
    <tr>
      <th scope="col">Email</th>
      <th scope="col">Signed in</th>
      <th scope="col">Admin</th>
      <th scope="col">Actions</th>
    </tr>
  </thead>
  <tbody>
    <% @users.each do |user| %>
      <tr>
        <td><%= user.email %></td>
        <td><%= image_tag sign_in_icon(user), height: '27', width: '27',
                          title: title(user),
                          alt: alt(user),
                          role: 'img' %></td>
        <td><%= image_tag 'security-key.svg',
                          height: '27', width: '27',
                          alt: 'admin user icon',
                          role: 'img' if user.admin? %></td>
        <td>
          <%= button_to 'Delete', user_path(user.id), method: :delete,
                      form_class: 'display-inline',
                      class: 'usa-button usa-button--unstyled usa-link margin-right-1',
                      data: { confirm: t('notices.confirm_delete') } %>
          <%= link_to 'Edit', edit_user_path(user.id), class: 'usa-link' %>
        </td>
      </tr>
    <% end %>
  </tbody>
</table>