Skip to content

Commit 11cae0f

Browse files
authored
Merge pull request #9251 from GilbertCherrie/fix_ae_method_workflow_template_summary_page
Fix ae method workflow template summary page
2 parents e770419 + a27efd5 commit 11cae0f

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

app/controllers/miq_ae_class_controller.rb

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,12 +1031,11 @@ def method_form_fields
10311031
# ManageIQ::Providers::AnsibleTower::Provider.where('zone_id != ?', Zone.maintenance_zone.id)
10321032
list_of_managers = ManageIQ::Providers::ExternalAutomationManager
10331033
.where(:enabled => true)
1034-
.pluck(:id, :name)
1035-
.map { |r| {:id => r[0], :name => r[1]} }
1034+
.map { |provider| {:id => provider.id, :name => provider.name} }
10361035

10371036
if method&.options[:ansible_template_id]
1038-
manager_id = ManageIQ::Providers::ExternalAutomationManager::ConfigurationScript
1039-
.find_by(:id => method.options[:ansible_template_id])&.manager_id
1037+
manager_class = get_template_class(method.location)
1038+
manager_id = manager_class.find_by(:id => method.options[:ansible_template_id])&.manager_id
10401039
end
10411040
end
10421041

@@ -1844,6 +1843,14 @@ def ae_method_operations
18441843

18451844
private
18461845

1846+
def get_template_class(location)
1847+
if location == "ansible_workflow_template"
1848+
ManageIQ::Providers::ExternalAutomationManager::ConfigurationWorkflow
1849+
else
1850+
ManageIQ::Providers::ExternalAutomationManager::ConfigurationScript
1851+
end
1852+
end
1853+
18471854
def feature_by_action
18481855
features_in_action = %w[
18491856
miq_ae_class_copy miq_ae_class_edit miq_ae_class_new
@@ -2819,13 +2826,15 @@ def get_method_node_info(node_id)
28192826
set_right_cell_text(x_node, @record)
28202827
end
28212828

2822-
def fetch_manager_name(ansible_template_id)
2829+
def fetch_manager_name(ansible_template_id, klass)
28232830
return nil if ansible_template_id.blank?
28242831

2825-
ManageIQ::Providers::ExternalAutomationManager::ConfigurationScript.find_by(:id => ansible_template_id)&.manager&.name
2832+
klass.find_by(:id => ansible_template_id)&.manager&.name
28262833
end
28272834

28282835
def fetch_playbook_details(record)
2836+
template_class = get_template_class(record.location)
2837+
28292838
options = record.options
28302839
details = {
28312840
:repository => fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScriptSource, options[:repository_id]),
@@ -2837,12 +2846,12 @@ def fetch_playbook_details(record)
28372846
:hosts => options[:hosts],
28382847
:log_output => options[:log_output],
28392848
:ansible_template_id => options[:ansible_template_id],
2840-
:manager_name => fetch_manager_name(options[:ansible_template_id]),
2849+
:manager_name => fetch_manager_name(options[:ansible_template_id], template_class),
28412850
}
28422851
details[:network_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::NetworkCredential, options[:network_credential_id]) if options[:network_credential_id]
28432852
details[:cloud_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::CloudCredential, options[:cloud_credential_id]) if options[:cloud_credential_id]
28442853
details[:vault_credential] = fetch_name_from_object(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::VaultCredential, options[:vault_credential_id]) if options[:vault_credential_id]
2845-
details[:ansible_template] = fetch_name_from_object(ManageIQ::Providers::ExternalAutomationManager::ConfigurationScript, options[:ansible_template_id]) if options[:ansible_template_id]
2854+
details[:ansible_template] = fetch_name_from_object(template_class, options[:ansible_template_id]) if options[:ansible_template_id]
28462855
details
28472856
end
28482857

0 commit comments

Comments
 (0)