<ul class="nav nav-tabs">
  <li class="nav-item">
    <%= link_to t(".all_blocks"),
                user_blocks_path,
                :class => ["nav-link", { :active => action_name == "index" }] %>
  </li>
  <% if current_user&.blocks&.exists? %>
    <li class="nav-item">
      <%= link_to t(".blocks_on_me"),
                  user_received_blocks_path(current_user),
                  :class => ["nav-link", { :active => controller_name == "received_blocks" && current_user == @user }] %>
    </li>
  <% end %>
  <% on_user = @user || @user_block&.user %>
  <% if on_user != current_user && on_user&.blocks&.exists? %>
    <li class="nav-item">
      <%= link_to t(".blocks_on_user_html", :user => tag.span(on_user.display_name, :class => "username text-truncate d-inline-block align-bottom", :dir => "auto")),
                  user_received_blocks_path(on_user),
                  :class => ["nav-link", { :active => controller_name == "received_blocks" }] %>
    </li>
  <% end %>
  <% if current_user&.blocks_created&.exists? %>
    <li class="nav-item">
      <%= link_to t(".blocks_by_me"),
                  user_issued_blocks_path(current_user),
                  :class => ["nav-link", { :active => controller_name == "issued_blocks" && current_user == @user }] %>
    </li>
  <% end %>
  <% by_user = @user || @user_block&.creator %>
  <% if by_user != current_user && by_user&.blocks_created&.exists? %>
    <li class="nav-item">
      <%= link_to t(".blocks_by_user_html", :user => tag.span(by_user.display_name, :class => "username text-truncate d-inline-block align-bottom", :dir => "auto")),
                  user_issued_blocks_path(by_user),
                  :class => ["nav-link", { :active => controller_name == "issued_blocks" }] %>
    </li>
  <% end %>
  <% if @user_block&.persisted? %>
    <li class="nav-item">
      <%= link_to t(".block", :id => @user_block.id),
                  user_block_path(@user_block),
                  :class => "nav-link active" %>
    </li>
  <% elsif @user_block&.new_record? %>
    <li class="nav-item">
      <%= link_to t(".new_block"),
                  new_user_block_path,
                  :class => "nav-link active" %>
    </li>
  <% end %>
</ul>
