sul-dlss/argo

View on GitHub
app/components/top_navbar_component.html.erb

Summary

Maintainability
Test Coverage
<header>
  <div class="container">
    <a class="su-brand-bar__logo" href="https://www.stanford.edu">Stanford University</a>
  </div>
  <nav
    class="navbar navbar-expand-md bg-dark stone-dark"
    role="navigation">
    <div class="container">
      <a
        class="mb-0 navbar-brand navbar-logo nav-link"
        href="https://library.stanford.edu">Stanford Libraries</a>
      <button
        class="navbar-toggler navbar-toggler-right"
        type="button"
        data-toggle="collapse"
        data-bs-toggle="collapse"
        data-target="#user-util-collapse"
        data-bs-target="#user-util-collapse"
        aria-controls="user-util-collapse"
        aria-expanded="false"
        aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
      </button>

      <div
        class="collapse navbar-collapse justify-content-md-end"
        id="user-util-collapse">
        <ul class="navbar-nav">
          <li class="nav-item">
            <%= link_to 'Feedback', 'mailto:argo-feedback@lists.stanford.edu', class: 'nav-link' %>
          </li>
          <% if current_user %>
            <li class="nav-item ms-md-3">
              <p class='navbar-text'>Logged in as <%= current_user.to_s.html_safe %></p>
            </li>
          <% end %>
          <hr>
          <% if session[:groups].present? %>
            <li class='dropdown nav-item d-md-none'>
              <a href='#' class='dropdown-toggle impersonating link-warning nav-link' data-bs-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false'>
                Impersonating: <%= session[:groups].join(' ') %>
                <span class='caret'></span>
              </a>
              <ul class='dropdown-menu'>
                <li>
                  <%= link_to 'Stop Impersonating', auth_forget_impersonated_groups_path %>
                </li>
              </ul>
            </li>
          <% elsif can? :impersonate, User %>
            <li class="nav-item d-md-none">
              <%= link_to 'Impersonate', auth_groups_path, class: 'nav-link' %>
            </li>
          <% end %>

          <li class="nav-item d-md-none">
            <%= link_to 'Bulk&nbsp;Action'.html_safe, bulk_actions_path, class: 'nav-link' %>
          </li>

          <li class="nav-item d-md-none">
            <%= link_to 'All&nbsp;Workflows'.html_safe, report_workflow_grid_path, class: 'nav-link' %>
          </li>

          <li class='nav-item d-md-none dropdown'>
            <a href='#' class='nav-link dropdown-toggle' id="registerDropdown" data-bs-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false'>
              Register
              <span class='caret'></span>
            </a>
            <div class="dropdown-menu" aria-labelledby="registerDropdown">
              <%= link_to 'Register Items', registration_path, class: 'dropdown-item' %>
              <% if can? :create, Cocina::Models::AdminPolicy %>
                <%= link_to 'Register APO', new_apo_path, class: 'dropdown-item' %>
              <% end %>
              <%= link_to 'Agreement', new_agreement_path, class: 'dropdown-item' %>
            </div>
          </li>
        </ul>
      </div>
    </div>
  </nav>

  <div class="masthead bg-dark stone-dark">
    <div class="container">
      <div class="row align-items-center">
        <div
          class="col-md-8 d-flex justify-content-center justify-content-md-start">
          <div class="h1 my-3">
            <%= link_to 'Argo', root_path, class: 'nav-link' %>
          </div>
        </div>
        <div class="col-md-4 d-none d-md-block">
          <nav
            class="navbar navbar-expand d-flex justify-content-end"
            aria-label="browse">
            <ul class="navbar-nav">
              <% if session[:groups].present? %>
                <li class='dropdown nav-item'>
                  <a href='#' class='dropdown-toggle impersonating nav-link' data-bs-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false'>
                    Impersonating: <%= session[:groups].join(' ') %>
                    <span class='caret'></span>
                  </a>
                  <ul class='dropdown-menu'>
                    <li>
                      <%= link_to 'Stop Impersonating', auth_forget_impersonated_groups_path %>
                    </li>
                  </ul>
                </li>
              <% elsif can? :impersonate, User %>
                <li class="nav-item">
                  <%= link_to 'Impersonate', auth_groups_path, class: 'nav-link' %>
                </li>
              <% end %>

              <li class="nav-item ms-3">
                <%= link_to 'Bulk&nbsp;Action'.html_safe, bulk_actions_path, class: 'nav-link' %>
              </li>

              <li class="nav-item ms-3">
                <%= link_to 'All&nbsp;Workflows'.html_safe, report_workflow_grid_path, class: 'nav-link' %>
              </li>

              <li class='nav-item ms-3 dropdown'>
                <a href='#' class='nav-link dropdown-toggle' id="registerDropdown" data-bs-toggle='dropdown' role='button' aria-haspopup='true' aria-expanded='false'>
                  Register
                  <span class='caret'></span>
                </a>
                <div class="dropdown-menu" aria-labelledby="registerDropdown">
                  <%= link_to 'Register Items', registration_path, class: 'dropdown-item' %>
                  <% if can? :create, Cocina::Models::AdminPolicy %>
                    <%= link_to 'Register APO', new_apo_path, class: 'dropdown-item' %>
                  <% end %>
                  <%= link_to 'Agreement', new_agreement_path, class: 'dropdown-item' %>
                </div>
              </li>
            </ul>
          </nav>
        </div>
      </div>
    </div>
  </div>
</header>