Sha256: f808b903be6659b66e13baceb13e59e06687206683062a6985fe3816a11d7f6f

Contents?: true

Size: 992 Bytes

Versions: 182

Compression:

Stored size: 992 Bytes

Contents

# frozen_string_literal: true

class Avo::SidebarProfileComponent < ViewComponent::Base
  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

182 entries across 182 versions & 1 rubygems

Version Path
avo-2.53.0 app/components/avo/sidebar_profile_component.rb
avo-2.52.0 app/components/avo/sidebar_profile_component.rb
avo-3.9.2 app/components/avo/sidebar_profile_component.rb
avo-3.9.1 app/components/avo/sidebar_profile_component.rb
avo-3.8.2 app/components/avo/sidebar_profile_component.rb
avo-3.9.0 app/components/avo/sidebar_profile_component.rb
avo-3.8.1 app/components/avo/sidebar_profile_component.rb
avo-3.8.0 app/components/avo/sidebar_profile_component.rb
avo-3.6.4 app/components/avo/sidebar_profile_component.rb
avo-3.6.3 app/components/avo/sidebar_profile_component.rb
avo-3.6.2 app/components/avo/sidebar_profile_component.rb
avo-2.49.0 app/components/avo/sidebar_profile_component.rb
avo-3.6.1 app/components/avo/sidebar_profile_component.rb
avo-3.6.0 app/components/avo/sidebar_profile_component.rb
avo-3.5.8 app/components/avo/sidebar_profile_component.rb
avo-3.5.7 app/components/avo/sidebar_profile_component.rb
avo-3.5.6 app/components/avo/sidebar_profile_component.rb
avo-3.5.6.beta1 app/components/avo/sidebar_profile_component.rb
avo-3.5.5 app/components/avo/sidebar_profile_component.rb
avo-3.5.4 app/components/avo/sidebar_profile_component.rb