Skip to content

Commit

Permalink
Changes to use new subclass to show 'Workflow' & 'Job' templates in UI
Browse files Browse the repository at this point in the history
Reverted some of the changes that were made to use ManageIQ/manageiq#17580 and adjusted code to use subclass in ManageIQ/manageiq#17659

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1590441
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1468339
  • Loading branch information
lgalis authored and h-kataria committed Jul 31, 2018
1 parent 64345af commit f49927f
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 31 deletions.
20 changes: 9 additions & 11 deletions app/controllers/automation_manager_controller.rb
Expand Up @@ -52,7 +52,7 @@ def tagging
tagging_edit('ConfiguredSystem', false)
when :configuration_scripts
assert_privileges("automation_manager_configuration_script_tag")
tagging_edit('ConfigurationScriptBase', false)
tagging_edit('ConfigurationScript', false)
end
render_tagging_form
end
Expand Down Expand Up @@ -128,7 +128,7 @@ def configuration_scripts_tree_rec
nodes = x_node.split('-')
case nodes.first
when "root", "at", "cf", "cw"
find_record(ConfigurationScriptBase, params[:id])
find_record(ConfigurationScript, params[:id])
end
end

Expand Down Expand Up @@ -170,7 +170,7 @@ def providers_active_tree?
private

def is_template_record?
@record.kind_of?(ConfigurationWorkflow) || @record.kind_of?(ConfigurationScript)
@record.kind_of?(ManageIQ::Providers::AutomationManager::ConfigurationWorkflow) || @record.kind_of?(ConfigurationScript)
end
helper_method :is_template_record?

Expand Down Expand Up @@ -262,7 +262,7 @@ def provider_node(id, model)
@no_checkboxes = true
options = {:model => "ManageIQ::Providers::AutomationManager::InventoryRootGroup",
:match_via_descendants => 'ConfiguredSystem',
:named_scope => [[:without_playbooks_for_manager, provider.id]],
:named_scope => [[:with_provider, provider.id]],
: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)))
Expand All @@ -272,8 +272,8 @@ def provider_node(id, model)
end

