Sha256: 1f7eae992bc51b556ea2bb48859bc59d111c04433b55cdffea761b9e724b8f6b

Contents?: true

Size: 839 Bytes

Versions: 10

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

module PandaCms
  module Admin
    class UserActivityComponent < ViewComponent::Base
      attr_accessor :model
      attr_accessor :time
      attr_accessor :user

      # @param whodunnit_to [ActiveRecord::Base] Model instance to which the user activity is related
      def initialize(whodunnit_to: nil, at: nil, user: nil)
        if whodunnit_to
          @model = whodunnit_to
          whodunnit_id = @model.versions&.last&.whodunnit
          if whodunnit_id
            @user = User.find(whodunnit_id)
            @time = @model.updated_at
          end
        elsif user.is_a?(::PandaCms::User) && at.is_a?(::ActiveSupport::TimeWithZone)
          @user = user
          @time = at
        end

        if !@time
          @user = nil
          @time = nil
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
panda_cms-0.6.3 app/components/panda_cms/admin/user_activity_component.rb
panda_cms-0.6.2 app/components/panda_cms/admin/user_activity_component.rb
panda_cms-0.6.1 app/components/panda_cms/admin/user_activity_component.rb
panda_cms-0.6.0 app/components/panda_cms/admin/user_activity_component.rb
panda_cms-0.5.10 app/components/panda_cms/admin/user_activity_component.rb
panda_cms-0.5.9 app/components/panda_cms/admin/user_activity_component.rb
panda_cms-0.5.8 app/components/panda_cms/admin/user_activity_component.rb
panda_cms-0.5.7 app/components/panda_cms/admin/user_activity_component.rb
panda_cms-0.5.6 app/components/panda_cms/admin/user_activity_component.rb
panda_cms-0.5.5 app/components/panda_cms/admin/user_activity_component.rb