Sha256: ba95bec5bd01156af97dccf07725eae997e4707ed50a7036b51c71c75df0c793

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

class Avo::SidebarProfileComponent < Avo::BaseComponent
  prop :user

  delegate :main_app, to: :helpers

  def avatar
    if @user.respond_to?(:avatar) && @user.avatar.present?
      @user.avatar
    else
      ""
    end
  end

  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

  def title
    if @user.respond_to?(:avo_title) && @user.avo_title.present?
      @user.avo_title
    else
      ""
    end
  end

  def sign_out_method
    :delete
  end

  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

  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

  def can_sign_out_user?
    sign_out_path.present? && main_app.respond_to?(sign_out_path&.to_sym)
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
avo-3.15.1 app/components/avo/sidebar_profile_component.rb
avo-3.15.0 app/components/avo/sidebar_profile_component.rb
avo-3.14.5 app/components/avo/sidebar_profile_component.rb
avo-3.14.4 app/components/avo/sidebar_profile_component.rb
avo-3.14.3 app/components/avo/sidebar_profile_component.rb