Class: Avo::SidebarProfileComponent
- Inherits:
-
BaseComponent
- Object
- BaseComponent
- Avo::SidebarProfileComponent
- Defined in:
- app/components/avo/sidebar_profile_component.rb
Instance Method Summary collapse
- #avatar ⇒ Object
- #can_sign_out_user? ⇒ Boolean
- #custom_profile_component ⇒ Object
- #default_sign_out_path ⇒ Object
- #initials ⇒ Object
- #name ⇒ Object
- #render_custom_profile_menu? ⇒ Boolean
- #sign_out_method ⇒ Object
- #sign_out_path ⇒ Object
- #title ⇒ Object
Instance Method Details
#avatar ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/components/avo/sidebar_profile_component.rb', line 8 def avatar if @user.respond_to?(:avatar) && @user.avatar.present? @user.avatar else "" end end |
#can_sign_out_user? ⇒ Boolean
57 58 59 |
# File 'app/components/avo/sidebar_profile_component.rb', line 57 def can_sign_out_user? sign_out_path.present? && main_app.respond_to?(sign_out_path&.to_sym) end |
#custom_profile_component ⇒ Object
61 62 63 |
# File 'app/components/avo/sidebar_profile_component.rb', line 61 def custom_profile_component Avo::Sidebar::CustomProfileComponent.new end |
#default_sign_out_path ⇒ Object
51 52 53 54 55 |
# File 'app/components/avo/sidebar_profile_component.rb', line 51 def default_sign_out_path default_path = :"destroy_#{Avo.configuration.current_user_resource_name}_session_path" default_path if main_app.respond_to?(default_path) end |
#initials ⇒ Object
36 37 38 |
# File 'app/components/avo/sidebar_profile_component.rb', line 36 def initials name.split(" ").map(&:first).join("").first(2).upcase end |
#name ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'app/components/avo/sidebar_profile_component.rb', line 16 def name if @user.respond_to?(:name) && @user.name.present? @user.name elsif @user.respond_to?(:email) && @user.email.present? @user.email elsif @user.respond_to?(:email_address) && @user.email_address.present? @user.email_address else "Avo user" end end |
#render_custom_profile_menu? ⇒ Boolean
65 66 67 68 69 |
# File 'app/components/avo/sidebar_profile_component.rb', line 65 def return false unless Avo.plugin_manager.installed?("avo-menu") custom_profile_component.render? end |
#sign_out_method ⇒ Object
40 41 42 |
# File 'app/components/avo/sidebar_profile_component.rb', line 40 def sign_out_method :delete end |
#sign_out_path ⇒ Object
44 45 46 47 48 49 |
# File 'app/components/avo/sidebar_profile_component.rb', line 44 def sign_out_path return Avo.configuration.sign_out_path_name if Avo.configuration.sign_out_path_name.present? return :session_path if helpers.possibly_rails_authentication? default_sign_out_path end |
#title ⇒ Object
28 29 30 31 32 33 34 |
# File 'app/components/avo/sidebar_profile_component.rb', line 28 def title if @user.respond_to?(:avo_title) && @user.avo_title.present? @user.avo_title else "" end end |