- content_for :page_title do
  = t('admin.accounts.title')

.filters
  .filter-subset
    %strong= t('admin.accounts.location.title')
    %ul
      %li= filter_link_to t('admin.accounts.location.local'), remote: nil
      %li= filter_link_to t('admin.accounts.location.remote'), remote: '1'
  .filter-subset
    %strong= t('admin.accounts.moderation.title')
    %ul
      %li= link_to safe_join([t('admin.accounts.moderation.pending'), "(#{number_with_delimiter(User.pending.count)})"], ' '), admin_pending_accounts_path
      %li= filter_link_to t('admin.accounts.moderation.active'), silenced: nil, suspended: nil, pending: nil
      %li= filter_link_to t('admin.accounts.moderation.silenced'), silenced: '1', suspended: nil, pending: nil
      %li= filter_link_to t('admin.accounts.moderation.suspended'), suspended: '1', silenced: nil, pending: nil
  .filter-subset
    %strong= t('admin.accounts.role')
    %ul
      %li= filter_link_to t('admin.accounts.moderation.all'), staff: nil
      %li= filter_link_to t('admin.accounts.roles.staff'), staff: '1'
  .filter-subset
    %strong= t 'generic.order_by'
    %ul
      %li= filter_link_to t('relationships.most_recent'), order: nil
      %li= filter_link_to t('admin.accounts.username'), order: 'alphabetic'
      %li= filter_link_to t('relationships.last_active'), order: 'active'

= form_tag admin_accounts_url, method: 'GET', class: 'simple_form' do
  .fields-group
    - AccountFilter::KEYS.each do |key|
      - if params[key].present?
        = hidden_field_tag key, params[key]

    - %i(username by_domain display_name email ip).each do |key|
      - unless key == :by_domain && params[:remote].blank?
        .input.string.optional
          = text_field_tag key, params[key], class: 'string optional', placeholder: I18n.t("admin.accounts.#{key}")

    .actions
      %button.button= t('admin.accounts.search')
      = link_to t('admin.accounts.reset'), admin_accounts_path, class: 'button negative'

.table-wrapper
  %table.table
    %thead
      %tr
        %th= t('admin.accounts.username')
        %th= t('admin.accounts.role')
        %th= t('admin.accounts.most_recent_ip')
        %th= t('admin.accounts.most_recent_activity')
        %th
    %tbody
      = render @accounts

= paginate @accounts