Skip to content

Commit

Permalink
Fix actions' icons of policy events
Browse files Browse the repository at this point in the history
  • Loading branch information
Jozef Zigmund committed Mar 21, 2017
1 parent 741917e commit bb185b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
12 changes: 12 additions & 0 deletions app/presenters/tree_builder_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,18 @@ 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

private

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

0 comments on commit bb185b5

Please sign in to comment.