Merge branch 'main' of github.com:hackclub/harbor

This commit is contained in:
Max Wofford 2025-02-19 18:06:01 -05:00
commit 1a52fdf868
5 changed files with 27 additions and 2 deletions

View file

@ -89,3 +89,5 @@ group :test do
gem "capybara"
gem "selenium-webdriver"
end
gem "avo-record_link_field", "~> 0.0.2"

View file

@ -95,6 +95,7 @@ GEM
view_component (>= 3.7.0)
zeitwerk (>= 2.6.12)
avo-heroicons (0.1.1)
avo-record_link_field (0.0.2)
base64 (0.2.0)
bcrypt_pbkdf (1.1.1)
benchmark (0.4.0)
@ -444,6 +445,7 @@ PLATFORMS
DEPENDENCIES
avo (>= 3.2.1)
avo-record_link_field (~> 0.0.2)
bootsnap
brakeman
capybara

View file

@ -9,8 +9,8 @@ class Avo::Resources::User < Avo::BaseResource
field :slack_uid, as: :text
field :avatar_url, as: :text
field :is_admin, as: :boolean
field :created_at, as: :date_time
field :updated_at, as: :date_time
field :created_at, as: :date_time, readonly: true
field :updated_at, as: :date_time, readonly: true
# Show versions/history in the show page
field :versions, as: :has_many

View file

@ -13,6 +13,7 @@ class Avo::Resources::Version < Avo::BaseResource
field :item_id, as: :number
field :event, as: :text
field :whodunnit, as: :text
field :user, as: :record_link
field :object, as: :code
field :created_at, as: :date_time
end

View file

@ -0,0 +1,20 @@
# 🔧🐒
Rails.configuration.to_prepare do
Avo::BaseApplicationController.class_eval do
before_action :set_paper_trail_whodunnit
def user_for_paper_trail
Avo::Current.user&.id
end
end
PaperTrail::Version.class_eval do
def user
begin
User.find(whodunnit) if whodunnit
rescue ActiveRecord::RecordNotFound
nil
end
end
end
end