Class: Panda::Core::Admin::UserActivityComponent

Inherits:
Base
  • Object
show all
Includes:
ActionView::Helpers::DateHelper
Defined in:
app/components/panda/core/admin/user_activity_component.rb

Constant Summary

Constants inherited from Base

Base::TAILWIND_MERGER

Instance Method Summary collapse

Methods inherited from Base

#after_template, #attrs, #before_template, #default_attrs, #merge_attrs, #tailwind_merge_attrs

Instance Method Details

#view_templateObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/components/panda/core/admin/user_activity_component.rb', line 13

def view_template
  return unless should_render?

  if @user.is_a?(Panda::Core::User) && time
    render Panda::Core::Admin::UserDisplayComponent.new(
      user: @user,
      metadata: "#{time_ago_in_words(time)} ago"
    )
  elsif @user.is_a?(Panda::Core::User)
    render Panda::Core::Admin::UserDisplayComponent.new(
      user: @user,
      metadata: "Not published"
    )
  elsif time
    div(class: "text-black/60") { "#{time_ago_in_words(time)} ago" }
  end
end