Skip to content

Commit

Permalink
feature: audit logs (#2703)
Browse files Browse the repository at this point in the history
* WIP

* wip

* WIP

* wip

* typo

* WIP

* WIP

* wip

* wip

* wip

* dont break if db do not exist

* wip

* rename package

* extract audit method and safe_call it

* register all activity

* Update app/components/avo/sidebar_component.html.erb

* Update lib/avo/configuration.rb

* Update lib/avo/configuration.rb

* rename to avo-audit_logging

* feature: log attach and detach

* unbundle audits from enterprise license

* implement gem configuration

* rm unused config attribute

* clear template

* extract direct call

* remove direct audit call

* rm set_paper_trail_whodunnit

* revert safe_call enhancement

* temporary solution for not defined audit

* wip

* .

* lint

* extract audit call

* rm activity

* Update lib/tasks/avo_tasks.rake
  • Loading branch information
Paul-Bob authored Oct 9, 2024
1 parent 7557440 commit 71383ad
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions app/controllers/avo/actions_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class ActionsController < ApplicationController
end
before_action :set_action, only: [:show, :handle]
before_action :verify_authorization, only: [:show, :handle]
before_action :set_query, :set_fields, only: :handle

layout :choose_layout

Expand Down Expand Up @@ -47,14 +48,11 @@ def build_background_url
end

def handle
resource_ids = action_params[:fields][:avo_resource_ids].split(",")

performed_action = @action.handle_action(
fields: action_params[:fields].except(:avo_resource_ids, :avo_selected_query),
fields: @fields,
current_user: _current_user,
resource: @resource,
query: decrypted_query ||
(resource_ids.any? ? @resource.find_record(resource_ids, params: params) : [])
query: @query
)

@response = performed_action.response
Expand All @@ -63,6 +61,16 @@ def handle

private

def set_query
resource_ids = action_params[:fields][:avo_resource_ids].split(",")

@query = decrypted_query || (resource_ids.any? ? @resource.find_record(resource_ids, params: params) : [])
end

def set_fields
@fields = action_params[:fields].except(:avo_resource_ids, :avo_selected_query)
end

def action_params
@action_params ||= params.permit(:id, :authenticity_token, :resource_name, :action_id, :button, fields: {})
end
Expand Down

0 comments on commit 71383ad

Please sign in to comment.