Skip to content

Commit

Permalink
Merge pull request #1229 from hayesr/fix_rbac_features_regression
Browse files Browse the repository at this point in the history
Fix Features Tree for "everything under" features
  • Loading branch information
himdel committed Jun 15, 2017
2 parents a7907c9 + b8c1008 commit 086f2e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion app/presenters/tree_builder_ops_rbac_features.rb
Expand Up @@ -6,7 +6,7 @@ class TreeBuilderOpsRbacFeatures < TreeBuilder
def initialize(name, type, sandbox, build, role:, editable: false)
@role = role
@editable = editable
@features = @role.miq_product_features.order(:identifier).pluck(:identifier)
@features = @role.miq_product_features.map(&:identifier)

@root_counter = []

Expand Down
14 changes: 13 additions & 1 deletion app/presenters/tree_node/menu/item.rb
Expand Up @@ -4,13 +4,25 @@ class Item < TreeNode::Menu::Node
set_attribute(:key) { "#{@options[:node_id_prefix]}__#{@object.feature}" }
set_attribute(:title) { _(details[:name]) }
set_attribute(:tooltip) { _(details[:description]) || _(details[:name]) }
set_attribute(:selected) { @options[:features].include?(@object.feature) }
set_attribute(:selected) { parent_selected? || self_selected? }

private

def details
::MiqProductFeature.obj_features[@object.feature].try(:[], :feature).try(:details)
end

def feature_parent
::MiqProductFeature.obj_features[::MiqProductFeature.feature_parent(@object.feature)][:feature]
end

def parent_selected?
@options[:features].include?(feature_parent.identifier)
end

def self_selected?
@options[:features].include?(@object.feature)
end
end
end
end

0 comments on commit 086f2e2

Please sign in to comment.