From 1dcdeb874f114b327e6f01bf2db4b8fe0b21660d Mon Sep 17 00:00:00 2001 From: Lucy Fu Date: Mon, 20 Aug 2018 17:36:45 -0400 Subject: [PATCH] Add username, button name and automate entry point to CustomButtonEvent. https://bugzilla.redhat.com/show_bug.cgi?id=1511126 --- app/models/custom_button.rb | 4 +++- app/models/custom_button_event.rb | 10 ++++++++++ app/models/resource_action.rb | 1 + 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/app/models/custom_button.rb b/app/models/custom_button.rb index 7b1c0b379fb0..d017a2622e95 100644 --- a/app/models/custom_button.rb +++ b/app/models/custom_button.rb @@ -101,12 +101,14 @@ def publish_event(source, target, args) :message => 'Custom button launched', :source => source, :target => target, + :username => args[:username], :user_id => args[:user_id], :group_id => args[:miq_group_id], :tenant_id => args[:tenant_id], :full_data => { :args => args, - :automate_entry_point => resource_action.ae_path + :automate_entry_point => resource_action.ae_path, + :button_name => name } ) end diff --git a/app/models/custom_button_event.rb b/app/models/custom_button_event.rb index d2d56e01ad8e..3e519d14283b 100644 --- a/app/models/custom_button_event.rb +++ b/app/models/custom_button_event.rb @@ -1,2 +1,12 @@ class CustomButtonEvent < EventStream + virtual_column :button_name, :type => :string + virtual_column :automate_entry_point, :type => :string + + def automate_entry_point + full_data[:automate_entry_point] + end + + def button_name + full_data[:button_name] + end end diff --git a/app/models/resource_action.rb b/app/models/resource_action.rb index 56b876f9384f..b0fe17e2afe8 100644 --- a/app/models/resource_action.rb +++ b/app/models/resource_action.rb @@ -38,6 +38,7 @@ def automate_queue_hash(target, override_attrs, user) args[:user_id] ||= user.id args[:miq_group_id] ||= user.current_group.id args[:tenant_id] ||= user.current_tenant.id + args[:username] ||= user.userid end end