rubyforgood/babywearing

View on GitHub
app/views/layouts/_header_signed_in.html.erb

Summary

Maintainability
Test Coverage
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
  <a class="navbar-brand" href="/"><%= image_tag "Babywearing Logo.svg", alt: "Mid-Atlantic Babywearing Logo" %></a>
  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <% if !@admin_org && policy(:menu).show? %>
      <ul class="navbar-nav mr-auto">
        <% if policy(User).new? %>
          <li class="nav-item active background-blue">
            <%= link_to new_user_registration_path, class: 'nav-link nav-icon nav-first' do %>
              <%= image_tag "BW- CREATE USER ICON.svg", alt: "Create a User" %><p>NEW USER</p>
            <% end %>
          </li>
        <% end %>
        <% if !@admin_org && policy(Carrier).new? %>
          <li class="nav-item active background-slate">
            <%= link_to new_carrier_path, class: 'nav-link nav-icon nav-second' do %>
              <%= image_tag "BW- ADD USER ICON.svg", alt: "Add a Carrier" %><p>ADD CARRIER</p>
            <% end %>
          </li>
        <% end %>
        <% if policy(User).new? %>
          <li class="nav-item active background-purple members-tile">
            <%= link_to users_path, class: 'nav-link nav-icon nav-third' do %>
              <%= fa_icon "users", class: "members-icon" %><p>VIEW USERS</p>
            <% end %>
          </li>
        <% end %>
        <% if policy(User).new? %>
          <li class="nav-item active background-dark-purple">
            <%= link_to loan_listing_path, class: 'nav-link nav-icon nav-fourth' do %>
              <%= image_tag "BW- CART ICON.svg", alt: "View Loans" %><p>VIEW LOANS</p>
            <% end %>
          </li>
        <% end %>
        <li class="nav-item active background-darkest-purple">
          <%= link_to carriers_path, class: 'nav-link nav-icon nav-fifth' do %>
            <%= image_tag "BW - INVENTORY ICON.svg", alt: "View Loans" %><p>VIEW CARRIERS</p>
          <% end %>
        </li>
      </ul>
      <% if !@admin_org && show_quick_access?(current_user) %>
        <ul class="nav navbar-nav navbar-middle">
          <div class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Quick Access<span class="caret"></span></a>
            <div class="dropdown-menu" role="menu">
              <%= link_to 'Agreements', agreements_path, class: 'dropdown-item' if policy(Agreement).index? %>
              <%= link_to 'Email Templates', email_templates_path, class: 'dropdown-item' if policy(EmailTemplate).index? %>
              <%= link_to 'Fee Types', fee_types_path, class: 'dropdown-item' if policy(FeeType).index? %>
              <%= link_to 'Locations', locations_path, class: 'dropdown-item' if policy(Location).index? %>
              <%= link_to 'Membership Types', membership_types_path, class: 'dropdown-item' if policy(MembershipType).index? %></li>
            </div>
          </div>
        </ul>
      <% end %>
    <% end %>
    <ul class="navbar-nav ml-auto">
      <li class="nav-item dropdown">
        <a class="nav-link dropdown-toggle d-flex align-items-center user-dropdown" href="#" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          <span class="bg-info text-white font-weight-bolder rounded-circle text-uppercase justify-content-center d-flex align-items-center" style="width: 40px; height: 40px"><%= user_initials(current_user) %></span>
        </a>
        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
          <h6 class="dropdown-header">Logged in as <strong><%= current_user.email %></strong></h6>
          <%= link_to 'Agreements', user_signatures_path(current_user), class: 'dropdown-item' unless @admin_org ||
                                                                  AgreementVersion.active.count == 0 %>
          <%= link_to 'Edit profile', edit_user_registration_path, :class => 'dropdown-item' %>
          <div class="dropdown-divider"></div>
          <%= link_to "Logout", destroy_user_session_path, method: :delete, :class => 'dropdown-item' %>
        </div>
      </li>
    </ul>
  </div>
</nav>