def cs_provider_node(provider)
options = {:model => "ConfigurationScriptBase",
:named_scope => [[:without_playbooks_for_manager, provider.id]],
options = {:model => "ConfigurationScript",
:named_scope => [[:with_manager, provider.id]],
:gtl_dbname => "automation_manager_configuration_scripts"}
@show_adv_search = true
process_show_list(options)
Expand Down Expand Up @@ -307,15 +307,14 @@ def configuration_scripts_list(id, model)
@show_adv_search = true
if x_active_tree == :configuration_scripts_tree
options = {:model => model.to_s,
:named_scope => :without_playbooks,
:gtl_dbname => "configuration_scripts"}
@right_cell_text = _("All Ansible Tower Templates")
process_show_list(options)
end
end

def configuration_script_node(id)
@record = @configuration_script_record = find_record(ConfigurationScriptBase, id)
@record = @configuration_script_record = find_record(ConfigurationScript, id)
@show_adv_search = false
display_node(id, nil)
end
Expand All @@ -334,8 +333,7 @@ def default_node
process_show_list(options)
@right_cell_text = _("All Ansible Tower Configured Systems")
elsif x_active_tree == :configuration_scripts_tree
options = {:model => "ConfigurationScriptBase",
:named_scope => :without_playbooks,
options = {:model => "ConfigurationScript",
:gtl_dbname => "automation_manager_configuration_scripts"}
process_show_list(options)
@right_cell_text = _("All Ansible Tower Templates")
Expand Down Expand Up @@ -455,7 +453,7 @@ def valid_configuration_script_record?(configuration_script_record)

def configscript_service_dialog
assert_privileges("automation_manager_configuration_script_service_dialog")
cs = ConfigurationScriptBase.find_by(:id => params[:id])
cs = ConfigurationScript.find_by(:id => params[:id])
@edit = {:new => {:dialog_name => ""},
:key => "cs_edit__#{cs.id}",
:rec_id => cs.id}
Expand Down
6 changes: 3 additions & 3 deletions app/controllers/catalog_controller.rb
Expand Up @@ -892,7 +892,7 @@ def atomic_req_submit
add_flash(_("Provider is required, please select one from the list"), :error)
else
# ensure Job Template is selected as well, required field
add_flash(_("Job Template is required, please select one from the list"), :error) if @edit[:new][:template_id].blank?
add_flash(_("Template is required, please select one from the list"), :error) if @edit[:new][:template_id].blank?
end
end

Expand Down Expand Up @@ -1487,7 +1487,7 @@ def available_container_managers
ct = ContainerTemplate.find_by(:id => @record.config_info[:provision][:container_template_id]) if @record.config_info[:provision] && @record.config_info[:provision][:container_template_id]
@edit[:new][:template_id] = ct.try(:id)
@edit[:new][:manager_id] = ct.try(:ext_management_system).try(:id)
available_job_or_container_templates(@edit[:new][:manager_id]) if @edit[:new][:manager_id]
available_container_templates(@edit[:new][:manager_id]) if @edit[:new][:manager_id]
end

def get_form_vars_orchestration
Expand Down Expand Up @@ -1565,7 +1565,7 @@ def available_ansible_tower_managers
ManageIQ::Providers::AnsibleTower::AutomationManager.all.collect { |t| [t.name, t.id] }.sort
@edit[:new][:template_id] = @record.job_template.try(:id)
@edit[:new][:manager_id] = @record.job_template.try(:manager).try(:id)
available_job_or_container_templates(@edit[:new][:manager_id]) if @edit[:new][:manager_id]
available_job_templates(@edit[:new][:manager_id]) if @edit[:new][:manager_id]
end

def add_orchestration_template_vars(st)
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/mixins/manager_controller_mixin.rb
Expand Up @@ -370,7 +370,7 @@ def display_adv_searchbox
def miq_search_node
options = {:model => model_from_active_tree(x_active_tree)}
if x_active_tree == :configuration_scripts_tree
options = {:model => "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript",
options = {:model => "ConfigurationScript",
:gtl_dbname => "automation_manager_configuration_scripts"}
end
process_show_list(options)
Expand Down
5 changes: 5 additions & 0 deletions app/decorators/configuration_script_decorator.rb
@@ -0,0 +1,5 @@
class ConfigurationScriptDecorator < MiqDecorator
def self.fonticon
'pficon pficon-template'
end
end
Expand Up @@ -3,9 +3,5 @@ class AutomationManager::ConfigurationWorkflowDecorator < MiqDecorator
def self.fonticon
'pficon pficon-template'
end

def self.fileicon
'100/configuration_script.png'
end
end
end
10 changes: 5 additions & 5 deletions app/helpers/application_helper.rb
Expand Up @@ -137,7 +137,7 @@ def type_has_quadicon(type)
"ManageIQ::Providers::CloudManager::Vm" => VmOrTemplate,
"ManageIQ::Providers::InfraManager::Template" => VmOrTemplate,
"ManageIQ::Providers::InfraManager::Vm" => VmOrTemplate,
"ManageIQ::Providers::AutomationManager" => ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript
"ManageIQ::Providers::AutomationManager" => ConfigurationScript
}.freeze

def controller_to_model
Expand All @@ -157,7 +157,7 @@ def controller_to_model
"chargebacks" => ChargebackRate,
"playbooks" => ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook,
"physical_servers_with_host" => PhysicalServer,
"manageiq/providers/automation_managers" => ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript,
"manageiq/providers/automation_managers" => ConfigurationScript,
"vms" => VmOrTemplate,
"ServiceCatalog" => ServiceTemplate
}.freeze
Expand Down Expand Up @@ -333,7 +333,7 @@ def view_to_url(view, parent = nil)
elsif %w(ConfiguredSystem).include?(view.db) && (request.parameters[:controller] == "provider_foreman" || request.parameters[:controller] == "automation_manager")
return url_for_only_path(:action => action, :id => nil) + "/"
elsif %w(MiqWidget
ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript
ConfigurationScript
MiqReportResult).include?(view.db) &&
%w(report automation_manager).include?(request.parameters[:controller])
suffix = ''
Expand Down Expand Up @@ -454,7 +454,7 @@ def db_to_controller(db, action = "show")
controller = request.parameters[:controller]
when "OrchestrationStackOutput", "OrchestrationStackParameter", "OrchestrationStackResource",
"ManageIQ::Providers::CloudManager::OrchestrationStack",
"ManageIQ::Providers::AnsibleTower::AutomationManager::Job", "ConfigurationScriptBase"
"ManageIQ::Providers::AnsibleTower::AutomationManager::Job", "ConfigurationScript"
controller = request.parameters[:controller]
when "ContainerVolume"
controller = "persistent_volume"
Expand Down Expand Up @@ -972,7 +972,7 @@ def configuration_manager_scripts_tree(tree)
when :configuration_manager_cs_filter_tree
"ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem"
when :configuration_scripts_tree
"ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript"
"ConfigurationScript"
end
end

Expand Down
Expand Up @@ -9,7 +9,7 @@ class ApplicationHelper::Toolbar::ConfigurationScriptCenter < ApplicationHelper:
button(
:configscript_service_dialog,
'pficon pficon-add-circle-o fa-lg',
t = N_('Create Service Dialog from this Job Template'),
t = N_('Create Service Dialog from this Template'),
t),
]
),
Expand All @@ -23,7 +23,7 @@ class ApplicationHelper::Toolbar::ConfigurationScriptCenter < ApplicationHelper:
button(
:configuration_script_tag,
'pficon pficon-edit fa-lg',
N_('Edit Tags for this Job Template'),
N_('Edit Tags for this Template'),
N_('Edit Tags'),
:url => "tagging",
:url_parms => "main_div",
Expand Down
Expand Up @@ -5,7 +5,7 @@ class TreeBuilderAutomationManagerConfigurationScripts < TreeBuilder
private

def tree_init_options(_tree_name)
{:leaf => "ConfigurationScriptBase"}
{:leaf => "ConfigurationScript"}
end

def set_locals_for_render
Expand Down Expand Up @@ -43,7 +43,7 @@ def x_get_tree_roots(count_only, _options)
end

def x_get_tree_cmat_kids(object, count_only)
scripts = ConfigurationScriptBase.where(:manager_id => object.id).where.not(:type => ConfigurationScriptBase::EXCLUDED_WORKFLOW_TYPES)
scripts = ConfigurationScript.where(:manager_id => object.id)
count_only_or_objects_filtered(count_only, scripts, "name")
end

Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/print/textual_summary.html.haml
Expand Up @@ -3,7 +3,7 @@
= render :partial => "#{controller}/main_configuration_profile"
- elsif @record.kind_of?(ManageIQ::Providers::AutomationManager::InventoryGroup)
= render :partial => "#{controller}/main_inventory_group"
- elsif is_template_record?
- elsif @record.kind_of?(ManageIQ::Providers::AutomationManager::ConfigurationWorkflow) || @record.kind_of?(ConfigurationScript)
= render :partial => "#{controller}/configuration_script"
- else
= render :partial => "layouts/textual_groups_generic"
Expand Up @@ -15,7 +15,7 @@ title: Ansible Tower Templates
name: Templates

# Main DB table report is based on
db: ConfigurationScriptBase
db: ConfigurationScript

# Columns to fetch from the main table
cols:
Expand Down
2 changes: 1 addition & 1 deletion spec/controllers/automation_manager_controller_spec.rb
Expand Up @@ -427,7 +427,7 @@
allow(controller).to receive(:x_active_tree).and_return(:configuration_scripts_tree)
allow(controller).to receive(:x_active_accord).and_return(:configuration_scripts)
controller.instance_variable_set(:@_params, :id => "configuration_scripts")
expect(controller).to receive(:get_view).with("ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript", :gtl_dbname => "automation_manager_configuration_scripts").and_call_original
expect(controller).to receive(:get_view).with("ConfigurationScript", :gtl_dbname => "automation_manager_configuration_scripts").and_call_original
controller.send(:accordion_select)
end
end
Expand Down

0 comments on commit f49927f

Please sign in to comment.