dobtco/dispatch

View on GitHub
app/views/application/_navbar.html.erb

Summary

Maintainability
Test Coverage
<nav class='navbar'>
  <div class='container'>
    <div class='navbar_header'>
      <a class='navbar_brand' href='<%= root_path %>'><%= DispatchConfiguration.site_title %></a>
      <a class='navbar_toggle' href='#'><i class='fa fa-reorder'></i></a>
    </div>
    <div class='navbar_content_wrapper'>
      <div class='navbar_content navbar_content_primary'>
        <ul>
          <li <% if content_for(:page_key) == 'opportunities-index' %>class='active'<% end %>>
            <a href='<%= opportunities_path %>'><%= t('browse') %></a>
          </li>

          <% if policy(:opportunity).approve? %>
            <li <% if content_for(:page_key) == 'opportunities-pending' %>class='active'<% end %>>
              <a href='<%= pending_opportunities_path %>'>
                <%= t('approve') %>

                <% if policy(:opportunity).approve? && Opportunity.not_approved.count > 0 %>
                  <span class='navbar_badge'><%= Opportunity.not_approved.count %></span>
                <% end %>
              </a>
            </li>
          <% end %>

          <% if current_user.try(:admin?) %>
            <li>
              <a href='<%= admin_root_path %>'><%= t('admin') %></a>
            </li>
          <% end %>
        </ul>
      </div>

      <div class='navbar_content navbar_content_secondary'>
        <ul>
          <% if signed_in? %>
            <li>
              <a href='<%= edit_user_registration_path %>'><%= current_user.name %></a>
            </li>
            <li>
              <a href='<%= destroy_user_session_path %>' data-method='delete'><%= t('sign_out') %></a>
            </li>
          <% else %>
            <% if content_for(:page_key) != 'sign-in' %>
              <li>
                <span>
                  <a class='button small primary' href='<%= new_user_session_path %>'><%= t('sign_in') %></a>
                </span>
              </li>
            <% end %>
          <% end %>
        </ul>
        <% if policy(:opportunity).create? && content_for(:page_key) != 'opportunities-new' %>
          <a href='<%= new_opportunity_path %>' class='button secondary small'><%= t('post_an_opportunity') %></a>
        <% end %>
      </div>
    </div>
  </div>
</nav>