Add user menu to navbar
This commit is contained in:
parent
2aa0dc5314
commit
db843b8189
1 changed files with 36 additions and 20 deletions
|
@ -3,34 +3,50 @@
|
|||
<%= translate :title %>
|
||||
</a>
|
||||
|
||||
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
|
||||
<button class="navbar-toggler"
|
||||
type="button"
|
||||
data-toggle="collapse"
|
||||
data-target="#navbarSupportedContent"
|
||||
aria-controls="navbarSupportedContent"
|
||||
aria-expanded="false"
|
||||
aria-label="Toggle navigation">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
|
||||
<div class="collapse navbar-collapse" id="navbarSupportedContent">
|
||||
<ul class="navbar-nav mr-auto">
|
||||
</ul>
|
||||
|
||||
<% if user_signed_in? %>
|
||||
<span class="navbar-text mr-2">
|
||||
<%= current_user.email %>
|
||||
</span>
|
||||
<ul class="navbar-nav ml-auto">
|
||||
<li class="nav-item dropdown">
|
||||
<%= link_to truncate(current_user.email),
|
||||
'#',
|
||||
id: :navbarDropdown,
|
||||
role: :button,
|
||||
class: 'nav-link dropdown-toggle',
|
||||
'data-toggle': :dropdown,
|
||||
'aria-haspopup': true,
|
||||
'aria-expanded': false %>
|
||||
|
||||
<%= link_to translate('users.shared.links.sign_out'),
|
||||
destroy_user_session_path,
|
||||
method: :delete,
|
||||
role: :button,
|
||||
class: 'btn btn-light' %>
|
||||
<div class="dropdown-menu" aria-labelledby="navbarDropdown">
|
||||
<%= link_to translate('users.shared.links.sign_out'),
|
||||
destroy_user_session_path,
|
||||
method: :delete,
|
||||
role: :button,
|
||||
class: 'dropdown-item' %>
|
||||
</div>
|
||||
</li>
|
||||
</ul>
|
||||
<% else %>
|
||||
<%= link_to translate('users.shared.links.sign_in'),
|
||||
new_user_session_path,
|
||||
role: :button,
|
||||
class: 'btn btn-light mr-2' %>
|
||||
<div class="ml-auto">
|
||||
<%= link_to translate('users.shared.links.sign_in'),
|
||||
new_user_session_path,
|
||||
role: :button,
|
||||
class: 'btn btn-light mr-2' %>
|
||||
|
||||
<%= link_to translate('users.shared.links.sign_up'),
|
||||
new_user_registration_path,
|
||||
role: :button,
|
||||
class: 'btn btn-primary' %>
|
||||
<%= link_to translate('users.shared.links.sign_up'),
|
||||
new_user_registration_path,
|
||||
role: :button,
|
||||
class: 'btn btn-primary' %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</nav>
|
||||
|
|
Reference in a new issue