Sha256: ba95bec5bd01156af97dccf07725eae997e4707ed50a7036b51c71c75df0c793

Contents?: true

Size: 1.22 KB

Versions: 42

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

42 entries across 42 versions & 1 rubygems

Version Path
avo-3.18.1.tw4 app/components/avo/sidebar_profile_component.rb
avo-3.18.1 app/components/avo/sidebar_profile_component.rb
avo-3.18.0.tw4 app/components/avo/sidebar_profile_component.rb
avo-3.18.0 app/components/avo/sidebar_profile_component.rb
avo-3.17.9.beta2 app/components/avo/sidebar_profile_component.rb
avo-3.17.9.beta1 app/components/avo/sidebar_profile_component.rb
avo-3.17.9.tw4 app/components/avo/sidebar_profile_component.rb
avo-3.17.9 app/components/avo/sidebar_profile_component.rb
avo-3.17.8.tw4 app/components/avo/sidebar_profile_component.rb
avo-3.17.8 app/components/avo/sidebar_profile_component.rb
avo-3.17.7 app/components/avo/sidebar_profile_component.rb
avo-3.17.6.tw4 app/components/avo/sidebar_profile_component.rb
avo-3.17.6 app/components/avo/sidebar_profile_component.rb
avo-3.17.5 app/components/avo/sidebar_profile_component.rb
avo-3.17.4 app/components/avo/sidebar_profile_component.rb
avo-3.17.3 app/components/avo/sidebar_profile_component.rb
avo-3.17.5.tw4 app/components/avo/sidebar_profile_component.rb
avo-3.17.4.tw4 app/components/avo/sidebar_profile_component.rb
avo-3.17.3.tw4 app/components/avo/sidebar_profile_component.rb
avo-3.17.2.tw4 app/components/avo/sidebar_profile_component.rb