Class: Avo::SidebarProfileComponent

Inherits:
BaseComponent
  • Object
show all
Defined in:
app/components/avo/sidebar_profile_component.rb

Constant Summary

Constants included from Concerns::FindAssociationField

Concerns::FindAssociationField::ASSOCIATIONS

Instance Method Summary collapse

Methods inherited from BaseComponent

#component_name, #hotkey_badge

Methods included from ApplicationHelper

#a_button, #a_link, #body_classes, #button_classes, #chart_color, #container_classes, #d, #decode_filter_params, #e, #editor_file_path, #editor_url, #empty_state, #encode_filter_params, #frame_id, #get_model_class, #input_classes, #mount_path, #number_to_social, #possibly_rails_authentication?, #render_license_warning, #root_path_without_url, #rtl?, #text_direction, #ui, #wrap_in_modal

Methods included from ResourcesHelper

#field_wrapper, #filter_wrapper, #index_field_wrapper, #item_selector_data_attributes, #record_path, #record_title, #resource_for_record, #resource_grid, #resource_show_path, #resource_table

Methods included from Concerns::FindAssociationField

#find_association_field

Instance Method Details

#avatarObject



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

Returns:

  • (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_componentObject



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_pathObject



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

#initialsObject



36
37
38
# File 'app/components/avo/sidebar_profile_component.rb', line 36

def initials
  name.split(" ").map(&:first).join("").first(2).upcase
end

#nameObject



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

Returns:

  • (Boolean)


65
66
67
68
69
# File 'app/components/avo/sidebar_profile_component.rb', line 65

def render_custom_profile_menu?
  return false unless Avo.plugin_manager.installed?("avo-menu")

  custom_profile_component.render?
end

#sign_out_methodObject



40
41
42
# File 'app/components/avo/sidebar_profile_component.rb', line 40

def sign_out_method
  :delete
end

#sign_out_pathObject



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

#titleObject



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