_navbar.html.erb 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <% if user_masquerade? %>
  2. <div class="alert alert-warning text-center">
  3. You're logged in as <b><%= current_user.name %> (<%= current_user.email %>)</b>
  4. <%= link_to back_masquerade_path(current_user) do %><%= icon("times") %> Logout <% end %>
  5. </div>
  6. <% end %>
  7. <nav class="navbar navbar-expand-md navbar-light bg-light">
  8. <div class="container">
  9. <%= link_to "Jumpstart", root_path, class: "navbar-brand" %>
  10. <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarMain" aria-controls="navbarsExample04" aria-expanded="false" aria-label="Toggle navigation">
  11. <span class="navbar-toggler-icon"></span>
  12. </button>
  13. <div class="collapse navbar-collapse" id="navbarMain">
  14. <ul class="navbar-nav mr-auto mt-2 mt-md-0">
  15. </ul>
  16. <ul class="navbar-nav">
  17. <li class="nav-item"><%= link_to "What's New", announcements_path, class: "nav-link #{unread_announcements(current_user)}" %></li>
  18. <% if user_signed_in? %>
  19. <li class="nav-item">
  20. <%= link_to notifications_path, class: "nav-link" do %>
  21. <span><i class="fa fa-flag-o" aria-hidden="true"></i></span>
  22. <% end %>
  23. </li>
  24. <li class="nav-item dropdown">
  25. <%= link_to root_path, id: "navbar-dropdown", class: "nav-link dropdown-toggle", data: { toggle: "dropdown" }, aria: { haspopup: true, expanded: false } do %>
  26. <%= image_tag gravatar_image_url(current_user.email, size: 40), height: 20, width: 20, class: "rounded" %>
  27. <% end %>
  28. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbar-dropdown">
  29. <% if current_user.admin? %>
  30. <%= link_to "Admin Area", admin_root_path, class: "dropdown-item" %>
  31. <% end %>
  32. <%= link_to "Settings", edit_user_registration_path, class: "dropdown-item" %>
  33. <div class="dropdown-divider"></div>
  34. <%= link_to "Logout", destroy_user_session_path, method: :delete, class: "dropdown-item" %>
  35. </div>
  36. </li>
  37. <% else %>
  38. <li class="nav-item"><%= link_to "Sign Up", new_user_registration_path, class: "nav-link" %></li>
  39. <li class="nav-item"><%= link_to "Login", new_user_session_path, class: "nav-link" %></li>
  40. <% end %>
  41. </ul>
  42. </div>
  43. </div>
  44. </nav>