From 33910f83690ad5d8b0304a1dbe9701f74acd1b0b Mon Sep 17 00:00:00 2001 From: Hilda Stastna Date: Mon, 9 Jan 2017 14:58:43 +0100 Subject: [PATCH] Refactoring code of x_get_tree_custom_kids method depends on https://github.com/ManageIQ/manageiq-ui-classic/pull/98 Refactoring code of x_get_tree_custom_kids method as the same code needs to be in the method in tree_builder_vms_filter.rb and in tree_builder_storage.rb; moving the code to new methods in miq_search.rb. --- app/presenters/tree_builder_storage.rb | 10 ++-------- app/presenters/tree_builder_vms_filter.rb | 8 +------- 2 files changed, 3 insertions(+), 15 deletions(-) diff --git a/app/presenters/tree_builder_storage.rb b/app/presenters/tree_builder_storage.rb index 39eca60af75..41af7e056c7 100644 --- a/app/presenters/tree_builder_storage.rb +++ b/app/presenters/tree_builder_storage.rb @@ -27,13 +27,7 @@ def x_get_tree_roots(count_only, _options) end def x_get_tree_custom_kids(object, count_only, options) - objects = MiqSearch.where(:db => options[:leaf]) - objects = case object[:id] - when "global" # Global filters - objects.visible_to_all - when "my" # My filters - objects.where(:search_type => "user", :search_key => User.current_user.userid) - end - count_only_or_objects(count_only, objects, "description") + objects = MiqSearch.where(:db => options[:leaf]).filters_by_type(object[:id]) + count_only_or_objects(count_only, objects, 'description') end end diff --git a/app/presenters/tree_builder_vms_filter.rb b/app/presenters/tree_builder_vms_filter.rb index eba8bcdc86d..e4ef1c9a4af 100644 --- a/app/presenters/tree_builder_vms_filter.rb +++ b/app/presenters/tree_builder_vms_filter.rb @@ -28,13 +28,7 @@ def x_get_tree_roots(count_only, _options) end def x_get_tree_custom_kids(object, count_only, options) - objects = MiqSearch.where(:db => options[:leaf]) - objects = case object[:id] - when "global" # Global filters - objects.visible_to_all - when "my" # My filters - objects.where(:search_type => "user", :search_key => User.current_user.userid) - end + objects = MiqSearch.where(:db => options[:leaf]).filters_by_type(object[:id]) count_only_or_objects(count_only, objects, 'description') end end