Sha256: 2c467c4d684061d9655af70bdb8c237944fdded366be3665b6fe47493ee92ae3

Contents?: true

Size: 991 Bytes

Versions: 19

Compression:

Stored size: 991 Bytes

Contents

# frozen_string_literal: true

class Avo::SidebarProfileComponent < Avo::BaseComponent
  attr_reader :user

  def initialize(user:)
    @user = user
  end

  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
    else
      "Avo user"
    end
  end

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

  def destroy_user_session_path
    # If `sign_out_path_name` is configured, use it. Otherwise construct the
    # path name based on `current_user_resource_name`.
    (Avo.configuration.sign_out_path_name || "destroy_#{Avo.configuration.current_user_resource_name}_session_path").to_sym
  end

  def can_destroy_user?
    helpers.main_app.respond_to?(destroy_user_session_path)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
avo-3.11.7 app/components/avo/sidebar_profile_component.rb
avo-3.11.6 app/components/avo/sidebar_profile_component.rb
avo-3.11.5 app/components/avo/sidebar_profile_component.rb
avo-3.11.4 app/components/avo/sidebar_profile_component.rb
avo-3.11.3 app/components/avo/sidebar_profile_component.rb
avo-3.11.2 app/components/avo/sidebar_profile_component.rb
avo-3.11.1 app/components/avo/sidebar_profile_component.rb
avo-3.11.0 app/components/avo/sidebar_profile_component.rb
avo-3.10.10 app/components/avo/sidebar_profile_component.rb
avo-3.10.9 app/components/avo/sidebar_profile_component.rb
avo-3.10.8 app/components/avo/sidebar_profile_component.rb
avo-3.10.7 app/components/avo/sidebar_profile_component.rb
avo-3.10.6 app/components/avo/sidebar_profile_component.rb
avo-3.10.5 app/components/avo/sidebar_profile_component.rb
avo-3.10.4 app/components/avo/sidebar_profile_component.rb
avo-3.10.3 app/components/avo/sidebar_profile_component.rb
avo-3.10.2 app/components/avo/sidebar_profile_component.rb
avo-3.10.1 app/components/avo/sidebar_profile_component.rb
avo-3.10.0 app/components/avo/sidebar_profile_component.rb