diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 92889765b439..4af72c8d1a24 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2220,10 +2220,10 @@ def controller_for_common_methods end end - def replace_trees_by_presenter(presenter, trees) - trees.each_pair do |name, tree| + def reload_trees_by_presenter(presenter, trees) + trees.each_pair do |_, tree| next unless tree.present? - presenter.reload_tree(name, tree) + presenter.reload_tree(tree.name, tree.locals_for_render[:bs_tree]) end end diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index 248acaab5cf3..3cc65d284dd3 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -1967,7 +1967,7 @@ def replace_right_cell(options = {}) :active_tree => x_active_tree, :add_nodes => add_nodes ) - replace_trees_by_presenter(presenter, trees) + reload_trees_by_presenter(presenter, trees) if @sb[:buttons_node] if action == "group_reorder" diff --git a/app/controllers/chargeback_controller.rb b/app/controllers/chargeback_controller.rb index e645011650c9..9284b43b3eb7 100644 --- a/app/controllers/chargeback_controller.rb +++ b/app/controllers/chargeback_controller.rb @@ -838,7 +838,7 @@ def replace_right_cell(options = {}) presenter = ExplorerPresenter.new( :active_tree => x_active_tree, ) - replace_trees_by_presenter(presenter, :cb_rates => cb_rates_build_tree) if replace_trees.include?(:cb_rates) + reload_trees_by_presenter(presenter, :cb_rates => cb_rates_build_tree) if replace_trees.include?(:cb_rates) # FIXME # if params[:action].ends_with?("_delete") diff --git a/app/controllers/miq_ae_class_controller.rb b/app/controllers/miq_ae_class_controller.rb index cd35c6a16ae2..a03038816244 100644 --- a/app/controllers/miq_ae_class_controller.rb +++ b/app/controllers/miq_ae_class_controller.rb @@ -280,7 +280,7 @@ def replace_right_cell(options = {}) :add_nodes => add_nodes, ) - replace_trees_by_presenter(presenter, :ae => build_ae_tree) unless replace_trees.blank? + reload_trees_by_presenter(presenter, :ae => build_ae_tree) unless replace_trees.blank? if @sb[:action] == "miq_ae_field_seq" presenter.update(:class_fields_div, r[:partial => "fields_seq_form"]) diff --git a/app/controllers/miq_ae_customization_controller.rb b/app/controllers/miq_ae_customization_controller.rb index 60f032f289a2..8af321840395 100644 --- a/app/controllers/miq_ae_customization_controller.rb +++ b/app/controllers/miq_ae_customization_controller.rb @@ -248,7 +248,7 @@ def replace_right_cell(options = {}) @explorer = true presenter = ExplorerPresenter.new(:active_tree => x_active_tree) - replace_trees_by_presenter(presenter, trees) + reload_trees_by_presenter(presenter, trees) presenter[:osf_node] = x_node unless @in_a_form if ['dialog_edit', 'dialog_copy'].include?(params[:pressed]) diff --git a/app/controllers/miq_policy_controller.rb b/app/controllers/miq_policy_controller.rb index d21e71bd4ac9..3728782ebe38 100644 --- a/app/controllers/miq_policy_controller.rb +++ b/app/controllers/miq_policy_controller.rb @@ -522,7 +522,7 @@ def replace_right_cell(options = {}) raise _("unknown tree in replace_trees: %{name}") % {name => name} end end - replace_trees_by_presenter(presenter, trees) + reload_trees_by_presenter(presenter, trees) if params[:action].ends_with?('_delete') && !x_node.starts_with?('p') && diff --git a/app/controllers/mixins/manager_controller_mixin.rb b/app/controllers/mixins/manager_controller_mixin.rb index 07a789a1e253..9bd8e95129fe 100644 --- a/app/controllers/mixins/manager_controller_mixin.rb +++ b/app/controllers/mixins/manager_controller_mixin.rb @@ -310,7 +310,7 @@ def replace_right_cell(options = {}) update_partials(record_showing, presenter) replace_search_box(presenter) handle_bottom_cell(presenter) - replace_trees_by_presenter(presenter, trees) + reload_trees_by_presenter(presenter, trees) rebuild_toolbars(record_showing, presenter) presenter[:right_cell_text] = @right_cell_text presenter[:osf_node] = x_node # Open, select, and focus on this node diff --git a/app/controllers/ops_controller.rb b/app/controllers/ops_controller.rb index 2bb1517dceb8..9e4060665122 100644 --- a/app/controllers/ops_controller.rb +++ b/app/controllers/ops_controller.rb @@ -774,7 +774,7 @@ def replace_explorer_trees(replace_trees, presenter) trees[:diagnostics] = diagnostics_build_tree if replace_trees.include?(:diagnostics) trees[:vmdb] = db_build_tree if replace_trees.include?(:vmdb) end - replace_trees_by_presenter(presenter, trees) + reload_trees_by_presenter(presenter, trees) end # Build the audit object when a profile is saved diff --git a/app/controllers/pxe_controller.rb b/app/controllers/pxe_controller.rb index 7f977de5aabc..5aa2b8d7f48f 100644 --- a/app/controllers/pxe_controller.rb +++ b/app/controllers/pxe_controller.rb @@ -117,7 +117,7 @@ def replace_right_cell(options = {}) c_tb = build_toolbar(center_toolbar_filename) unless @in_a_form h_tb = build_toolbar('x_history_tb') - replace_trees_by_presenter(presenter, trees) + reload_trees_by_presenter(presenter, trees) # Rebuild the toolbars presenter.reload_toolbars(:history => h_tb) diff --git a/app/controllers/report_controller.rb b/app/controllers/report_controller.rb index 373a8da8021c..a297fa11230a 100644 --- a/app/controllers/report_controller.rb +++ b/app/controllers/report_controller.rb @@ -690,7 +690,7 @@ def replace_right_cell(options = {}) # :replace_trees key can be an array of tr v_tb = build_toolbar("report_view_tb") if @report && [:reports_tree, :savedreports_tree].include?(x_active_tree) end - replace_trees_by_presenter(presenter, trees) + reload_trees_by_presenter(presenter, trees) presenter[:osf_node] = x_node # Open, select, and focus on this node session[:changed] = (@edit[:new] != @edit[:current]) if @edit && @edit[:current] # to get save/reset buttons to highlight when something is changed diff --git a/app/controllers/service_controller.rb b/app/controllers/service_controller.rb index f6bfd5126d29..7da1a24ef3f9 100644 --- a/app/controllers/service_controller.rb +++ b/app/controllers/service_controller.rb @@ -326,7 +326,7 @@ def replace_right_cell(options = {}) ) if Array(replace_trees).include?(:svcs) - replace_trees_by_presenter(presenter, :svcs => build_svcs_tree) + reload_trees_by_presenter(presenter, :svcs => build_svcs_tree) end # Replace right cell divs diff --git a/app/controllers/storage_controller.rb b/app/controllers/storage_controller.rb index 79ee4672ddba..b6d96423c147 100644 --- a/app/controllers/storage_controller.rb +++ b/app/controllers/storage_controller.rb @@ -396,7 +396,7 @@ def replace_right_cell(options = {}) update_partials(record_showing, presenter) replace_search_box(presenter) handle_bottom_cell(presenter) - replace_trees_by_presenter(presenter, trees) + reload_trees_by_presenter(presenter, trees) rebuild_toolbars(record_showing, presenter) case x_active_tree when :storage_tree diff --git a/app/presenters/explorer_presenter.rb b/app/presenters/explorer_presenter.rb index 9de9ff980c89..059f648a3332 100644 --- a/app/presenters/explorer_presenter.rb +++ b/app/presenters/explorer_presenter.rb @@ -142,8 +142,8 @@ def reload_toolbars(toolbars) self end - def reload_tree(_name, tree) - @options[:reload_trees][tree.name] = tree.locals_for_render[:bs_tree] + def reload_tree(name, data) + @options[:reload_trees][name] = data end def replace(div_name, content) diff --git a/spec/controllers/application_controller_spec.rb b/spec/controllers/application_controller_spec.rb index e064360cbc97..d840fbcf7bee 100644 --- a/spec/controllers/application_controller_spec.rb +++ b/spec/controllers/application_controller_spec.rb @@ -300,7 +300,7 @@ end end - describe "#replace_trees_by_presenter" do + describe "#reload_trees_by_presenter" do let(:tree_1) { double(:name => 'tree_1') } let(:tree_2) { double(:name => 'tree_2') } let(:trees) { {'tree_1' => tree_1, 'tree_2' => tree_2, 'tree_3' => nil} } @@ -310,7 +310,7 @@ allow(tree_1).to receive(:locals_for_render).and_return(:bs_tree => {}) allow(tree_2).to receive(:locals_for_render).and_return(:bs_tree => {}) expect(presenter).to receive(:reload_tree).with(any_args).twice - controller.send(:replace_trees_by_presenter, presenter, trees) + controller.send(:reload_trees_by_presenter, presenter, trees) end end end diff --git a/spec/controllers/miq_ae_class_controller_spec.rb b/spec/controllers/miq_ae_class_controller_spec.rb index 147032e91283..6f3afafe619d 100644 --- a/spec/controllers/miq_ae_class_controller_spec.rb +++ b/spec/controllers/miq_ae_class_controller_spec.rb @@ -97,7 +97,7 @@ :trees => {:ae_tree => {:active_node => node}}) controller.instance_variable_set(:@_params, :button => "reset", :id => cls1.id) allow(controller).to receive(:open_parent_nodes) - expect(controller).to_not receive(:replace_trees_by_presenter) + expect(controller).to_not receive(:reload_trees_by_presenter) expect(controller).to receive(:render) controller.send(:copy_objects) expect(controller.send(:flash_errors?)).not_to be_truthy