_navbar.html.erb 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 "Spark", 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 dropdown">
  20. <%= link_to root_path, id: "navbar-dropdown", class: "nav-link dropdown-toggle", data: { toggle: "dropdown" }, aria: { haspopup: true, expanded: false } do %>
  21. <%= image_tag gravatar_image_url(current_user.email, size: 40), height: 20, width: 20, class: "rounded" %>
  22. <% end %>
  23. <div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbar-dropdown">
  24. <% if current_user.admin? %>
  25. <%= link_to "Admin Area", admin_root_path, class: "dropdown-item" %>
  26. <% end %>
  27. <%= link_to "Settings", edit_user_registration_path, class: "dropdown-item" %>
  28. <div class="dropdown-divider"></div>
  29. <%= link_to "Logout", destroy_user_session_path, method: :delete, class: "dropdown-item" %>
  30. </div>
  31. </li>
  32. <% else %>
  33. <li class="nav-item"><%= link_to "Sign Up", new_user_registration_path, class: "nav-link" %></li>
  34. <li class="nav-item"><%= link_to "Login", new_user_session_path, class: "nav-link" %></li>
  35. <% end %>
  36. </ul>
  37. </div>
  38. </div>
  39. </nav>