Skip to content

Commit

Permalink
Merge pull request #4138 from h-kataria/configuration_workflows_ui
Browse files Browse the repository at this point in the history
Show Configuration Workflows in UI
  • Loading branch information
martinpovolny authored Aug 2, 2018
2 parents fa447ea + 26ae0c9 commit 0a0df98
Show file tree
Hide file tree
Showing 19 changed files with 79 additions and 48 deletions.
2 changes: 1 addition & 1 deletion app/controllers/application_controller/tags.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ def tagging_edit_tags_reset
return unless load_edit("#{session[:tag_db]}_edit_tags__#{id}")
@object_ids = @edit[:object_ids]
end
@in_a_form = true
tagging_tags_set_form_vars
@display = nil
@in_a_form = true
session[:changed] = false
add_flash(_("All changes have been reset"), :warning) if params[:button] == "reset"
@title = _('Tag Assignment')
Expand Down
35 changes: 20 additions & 15 deletions app/controllers/automation_manager_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def tagging
tagging_edit('ConfiguredSystem', false)
when :configuration_scripts
assert_privileges("automation_manager_configuration_script_tag")
tagging_edit('ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript', false)
tagging_edit('ConfigurationScript', false)
end
render_tagging_form
end
Expand Down Expand Up @@ -127,8 +127,8 @@ def automation_manager_cs_filter_tree_rec
def configuration_scripts_tree_rec
nodes = x_node.split('-')
case nodes.first
when "root", "at", "cf"
find_record(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript, params[:id])
when "root", "at", "cf", "cw"
find_record(ConfigurationScript, params[:id])
end
end

Expand Down Expand Up @@ -169,6 +169,11 @@ def providers_active_tree?

private

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

def textual_group_list
[%i(properties tags)]
end
Expand Down Expand Up @@ -196,7 +201,7 @@ def features
:role => "automation_manager_configuration_scripts_accord",
:role_any => true,
:name => :configuration_scripts,
:title => _("Job Templates")
:title => _("Templates")
)
]
end
Expand All @@ -218,7 +223,7 @@ def get_node_info(treenodeid, _show_list = true)
inventory_group_node(id, model)
when "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem", "ConfiguredSystem"
configured_system_list(id, model)
when "ConfigurationScript"
when "ConfigurationScript", "ConfigurationWorkflow"
configuration_scripts_list(id, model)
when "MiqSearch"
miq_search_node
Expand Down Expand Up @@ -267,12 +272,12 @@ def provider_node(id, model)
end

def cs_provider_node(provider)
options = {:model => "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript",
:named_scope => [[:with_manager, provider.id]],
:gtl_dbname => "automation_manager_configuration_scripts"}
options = {:model => "ConfigurationScript",
:named_scope => [[:with_manager, provider.id]],
:gtl_dbname => "automation_manager_configuration_scripts"}
@show_adv_search = true
process_show_list(options)
@right_cell_text = _("Job Templates under \"%{name}\"") % {:name => provider.name}
@right_cell_text = _("Templates under \"%{name}\"") % {:name => provider.name}
end

def inventory_group_node(id, model)
Expand Down Expand Up @@ -303,13 +308,13 @@ def configuration_scripts_list(id, model)
if x_active_tree == :configuration_scripts_tree
options = {:model => model.to_s,
:gtl_dbname => "configuration_scripts"}
@right_cell_text = _("All Ansible Tower Job Templates")
@right_cell_text = _("All Ansible Tower Templates")
process_show_list(options)
end
end

