-
Notifications
You must be signed in to change notification settings - Fork 899
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
API for vm_infras in reconfigure form #22980
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
Comment on lines
+265
to
+266
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. targets should be passed in as a scope Don't add this here. |
||
else | ||
target_ids = targets.collect(&:id) | ||
klass = targets.first.class | ||
|
@@ -337,7 +339,18 @@ def search(options = {}) | |
auth_count = inner_scope.except(:offset, :limit, :order).count(:all) | ||
end | ||
end | ||
targets = scope | ||
|
||
if targets.count != 1 | ||
targets = scope | ||
else | ||
first_target = targets.first | ||
|
||
if first_target.is_a?(Hash) && first_target[:objectIds].blank? | ||
targets = scope | ||
elsif targets.all? { |element| Integer === element } | ||
targets = scope | ||
end | ||
end | ||
|
||
unless options[:skip_counts] | ||
auth_count ||= attrs[:apply_limit_in_sql] && limit ? targets.except(:offset, :limit, :order).count(:all) : targets.length | ||
|
@@ -367,7 +380,7 @@ def search(options = {}) | |
end | ||
|
||
# Preserve sort order of incoming target_ids | ||
if !target_ids.nil? && !order | ||
if !target_ids.nil? && !order && !targets.kind_of?(Array) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please share reason for this change. I do agree, that this sorting is called in a few places that I wish it were not. The solution I find is to pass in a scope and that solves this problem. |
||
targets = targets.sort_by { |a| target_ids.index(a.id) } | ||
end | ||
targets = targets.to_a if targets.kind_of?(Enumerator::Lazy) | ||
|
@@ -505,7 +518,7 @@ def rbac_class(scope) | |
# So once calc_filtered_ids uses pluck_ids for all, then that filter | ||
# can converted across to a 100% sql friendly query | ||
def pluck_ids(targets) | ||
targets.pluck(:id) if targets | ||
targets&.pluck(:id) | ||
end | ||
|
||
def self_service_ownership_scope?(miq_group, klass) | ||
|
@@ -589,14 +602,14 @@ def scope_by_ids(scope, filtered_ids) | |
end | ||
|
||
def get_belongsto_filter_object_ids(klass, filter) | ||
return nil if !BELONGSTO_FILTER_CLASSES.include?(safe_base_class(klass).name) || filter.blank? | ||
return nil if BELONGSTO_FILTER_CLASSES.exclude?(safe_base_class(klass).name) || filter.blank? | ||
|
||
get_belongsto_matches(filter, rbac_class(klass)).collect(&:id) | ||
end | ||
|
||
def get_managed_filter_object_ids(scope, filter) | ||
klass = scope.respond_to?(:klass) ? scope.klass : scope | ||
return nil if !TAGGABLE_FILTER_CLASSES.include?(safe_base_class(klass).name) || filter.blank? | ||
return nil if TAGGABLE_FILTER_CLASSES.exclude?(safe_base_class(klass).name) || filter.blank? | ||
return scope.where(filter.to_sql.first) if filter.kind_of?(MiqExpression) | ||
|
||
scope.find_tags_by_grouping(filter, :ns => '*').reorder(nil) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Confused why we're adding a new top level node when we already have
Reconfigure VMs
/vm_reconfigure_all
https://github.com/ManageIQ/manageiq/blob/master/db/fixtures/miq_product_features.yml#L5949-L5973There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need infra specific features?
Can we use 1 set of privileges for both views?