Extract component for account/admin menu links
This way we remove the duplication in the layouts which had these links. Since we're now passing the `current_user` option to partials in all cases, IMHO the code is easier to follow if we use the `Layout::NotificationItemComponent` instead of its partial.
This commit is contained in:
5
app/components/layout/account_menu_component.html.erb
Normal file
5
app/components/layout/account_menu_component.html.erb
Normal file
@@ -0,0 +1,5 @@
|
||||
<ul class="menu" data-responsive-menu="medium-dropdown">
|
||||
<%= render "shared/admin_login_items", current_user: user %>
|
||||
<%= render Layout::NotificationItemComponent.new(user) %>
|
||||
<%= render "devise/menu/login_items", current_user: user %>
|
||||
</ul>
|
||||
7
app/components/layout/account_menu_component.rb
Normal file
7
app/components/layout/account_menu_component.rb
Normal file
@@ -0,0 +1,7 @@
|
||||
class Layout::AccountMenuComponent < ApplicationComponent
|
||||
attr_reader :user
|
||||
|
||||
def initialize(user)
|
||||
@user = user
|
||||
end
|
||||
end
|
||||
@@ -28,11 +28,7 @@
|
||||
<% if show_admin_menu?(user) || namespace != "management" %>
|
||||
<div id="responsive_menu">
|
||||
<div class="top-bar-right">
|
||||
<ul class="menu" data-responsive-menu="medium-dropdown">
|
||||
<%= render "shared/admin_login_items", current_user: user %>
|
||||
<%= render "layouts/notification_item", current_user: user %>
|
||||
<%= render "devise/menu/login_items", current_user: user %>
|
||||
</ul>
|
||||
<%= render Layout::AccountMenuComponent.new(user) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
Reference in New Issue
Block a user