def configuration_script_node(id)
@record = @configuration_script_record = find_record(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript, id)
@record = @configuration_script_record = find_record(ConfigurationScript, id)
@show_adv_search = false
display_node(id, nil)
end
Expand All @@ -328,10 +333,10 @@ def default_node
process_show_list(options)
@right_cell_text = _("All Ansible Tower Configured Systems")
elsif x_active_tree == :configuration_scripts_tree
options = {:model => "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript",
options = {:model => "ConfigurationScript",
:gtl_dbname => "automation_manager_configuration_scripts"}
process_show_list(options)
@right_cell_text = _("All Ansible Tower Job Templates")
@right_cell_text = _("All Ansible Tower Templates")
end
end

Expand All @@ -343,7 +348,7 @@ def leaf_record
get_node_info(x_node)
@delete_node = params[:id] if @replace_trees
type, _id = parse_nodetype_and_id(x_node)
type && %w(ConfiguredSystem ConfigurationScript).include?(TreeBuilder.get_model_for_prefix(type))
type && %w(ConfiguredSystem ConfigurationScript ConfigurationWorkflow).include?(TreeBuilder.get_model_for_prefix(type))
end

def managed_group_record?(node = x_node)
Expand Down Expand Up @@ -448,7 +453,7 @@ def valid_configuration_script_record?(configuration_script_record)

def configscript_service_dialog
assert_privileges("automation_manager_configuration_script_service_dialog")
cs = ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript.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
26 changes: 20 additions & 6 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -890,9 +890,9 @@ def atomic_req_submit
if @edit[:new][:st_prov_type] == 'generic_ansible_tower'
if @edit[:new][:manager_id].blank?
add_flash(_("Provider is required, please select one from the list"), :error)
else
elsif @edit[:new][:template_id].blank?
# 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)
end
end

Expand Down Expand Up @@ -1486,7 +1486,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 All @@ -1511,7 +1511,8 @@ def fetch_form_vars_ansible_or_ct
@edit[:new][:manager_id] = nil
else
@edit[:new][:manager_id] = params[:manager_id]
available_job_or_container_templates(params[:manager_id]) if %w(generic_ansible_tower generic_container_template).include?(@edit[:new][:st_prov_type])
available_job_templates(params[:manager_id]) if @edit[:new][:st_prov_type] == 'generic_ansible_tower'
available_container_templates(params[:manager_id]) if @edit[:new][:st_prov_type] == 'generic_container_template'
end
end
@edit[:new][:template_id] = params[:template_id] if params[:template_id]
Expand Down Expand Up @@ -1540,18 +1541,31 @@ def available_orchestration_templates
available_orchestration_managers(@record.orchestration_template.id) if @record.orchestration_template
end

def available_job_or_container_templates(manager_id)
def available_container_templates(manager_id)
method = @edit[:new][:st_prov_type] == 'generic_ansible_tower' ? 'configuration_scripts' : 'container_templates'
@edit[:new][:available_templates] =
ExtManagementSystem.find_by(:id => manager_id).send(method).collect { |t| [t.name, t.id] }.sort
end

def available_job_templates(manager_id)
@edit[:new][:available_templates] = []
all_job_templates = ExtManagementSystem.find_by(:id => manager_id).send('configuration_scripts').collect { |t| [t.name, t.id] }.sort
all_workflow_templates = ExtManagementSystem.find_by(:id => manager_id).send('configuration_workflows').collect { |t| [t.name, t.id] }.sort
@edit[:new][:available_templates].push(["",
[["<#{_('Choose a Template')}>",
:selected => "<#{_('Choose a Template')}>",
:disabled => "<#{_('Choose a Template')}>",
:style => 'display:none']]])
@edit[:new][:available_templates].push(["Job Templates", all_job_templates]) if all_job_templates.present?
@edit[:new][:available_templates].push(["Workflow Templates", all_workflow_templates]) if all_workflow_templates.present?
end

def available_ansible_tower_managers
@edit[:new][:available_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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class ConfigurationScriptDecorator < MiqDecorator
def self.fonticon
'pficon pficon-template'
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module ManageIQ::Providers::AnsibleTower
class AutomationManager::ConfigurationWorkflowDecorator < MiqDecorator
def self.fonticon
'pficon pficon-template'
end
end
end
10 changes: 5 additions & 5 deletions app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ApplicationHelper::Toolbar::XConfigurationScriptCenter < 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::XConfigurationScriptCenter < 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
1 change: 1 addition & 0 deletions app/presenters/tree_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,7 @@ def resolve_object_lambdas(count_only, objects)
"cl" => "Classification",
"cf" => "ConfigurationScript",
"cfp" => "ConfigurationScriptPayload",
"cw" => "ConfigurationWorkflow",
"cnt" => "Container",
"co" => "Condition",
"cbg" => "CustomButtonSet",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class TreeBuilderAutomationManagerConfigurationScripts < TreeBuilder
private

def tree_init_options(_tree_name)
{:leaf => "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript"}
{:leaf => "ConfigurationScript"}
end

def set_locals_for_render
Expand All @@ -15,7 +15,7 @@ def set_locals_for_render

def root_options
{
:text => t = _("All Ansible Tower Job Templates"),
:text => t = _("All Ansible Tower Templates"),
:tooltip => t
}
end
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 = ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript.where(:manager_id => object.id)
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/presenters/tree_node/configuration_script_base.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module TreeNode
class ConfigurationScriptBase < Node
set_attribute(:icon, 'pficon pficon-template')
set_attribute(:tooltip) { _("Ansible Tower Job Template: %{name}") % {:name => @object.name} }
set_attribute(:tooltip) { _("%{type}: %{name}") % {:name => @object.name, :type => ui_lookup(:model => @object.type)} }
end
end
2 changes: 1 addition & 1 deletion app/views/automation_manager/explorer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
- elsif @configured_system_record
#main_div
= render :partial => "layouts/textual_groups_generic"
- elsif @record.kind_of?(ConfigurationScript)
- elsif template_record?
#main_div
= render(:partial => 'automation_manager/configuration_script', :locals => {:controller => "automation_manager"})
- else
Expand Down
5 changes: 2 additions & 3 deletions app/views/catalog/_form_basic_info.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,12 @@
:javascript
miqSelectPickerEvent('manager_id', '#{url}')
- if @edit[:new][:manager_id]
- opts = [["<#{_('Choose')}>", nil]] + @edit[:new][:available_templates]
.form-group
%label.col-md-2.control-label
= @edit[:new][:st_prov_type] == "generic_ansible_tower" ? _('Ansible Tower Job Template') : _('Container Template')
= @edit[:new][:st_prov_type] == "generic_ansible_tower" ? _('Ansible Tower Template') : _('Container Template')
.col-md-8
= select_tag('template_id',
options_for_select(opts, @edit[:new][:template_id]),
grouped_options_for_select(@edit[:new][:available_templates], @edit[:new][:template_id]),
"data-miq_sparkle_on" => true,
:class => "selectpicker")
:javascript
Expand Down
2 changes: 1 addition & 1 deletion app/views/catalog/_sandt_tree_show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
- elsif @record.prov_type == "generic_ansible_tower"
.form-group
%label.col-md-3.control-label
= _('Ansible Tower Job Template')
= _('Ansible Tower Template')
.col-md-9
= h(@record.try(:job_template).try(:name))
- elsif @record.prov_type == "generic_container_template"
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/print/textual_summary.html.haml
Original file line number Diff line number Diff line change
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 @record.kind_of?(ManageIQ::Providers::AutomationManager::ConfigurationScript)
- elsif @record.kind_of?(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationWorkflow) || @record.kind_of?(ConfigurationScript)
= render :partial => "#{controller}/configuration_script"
- else
= render :partial => "layouts/textual_groups_generic"
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
#

# Report title
title: Ansible Tower Job Templates
title: Ansible Tower Templates

# Menu name
name: Job Templates
name: Templates

# Main DB table report is based on
db: ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript
db: ConfigurationScript

# Columns to fetch from the main table
cols:
Expand Down
Loading

0 comments on commit 0a0df98

Please sign in to comment.