Skip to content

Commit

Permalink
Add 'Switch to' link in admin navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
jp524 committed May 21, 2024
1 parent de8833f commit 6477729
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions app/views/layouts/_lte_admin_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@
<a class="nav-link" data-bs-toggle="dropdown" href="#">
<%= current_user.display_name %>
</a>

<div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
<%= link_to "Switch To: to be implemented", "#", class:"dropdown-item" %>
<% current_user.switchable_roles.each do |role| %>
<% next if role == current_role %>
<%= link_to switch_to_role_users_path(role_id: role.id), class:"dropdown-item" do %>
<i class="fa fa-repeat text-aqua"></i><%= "Switch to: #{role.resource&.name || "Super Admin"}" %>
<% end %>
<% end %>

<div class="dropdown-divider"></div>

<%= link_to destroy_user_session_path, class:"dropdown-item dropdown-footer", method: :delete do %>
<i class="fa fa-sign-out mr-2"></i> Log Out
<i class="fa fa-sign-out mr-2"></i> Log Out
<% end %>
</div>
</li>
2 changes: 1 addition & 1 deletion app/views/layouts/_lte_navbar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<% current_user.switchable_roles.each do |role| %>
<% next if role == current_role %>
<%= link_to switch_to_role_users_path(role_id: role.id), class:"dropdown-item" do %>
<i class="fa fa-repeat text-aqua"></i><%= "Switch to: #{role.resource.name}" %>
<i class="fa fa-repeat text-aqua"></i><%= "Switch to: #{role.resource&.name || "Super Admin"}" %>
<% end %>
<% end %>
<% if current_organization.id.present? &&
Expand Down

0 comments on commit 6477729

Please sign in to comment.