<% content_for(:secondary_links) do %>
  <%= quick_search_form_for(:name_matches, users_path, "users", autocomplete: "user", redirect: true) %>
  <%= subnav_link_to "Listing", users_path %>

  <% if CurrentUser.user.is_anonymous? %>
    <%= subnav_link_to "Sign up", new_user_path %>
  <% end %>

  <% if @user && !@user.new_record? && !CurrentUser.user.is_anonymous? %>
    <li>|</li>
    <% if @user.id == CurrentUser.user.id %>
      <%= subnav_link_to "Profile", profile_path %>
      <%= subnav_link_to "Settings", settings_path %>
      <%= subnav_link_to "Messages #{unread_dmail_indicator(CurrentUser.user)}", dmails_path(search: { folder: "received" }) %>

      <% if !@user.is_platinum? %>
        <%= subnav_link_to "Upgrade", new_user_upgrade_path %>
      <% end %>
    <% else %>
      <%= subnav_link_to "Send message", new_dmail_path(:dmail => {:to_id => @user.id}) %>
      <% if !@user.is_platinum? %>
        <%= subnav_link_to "Gift upgrade", new_user_upgrade_path(:user_id => @user.id) %>
      <% end %>
    <% end %>

    <% if policy(CurrentUser.user).promote? %>
      <%= subnav_link_to "Promote", edit_admin_user_path(@user) %>
    <% end %>

    <% if policy(Ban.new(user: @user)).create? %>
      <% if @user.is_banned? && @user.active_ban.present? %>
        <%= subnav_link_to "Unban", ban_path(@user.active_ban) %>
      <% else %>
        <%= subnav_link_to "Ban", new_ban_path(:ban => {:user_id => @user.id}) %>
      <% end %>
    <% end %>

    <li>|</li>
    <%= subnav_link_to "Log out", logout_path %>
  <% end %>
<% end %>
