Skip to content

Commit

Permalink
Add username, button id/name and automate entry point to CustomButton…
Browse files Browse the repository at this point in the history
  • Loading branch information
lfu committed Aug 21, 2018
1 parent c25b386 commit 9b02269
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/models/custom_button.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,12 +101,15 @@ 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_id => id,
:button_name => name
}
)
end
Expand Down
10 changes: 10 additions & 0 deletions app/models/custom_button_event.rb
Original file line number Diff line number Diff line change
@@ -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
CustomButton.find(full_data[:button_id])&.name || full_data[:button_name]
end
end
1 change: 1 addition & 0 deletions app/models/resource_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
1 change: 1 addition & 0 deletions spec/models/resource_action_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
:user_id => user.id,
:miq_group_id => user.current_group.id,
:tenant_id => user.current_tenant.id,
:username => user.userid,
:attrs => ae_attributes,
}
end
Expand Down

0 comments on commit 9b02269

Please sign in to comment.