rubyforgood/casa

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

Summary

Maintainability
Test Coverage
<header class="header pt-0">
  <%= render 'layouts/banner' %>

  <% if current_user != true_user %>
    <%= link_to stop_impersonating_volunteers_path, method: :post, class: "pt-4 pb-4 bg-danger", style: "padding-left: 15px; display: block;" do %>
      You (<%= true_user.display_name %>) are signed in as <%= current_user.display_name %>.
      Click here to stop impersonating.
    <% end %>
  <% end %>

  <div class="container-fluid pt-30">
    <div class="row">
      <div class="col-lg-5 col-md-5 col-6">
        <button type="button" class="btn btn-sidebar d-md-none" data-controller="navbar" data-action="click->navbar#click" data-navbar-sidebar-outlet=".sidebar-controller">
          <i class="lni lni-menu"></i>
        </button>
      </div>

      <div class="col-lg-7 col-md-7 col-6">
        <div class="header-right">
          <!-- notification start -->
          <!-- message start -->

          <div class="header-message-box ml-15 d-none d-md-flex">
            <%= link_to notifications_path do %>

              <button
                class="dropdown-toggle"
                type="button"
                id="message"
                aria-expanded="false">

                <i class="lni lni-envelope"></i>
                <% notifications = current_user.notifications.unread.count %>
                <% if notifications > 0 %>
                  <span><%= notifications %></span>
                <% end %>
              </button>
            <% end %>

          </div>

          <div class="profile-box ml-15">
            <button
              class="dropdown-toggle bg-transparent border-0"
              type="button"
              id="profile"
              data-bs-toggle="dropdown"
              aria-expanded="false">
              <div class="profile-info">
                <div class="info">
                  <h6><%= current_user.display_name %>
                  </h6>
                  <div class="image">
                    <img
                      src="<%= "/assets/images/profile/profile-image-#{rand(8) + 1}.png" %>">
                  </div>
                </div>
              </div>
              <i class="lni lni-chevron-down"></i>
            </button>
            <ul
              class="dropdown-menu dropdown-menu-end"
              aria-labelledby="profile">
              <li>
                <span>
                  <strong>Role: <%= current_role %></strong>
                </span>
              </li>
              <li>
                <span>
                  <strong> <%= current_user.email %></strong>
                </span>
              </li>
              <li>
                <%= link_to edit_users_path do %>
                  <i class="lni lni-pencil"></i>
                  Edit Profile
                <% end %>
              </li>
              <li>
                <%= link_to notifications_path do %>
                  <i class="lni lni-envelope"></i>
                  Messages
                <% end %>
              </li>
              <% if policy(:application).modify_organization? %>
                <li>
                  <%= link_to edit_casa_org_path(current_organization) do %>
                    <i class="lni lni-cogs mr-10"></i>
                    Edit Organization
                  <% end %>
                </li>
              <% end %>
              <li>
                <% help_url = current_user.volunteer? ? help_volunteers_url : help_admins_supervisors_url %>
                <%= link_to help_url, target: :_blank do %>
                  <i class="lni lni-question-circle"></i>
                  Help
                <% end %>
              </li>
              <li>
                <%= link_to destroy_user_session_path do %>
                  <i class="lni lni-exit"></i>
                  Sign Out
                <% end %>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
  </div>
</header>
<%= render 'layouts/flash_messages' %>