Skip to content

Commit

Permalink
Merge pull request #1209 from lgalis/advanced_search_bar_ansible_towe…
Browse files Browse the repository at this point in the history
…r_fix

Advanced search bar ansible tower fix
(cherry picked from commit afcaff5)

https://bugzilla.redhat.com/show_bug.cgi?id=1447126
  • Loading branch information
Dan Clarizio authored and simaishi committed May 1, 2017
1 parent dde21c3 commit 4ae4bcf
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/controllers/automation_manager_controller.rb
Expand Up @@ -260,6 +260,7 @@ def provider_node(id, model)
elsif x_active_tree == :configuration_scripts_tree
cs_provider_node(provider)
else
@show_adv_search = true
@no_checkboxes = true
options = {:model => "ManageIQ::Providers::AutomationManager::InventoryRootGroup",
:match_via_descendants => ConfiguredSystem,
Expand All @@ -277,6 +278,7 @@ def cs_provider_node(provider)
:match_via_descendants => ConfigurationScript,
:where_clause => ["manager_id IN (?)", provider.id],
:gtl_dbname => "automation_manager_configuration_scripts"}
@show_adv_search = true
process_show_list(options)
@right_cell_text = _("%{model} \"%{name}\"") % {:name => provider.name,
:model => "#{ui_lookup(:tables => "job_templates")} under "}
Expand All @@ -289,6 +291,7 @@ def inventory_group_node(id, model)
self.x_node = "root"
get_node_info("root")
else
@show_adv_search = true
options = {:model => "ConfiguredSystem",
:match_via_descendants => ConfiguredSystem,
:where_clause => ["inventory_root_group_id IN (?)", from_cid(@inventory_group_record.id)],
Expand All @@ -306,6 +309,7 @@ def inventory_group_node(id, model)

def configuration_scripts_list(id, model)
return configuration_script_node(id) if id
@show_adv_search = true
@listicon = "configuration_script"
if x_active_tree == :configuration_scripts_tree
options = {:model => model.to_s,
Expand All @@ -317,11 +321,13 @@ def configuration_scripts_list(id, model)

def configuration_script_node(id)
@record = @configuration_script_record = find_record(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript, id)
@show_adv_search = false
display_node(id, nil)
end

def default_node
return unless x_node == "root"
@show_adv_search = true
if x_active_tree == :automation_manager_providers_tree
options = {:model => "ManageIQ::Providers::AnsibleTower::AutomationManager",
:gtl_dbname => "automation_manager_providers"}
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/mixins/manager_controller_mixin.rb
Expand Up @@ -346,7 +346,7 @@ def configured_system_node(id, model)
end

def display_adv_searchbox
!(@configured_system_record || @in_a_form || group_summary_tab_selected?)
!(@configured_system_record || @configuration_script_record || @in_a_form || group_summary_tab_selected?)
end

def miq_search_node
Expand Down
12 changes: 11 additions & 1 deletion spec/controllers/automation_manager_controller_spec.rb
Expand Up @@ -337,7 +337,9 @@
search_text = controller.instance_variable_get(:@search_text)
expect(search_text).to eq("manager")
view = controller.instance_variable_get(:@view)
show_adv_search = controller.instance_variable_get(:@show_adv_search)
expect(view.table.data.size).to eq(2)
expect(show_adv_search).to eq(true)
end

it "renders tree_select for ansible tower job templates tree node" do
Expand All @@ -347,6 +349,11 @@
controller.instance_variable_set(:@_params, :id => "at-" + ApplicationRecord.compress_id(@automation_manager1.id))
controller.send(:tree_select)
view = controller.instance_variable_get(:@view)
show_adv_search = controller.instance_variable_get(:@show_adv_search)
expect(show_adv_search).to eq(true)
expect(view.table.data.size).to eq(2)
expect(show_adv_search).to eq(true)

expect(view.table.data[0].name).to eq("ConfigScript1")
expect(view.table.data[1].name).to eq("ConfigScript3")
end
Expand Down Expand Up @@ -446,7 +453,8 @@

seed_session_trees('automation_manager', :automation_manager_cs_filter, "cs-#{tree_node_id}")
get :explorer

show_adv_search = controller.instance_variable_get(:@show_adv_search)
expect(show_adv_search).to be_falsey
expect(response.status).to eq(200)
expect(response).to render_template(:partial => 'layouts/_textual_groups_generic')
end
Expand All @@ -472,6 +480,8 @@
allow(controller).to receive(:x_active_accord).and_return(:configuration_scripts)
allow(controller).to receive(:x_node).and_return(tree_node_id)
get :explorer
show_adv_search = controller.instance_variable_get(:@show_adv_search)
expect(show_adv_search).to eq(false)
expect(response.status).to eq(200)
expect(response.body).to include("Question Name")
expect(response.body).to include("Question Description")
Expand Down

0 comments on commit 4ae4bcf

Please sign in to comment.