Skip to content

Commit

Permalink
vm_infras API changes for manageiq
Browse files Browse the repository at this point in the history
  • Loading branch information
jaisejose1123 committed Apr 8, 2024
1 parent dfbf8e7 commit a607d24
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
10 changes: 10 additions & 0 deletions db/fixtures/miq_product_features.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4186,6 +4186,16 @@
:feature_type: view
:identifier: cloud_database_flavor_show

# Vm Infra
- :name: Vm Infras
:description: Every thing to Vm infras
:feature_type: node
:identifier: vm_infra
:children:
- :name: View
:description: View Vm Infras
:feature_type: view
:identifier: vm_infra_view

# Cloud Network
- :name: Cloud Networks
Expand Down
16 changes: 12 additions & 4 deletions lib/rbac/filterer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,8 @@ def search(options = {})
if targets.first.kind_of?(Numeric)
target_ids = targets
# assume klass is passed in
elsif targets.first.kind_of?(Hash)
target_ids = targets.first[:objectIds]
else
target_ids = targets.collect(&:id)
klass = targets.first.class
Expand Down Expand Up @@ -337,8 +339,9 @@ def search(options = {})
auth_count = inner_scope.except(:offset, :limit, :order).count(:all)
end
end
targets = scope


targets = scope unless targets[0][:objectIds].present?

unless options[:skip_counts]
auth_count ||= attrs[:apply_limit_in_sql] && limit ? targets.except(:offset, :limit, :order).count(:all) : targets.length
end
Expand All @@ -365,10 +368,14 @@ def search(options = {})
end
targets = targets.drop(offset.to_i).take(limit.to_i)
end

# Preserve sort order of incoming target_ids
if !target_ids.nil? && !order
targets = targets.sort_by { |a| target_ids.index(a.id) }
if targets.kind_of?(Array)
targets = targets
else
targets = targets.sort_by { |a| target_ids.index(a.id) }
end
end
targets = targets.to_a if targets.kind_of?(Enumerator::Lazy)

Expand Down Expand Up @@ -923,3 +930,4 @@ def matches_search_filters?(obj, filter, timezone, prune_sql: true)
end
end
end

0 comments on commit a607d24

Please sign in to comment.