Skip to content

Commit

Permalink
Merge pull request #840 from lgalis/automation_providers_error_when_s…
Browse files Browse the repository at this point in the history
…witching_view_type

Fixed quadicon link for automation providers
  • Loading branch information
Dan Clarizio authored Apr 12, 2017
2 parents 55300f3 + e594ecc commit 6f5c40f
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
14 changes: 7 additions & 7 deletions app/controllers/automation_manager_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def concrete_model
end

def managed_group_kls
ManageIQ::Providers::AutomationManager::InventoryGroup
ManageIQ::Providers::AutomationManager::InventoryRootGroup
end

def manager_prefix
Expand Down Expand Up @@ -113,7 +113,7 @@ def automation_manager_providers_tree_rec
nodes = x_node.split('-')
case nodes.first
when "root" then find_record(ManageIQ::Providers::AnsibleTower::AutomationManager, params[:id])
when "at" then find_record(ManageIQ::Providers::AutomationManager::InventoryGroup, params[:id])
when "at", "e" then find_record(ManageIQ::Providers::AutomationManager::InventoryRootGroup, params[:id])
when "f" then find_record(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem, params[:id])
when "xx" then
case nodes.second
Expand Down Expand Up @@ -228,8 +228,8 @@ def get_node_info(treenodeid)
end

case model
when "ManageIQ::Providers::AnsibleTower::AutomationManager"
provider_list(id, model)
when "ManageIQ::Providers::AnsibleTower::AutomationManager", "ExtManagementSystem"
provider_list(id, "ManageIQ::Providers::AnsibleTower::AutomationManager")
when "EmsFolder"
inventory_group_node(id, model)
when "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem", "ConfiguredSystem"
Expand Down Expand Up @@ -261,10 +261,10 @@ def provider_node(id, model)
cs_provider_node(provider)
else
@no_checkboxes = true
options = {:model => "ManageIQ::Providers::AutomationManager::InventoryGroup",
options = {:model => "ManageIQ::Providers::AutomationManager::InventoryRootGroup",
:match_via_descendants => ConfiguredSystem,
:where_clause => ["ems_id IN (?)", provider.id],
:gtl_dbname => "automation_manager_groups"}
:gtl_dbname => "automation_manager_providers"}
process_show_list(options)
record_model = ui_lookup(:model => self.class.model_to_name(model || TreeBuilder.get_model_for_prefix(@nodetype)))
@right_cell_text = _("%{model} \"%{name}\"") % {:name => provider.name,
Expand All @@ -283,7 +283,7 @@ def cs_provider_node(provider)
end

def inventory_group_node(id, model)
@record = @inventory_group_record = find_record(ManageIQ::Providers::AutomationManager::InventoryGroup, id) if model
@record = @inventory_group_record = find_record(ManageIQ::Providers::AutomationManager::InventoryRootGroup, id) if model

if @inventory_group_record.nil?
self.x_node = "root"
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/configuration_job_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,5 @@ def textual_group_list
end
helper_method :textual_group_list

menu_section :conf
menu_section :aut
end
9 changes: 6 additions & 3 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ def url_for_record(record, action = "show") # Default action is show
"vm_or_template"
elsif record.kind_of?(VmOrTemplate)
controller_for_vm(model_for_vm(record))
elsif record.kind_of?(ManageIQ::Providers::AnsibleTower::AutomationManager) ||
record.kind_of?(ManageIQ::Providers::ExternalAutomationManager::InventoryRootGroup)
"automation_manager"
elsif record.kind_of?(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook)
"ansible_playbook"
elsif record.kind_of?(ManageIQ::Providers::EmbeddedAutomationManager::Authentication)
Expand Down Expand Up @@ -235,7 +238,7 @@ def url_for_db(db, action = "show", item = nil) # Default action is show
)
elsif @host && ["Patch", "GuestApplication"].include?(db)
return url_for_only_path(:controller => "host", :action => @lastaction, :id => @host, :show => @id)
elsif %w(ConfiguredSystem ConfigurationProfile EmsFolder).include?(db)
elsif %w(ConfiguredSystem ConfigurationProfile).include?(db)
return url_for_only_path(:controller => "provider_foreman", :action => @lastaction, :id => @record, :show => @id)
else
controller, action = db_to_controller(db, action)
Expand Down Expand Up @@ -284,10 +287,10 @@ def view_to_url(view, parent = nil)
elsif ["Vm"].include?(view.db) && parent && request.parameters[:controller] != "vm"
# this is to handle link to a vm in vm explorer from service explorer
return url_for_only_path(:controller => "vm_or_template", :action => "show") + "/"
elsif %w(ConfigurationProfile EmsFolder).include?(view.db) &&
elsif %w(ConfigurationProfile).include?(view.db) &&
request.parameters[:controller] == "provider_foreman"
return url_for_only_path(:action => action, :id => nil) + "/"
elsif %w(ManageIQ::Providers::AutomationManager::InventoryGroup EmsFolder).include?(view.db) &&
elsif %w(ManageIQ::Providers::AutomationManager::InventoryRootGroup EmsFolder).include?(view.db) &&
request.parameters[:controller] == "automation_manager"
return url_for_only_path(:action => action, :id => nil) + "/"
elsif %w(ConfiguredSystem).include?(view.db) && (request.parameters[:controller] == "provider_foreman" || request.parameters[:controller] == "automation_manager")
Expand Down
8 changes: 4 additions & 4 deletions app/helpers/application_helper/toolbar_chooser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,10 @@ def configuration_scripts_tree_center_tb(nodes)

def automation_manager_providers_tree_center_tb(nodes)
case nodes.first
when "root" then "automation_manager_providers_center_tb"
when "at" then "automation_manager_provider_center_tb"
when "f" then inventory_group_center_tb
when "xx" then "configured_systems_ansible_center_tb"
when "root" then "automation_manager_providers_center_tb"
when "at", "e" then "automation_manager_provider_center_tb"
when "f" then inventory_group_center_tb
when "xx" then "configured_systems_ansible_center_tb"
end
end

Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
explorer
form_fields
show
x_show
show_list
tagging_edit
),
Expand Down
5 changes: 5 additions & 0 deletions spec/helpers/application_helper_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,11 @@
expect(subject).to eq(helper.url_for_db(helper.controller_for_vm(helper.model_for_vm(@record)), @action))
end

it "when record is ManageIQ::Providers::AnsibleTower::AutomationManager" do
@record = ManageIQ::Providers::AnsibleTower::AutomationManager.new
expect(subject).to eq("/automation_manager/#{@action}")
end

it "when record is not VmOrTemplate" do
@record = FactoryGirl.create(:host)
expect(subject).to eq(helper.url_for_db(@record.class.base_class.to_s, @action))
Expand Down

0 comments on commit 6f5c40f

Please sign in to comment.