Class: Alchemy::Admin::CurrentUserName
- Inherits:
-
ViewComponent::Base
- Object
- ViewComponent::Base
- Alchemy::Admin::CurrentUserName
- Defined in:
- app/components/alchemy/admin/current_user_name.rb
Overview
This component is used to display the name of the current Alchemy user in the admin interface.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(user:) ⇒ CurrentUserName
constructor
A new instance of CurrentUserName.
- #render? ⇒ Boolean
Constructor Details
#initialize(user:) ⇒ CurrentUserName
Returns a new instance of CurrentUserName.
5 6 7 8 |
# File 'app/components/alchemy/admin/current_user_name.rb', line 5 def initialize(user:) @user = user @display_name = user.try(:alchemy_display_name) end |
Instance Method Details
#call ⇒ Object
10 11 12 13 14 15 16 17 |
# File 'app/components/alchemy/admin/current_user_name.rb', line 10 def call tag.span class: "current-user-name" do safe_join [ '<alchemy-icon name="user" size="1x"></alchemy-icon>'.html_safe, link_to_if(edit_user_path, display_name, edit_user_path) ] end end |
#render? ⇒ Boolean
19 20 21 |
# File 'app/components/alchemy/admin/current_user_name.rb', line 19 def render? user && display_name.present? end |