Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix actions' icons of policy events #754

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/presenters/tree_builder_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,16 @@ def x_get_tree_ev_kids(parent, count_only, parents)

success = count_only_or_objects(count_only, pol_rec ? pol_rec.actions_for_event(parent, :success) : [])
failure = count_only_or_objects(count_only, pol_rec ? pol_rec.actions_for_event(parent, :failure) : [])
unless count_only
add_flag_to(success, :success) unless success.empty?
add_flag_to(failure, :failure) unless failure.empty?
end
success + failure
end

def add_flag_to(array, flag)
array.each do |i|
i.instance_variable_set(:@flag, flag)
end
end
end
18 changes: 7 additions & 11 deletions app/presenters/tree_node/miq_action.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,16 @@ class MiqAction < Node
set_attribute(:title, &:description)
set_attribute(:icon) do
if @options[:tree] != :action_tree
if @options[:tree] == :policy_profile_tree
policy_id = @parent_id.split('-')[2].split('_').first
event_id = @parent_id.split('-').last
else
policy_id = @parent_id.split('_')[2].split('-').last
event_id = @parent_id.split('_').last.split('-').last
end
p = ::MiqPolicy.find_by_id(ApplicationRecord.uncompress_id(policy_id))
ev = ::MiqEventDefinition.find_by_id(ApplicationRecord.uncompress_id(event_id))

p.action_result_for_event(@object, ev) ? "pficon pficon-ok" : "pficon pficon-error-circle-o"
flag_of(@object) == :success ? "pficon pficon-ok" : "pficon pficon-error-circle-o"
else
@object.decorate.fonticon
end
end

private

def flag_of(object)
object.instance_variable_get(:@flag)
end
end
end