From 6173e3a9aa1a16ea80329c76902c9a12073ff152 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Sun, 15 Mar 2020 18:12:41 -0400 Subject: [PATCH 01/33] First cut of Non-explorer version of Configuration Management - Added new sub-tabs under Configuration Management - Providers, Profiles, Configured Systems. - Displaying non-explorer version of each of the above subtabs as list views, summary screens, showing advanced search for Configured Systems list view and nameonly search for Providers and Profiles, mimicing same behavior as it is in the explorer version of Configuration explorer. --- .../configuration_manager_controller.rb | 38 ++++ .../configuration_profile_controller.rb | 34 ++++ .../configured_system_controller.rb | 39 ++++ app/helpers/application_helper.rb | 17 ++ app/helpers/application_helper/listnav.rb | 1 + .../application_helper/page_layouts.rb | 1 + app/helpers/configuration_manager_helper.rb | 3 + .../textual_summary.rb | 173 ++++++++++++++++++ app/helpers/configured_system_helper.rb | 3 + .../textual_summary.rb | 121 ++++++++++++ app/presenters/menu/default_menu.rb | 3 + .../configuration_manager/show.html.haml | 4 + .../configuration_manager/show_list.html.haml | 2 + .../configuration_profile/show.html.haml | 12 ++ .../configuration_profile/show_list.html.haml | 2 + app/views/configured_system/show.html.haml | 1 + .../configured_system/show_list.html.haml | 2 + .../_center_div_with_listnav.html.haml | 2 +- config/routes.rb | 114 ++++++++++++ product/views/ConfiguredSystem.yaml | 1 + ...igurationManager_ConfigurationProfile.yaml | 83 +++++++++ 21 files changed, 655 insertions(+), 1 deletion(-) create mode 100644 app/controllers/configuration_manager_controller.rb create mode 100644 app/controllers/configuration_profile_controller.rb create mode 100644 app/controllers/configured_system_controller.rb create mode 100644 app/helpers/configuration_manager_helper.rb create mode 100644 app/helpers/configuration_manager_helper/textual_summary.rb create mode 100644 app/helpers/configured_system_helper.rb create mode 100644 app/helpers/configured_system_helper/textual_summary.rb create mode 100644 app/views/configuration_manager/show.html.haml create mode 100644 app/views/configuration_manager/show_list.html.haml create mode 100644 app/views/configuration_profile/show.html.haml create mode 100644 app/views/configuration_profile/show_list.html.haml create mode 100644 app/views/configured_system/show.html.haml create mode 100644 app/views/configured_system/show_list.html.haml create mode 100644 product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfigurationProfile.yaml diff --git a/app/controllers/configuration_manager_controller.rb b/app/controllers/configuration_manager_controller.rb new file mode 100644 index 00000000000..3fa13f2a240 --- /dev/null +++ b/app/controllers/configuration_manager_controller.rb @@ -0,0 +1,38 @@ +class ConfigurationManagerController < ApplicationController + include Mixins::GenericListMixin + include Mixins::GenericShowMixin + include Mixins::GenericSessionMixin + include Mixins::BreadcrumbsMixin + + before_action :check_privileges + before_action :get_session_data + after_action :cleanup_action + after_action :set_session_data + + def self.model + ManageIQ::Providers::ConfigurationManager + end + + def self.table_name + @table_name ||= "configuration_manager" + end + + private + + # def textual_group_list + # [%i[properties], %i[relationships smart_management]] + # end + # helper_method :textual_group_list + + def breadcrumbs_options + { + :breadcrumbs => [ + {:title => _("Configuration Management")}, + {:title => _("Providers"), :url => controller_url}, + ], + } + end + + menu_section :conf + has_custom_buttons +end diff --git a/app/controllers/configuration_profile_controller.rb b/app/controllers/configuration_profile_controller.rb new file mode 100644 index 00000000000..67ccd65ee01 --- /dev/null +++ b/app/controllers/configuration_profile_controller.rb @@ -0,0 +1,34 @@ +class ConfigurationProfileController < ApplicationController + include Mixins::GenericListMixin + include Mixins::GenericShowMixin + include Mixins::GenericSessionMixin + include Mixins::BreadcrumbsMixin + + before_action :check_privileges + before_action :get_session_data + after_action :cleanup_action + after_action :set_session_data + + def self.model + ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile + end + + def self.table_name + @table_name ||= "configuration_profile" + end + + private + + def breadcrumbs_options + { + :breadcrumbs => [ + {:title => _("Configuration Profile")}, + {:title => _("Profiles"), :url => controller_url}, + ], + } + end + + menu_section :cnt + + has_custom_buttons +end diff --git a/app/controllers/configured_system_controller.rb b/app/controllers/configured_system_controller.rb new file mode 100644 index 00000000000..c8918154642 --- /dev/null +++ b/app/controllers/configured_system_controller.rb @@ -0,0 +1,39 @@ +class ConfiguredSystemController < ApplicationController + include Mixins::GenericListMixin + include Mixins::GenericShowMixin + include Mixins::GenericSessionMixin + include Mixins::BreadcrumbsMixin + + before_action :check_privileges + before_action :get_session_data + after_action :cleanup_action + after_action :set_session_data + + def self.model + ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem + end + + def self.table_name + @table_name ||= "configured_system" + end + + private + + def textual_group_list + [%i[properties environment os], %i[tenancy tags]] + end + helper_method :textual_group_list + + def breadcrumbs_options + { + :breadcrumbs => [ + {:title => _("Configuration Management")}, + {:title => _("Configured Systems"), :url => controller_url}, + ], + } + end + + menu_section :cnt + + has_custom_buttons +end diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a8463f44312..e20988fa907 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -240,6 +240,9 @@ def view_to_url(view, parent = nil) if controller == "ems_cloud" && action == "show" return ems_clouds_path end + # if controller == "ems_configuration" && action == "show" + # return configuration_managers_path + # end if controller == "ems_infra" && action == "show" return ems_infras_path end @@ -422,6 +425,9 @@ def db_to_controller(db, action = "show") controller = request.parameters[:controller] when "OrchestrationStackOutput", "OrchestrationStackParameter", "OrchestrationStackResource", "ManageIQ::Providers::CloudManager::OrchestrationStack", + "ManageIQ::Providers::ConfigurationManager", + "ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile", + "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem", "ManageIQ::Providers::AnsibleTower::AutomationManager::Job", "ConfigurationScript" controller = request.parameters[:controller] when "ContainerVolume" @@ -651,6 +657,14 @@ def taskbar_in_header? end end + def nameonly_search? + nameonly_search_layouts = %w[ + configuration_manager + configuration_profile + ] + nameonly_search_layouts.include?(@layout) + end + # checking if any of the toolbar is visible def toolbars_visible? (@toolbars['history_tb'] || @toolbars['center_tb'] || @toolbars['view_tb']) && @@ -755,7 +769,10 @@ def display_adv_search? cloud_volume_snapshot cloud_volume_type configuration_job + configuration_manager + configuration_profile configuration_scripts + configured_system container container_build container_group diff --git a/app/helpers/application_helper/listnav.rb b/app/helpers/application_helper/listnav.rb index 5a3dd401212..c7158b21c2b 100644 --- a/app/helpers/application_helper/listnav.rb +++ b/app/helpers/application_helper/listnav.rb @@ -15,6 +15,7 @@ def render_listnav_filename cloud_volume_snapshot cloud_volume_type configuration_job + configured_system container container_build container_group diff --git a/app/helpers/application_helper/page_layouts.rb b/app/helpers/application_helper/page_layouts.rb index f9c184ca3b0..c813b12c895 100644 --- a/app/helpers/application_helper/page_layouts.rb +++ b/app/helpers/application_helper/page_layouts.rb @@ -189,6 +189,7 @@ def show_adv_search? cloud_volume_snapshot cloud_volume_type configuration_job + configured_system container container_build container_group diff --git a/app/helpers/configuration_manager_helper.rb b/app/helpers/configuration_manager_helper.rb new file mode 100644 index 00000000000..c4cefa93dcc --- /dev/null +++ b/app/helpers/configuration_manager_helper.rb @@ -0,0 +1,3 @@ +module ConfigurationManagerHelper + include_concern 'TextualSummary' +end diff --git a/app/helpers/configuration_manager_helper/textual_summary.rb b/app/helpers/configuration_manager_helper/textual_summary.rb new file mode 100644 index 00000000000..e499a46b78e --- /dev/null +++ b/app/helpers/configuration_manager_helper/textual_summary.rb @@ -0,0 +1,173 @@ +module ConfigurationManagerHelper::TextualSummary + include TextualMixins::TextualRefreshStatus + include TextualMixins::TextualCustomButtonEvents + include TextualMixins::TextualZone + include TextualMixins::EmsCommon + # + # Groups + # + + def textual_group_properties + TextualGroup.new( + _("Properties"), + %i[description hostname ipaddress type port guid region keystone_v3_domain_id] + ) + end + + def textual_group_relationships + TextualGroup.new( + _("Relationships"), + %i[ + ems_infra network_manager availability_zones host_aggregates cloud_tenants flavors + security_groups instances images cloud_volumes orchestration_stacks storage_managers + custom_button_events tenant + ] + ) + end + + def textual_group_status + TextualGroup.new(_("Status"), textual_authentications(@record.authentication_for_summary) + %i[refresh_status refresh_date]) + end + + def textual_group_smart_management + TextualTags.new(_("Smart Management"), %i[zone tags]) + end + + def textual_group_topology + items = %w[topology] + i = items.collect { |m| send("textual_#{m}") }.flatten.compact + TextualGroup.new(_("Overview"), i) + end + + # + # Items + # + def textual_description + return nil if @record.try(:description).blank? + {:label => _("Description"), :value => @record.description} + end + + def textual_region + return nil if @record.provider_region.blank? + label_val = _('Region') + {:label => label_val, :value => @record.provider_region} + end + + def textual_keystone_v3_domain_id + return nil if !@record.respond_to?(:keystone_v3_domain_id) || @record.keystone_v3_domain_id.nil? + label_val = _("Keystone V3 Domain ID") + {:label => label_val, :value => @record.keystone_v3_domain_id} + end + + def textual_hostname + @record.hostname + end + + def textual_ipaddress + return nil if @record.ipaddress.blank? + {:label => _("Discovered IP Address"), :value => @record.ipaddress} + end + + def textual_type + {:label => _('Type'), :value => @record.emstype_description} + end + + def textual_port + @record.supports_port? ? {:label => _("API Port"), :value => @record.port} : nil + end + + def textual_guid + {:label => _("Management Engine GUID"), :value => @record.guid} + end + + def textual_instances + num = @record.number_of(:vms) + h = {:label => _('Instances'), :icon => "pficon pficon-virtual-machine", :value => num} + if num.positive? && role_allows?(:feature => "vm_show_list") + h[:link] = ems_cloud_path(@record.id, :display => 'instances') + h[:title] = _("Show all Instances") + end + h + end + + def textual_images + num = @record.number_of(:miq_templates) + h = {:label => _('Images'), :icon => "pficon pficon-virtual-machine", :value => num} + if num.positive? && role_allows?(:feature => "miq_template_show_list") + h[:link] = ems_cloud_path(@record.id, :display => 'images') + h[:title] = _("Show all Images") + end + h + end + + def textual_cloud_volumes + num = @record.number_of(:cloud_volumes) + h = {:label => _('Cloud Volumes'), :icon => "pficon pficon-volume", :value => num} + if num.positive? && role_allows?(:feature => "cloud_volume_show_list") + h[:link] = ems_cloud_path(@record.id, :display => 'cloud_volumes') + h[:title] = _("Show Cloud Volumes") + end + h + end + + def textual_ems_infra + textual_link(@record.try(:provider).try(:infra_ems)) + end + + def textual_network_manager + textual_link(@record.ext_management_system.try(:network_manager)) + end + + def textual_storage_managers + num = @record.try(:storage_managers) ? @record.number_of(:storage_managers) : 0 + h = {:label => _('Storage Managers'), :icon => "fa fa-database", :value => num} + if num.positive? && role_allows?(:feature => "ems_storage_show_list") + h[:title] = _("Show all Storage Managers") + h[:link] = ems_cloud_path(@record.id, :display => 'storage_managers') + end + h + end + + def textual_availability_zones + textual_link(@record.availability_zones, :label => _('Availability Zones')) + end + + def textual_host_aggregates + textual_link(@record.host_aggregates, :label => _('Host Aggregates')) + end + + def textual_cloud_tenants + textual_link(@record.cloud_tenants, :label => _('Cloud Tenants')) + end + + def textual_orchestration_stacks + textual_link(@record.orchestration_stacks, :label => _('Orchestration Stacks')) + end + + def textual_flavors + textual_link(@record.flavors, :label => _('Flavors')) + end + + def textual_security_groups + num = @record.number_of(:security_groups) + h = {:label => _('Security Groups'), :icon => "pficon pficon-cloud-security", :value => num} + if num.positive? && role_allows?(:feature => "security_group_show_list") + h[:link] = ems_cloud_path(@record.id, :display => 'security_groups') + h[:title] = _("Show all Security Groups") + end + h + end + + def textual_topology + {:label => _('Topology'), + :icon => "pficon pficon-topology", + :link => url_for_only_path(:controller => 'cloud_topology', :action => 'show', :id => @record.id), + :title => _("Show topology")} + end + + def textual_tenant + return nil unless User.current_user.super_admin_user? + + {:label => _('Tenant'), :value => @record.tenant.name} + end +end diff --git a/app/helpers/configured_system_helper.rb b/app/helpers/configured_system_helper.rb new file mode 100644 index 00000000000..dcc9082750b --- /dev/null +++ b/app/helpers/configured_system_helper.rb @@ -0,0 +1,3 @@ +module ConfiguredSystemHelper + include_concern 'TextualSummary' +end diff --git a/app/helpers/configured_system_helper/textual_summary.rb b/app/helpers/configured_system_helper/textual_summary.rb new file mode 100644 index 00000000000..c22fdb61604 --- /dev/null +++ b/app/helpers/configured_system_helper/textual_summary.rb @@ -0,0 +1,121 @@ +module ConfiguredSystemHelper::TextualSummary + include TextualMixins::TextualGroupTags + + def textual_group_properties + TextualGroup.new( + _("Properties"), + %i[hostname ipmi_present ipaddress mac_address configuration_profile_desc provider_name zone] + ) + end + + def textual_hostname + { + :label => _("Hostname"), + :icon => "ff ff-configured-system", + :value => @record.hostname, + } + end + + def textual_ipmi_present + {:label => _("IPMI Present"), :value => @record.ipmi_present} + end + + def textual_ipaddress + {:label => _("IP Address"), :value => @record.ipaddress} + end + + def textual_mac_address + {:label => _("Mac address"), :value => @record.mac_address} + end + + def textual_configuration_profile_desc + h = { + :label => _("Configuration Profile Description"), + :value => @record.configuration_profile.try(:description), + :explorer => true + } + h[:icon] = "fa fa-list-ul" if @record.configuration_profile + h + end + + def textual_provider_name + { + :label => _("Provider"), + :image => @record.configuration_manager.decorate.fileicon, + :value => @record.configuration_manager.try(:name), + :explorer => true + } + end + + def textual_zone + {:label => _("Zone"), :value => @record.configuration_manager.my_zone} + end + + def textual_group_environment + TextualGroup.new( + _("Environment"), + %i[configuration_environment_name configuration_domain_name configuration_realm_name] + ) + end + + def textual_configuration_environment_name + {:label => _("Environment"), :value => @record.configuration_profile.try(:configuration_environment_name)} + end + + def textual_configuration_domain_name + {:label => _("Domain"), :value => @record.configuration_profile.try(:configuration_domain_name)} + end + + def textual_configuration_realm_name + {:label => _("Realm"), :value => @record.configuration_profile.try(:configuration_realm_name)} + end + + def textual_group_os + TextualGroup.new( + _("Operating System"), + %i[ + configuration_compute_profile_name configuration_architecture_name operating_system_flavor_name + customization_script_medium_name customization_script_ptable_name + ] + ) + end + + def textual_configuration_compute_profile_name + {:label => _("Compute Profile"), :value => @record.configuration_profile.try(:configuration_compute_profile_name)} + end + + def textual_configuration_architecture_name + {:label => _("Architecture"), :value => @record.configuration_profile.try(:configuration_architecture_name)} + end + + def textual_operating_system_flavor_name + {:label => _("OS Information"), :value => @record.configuration_profile.try(:operating_system_flavor_name)} + end + + def textual_customization_script_medium_name + {:label => _("Medium"), :value => @record.configuration_profile.try(:customization_script_medium_name)} + end + + def textual_customization_script_ptable_name + {:label => _("Partition Table"), :value => @record.configuration_profile.try(:customization_script_ptable_name)} + end + + def textual_group_tenancy + TextualGroup.new(_("Tenancy"), %i[configuration_locations_name configuration_organizations_name]) + end + + def textual_configuration_locations_name + { + :label => _("Configuration Location"), + :value => (@record.configuration_profile.try(:configuration_locations) || []).collect(&:name).join(", ") + } + end + + def textual_configuration_organizations_name + { + :label => _("Configuration Organization"), + :value => (@record.configuration_profile.try(:configuration_organizations) || []).collect(&:name).join(", ") + } + end + +end diff --git a/app/presenters/menu/default_menu.rb b/app/presenters/menu/default_menu.rb index 8591882ad12..e4e64014d50 100644 --- a/app/presenters/menu/default_menu.rb +++ b/app/presenters/menu/default_menu.rb @@ -14,6 +14,9 @@ def compute_menu_section def configuration_menu_section Menu::Section.new(:conf, N_("Configuration"), 'fa fa-cog', [ Menu::Item.new('provider_foreman', N_('Management'), 'provider_foreman_explorer', {:feature => 'provider_foreman_explorer', :any => true}, '/provider_foreman/explorer'), + Menu::Item.new('configuration_manager', N_('Providers'), 'configuration_manager', {:feature => 'configuration_manager_show_list'}, '/configuration_manager/show_list'), + Menu::Item.new('configuration_profile', N_('Profiles'), 'configuration_profile', {:feature => 'configuration_profile_show_list'}, '/configuration_profile/show_list'), + Menu::Item.new('configured_system', N_('Configured Systems'), 'configured_system', {:feature => 'configured_system_show_list'}, '/configured_system/show_list'), ]) end diff --git a/app/views/configuration_manager/show.html.haml b/app/views/configuration_manager/show.html.haml new file mode 100644 index 00000000000..58d5f016aec --- /dev/null +++ b/app/views/configuration_manager/show.html.haml @@ -0,0 +1,4 @@ +- if %w(configuration_profiles).include?(@display) + = render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"} +- elsif @showtype == "main" + = render :partial => "layouts/textual_groups_generic" diff --git a/app/views/configuration_manager/show_list.html.haml b/app/views/configuration_manager/show_list.html.haml new file mode 100644 index 00000000000..039604839f2 --- /dev/null +++ b/app/views/configuration_manager/show_list.html.haml @@ -0,0 +1,2 @@ +#main_div + = render :partial => 'layouts/gtl' diff --git a/app/views/configuration_profile/show.html.haml b/app/views/configuration_profile/show.html.haml new file mode 100644 index 00000000000..451471b4bef --- /dev/null +++ b/app/views/configuration_profile/show.html.haml @@ -0,0 +1,12 @@ +- if %w(configured_systems).include?(@display) + = render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"} +- elsif @showtype == "main" + = render :partial => "layouts/flash_msg" + .row + .col-md-12.col-lg-6 + = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_configuration_profile_group_properties), @record) + = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Environment'), textual_configuration_profile_group_environment), @record) + = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Operating System'), textual_configuration_profile_group_os), @record) + .col-md-12.col-lg-6 + = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Tenancy'), textual_configuration_profile_group_tenancy), @record) + diff --git a/app/views/configuration_profile/show_list.html.haml b/app/views/configuration_profile/show_list.html.haml new file mode 100644 index 00000000000..039604839f2 --- /dev/null +++ b/app/views/configuration_profile/show_list.html.haml @@ -0,0 +1,2 @@ +#main_div + = render :partial => 'layouts/gtl' diff --git a/app/views/configured_system/show.html.haml b/app/views/configured_system/show.html.haml new file mode 100644 index 00000000000..7aa7a5d10da --- /dev/null +++ b/app/views/configured_system/show.html.haml @@ -0,0 +1 @@ += render :partial => "layouts/textual_groups_generic" diff --git a/app/views/configured_system/show_list.html.haml b/app/views/configured_system/show_list.html.haml new file mode 100644 index 00000000000..039604839f2 --- /dev/null +++ b/app/views/configured_system/show_list.html.haml @@ -0,0 +1,2 @@ +#main_div + = render :partial => 'layouts/gtl' diff --git a/app/views/layouts/_center_div_with_listnav.html.haml b/app/views/layouts/_center_div_with_listnav.html.haml index 429424290bc..13cd6723062 100644 --- a/app/views/layouts/_center_div_with_listnav.html.haml +++ b/app/views/layouts/_center_div_with_listnav.html.haml @@ -18,7 +18,7 @@ = render :partial => 'layouts/tabs' .col-md-5 %br - = render :partial => 'layouts/searchbar' + = render :partial => 'layouts/searchbar', :locals => {:nameonly => nameonly_search?} .row .col-md-12 = yield diff --git a/config/routes.rb b/config/routes.rb index 1f5c0d01a94..7a85bc361ef 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2662,6 +2662,120 @@ dialog_runner_post }, + :configuration_manager => { + :get => %w( + download_data + download_summary_pdf + form_fields + show + show_list + tagging_edit + ), + :post => %w( + authentication_validate + button + change_tab + delete + edit + form_field_changed + new + provision + quick_search + refresh + reload + show + show_list + tagging + tagging_edit + tag_edit_form_field_changed + cs_form_field_changed + users + wait_for_task + button + ) + + adv_search_post + + dialog_runner_post + + exp_post + + perf_post + + save_post + }, + + :configuration_profile => { + :get => %w( + download_data + download_summary_pdf + form_fields + show + show_list + tagging_edit + ), + :post => %w( + authentication_validate + button + change_tab + delete + edit + form_field_changed + new + provision + quick_search + refresh + reload + show + show_list + tagging + tagging_edit + tag_edit_form_field_changed + cs_form_field_changed + users + wait_for_task + button + ) + + adv_search_post + + dialog_runner_post + + exp_post + + perf_post + + save_post + }, + + :configured_system => { + :get => %w( + download_data + download_summary_pdf + form_fields + show + show_list + tagging_edit + ), + :post => %w( + authentication_validate + button + change_tab + delete + edit + form_field_changed + new + provision + quick_search + refresh + reload + show + show_list + tagging + tagging_edit + tag_edit_form_field_changed + cs_form_field_changed + users + wait_for_task + button + ) + + adv_search_post + + dialog_runner_post + + exp_post + + perf_post + + save_post + }, + :provider_foreman => { :get => %w( download_data diff --git a/product/views/ConfiguredSystem.yaml b/product/views/ConfiguredSystem.yaml index c9cd6d3d7e6..61662f12e89 100644 --- a/product/views/ConfiguredSystem.yaml +++ b/product/views/ConfiguredSystem.yaml @@ -37,6 +37,7 @@ col_order: - build_state - my_zone - configuration_environment_name +- configuration_profile_name # Column titles, in order headers: diff --git a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfigurationProfile.yaml b/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfigurationProfile.yaml new file mode 100644 index 00000000000..498cc1af6e1 --- /dev/null +++ b/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfigurationProfile.yaml @@ -0,0 +1,83 @@ +# +# This is an MIQ Report configuration file +# Single value parameters are specified as: +# single_value_parm: value +# Multiple value parameters are specified as: +# multi_value_parm: +# - value 1 +# - value 2 +# + +# Report title +title: ConfigurationProfile + +# Menu name +name: ConfigurationProfile + +# Main DB table report is based on +db: ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile + +# Columns to fetch from the main table +cols: +- description +- total_configured_systems +- configuration_environment_name +- my_zone +- region_description + +# Included tables (joined, has_one, has_many) and columns + +# Included tables and columns for query performance + +# Order of columns (from all tables) +col_order: +- description +- total_configured_systems +- configuration_environment_name +- my_zone +- region_description + +# Column titles, in order +headers: +- Description +- Total Configured Systems +- Environment +- Zone +- Region + +col_formats: +- +- +- +- +- + +# Condition(s) string for the SQL query +conditions: + +# Order string for the SQL query +order: Ascending + +# Columns to sort the report on, in order +sortby: +- description + +# Group rows (y=yes,n=no,c=count) +group: n + +# Graph type +# Bar +# Column +# ColumnThreed +# ParallelThreedColumn +# Pie +# PieThreed +# StackedBar +# StackedColumn +# StackedThreedColumn + +graph: + +# Dimensions of graph (1 or 2) +# Note: specifying 2 for a single dimension graph may not return expected results +dims: From 006f335a9c702f1f495ccd8c76f61b64731106e8 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 16 Mar 2020 10:28:24 -0400 Subject: [PATCH 02/33] Fixed value of `menu_section` in controllers - Fixed value of `menu_section` in controllers so the correct parent menu item is highlighted on the left - Removed `has_custom_buttons` --- app/controllers/configuration_manager_controller.rb | 1 - app/controllers/configuration_profile_controller.rb | 4 +--- app/controllers/configured_system_controller.rb | 4 +--- 3 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/controllers/configuration_manager_controller.rb b/app/controllers/configuration_manager_controller.rb index 3fa13f2a240..494987f74be 100644 --- a/app/controllers/configuration_manager_controller.rb +++ b/app/controllers/configuration_manager_controller.rb @@ -34,5 +34,4 @@ def breadcrumbs_options end menu_section :conf - has_custom_buttons end diff --git a/app/controllers/configuration_profile_controller.rb b/app/controllers/configuration_profile_controller.rb index 67ccd65ee01..5f98c8745d0 100644 --- a/app/controllers/configuration_profile_controller.rb +++ b/app/controllers/configuration_profile_controller.rb @@ -28,7 +28,5 @@ def breadcrumbs_options } end - menu_section :cnt - - has_custom_buttons + menu_section :conf end diff --git a/app/controllers/configured_system_controller.rb b/app/controllers/configured_system_controller.rb index c8918154642..e3b50c3ddac 100644 --- a/app/controllers/configured_system_controller.rb +++ b/app/controllers/configured_system_controller.rb @@ -33,7 +33,5 @@ def breadcrumbs_options } end - menu_section :cnt - - has_custom_buttons + menu_section :conf end From 09277ae09ccf1db7a93b7bc9388aecd446482a62 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 16 Mar 2020 10:45:18 -0400 Subject: [PATCH 03/33] Added listnav partials --- .../listnav/_configuration_manager.html.haml | 14 ++++++++++++++ .../listnav/_configuration_profile.html.haml | 14 ++++++++++++++ .../layouts/listnav/_configured_system.html.haml | 14 ++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 app/views/layouts/listnav/_configuration_manager.html.haml create mode 100644 app/views/layouts/listnav/_configuration_profile.html.haml create mode 100644 app/views/layouts/listnav/_configured_system.html.haml diff --git a/app/views/layouts/listnav/_configuration_manager.html.haml b/app/views/layouts/listnav/_configuration_manager.html.haml new file mode 100644 index 00000000000..a3f84467f28 --- /dev/null +++ b/app/views/layouts/listnav/_configuration_manager.html.haml @@ -0,0 +1,14 @@ +- if @record.try(:name) + #accordion.panel-group + = miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do + = render :partial => 'shared/quadicon', :locals => {:record => @record} + + = miq_accordion_panel(_("Properties"), false, "stack_prop") do + %ul.nav.nav-pills.nav-stacked + %li + = link_to_with_icon(_('Summary'), + {:action => 'show', :id => @record, :display => 'main'}, + :title => _("Show Summary")) + + = miq_accordion_panel(_("Relationships"), false, "stack_rel") do + %ul.nav.nav-pills.nav-stacked diff --git a/app/views/layouts/listnav/_configuration_profile.html.haml b/app/views/layouts/listnav/_configuration_profile.html.haml new file mode 100644 index 00000000000..a3f84467f28 --- /dev/null +++ b/app/views/layouts/listnav/_configuration_profile.html.haml @@ -0,0 +1,14 @@ +- if @record.try(:name) + #accordion.panel-group + = miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do + = render :partial => 'shared/quadicon', :locals => {:record => @record} + + = miq_accordion_panel(_("Properties"), false, "stack_prop") do + %ul.nav.nav-pills.nav-stacked + %li + = link_to_with_icon(_('Summary'), + {:action => 'show', :id => @record, :display => 'main'}, + :title => _("Show Summary")) + + = miq_accordion_panel(_("Relationships"), false, "stack_rel") do + %ul.nav.nav-pills.nav-stacked diff --git a/app/views/layouts/listnav/_configured_system.html.haml b/app/views/layouts/listnav/_configured_system.html.haml new file mode 100644 index 00000000000..a3f84467f28 --- /dev/null +++ b/app/views/layouts/listnav/_configured_system.html.haml @@ -0,0 +1,14 @@ +- if @record.try(:name) + #accordion.panel-group + = miq_accordion_panel(truncate(@record.name, :length => truncate_length), true, "icon") do + = render :partial => 'shared/quadicon', :locals => {:record => @record} + + = miq_accordion_panel(_("Properties"), false, "stack_prop") do + %ul.nav.nav-pills.nav-stacked + %li + = link_to_with_icon(_('Summary'), + {:action => 'show', :id => @record, :display => 'main'}, + :title => _("Show Summary")) + + = miq_accordion_panel(_("Relationships"), false, "stack_rel") do + %ul.nav.nav-pills.nav-stacked From c0aacb3ee3ba6ef518253c6073f5681b426dd7a4 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 16 Mar 2020 12:51:02 -0400 Subject: [PATCH 04/33] Added/fixed textual summary helpers --- .../textual_summary.rb | 138 +++--------------- app/helpers/configuration_profile_helper.rb | 3 + .../textual_summary.rb | 84 +++++++++++ .../configuration_manager/show.html.haml | 9 +- 4 files changed, 114 insertions(+), 120 deletions(-) create mode 100644 app/helpers/configuration_profile_helper.rb create mode 100644 app/helpers/configuration_profile_helper/textual_summary.rb diff --git a/app/helpers/configuration_manager_helper/textual_summary.rb b/app/helpers/configuration_manager_helper/textual_summary.rb index e499a46b78e..ced56be2b08 100644 --- a/app/helpers/configuration_manager_helper/textual_summary.rb +++ b/app/helpers/configuration_manager_helper/textual_summary.rb @@ -1,47 +1,11 @@ module ConfigurationManagerHelper::TextualSummary include TextualMixins::TextualRefreshStatus - include TextualMixins::TextualCustomButtonEvents include TextualMixins::TextualZone - include TextualMixins::EmsCommon - # - # Groups - # def textual_group_properties - TextualGroup.new( - _("Properties"), - %i[description hostname ipaddress type port guid region keystone_v3_domain_id] - ) + %i[description hostname ipaddress type port guid region] end - def textual_group_relationships - TextualGroup.new( - _("Relationships"), - %i[ - ems_infra network_manager availability_zones host_aggregates cloud_tenants flavors - security_groups instances images cloud_volumes orchestration_stacks storage_managers - custom_button_events tenant - ] - ) - end - - def textual_group_status - TextualGroup.new(_("Status"), textual_authentications(@record.authentication_for_summary) + %i[refresh_status refresh_date]) - end - - def textual_group_smart_management - TextualTags.new(_("Smart Management"), %i[zone tags]) - end - - def textual_group_topology - items = %w[topology] - i = items.collect { |m| send("textual_#{m}") }.flatten.compact - TextualGroup.new(_("Overview"), i) - end - - # - # Items - # def textual_description return nil if @record.try(:description).blank? {:label => _("Description"), :value => @record.description} @@ -53,12 +17,6 @@ def textual_region {:label => label_val, :value => @record.provider_region} end - def textual_keystone_v3_domain_id - return nil if !@record.respond_to?(:keystone_v3_domain_id) || @record.keystone_v3_domain_id.nil? - label_val = _("Keystone V3 Domain ID") - {:label => label_val, :value => @record.keystone_v3_domain_id} - end - def textual_hostname @record.hostname end @@ -80,94 +38,36 @@ def textual_guid {:label => _("Management Engine GUID"), :value => @record.guid} end - def textual_instances - num = @record.number_of(:vms) - h = {:label => _('Instances'), :icon => "pficon pficon-virtual-machine", :value => num} - if num.positive? && role_allows?(:feature => "vm_show_list") - h[:link] = ems_cloud_path(@record.id, :display => 'instances') - h[:title] = _("Show all Instances") - end - h - end - - def textual_images - num = @record.number_of(:miq_templates) - h = {:label => _('Images'), :icon => "pficon pficon-virtual-machine", :value => num} - if num.positive? && role_allows?(:feature => "miq_template_show_list") - h[:link] = ems_cloud_path(@record.id, :display => 'images') - h[:title] = _("Show all Images") - end - h + def textual_group_relationships + %i[configuration_profiles configured_systems] end - def textual_cloud_volumes - num = @record.number_of(:cloud_volumes) - h = {:label => _('Cloud Volumes'), :icon => "pficon pficon-volume", :value => num} - if num.positive? && role_allows?(:feature => "cloud_volume_show_list") - h[:link] = ems_cloud_path(@record.id, :display => 'cloud_volumes') - h[:title] = _("Show Cloud Volumes") + def textual_configuration_profiles + num = @record.number_of(:configuration_profiles) + h = {:label => _('Configuration Profiles'), :icon => "pficon pficon-configuration_profile", :value => num} + if num.positive? && role_allows?(:feature => "configuration_profile_show_list") + h[:link] = url_for_only_path(:action => 'show', :id => @record, :display => 'configuration_profiles') + h[:title] = _("Show all Configuration Profiles") end h end - def textual_ems_infra - textual_link(@record.try(:provider).try(:infra_ems)) - end - - def textual_network_manager - textual_link(@record.ext_management_system.try(:network_manager)) - end - - def textual_storage_managers - num = @record.try(:storage_managers) ? @record.number_of(:storage_managers) : 0 - h = {:label => _('Storage Managers'), :icon => "fa fa-database", :value => num} - if num.positive? && role_allows?(:feature => "ems_storage_show_list") - h[:title] = _("Show all Storage Managers") - h[:link] = ems_cloud_path(@record.id, :display => 'storage_managers') + def textual_configured_systems + num = @record.number_of(:configured_systems) + h = {:label => _('Configured Systems'), :icon => "pficon pficon-configured_system", :value => num} + if num.positive? && role_allows?(:feature => "configured_system_show_list") + h[:link] = url_for_only_path(:action => 'show', :id => @record, :display => 'configured_systems') + h[:title] = _("Show all Configured Systems") end h end - def textual_availability_zones - textual_link(@record.availability_zones, :label => _('Availability Zones')) - end - - def textual_host_aggregates - textual_link(@record.host_aggregates, :label => _('Host Aggregates')) - end - - def textual_cloud_tenants - textual_link(@record.cloud_tenants, :label => _('Cloud Tenants')) - end - - def textual_orchestration_stacks - textual_link(@record.orchestration_stacks, :label => _('Orchestration Stacks')) - end - - def textual_flavors - textual_link(@record.flavors, :label => _('Flavors')) - end - - def textual_security_groups - num = @record.number_of(:security_groups) - h = {:label => _('Security Groups'), :icon => "pficon pficon-cloud-security", :value => num} - if num.positive? && role_allows?(:feature => "security_group_show_list") - h[:link] = ems_cloud_path(@record.id, :display => 'security_groups') - h[:title] = _("Show all Security Groups") - end - h + def textual_group_status + textual_authentications(@record.authentication_for_summary) + %i[refresh_status refresh_date] end - def textual_topology - {:label => _('Topology'), - :icon => "pficon pficon-topology", - :link => url_for_only_path(:controller => 'cloud_topology', :action => 'show', :id => @record.id), - :title => _("Show topology")} + def textual_group_tags + %i[tags] end - def textual_tenant - return nil unless User.current_user.super_admin_user? - - {:label => _('Tenant'), :value => @record.tenant.name} - end end diff --git a/app/helpers/configuration_profile_helper.rb b/app/helpers/configuration_profile_helper.rb new file mode 100644 index 00000000000..c8111d1757d --- /dev/null +++ b/app/helpers/configuration_profile_helper.rb @@ -0,0 +1,3 @@ +module ConfigurationProfileHelper + include_concern 'TextualSummary' +end diff --git a/app/helpers/configuration_profile_helper/textual_summary.rb b/app/helpers/configuration_profile_helper/textual_summary.rb new file mode 100644 index 00000000000..e0f72f6d577 --- /dev/null +++ b/app/helpers/configuration_profile_helper/textual_summary.rb @@ -0,0 +1,84 @@ +module ConfigurationProfileHelper::TextualSummary + def textual_configuration_profile_group_properties + %i[configuration_profile_name + configuration_profile_region + configuration_profile_zone] + end + + def textual_configuration_profile_name + {:label => _("Name"), :value => @record.name} + end + + def textual_configuration_profile_region + {:label => _("Region"), :value => @record.region_description} + end + + def textual_configuration_profile_zone + {:label => _("Zone"), :value => @record.my_zone} + end + + def textual_configuration_profile_group_environment + %i[configuration_profile_environment + configuration_profile_domain + configuration_profile_puppet_realm] + end + + def textual_configuration_profile_environment + {:label => _("Environment"), :value => @record.configuration_environment_name} + end + + def textual_configuration_profile_domain + {:label => _("Domain"), :value => @record.configuration_domain_name} + end + + def textual_configuration_profile_puppet_realm + {:label => _("Puppet Realm"), :value => @record.configuration_realm_name} + end + + def textual_configuration_profile_group_os + %i[configuration_profile_compute_profile + configuration_profile_architecture + configuration_profile_os + configuration_profile_medium + configuration_profile_partition_table] + end + + def textual_configuration_profile_compute_profile + {:label => _("Compute Profile"), :value => @record.configuration_compute_profile_name} + end + + def textual_configuration_profile_architecture + {:label => _("Architecture"), :value => @record.configuration_architecture_name} + end + + def textual_configuration_profile_os + {:label => _("OS"), :value => @record.operating_system_flavor_name} + end + + def textual_configuration_profile_medium + {:label => _("Medium"), :value => @record.customization_script_medium_name} + end + + def textual_configuration_profile_partition_table + {:label => _("Partition Table"), :value => @record.customization_script_ptable_name} + end + + def textual_configuration_profile_group_tenancy + %i[configuration_profile_configuration_locations + configuration_profile_configuration_organizations] + end + + def textual_configuration_profile_configuration_locations + { + :label => _("Configuration Location"), + :value => @record.configuration_locations.collect(&:name).join(", ") + } + end + + def textual_configuration_profile_configuration_organizations + { + :label => _("Configuration Organization"), + :value => @record.configuration_organizations.collect(&:name).join(", ") + } + end +end diff --git a/app/views/configuration_manager/show.html.haml b/app/views/configuration_manager/show.html.haml index 58d5f016aec..55923626f48 100644 --- a/app/views/configuration_manager/show.html.haml +++ b/app/views/configuration_manager/show.html.haml @@ -1,4 +1,11 @@ - if %w(configuration_profiles).include?(@display) = render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"} - elsif @showtype == "main" - = render :partial => "layouts/textual_groups_generic" + = render :partial => "layouts/flash_msg" + .row + .col-md-12.col-lg-6 + = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_group_properties), @record) + = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Relationships'), textual_group_relationships), @record) + .col-md-12.col-lg-6 + = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Status'), textual_group_status), @record) + = react 'GenericGroupWrapper', expand_generic_group(TextualTags.new(_('Smart Management'), textual_group_tags), @record) From ba12336ab96e5ebcecb17daf4f476cdfb6fe8749 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 16 Mar 2020 13:47:42 -0400 Subject: [PATCH 05/33] Fixed relationship links on textual summary screens --- .../configuration_manager_controller.rb | 9 +++---- .../configuration_profile_controller.rb | 4 +++ .../textual_summary.rb | 25 +++++++++++++++++++ .../configuration_manager/show.html.haml | 2 +- .../configuration_profile/show.html.haml | 3 ++- 5 files changed, 36 insertions(+), 7 deletions(-) diff --git a/app/controllers/configuration_manager_controller.rb b/app/controllers/configuration_manager_controller.rb index 494987f74be..6dc8312314f 100644 --- a/app/controllers/configuration_manager_controller.rb +++ b/app/controllers/configuration_manager_controller.rb @@ -17,12 +17,11 @@ def self.table_name @table_name ||= "configuration_manager" end - private + def self.display_methods + %w[configuration_profiles configured_systems] + end - # def textual_group_list - # [%i[properties], %i[relationships smart_management]] - # end - # helper_method :textual_group_list + private def breadcrumbs_options { diff --git a/app/controllers/configuration_profile_controller.rb b/app/controllers/configuration_profile_controller.rb index 5f98c8745d0..a0a3eb4733d 100644 --- a/app/controllers/configuration_profile_controller.rb +++ b/app/controllers/configuration_profile_controller.rb @@ -17,6 +17,10 @@ def self.table_name @table_name ||= "configuration_profile" end + def self.display_methods + %w[configured_systems] + end + private def breadcrumbs_options diff --git a/app/helpers/configuration_profile_helper/textual_summary.rb b/app/helpers/configuration_profile_helper/textual_summary.rb index e0f72f6d577..11aca60f026 100644 --- a/app/helpers/configuration_profile_helper/textual_summary.rb +++ b/app/helpers/configuration_profile_helper/textual_summary.rb @@ -35,6 +35,31 @@ def textual_configuration_profile_puppet_realm {:label => _("Puppet Realm"), :value => @record.configuration_realm_name} end + def textual_configuration_profile_group_relationships + %i[configuration_manager + configured_systems] + end + + def textual_configuration_manager + configuration_manager = @record.configuration_manager + h = {:label => "Configuration Manager", :icon => "pficon pficon-configuration_manager", :value => (configuration_manager.nil? ? _("None") : configuration_manager.name)} + if configuration_manager && role_allows?(:feature => "configuration_manager_show") + h[:title] = _("Show this Configuration Profile's Configuration Manager") + h[:link] = url_for_only_path(:controller => 'configuration_manager', :action => 'show', :id => configuration_manager) + end + h + end + + def textual_configured_systems + num = @record.number_of(:configured_systems) + h = {:label => _('Configured Systems'), :icon => "pficon pficon-configured_system", :value => num} + if num.positive? && role_allows?(:feature => "configured_system_show_list") + h[:link] = url_for_only_path(:action => 'show', :id => @record, :display => 'configured_systems') + h[:title] = _("Show all Configured Systems") + end + h + end + def textual_configuration_profile_group_os %i[configuration_profile_compute_profile configuration_profile_architecture diff --git a/app/views/configuration_manager/show.html.haml b/app/views/configuration_manager/show.html.haml index 55923626f48..a9082f37111 100644 --- a/app/views/configuration_manager/show.html.haml +++ b/app/views/configuration_manager/show.html.haml @@ -1,4 +1,4 @@ -- if %w(configuration_profiles).include?(@display) +- if %w(configuration_profiles configured_systems).include?(@display) = render :partial => "layouts/gtl", :locals => {:action_url => "show/#{@record.id}"} - elsif @showtype == "main" = render :partial => "layouts/flash_msg" diff --git a/app/views/configuration_profile/show.html.haml b/app/views/configuration_profile/show.html.haml index 451471b4bef..60afec4d1ec 100644 --- a/app/views/configuration_profile/show.html.haml +++ b/app/views/configuration_profile/show.html.haml @@ -5,8 +5,9 @@ .row .col-md-12.col-lg-6 = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_configuration_profile_group_properties), @record) + = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Relationships'), textual_configuration_profile_group_relationships), @record) = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Environment'), textual_configuration_profile_group_environment), @record) - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Operating System'), textual_configuration_profile_group_os), @record) .col-md-12.col-lg-6 + = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Operating System'), textual_configuration_profile_group_os), @record) = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Tenancy'), textual_configuration_profile_group_tenancy), @record) From e9f011fed5da921c5b30108dd7888a3027a4b771 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 16 Mar 2020 14:37:51 -0400 Subject: [PATCH 06/33] load toolbars for Configuration Manager(s) and Configured System(s) --- .../toolbar/configuration_manager_center.rb | 35 +++++++++ .../toolbar/configuration_managers_center.rb | 74 +++++++++++++++++++ .../toolbar/configured_system_center.rb | 17 +++++ .../application_helper/toolbar_chooser.rb | 2 + 4 files changed, 128 insertions(+) create mode 100644 app/helpers/application_helper/toolbar/configuration_manager_center.rb create mode 100644 app/helpers/application_helper/toolbar/configuration_managers_center.rb create mode 100644 app/helpers/application_helper/toolbar/configured_system_center.rb diff --git a/app/helpers/application_helper/toolbar/configuration_manager_center.rb b/app/helpers/application_helper/toolbar/configuration_manager_center.rb new file mode 100644 index 00000000000..c6de79dcf51 --- /dev/null +++ b/app/helpers/application_helper/toolbar/configuration_manager_center.rb @@ -0,0 +1,35 @@ +class ApplicationHelper::Toolbar::ConfigurationManagerCenter < ApplicationHelper::Toolbar::Basic + button_group('provider_vmdb', [ + select( + :provider_vmdb_choice, + nil, + t = N_('Configuration'), + t, + :enabled => true, + :items => [ + button( + :provider_foreman_refresh_provider, + 'fa fa-refresh fa-lg', + N_('Refresh relationships for all items related to this Provider'), + N_('Refresh Relationships and Power states'), + :url => "refresh", + :confirm => N_("Refresh relationships for all items related to this Provider?"), + :klass => ApplicationHelper::Button::EmsRefresh), + separator, + button( + :provider_foreman_edit_provider, + 'pficon pficon-edit fa-lg', + t = N_('Edit this Provider'), + t, + :url => "edit"), + button( + :provider_foreman_delete_provider, + 'pficon pficon-delete fa-lg', + t = N_('Remove this Provider from Inventory'), + t, + :url => "delete", + :confirm => N_("Warning: The selected Provider and ALL of their components will be permanently removed!")), + ] + ), + ]) +end diff --git a/app/helpers/application_helper/toolbar/configuration_managers_center.rb b/app/helpers/application_helper/toolbar/configuration_managers_center.rb new file mode 100644 index 00000000000..53d9dc16e78 --- /dev/null +++ b/app/helpers/application_helper/toolbar/configuration_managers_center.rb @@ -0,0 +1,74 @@ +class ApplicationHelper::Toolbar::ConfigurationManagersCenter < ApplicationHelper::Toolbar::Basic + button_group('provider_vmdb', [ + select( + :provider_vmdb_choice, + nil, + t = N_('Configuration'), + t, + :enabled => true, + :items => [ + button( + :provider_foreman_refresh_provider, + 'fa fa-refresh fa-lg', + N_('Refresh relationships for all items related to the selected items'), + N_('Refresh Relationships and Power states'), + :url => "refresh", + :url_parms => "main_div", + :send_checked => true, + :confirm => N_("Refresh relationships for all items related to the selected items?"), + :enabled => false, + :onwhen => "1+"), + separator, + button( + :provider_foreman_add_provider, + 'pficon pficon-add-circle-o fa-lg', + t = N_('Add a new Provider'), + t, + :enabled => true, + :url => "new"), + button( + :provider_foreman_edit_provider, + 'pficon pficon-edit fa-lg', + N_('Select a single item to edit'), + N_('Edit Selected item'), + :url => "edit", + :url_parms => "main_div", + :send_checked => true, + :enabled => false, + :onwhen => "1"), + button( + :provider_foreman_delete_provider, + 'pficon pficon-delete fa-lg', + t = N_('Remove selected items from Inventory'), + t, + :url => "delete", + :url_parms => "main_div", + :send_checked => true, + :confirm => N_("Warning: The selected items and ALL of their components will be permanently removed!"), + :enabled => false, + :onwhen => "1+"), + separator, + ] + ), + ]) + button_group('configuration_manager_policy', [ + select( + :configuration_manager_policy_choice, + nil, + t = N_('Policy'), + t, + :enabled => false, + :onwhen => "1+", + :items => [ + button( + :configuration_manager_provider_tag, + 'pficon pficon-edit fa-lg', + N_('Edit Tags for this Foreman Provider'), + N_('Edit Tags'), + :url_parms => "main_div", + :send_checked => true, + :onwhen => "1+") + ] + ) + ]) +end diff --git a/app/helpers/application_helper/toolbar/configured_system_center.rb b/app/helpers/application_helper/toolbar/configured_system_center.rb new file mode 100644 index 00000000000..7e077d1876a --- /dev/null +++ b/app/helpers/application_helper/toolbar/configured_system_center.rb @@ -0,0 +1,17 @@ +class ApplicationHelper::Toolbar::ConfiguredSystemCenter < ApplicationHelper::Toolbar::Basic + button_group('configured_system_policy', [ + select( + :configured_system_policy_choice, + nil, + t = N_('Policy'), + t, + :items => [ + button( + :configured_system_tag, + 'pficon pficon-edit fa-lg', + N_('Edit Tags for this Configured System'), + N_('Edit Tags')), + ] + ), + ]) +end diff --git a/app/helpers/application_helper/toolbar_chooser.rb b/app/helpers/application_helper/toolbar_chooser.rb index cbb291f7163..8e0d463a745 100644 --- a/app/helpers/application_helper/toolbar_chooser.rb +++ b/app/helpers/application_helper/toolbar_chooser.rb @@ -455,6 +455,8 @@ def center_toolbar_filename_classic cloud_volume_snapshot cloud_volume_type configuration_job + configuration_manager + configured_system container container_group container_node From f432d05a73b372c3aa69fac7ad2957f3e251c7b8 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Fri, 20 Mar 2020 17:59:52 -0400 Subject: [PATCH 07/33] Getting toolbar buttons working. --- .../application_controller/ci_processing.rb | 2 +- .../application_controller/tags.rb | 1 + .../automation_manager_controller.rb | 1 + .../configuration_manager_controller.rb | 134 ++++++ .../configured_system_controller.rb | 31 ++ .../automation_manager_controller_mixin.rb | 422 ++++++++++++++++++ .../provider_foreman_controller.rb | 1 + .../toolbar/configuration_manager_center.rb | 30 +- .../toolbar/configuration_managers_center.rb | 20 +- .../_shared_form.html.haml | 6 + .../configuration_manager/edit.html.haml | 1 + app/views/configuration_manager/new.html.haml | 2 + config/routes.rb | 3 + 13 files changed, 632 insertions(+), 22 deletions(-) create mode 100644 app/controllers/mixins/automation_manager_controller_mixin.rb create mode 100644 app/views/configuration_manager/edit.html.haml create mode 100644 app/views/configuration_manager/new.html.haml diff --git a/app/controllers/application_controller/ci_processing.rb b/app/controllers/application_controller/ci_processing.rb index b16291c62cd..b64b8809f40 100644 --- a/app/controllers/application_controller/ci_processing.rb +++ b/app/controllers/application_controller/ci_processing.rb @@ -306,7 +306,7 @@ def manager_button_operation(method, display_name) def process_managers(managers, task) controller_class = request.parameters[:controller] provider_class = case controller_class - when 'provider_foreman' then ManageIQ::Providers::ConfigurationManager + when 'configuration_manager', 'provider_foreman' then ManageIQ::Providers::ConfigurationManager when 'automation_manager' then ManageIQ::Providers::AutomationManager end diff --git a/app/controllers/application_controller/tags.rb b/app/controllers/application_controller/tags.rb index ee32d7f9118..32e9ba79574 100644 --- a/app/controllers/application_controller/tags.rb +++ b/app/controllers/application_controller/tags.rb @@ -102,6 +102,7 @@ def tagging_edit_tags_cancel replace_right_cell else session[:flash_msgs] = @flash_array.dup # Put msg in session for next transaction to display + p "XCCCCCCCCCCCCCCCCCCCCCC #{previous_breadcrumb_url.inspect}" javascript_redirect(previous_breadcrumb_url) end end diff --git a/app/controllers/automation_manager_controller.rb b/app/controllers/automation_manager_controller.rb index 1ede45457be..48b8a597173 100644 --- a/app/controllers/automation_manager_controller.rb +++ b/app/controllers/automation_manager_controller.rb @@ -7,6 +7,7 @@ class AutomationManagerController < ApplicationController include Mixins::GenericSessionMixin include Mixins::ManagerControllerMixin + include Mixins::AutomationManagerControllerMixin include Mixins::ExplorerPresenterMixin include Mixins::EmsCommon::Core include Mixins::EmsCommon::PauseResume diff --git a/app/controllers/configuration_manager_controller.rb b/app/controllers/configuration_manager_controller.rb index 6dc8312314f..9beeab7a3fa 100644 --- a/app/controllers/configuration_manager_controller.rb +++ b/app/controllers/configuration_manager_controller.rb @@ -3,6 +3,9 @@ class ConfigurationManagerController < ApplicationController include Mixins::GenericShowMixin include Mixins::GenericSessionMixin include Mixins::BreadcrumbsMixin + include Mixins::GenericFormMixin + include Mixins::ManagerControllerMixin + include Mixins::FindRecord before_action :check_privileges before_action :get_session_data @@ -21,8 +24,139 @@ def self.display_methods %w[configuration_profiles configured_systems] end + def button + @edit = session[:edit] # Restore @edit for adv search box + params[:display] = @display if %w[configuration_profiles configured_systems].include?(@display) # Were we displaying nested list + + # Handle Toolbar Policy Tag Button + @refresh_div = "main_div" # Default div for button.rjs to refresh + model = self.class.model + tag(model) if params[:pressed] == "#{params[:controller]}_tag" + + if [ConfiguredSystem].include?(model) + assign_policies(model) if params[:pressed] == "#{model.name.underscore}_protect" + check_compliance(model) if params[:pressed] == "#{model.name.underscore}_check_compliance" + end + + case params[:pressed] + when 'configuration_manager_edit_provider' + edit + when 'configuration_manager_add_provider' + new + when "configuration_manager_refresh_provider" + refresh + when "configuration_manager_delete_provider" + delete + end + + return if ["#{params[:controller]}_tag"].include?(params[:pressed]) && @flash_array.nil? # Tag screen showing + + if single_delete_test + single_delete_redirect + elsif (params[:pressed].ends_with?("_edit_provider") || params[:pressed] == "configuration_manager_add_provider") && @flash_array.nil? + if @flash_array + show_list + replace_gtl_main_div + else + javascript_redirect(:action => @refresh_partial, :id => @redirect_id) + end + elsif @refresh_div == "main_div" && @lastaction == "show_list" + replace_gtl_main_div + else + render_flash unless performed? + end + end + + def edit + @server_zones = Zone.visible.in_my_region.order('lower(description)').pluck(:description, :name) + case params[:button] + when "cancel" + cancel_provider + when "save" + add_provider + save_provider + else + assert_privileges("configuration_manager_edit_provider") + manager_id = params[:miq_grid_checks] || params[:id] || find_checked_items[0] + @provider_manager = find_record(concrete_model, manager_id) + @providerdisplay_type = _("Configuration Manager") + @sb[:action] = params[:action] + @in_a_form = true + @redirect_controller = "configuration_manager" + @redirect_id = @provider_manager.id + @refresh_partial = "edit" + end + end + + def form_fields + assert_privileges("configuration_manager_edit_provider") + # set value of read only zone text box, when there is only single zone + if params[:id] == "new" + return render(:json => {:zone => Zone.visible.in_my_region.size >= 1 ? Zone.visible.in_my_region.first.name : nil}) + end + + manager = find_record(concrete_model, params[:id]) + provider = manager.provider + + render :json => {:name => provider.name, + :zone => provider.zone.name, + :zone_hidden => !manager.enabled?, + :url => provider.url, + :verify_ssl => provider.verify_ssl, + :default_userid => provider.authentications.first.userid, + :default_auth_status => provider.authentication_status_ok?} + end + + def new + assert_privileges("configuration_manager_add_provider") + @provider_manager = concrete_model.new + @server_zones = Zone.visible.in_my_region.order('lower(description)').pluck(:description, :name) + @sb[:action] = params[:action] + @in_a_form = true + @redirect_controller = "configuration_manager" + @refresh_partial = "new" + end + private + def refresh + assert_privileges("configuration_manager_refresh_provider") + manager_button_operation('refresh_ems', _('Refresh')) + end + + def concrete_model + ManageIQ::Providers::ConfigurationManager + end + + def provider_class + ManageIQ::Providers::Foreman::Provider + end + + def delete + assert_privileges("configuration_manager_delete_provider") + checked_items = find_checked_items + checked_items.push(params[:id]) if checked_items.empty? && params[:id] + providers = Rbac.filtered(concrete_model.where(:id => checked_items).includes(:provider).collect(&:provider)) + if providers.empty? + add_flash(_("No Providers were selected for deletion"), :error) + else + providers.each do |provider| + AuditEvent.success( + :event => "provider_record_delete_initiated", + :message => "[#{provider.name}] Record delete initiated", + :target_id => provider.id, + :target_class => provider.type, + :userid => session[:userid] + ) + provider.destroy_queue + end + + add_flash(n_("Delete initiated for %{count} Provider", + "Delete initiated for %{count} Providers", + providers.length) % {:count => providers.length}) + end + end + def breadcrumbs_options { :breadcrumbs => [ diff --git a/app/controllers/configured_system_controller.rb b/app/controllers/configured_system_controller.rb index e3b50c3ddac..5721dc4efa9 100644 --- a/app/controllers/configured_system_controller.rb +++ b/app/controllers/configured_system_controller.rb @@ -17,6 +17,37 @@ def self.table_name @table_name ||= "configured_system" end + def button + @edit = session[:edit] # Restore @edit for adv search box + params[:display] = @display if %w[configuration_profiles configured_systems].include?(@display) # Were we displaying nested list + + # Handle Toolbar Policy Tag Button + @refresh_div = "main_div" # Default div for button.rjs to refresh + model = self.class.model + tag(model) if params[:pressed] == "#{params[:controller]}_tag" + if [ConfiguredSystem].include?(model) + assign_policies(model) if params[:pressed] == "#{model.name.underscore}_protect" + check_compliance(model) if params[:pressed] == "#{model.name.underscore}_check_compliance" + end + if params[:pressed] == 'service_dialog_from_ct' + create_service_dialog + return + end + + return if ["#{params[:controller]}_tag"].include?(params[:pressed]) && @flash_array.nil? # Tag screen showing + + # Handle scan + if params[:pressed] == "container_image_scan" + scan_images + + if @lastaction == "show" + javascript_flash + else + replace_main_div(:partial => "layouts/gtl") + end + end + end + private def textual_group_list diff --git a/app/controllers/mixins/automation_manager_controller_mixin.rb b/app/controllers/mixins/automation_manager_controller_mixin.rb new file mode 100644 index 00000000000..37a75d8d3b8 --- /dev/null +++ b/app/controllers/mixins/automation_manager_controller_mixin.rb @@ -0,0 +1,422 @@ +module Mixins + module AutomationManagerControllerMixin + extend ActiveSupport::Concern + + included do + include Mixins::GenericFormMixin + include Mixins::FindRecord + end + + def index + redirect_to(:action => 'explorer') + end + + def show_list + flash_to_session + redirect_to(:action => 'explorer') + end + + def explorer + @explorer = true + @lastaction = "explorer" + + # if AJAX request, replace right cell, and return + if request.xml_http_request? + replace_right_cell + return + end + + if params[:accordion] + self.x_active_tree = "#{params[:accordion]}_tree" + self.x_active_accord = params[:accordion] + end + if params[:button] + @miq_after_onload = "miqAjax('/#{controller_name}/x_button?pressed=#{params[:button]}');" + end + + build_accordions_and_trees + + params.instance_variable_get(:@parameters).merge!(session[:exp_parms]) if session[:exp_parms] # Grab any explorer parm overrides + session.delete(:exp_parms) + @in_a_form = false + + render :layout => "application" + end + + def identify_record(id, klass = self.class.model) + type, _id = parse_nodetype_and_id(x_node) + klass = TreeBuilder.get_model_for_prefix(type).constantize if type + record = super(id, klass) + record + end + + def tree_autoload + @view ||= session[:view] + super + end + + def change_tab + @sb[:active_tab] = params[:tab_id] + replace_right_cell + end + + def cs_edit_get_form_vars + copy_params_if_present(@edit[:new], params, %i[name description dialog_name]) + @edit[:new][:draft] = params[:draft] == "true" if params[:draft] + end + + def cs_form_field_changed + id = params[:id] + return unless load_edit("cs_edit__#{id}", "replace_cell__explorer") + + cs_edit_get_form_vars + render :update do |page| + page << javascript_prologue + page << javascript_hide("buttons_off") + page << javascript_show("buttons_on") + end + end + + def show(id = nil) + @flash_array = [] if params[:display] + @sb[:action] = nil + + @display = params[:display] || "main" + @lastaction = "show" + @record = if managed_group_record? + find_record(managed_group_kls, id || params[:id]) + else + find_record(ConfiguredSystem, id || params[:id]) + end + return if record_no_longer_exists?(@record) + + @explorer = true if request.xml_http_request? # Ajax request means in explorer + + @gtl_url = "/show" + end + + def tree_select + @lastaction = "explorer" + @flash_array = nil + self.x_active_tree = params[:tree] if params[:tree] + self.x_node = params[:id] + load_or_clear_adv_search + apply_node_search_text if x_active_tree == "#{manager_prefix}_providers_tree".to_sym + + if action_name == "reload" + replace_right_cell(:replace_trees => [x_active_accord]) + else + @sb[:active_tab] = if active_tab_configured_systems? + 'configured_systems' + else + 'summary' + end + replace_right_cell unless @edit && @edit[:adv_search_applied] && MiqExpression.quick_search?(@edit[:adv_search_applied][:exp]) + end + end + + def accordion_select + @lastaction = "explorer" + + @sb["#{controller_name.underscore}_search_text".to_sym] ||= {} + @sb["#{controller_name.underscore}_search_text".to_sym]["#{x_active_accord}_search_text"] = @search_text + + self.x_active_accord = params[:id].sub(/_accord$/, '') + self.x_active_tree = "#{x_active_accord}_tree" + + @search_text = @sb["#{controller_name.underscore}_search_text".to_sym]["#{x_active_accord}_search_text"] + + load_or_clear_adv_search + replace_right_cell(:replace_trees => [x_active_accord]) + end + + def new + assert_privileges("#{privilege_prefix}_add_provider") + @provider_manager = concrete_model.new + @server_zones = Zone.visible.in_my_region.order('lower(description)').pluck(:description, :name) + @sb[:action] = params[:action] + render_form + end + + def edit + @server_zones = Zone.visible.in_my_region.order('lower(description)').pluck(:description, :name) + case params[:button] + when "cancel" + cancel_provider + when "save" + add_provider + save_provider + else + assert_privileges("#{privilege_prefix}_edit_provider") + manager_id = params[:miq_grid_checks] || params[:id] || find_checked_items[0] + @provider_manager = find_record(concrete_model, manager_id) + @providerdisplay_type = self.class.model_to_name(@provider_manager.type) + @sb[:action] = params[:action] + render_form + end + end + + def delete + assert_privileges("#{privilege_prefix}_delete_provider") + checked_items = find_checked_items + checked_items.push(params[:id]) if checked_items.empty? && params[:id] + providers = Rbac.filtered(concrete_model.where(:id => checked_items).includes(:provider).collect(&:provider)) + if providers.empty? + add_flash(_("No Providers were selected for deletion"), :error) + else + providers.each do |provider| + AuditEvent.success( + :event => "provider_record_delete_initiated", + :message => "[#{provider.name}] Record delete initiated", + :target_id => provider.id, + :target_class => provider.type, + :userid => session[:userid] + ) + provider.destroy_queue + end + + add_flash(n_("Delete initiated for %{count} Provider", + "Delete initiated for %{count} Providers", + providers.length) % {:count => providers.length}) + end + replace_right_cell + end + + def refresh + assert_privileges("#{privilege_prefix}_refresh_provider") + @explorer = true + manager_button_operation('refresh_ems', _('Refresh')) + replace_right_cell + end + + private + + def tag_action + (params[:action] == 'x_button' && %w[automation_manager_provider_tag configuration_manager_provider_tag].include?(params[:pressed])) || (params[:action] == 'tagging' && params[:pressed] == 'reset') + end + + def replace_right_cell(options = {}) + if tag_action + render_tagging_form + return + end + replace_trees = options[:replace_trees] + return if @in_a_form + + @explorer = true + @in_a_form = false + @sb[:action] = nil + trees = rebuild_trees(replace_trees) + + record_showing = leaf_record + presenter = rendering_objects + get_tagdata(@record) if @record.try(:taggings) + update_partials(record_showing, presenter) # replace_search_box is called whithin update_partials + handle_bottom_cell(presenter) + reload_trees_by_presenter(presenter, trees) + rebuild_toolbars(record_showing, presenter) + presenter[:provider_paused] = provider_paused?(@record) + presenter[:right_cell_text] = @right_cell_text + presenter[:osf_node] = x_node # Open, select, and focus on this node + + render :json => presenter.for_render + end + + def display_node(id, _mode) + if @record.nil? + self.x_node = "root" + get_node_info("root") + else + show_record(id) + model_string = ui_lookup(:model => @record.class.to_s) + @right_cell_text = _("%{model} \"%{name}\"") % {:name => @record.name, :model => model_string} + end + end + + def sync_form_to_instance + @provider.name = params[:name] + @provider.url = params[:url] + @provider.verify_ssl = params[:verify_ssl].eql?("on") || params[:verify_ssl].eql?("true") + @provider.zone = Zone.find_by(:name => params[:zone].to_s) if params[:zone] + end + + def provider_list(id, model) + return provider_node(id, model) if id + + options = {:model => model.to_s} + @right_cell_text = _("All %{title} Providers") % {:title => self.class.model_to_name(model)} + process_show_list(options) + end + + def configured_system_list(id, model) + return configured_system_node(id, model) if id + + if x_active_tree == :configuration_manager_cs_filter_tree || x_active_tree == :automation_manager_cs_filter_tree + options = {:model => model.to_s} + @right_cell_text = _("All %{title} Configured Systems") % {:title => self.class.model_to_name(model)} + process_show_list(options) + end + end + + def configured_system_node(id, model) + @record = @configured_system_record = find_record(ConfiguredSystem, id) + display_node(id, model) + end + + def display_adv_searchbox + !(@configured_system_record || @configuration_script_record || @in_a_form || group_summary_tab_selected?) + end + + def miq_search_node + options = {:model => model_from_active_tree(x_active_tree)} + if x_active_tree == :configuration_scripts_tree + options = {:model => "ConfigurationScript", + :gtl_dbname => "automation_manager_configuration_scripts"} + end + process_show_list(options) + @right_cell_text = x_active_tree == :configuration_scripts_tree ? _("All Ansible Tower Job Templates") : _("All Configured Systems") + end + + def render_form + presenter = rendering_objects + @in_a_form = true + @sb[:action] = params[:action] + presenter.update(:main_div, r[:partial => 'form', :locals => {:controller => controller_name}]) + update_title(presenter) + rebuild_toolbars(false, presenter) + handle_bottom_cell(presenter) + presenter.update(:breadcrumbs, r[:partial => 'layouts/breadcrumbs']) + + render :json => presenter.for_render + end + + def render_tagging_form + return if %w[cancel save].include?(params[:button]) + + @in_a_form = true + @right_cell_text = _("Edit Tags") + clear_flash_msg + presenter = rendering_objects + update_tagging_partials(presenter) + update_title(presenter) + rebuild_toolbars(false, presenter) + handle_bottom_cell(presenter) + presenter.update(:breadcrumbs, r[:partial => 'layouts/breadcrumbs']) + + render :json => presenter.for_render + end + + def render_service_dialog_form + @in_a_form = true + clear_flash_msg + presenter = rendering_objects + update_service_dialog_partials(presenter) + rebuild_toolbars(false, presenter) + handle_bottom_cell(presenter, true) + presenter[:right_cell_text] = @right_cell_text + + render :json => presenter.for_render + end + + def update_title(presenter) + @right_cell_text = + case action_name + when "new" then _("Add a new Provider") + when "edit" then _("Edit Provider") + end + presenter[:right_cell_text] = @right_cell_text + end + + def apply_node_search_text + setup_search_text_for_node + previous_nodetype = search_text_type(@sb["#{controller_name.underscore}_search_text".to_sym][:previous_node]) + current_nodetype = search_text_type(@sb["#{controller_name.underscore}_search_text".to_sym][:current_node]) + + @sb["#{controller_name.underscore}_search_text".to_sym]["#{previous_nodetype}_search_text"] = @search_text + @search_text = @sb["#{controller_name.underscore}_search_text".to_sym]["#{current_nodetype}_search_text"] + @sb["#{controller_name.underscore}_search_text".to_sym]["#{x_active_accord}_search_text"] = @search_text + end + + def setup_search_text_for_node + @sb["#{controller_name.underscore}_search_text".to_sym] ||= {} + @sb["#{controller_name.underscore}_search_text".to_sym][:current_node] ||= x_node + @sb["#{controller_name.underscore}_search_text".to_sym][:previous_node] = @sb["#{controller_name.underscore}_search_text".to_sym][:current_node] + @sb["#{controller_name.underscore}_search_text".to_sym][:current_node] = x_node + end + + def replace_search_box(presenter, locals = {}) + super(presenter, locals) + + presenter[:clear_gtl_list_grid] = @gtl_type && @gtl_type != 'list' + end + + def handle_bottom_cell(presenter, hide_form_buttons = false) + # Handle bottom cell + if @pages || @in_a_form + if (@pages && !@in_a_form) || hide_form_buttons + presenter.hide(:form_buttons_div) + elsif @in_a_form + presenter.remove_paging.show(:form_buttons_div) + end + presenter.show(:paging_div) + else + presenter.hide(:paging_div) + end + end + + def rebuild_toolbars(record_showing, presenter) + if group_summary_tab_selected? + center_tb = "blank_view_tb" + record_showing = true + end + + if !@in_a_form && !@sb[:action] + center_tb ||= center_toolbar_filename + c_tb = build_toolbar(center_tb) + v_tb = build_toolbar(record_showing ? "x_summary_view_tb" : "x_gtl_view_tb") + end + + presenter.reload_toolbars(:center => c_tb, :view => v_tb) + + presenter.set_visibility(c_tb.present? || v_tb.present?, :toolbar) + + presenter[:record_id] = @record.try(:id) + + # Hide/show searchbox depending on if a list is showing + presenter.set_visibility(display_adv_searchbox, :adv_searchbox_div) + presenter[:clear_search_toggle] = clear_search_status + + presenter.hide(:blocker_div) unless @edit && @edit[:adv_search_open] + presenter.hide(:quicksearchbox) + presenter[:hide_modal] = true + + presenter[:lock_sidebar] = @in_a_form + end + + def construct_edit_for_audit + @edit ||= {} + @edit[:current] = {:name => @provider.name, + :url => @provider.url, + :verify_ssl => @provider.verify_ssl} + @edit[:new] = {:name => params[:name], + :url => params[:url], + :verify_ssl => params[:verify_ssl]} + end + + def breadcrumb_name(_model) + "#{ui_lookup(:ui_title => 'foreman')} #{_('Provider')}" + end + + def tagging_explorer_controller? + @explorer + end + + def valid_configured_system_record?(configured_system_record) + configured_system_record.try(:id) + end + + def title + _("Providers") + end + end +end diff --git a/app/controllers/provider_foreman_controller.rb b/app/controllers/provider_foreman_controller.rb index f5776c62aae..13c20aa1d3c 100644 --- a/app/controllers/provider_foreman_controller.rb +++ b/app/controllers/provider_foreman_controller.rb @@ -7,6 +7,7 @@ class ProviderForemanController < ApplicationController include Mixins::GenericSessionMixin include Mixins::ManagerControllerMixin + include Mixins::AutomationManagerControllerMixin include Mixins::ExplorerPresenterMixin include Mixins::EmsCommon::Core include Mixins::EmsCommon::PauseResume diff --git a/app/helpers/application_helper/toolbar/configuration_manager_center.rb b/app/helpers/application_helper/toolbar/configuration_manager_center.rb index c6de79dcf51..c3fd0a3384d 100644 --- a/app/helpers/application_helper/toolbar/configuration_manager_center.rb +++ b/app/helpers/application_helper/toolbar/configuration_manager_center.rb @@ -1,35 +1,47 @@ class ApplicationHelper::Toolbar::ConfigurationManagerCenter < ApplicationHelper::Toolbar::Basic - button_group('provider_vmdb', [ + button_group('configuration_manager_vmdb', [ select( - :provider_vmdb_choice, + :configuration_manager_vmdb_choice, nil, t = N_('Configuration'), t, :enabled => true, :items => [ button( - :provider_foreman_refresh_provider, + :configuration_manager_refresh_provider, 'fa fa-refresh fa-lg', N_('Refresh relationships for all items related to this Provider'), N_('Refresh Relationships and Power states'), - :url => "refresh", :confirm => N_("Refresh relationships for all items related to this Provider?"), :klass => ApplicationHelper::Button::EmsRefresh), separator, button( - :provider_foreman_edit_provider, + :configuration_manager_edit_provider, 'pficon pficon-edit fa-lg', t = N_('Edit this Provider'), - t, - :url => "edit"), + t), button( - :provider_foreman_delete_provider, + :configuration_manager_delete_provider, 'pficon pficon-delete fa-lg', t = N_('Remove this Provider from Inventory'), t, - :url => "delete", :confirm => N_("Warning: The selected Provider and ALL of their components will be permanently removed!")), ] ), ]) + button_group('configuration_manager_policy', [ + select( + :configuration_manager_policy_choice, + nil, + t = N_('Policy'), + t, + :items => [ + button( + :configuration_manager_tag, + 'pficon pficon-edit fa-lg', + N_('Edit Tags for this Configuration Manager'), + N_('Edit Tags')), + ] + ), + ]) end diff --git a/app/helpers/application_helper/toolbar/configuration_managers_center.rb b/app/helpers/application_helper/toolbar/configuration_managers_center.rb index 53d9dc16e78..8e80ccbc177 100644 --- a/app/helpers/application_helper/toolbar/configuration_managers_center.rb +++ b/app/helpers/application_helper/toolbar/configuration_managers_center.rb @@ -1,18 +1,17 @@ class ApplicationHelper::Toolbar::ConfigurationManagersCenter < ApplicationHelper::Toolbar::Basic - button_group('provider_vmdb', [ + button_group('configuration_manager_vmdb', [ select( - :provider_vmdb_choice, + :configuration_manager__vmdb_choice, nil, t = N_('Configuration'), t, :enabled => true, :items => [ button( - :provider_foreman_refresh_provider, + :configuration_manager_refresh_provider, 'fa fa-refresh fa-lg', N_('Refresh relationships for all items related to the selected items'), N_('Refresh Relationships and Power states'), - :url => "refresh", :url_parms => "main_div", :send_checked => true, :confirm => N_("Refresh relationships for all items related to the selected items?"), @@ -20,28 +19,25 @@ class ApplicationHelper::Toolbar::ConfigurationManagersCenter < ApplicationHelpe :onwhen => "1+"), separator, button( - :provider_foreman_add_provider, + :configuration_manager_add_provider, 'pficon pficon-add-circle-o fa-lg', t = N_('Add a new Provider'), t, - :enabled => true, - :url => "new"), + :enabled => true), button( - :provider_foreman_edit_provider, + :configuration_manager_edit_provider, 'pficon pficon-edit fa-lg', N_('Select a single item to edit'), N_('Edit Selected item'), - :url => "edit", :url_parms => "main_div", :send_checked => true, :enabled => false, :onwhen => "1"), button( - :provider_foreman_delete_provider, + :configuration_manager_delete_provider, 'pficon pficon-delete fa-lg', t = N_('Remove selected items from Inventory'), t, - :url => "delete", :url_parms => "main_div", :send_checked => true, :confirm => N_("Warning: The selected items and ALL of their components will be permanently removed!"), @@ -61,7 +57,7 @@ class ApplicationHelper::Toolbar::ConfigurationManagersCenter < ApplicationHelpe :onwhen => "1+", :items => [ button( - :configuration_manager_provider_tag, + :configuration_manager_tag, 'pficon pficon-edit fa-lg', N_('Edit Tags for this Foreman Provider'), N_('Edit Tags'), diff --git a/app/views/configuration_manager/_shared_form.html.haml b/app/views/configuration_manager/_shared_form.html.haml index 4fb1296dd7b..d170785d81c 100644 --- a/app/views/configuration_manager/_shared_form.html.haml +++ b/app/views/configuration_manager/_shared_form.html.haml @@ -91,3 +91,9 @@ 'new-record' => 'vm.newRecord', 'check-authentication' => true} = render :partial => "layouts/angular/generic_form_buttons" + +:javascript + ManageIQ.angular.app.value('configurationManagerFormId', '#{@provider_manager.id || "new"}'); + ManageIQ.angular.app.value('url', '/configuration_manager'); + ManageIQ.angular.app.value('modelName', 'configurationManagerModel'); + miq_bootstrap('#form_div'); diff --git a/app/views/configuration_manager/edit.html.haml b/app/views/configuration_manager/edit.html.haml new file mode 100644 index 00000000000..4b6255b467d --- /dev/null +++ b/app/views/configuration_manager/edit.html.haml @@ -0,0 +1 @@ += render :partial => 'configuration_manager/shared_form' diff --git a/app/views/configuration_manager/new.html.haml b/app/views/configuration_manager/new.html.haml new file mode 100644 index 00000000000..28c2f407243 --- /dev/null +++ b/app/views/configuration_manager/new.html.haml @@ -0,0 +1,2 @@ += render :partial => 'configuration_manager/shared_form' + diff --git a/config/routes.rb b/config/routes.rb index 7a85bc361ef..06b85bbd242 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2664,9 +2664,12 @@ :configuration_manager => { :get => %w( + button download_data download_summary_pdf + edit form_fields + new show show_list tagging_edit From c67e3cbea34263de2993a2a26b8b4662ffd20f8a Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 23 Mar 2020 10:28:08 -0400 Subject: [PATCH 08/33] Removed accidental add of debug statement --- app/controllers/application_controller/tags.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/app/controllers/application_controller/tags.rb b/app/controllers/application_controller/tags.rb index 32e9ba79574..ee32d7f9118 100644 --- a/app/controllers/application_controller/tags.rb +++ b/app/controllers/application_controller/tags.rb @@ -102,7 +102,6 @@ def tagging_edit_tags_cancel replace_right_cell else session[:flash_msgs] = @flash_array.dup # Put msg in session for next transaction to display - p "XCCCCCCCCCCCCCCCCCCCCCC #{previous_breadcrumb_url.inspect}" javascript_redirect(previous_breadcrumb_url) end end From 126a2beb09734cb8fc75d95519bceebde7cdf0a6 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 23 Mar 2020 11:26:47 -0400 Subject: [PATCH 09/33] Further cleanup of routes and CS controller + toolbars working. --- .../configured_system_controller.rb | 44 ++++++++++--------- .../toolbar/configured_systems_center.rb | 39 +++++++++++++++- config/routes.rb | 42 +----------------- 3 files changed, 62 insertions(+), 63 deletions(-) diff --git a/app/controllers/configured_system_controller.rb b/app/controllers/configured_system_controller.rb index 5721dc4efa9..2d3cb1f608b 100644 --- a/app/controllers/configured_system_controller.rb +++ b/app/controllers/configured_system_controller.rb @@ -19,36 +19,40 @@ def self.table_name def button @edit = session[:edit] # Restore @edit for adv search box - params[:display] = @display if %w[configuration_profiles configured_systems].include?(@display) # Were we displaying nested list # Handle Toolbar Policy Tag Button @refresh_div = "main_div" # Default div for button.rjs to refresh model = self.class.model - tag(model) if params[:pressed] == "#{params[:controller]}_tag" - if [ConfiguredSystem].include?(model) - assign_policies(model) if params[:pressed] == "#{model.name.underscore}_protect" - check_compliance(model) if params[:pressed] == "#{model.name.underscore}_check_compliance" - end - if params[:pressed] == 'service_dialog_from_ct' - create_service_dialog - return - end + tag(model) if params[:pressed] == "configured_system_tag" + provision if params[:pressed] == "configured_system_provision" return if ["#{params[:controller]}_tag"].include?(params[:pressed]) && @flash_array.nil? # Tag screen showing + end + + private - # Handle scan - if params[:pressed] == "container_image_scan" - scan_images + def provision + assert_privileges("configured_system_provision") + provisioning_ids = find_records_with_rbac(ConfiguredSystem, checked_or_params).ids - if @lastaction == "show" - javascript_flash - else - replace_main_div(:partial => "layouts/gtl") - end + unless ConfiguredSystem.provisionable?(provisioning_ids) + add_flash(_("Provisioning is not supported for at least one of the selected systems"), :error) + replace_right_cell + return end - end - private + if ConfiguredSystem.common_configuration_profiles_for_selected_configured_systems(provisioning_ids) + javascript_redirect(:controller => "miq_request", + :action => "prov_edit", + :prov_id => provisioning_ids, + :org_controller => "configured_system", + :escape => false) + else + render_flash(n_("No common configuration profiles available for the selected configured system", + "No common configuration profiles available for the selected configured systems", + provisioning_ids.size), :error) + end + end def textual_group_list [%i[properties environment os], %i[tenancy tags]] diff --git a/app/helpers/application_helper/toolbar/configured_systems_center.rb b/app/helpers/application_helper/toolbar/configured_systems_center.rb index 7c004171f5a..80515eb0728 100644 --- a/app/helpers/application_helper/toolbar/configured_systems_center.rb +++ b/app/helpers/application_helper/toolbar/configured_systems_center.rb @@ -1,4 +1,39 @@ class ApplicationHelper::Toolbar::ConfiguredSystemsCenter < ApplicationHelper::Toolbar::Basic - include ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::LifecycleMixin - include ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::PolicyMixin + button_group('configuration_manager_lifecycle', [ + select( + :configuration_manager_lifecycle_choice, + nil, + N_('Lifecycle'), + :enabled => true, + :items => [ + button( + :configured_system_provision, + 'pficon pficon-add-circle-o fa-lg', + N_('Provision Configured Systems'), + :url_parms => "main_div", + :send_checked => true, + :enabled => false, + :onwhen => "1+", + :klass => ApplicationHelper::Button::ConfiguredSystemProvision), + ] + ), + ]) + button_group('configuration_manager_policy', [ + select( + :configuration_manager_policy_choice, + nil, + N_('Policy'), + :items => [ + button( + :configured_system_tag, + 'pficon pficon-edit fa-lg', + N_('Edit Tags for this Configured System'), + N_('Edit Tags'), + :url_parms => "main_div", + :send_checked => true, + :enabled => false, + :onwhen => "1+"), + ] + ), + ]) end diff --git a/config/routes.rb b/config/routes.rb index 06b85bbd242..c74c6acad9f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2682,7 +2682,6 @@ edit form_field_changed new - provision quick_search refresh reload @@ -2691,15 +2690,10 @@ tagging tagging_edit tag_edit_form_field_changed - cs_form_field_changed - users wait_for_task - button ) + adv_search_post + - dialog_runner_post + exp_post + - perf_post + save_post }, @@ -2707,75 +2701,41 @@ :get => %w( download_data download_summary_pdf - form_fields show show_list - tagging_edit ), :post => %w( - authentication_validate - button - change_tab - delete - edit - form_field_changed - new - provision quick_search - refresh reload show show_list - tagging - tagging_edit - tag_edit_form_field_changed - cs_form_field_changed - users - wait_for_task - button - ) + - adv_search_post + - dialog_runner_post + - exp_post + - perf_post + - save_post + ) }, :configured_system => { :get => %w( download_data download_summary_pdf - form_fields show show_list tagging_edit ), :post => %w( - authentication_validate button - change_tab - delete - edit - form_field_changed new provision quick_search - refresh reload show show_list tagging tagging_edit tag_edit_form_field_changed - cs_form_field_changed - users wait_for_task - button ) + adv_search_post + dialog_runner_post + exp_post + - perf_post + save_post }, From dd14060da4cb10d028eff3e8fdba5a460ee5fa19 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Tue, 24 Mar 2020 15:07:18 -0400 Subject: [PATCH 10/33] Removed Configuration Management explorer related files & code. - Updated/removed any references to provider_foreman explorer. --- app/controllers/application_controller.rb | 8 - .../application_controller/ci_processing.rb | 2 +- .../application_controller/explorer.rb | 3 +- .../configuration_profile_controller.rb | 4 - .../configured_system_controller.rb | 4 - .../provider_foreman_controller.rb | 522 ------------------ .../restful_redirect_controller.rb | 4 +- app/helpers/application_helper.rb | 20 +- .../application_helper/page_layouts.rb | 1 - app/helpers/application_helper/title.rb | 2 - .../toolbar/configuration_managers_center.rb | 2 +- .../foreman/lifecycle_mixin.rb | 24 - .../configured_system/foreman/policy_mixin.rb | 23 - .../unassigned_profiles_group_center.rb | 4 - .../x_foreman_configured_system_center.rb | 40 -- ...oreman_foreman_configured_system_center.rb | 40 -- .../application_helper/toolbar_chooser.rb | 20 - .../provider_configuration_manager_helper.rb | 41 -- app/helpers/provider_foreman_helper.rb | 296 ---------- app/presenters/menu/default_menu.rb | 1 - app/presenters/tree_builder.rb | 2 - .../tree_builder_configuration_manager.rb | 58 -- ...onfiguration_manager_configured_systems.rb | 24 - .../tree_builder_configured_systems.rb | 20 - app/presenters/tree_node/node.rb | 1 - .../_configscript_service_dialog.html.haml | 17 - .../_configuration_profile.html.haml | 18 - .../_configuration_script.html.haml | 9 - app/views/provider_foreman/_form.html.haml | 7 - .../_inventory_group.html.haml | 18 - .../_main_configuration_profile.html.haml | 8 - .../_main_inventory_group.html.haml | 4 - app/views/provider_foreman/explorer.html.haml | 32 -- app/views/provider_foreman/show.html.haml | 4 - ...nageIQ_Providers_ConfigurationManager.yaml | 2 +- ...roviders_Foreman_ConfigurationManager.yaml | 103 ---- ...igurationManager_ConfigurationProfile.yaml | 83 --- ...ConfigurationManager_ConfiguredSystem.yaml | 88 --- 38 files changed, 7 insertions(+), 1552 deletions(-) delete mode 100644 app/controllers/provider_foreman_controller.rb delete mode 100644 app/helpers/application_helper/toolbar/configured_system/foreman/lifecycle_mixin.rb delete mode 100644 app/helpers/application_helper/toolbar/configured_system/foreman/policy_mixin.rb delete mode 100644 app/helpers/application_helper/toolbar/unassigned_profiles_group_center.rb delete mode 100644 app/helpers/application_helper/toolbar/x_foreman_configured_system_center.rb delete mode 100644 app/helpers/application_helper/toolbar/x_provider_foreman_foreman_configured_system_center.rb delete mode 100644 app/helpers/provider_configuration_manager_helper.rb delete mode 100644 app/helpers/provider_foreman_helper.rb delete mode 100644 app/presenters/tree_builder_configuration_manager.rb delete mode 100644 app/presenters/tree_builder_configuration_manager_configured_systems.rb delete mode 100644 app/presenters/tree_builder_configured_systems.rb delete mode 100644 app/views/provider_foreman/_configscript_service_dialog.html.haml delete mode 100644 app/views/provider_foreman/_configuration_profile.html.haml delete mode 100644 app/views/provider_foreman/_configuration_script.html.haml delete mode 100644 app/views/provider_foreman/_form.html.haml delete mode 100644 app/views/provider_foreman/_inventory_group.html.haml delete mode 100644 app/views/provider_foreman/_main_configuration_profile.html.haml delete mode 100644 app/views/provider_foreman/_main_inventory_group.html.haml delete mode 100644 app/views/provider_foreman/explorer.html.haml delete mode 100644 app/views/provider_foreman/show.html.haml delete mode 100644 product/views/ManageIQ_Providers_Foreman_ConfigurationManager.yaml delete mode 100644 product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfigurationProfile.yaml delete mode 100644 product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfiguredSystem.yaml diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 380ceeb818f..00e59d86b9f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -431,12 +431,6 @@ def report_data @view.table = filter_parent_name_tenant(@view.table) end - # Foreman has some unassigned rows which needs to be added after view is fetched - if options && options[:unassigned_profile_row] && options[:unassigned_configuration_profile] - options[:unassigned_profile_row][:id] ||= options[:unassigned_profile_row]['manager_id'] - @view.table.data.push(options[:unassigned_profile_row]) - @targets_hash[options[:unassigned_profile_row]['id']] = options[:unassigned_configuration_profile] - end render :json => { :settings => settings, :data => view_to_hash(@view, true), @@ -1990,8 +1984,6 @@ def controller_for_common_methods "vm" when 'automation_manager' "automation_manager_provider" - when 'provider_foreman' - "configuration_manager_provider" when "generic_object_definition" # tagging for nested list on the generic object class "generic_object" when "ansible_playbook" diff --git a/app/controllers/application_controller/ci_processing.rb b/app/controllers/application_controller/ci_processing.rb index b64b8809f40..b722fc2f094 100644 --- a/app/controllers/application_controller/ci_processing.rb +++ b/app/controllers/application_controller/ci_processing.rb @@ -306,7 +306,7 @@ def manager_button_operation(method, display_name) def process_managers(managers, task) controller_class = request.parameters[:controller] provider_class = case controller_class - when 'configuration_manager', 'provider_foreman' then ManageIQ::Providers::ConfigurationManager + when 'configuration_manager' then ManageIQ::Providers::ConfigurationManager when 'automation_manager' then ManageIQ::Providers::AutomationManager end diff --git a/app/controllers/application_controller/explorer.rb b/app/controllers/application_controller/explorer.rb index 4699050a03d..0dd7bd727a3 100644 --- a/app/controllers/application_controller/explorer.rb +++ b/app/controllers/application_controller/explorer.rb @@ -43,8 +43,7 @@ def x_history 'start' => :s1, 'stop' => :s1, 'suspend' => :s1, 'reset' => :s1, 'terminate' => :s1, 'pause' => :s1, 'shelve' => :s1, 'shelve_offload' => :s1, 'chargeback' => :s1, - 'foreman_pause' => :s1, 'foreman_resume' => :s1, 'manager_pause' => :s1, - 'manager_resume' => :s1, + 'manager_pause' => :s1, 'manager_resume' => :s1, # group 2 'clone' => :s2, 'compare' => :s2, 'drift' => :s2, diff --git a/app/controllers/configuration_profile_controller.rb b/app/controllers/configuration_profile_controller.rb index a0a3eb4733d..9c45e8fe0e0 100644 --- a/app/controllers/configuration_profile_controller.rb +++ b/app/controllers/configuration_profile_controller.rb @@ -9,10 +9,6 @@ class ConfigurationProfileController < ApplicationController after_action :cleanup_action after_action :set_session_data - def self.model - ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile - end - def self.table_name @table_name ||= "configuration_profile" end diff --git a/app/controllers/configured_system_controller.rb b/app/controllers/configured_system_controller.rb index 2d3cb1f608b..85f52c83497 100644 --- a/app/controllers/configured_system_controller.rb +++ b/app/controllers/configured_system_controller.rb @@ -9,10 +9,6 @@ class ConfiguredSystemController < ApplicationController after_action :cleanup_action after_action :set_session_data - def self.model - ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem - end - def self.table_name @table_name ||= "configured_system" end diff --git a/app/controllers/provider_foreman_controller.rb b/app/controllers/provider_foreman_controller.rb deleted file mode 100644 index 13c20aa1d3c..00000000000 --- a/app/controllers/provider_foreman_controller.rb +++ /dev/null @@ -1,522 +0,0 @@ -class ProviderForemanController < ApplicationController - before_action :check_privileges - before_action :get_session_data - - after_action :cleanup_action - after_action :set_session_data - - include Mixins::GenericSessionMixin - include Mixins::ManagerControllerMixin - include Mixins::AutomationManagerControllerMixin - include Mixins::ExplorerPresenterMixin - include Mixins::EmsCommon::Core - include Mixins::EmsCommon::PauseResume - include Mixins::BreadcrumbsMixin - - def self.model - ManageIQ::Providers::ConfigurationManager - end - - def self.table_name - @table_name ||= "provider_foreman" - end - - def self.model_to_name(provmodel) - if provmodel.include?("ManageIQ::Providers::Foreman") - Dictionary.gettext('foreman', :type => :ui_title, :translate => false) - end - end - - def concrete_model - ManageIQ::Providers::ConfigurationManager - end - - def managed_group_kls - ConfigurationProfile - end - - def manager_prefix - 'configuration_manager' - end - - def privilege_prefix - 'provider_foreman' - end - - def provision - assert_privileges("provider_foreman_configured_system_provision") if x_active_accord == :configuration_manager_providers - assert_privileges("configured_system_provision") if x_active_accord == :configuration_manager_cs_filter - provisioning_ids = find_records_with_rbac(ConfiguredSystem, checked_or_params).ids - - unless ConfiguredSystem.provisionable?(provisioning_ids) - add_flash(_("Provisioning is not supported for at least one of the selected systems"), :error) - replace_right_cell - return - end - - if ConfiguredSystem.common_configuration_profiles_for_selected_configured_systems(provisioning_ids) - javascript_redirect(:controller => "miq_request", - :action => "prov_edit", - :prov_id => provisioning_ids, - :org_controller => "configured_system", - :escape => false) - else - add_flash(n_("No common configuration profiles available for the selected configured system", - "No common configuration profiles available for the selected configured systems", - provisioning_ids.size), :error) - replace_right_cell - end - end - - def tagging - @explorer = true - case x_active_accord - when :configuration_manager_providers - assert_privileges("configuration_manager_provider_tag") - tagging_edit(class_for_provider_node.to_s, false) - when :configuration_manager_cs_filter - assert_privileges("configured_system_tag") - tagging_edit('ConfiguredSystem', false) - end - render_tagging_form - end - - def load_or_clear_adv_search - adv_search_build(model_from_active_tree(x_active_tree)) - session[:edit] = @edit - @explorer = true - - if x_active_tree == :configuration_manager_cs_filter_tree && params[:button] != 'saveit' # Configured Systems accordion - @nodetype, id = parse_nodetype_and_id(valid_active_node(x_node)) - search_id = @nodetype == "root" ? 0 : id - search_id = @edit[@expkey][:selected][:id] if params[:button] == "save" - listnav_search_selected(search_id) if !params.key?(:search_text) && params[:action] != 'x_show' # Clear or set the adv search filter - if @edit[:adv_search_applied] && - MiqExpression.quick_search?(@edit[:adv_search_applied][:exp]) && - %w[reload tree_select].include?(params[:action]) - self.x_node = params[:id] - quick_search_show # User will input the value - end - elsif provider_active_tree? && x_node != 'root' # Providers accordion, without Advanced Search - listnav_search_selected(0) - end - end - - # Display provider through Tenant's textual summary - def show - @explorer = true - @lastaction = "explorer" - - build_accordions_and_trees - - params[:action] = 'tree-select' - provider_node(params[:id], ExtManagementSystem.find_by(:id => params[:id]).type) - - render :layout => "application" - end - - def x_show - tree_record unless unassigned_configuration_profile?(params[:id]) - - if request.format.js? && !@record - check_for_unassigned_configuration_profile - return - end - - generic_x_show - end - - def tree_record - @record = case x_active_tree - when :configuration_manager_providers_tree then configuration_manager_providers_tree_rec - when :configuration_manager_cs_filter_tree then configuration_manager_cs_filter_tree_rec - end - end - - def check_for_unassigned_configuration_profile - if action_name == "x_show" - unassigned_configuration_profile?(params[:id]) ? tree_select : tree_select_unprovisioned_configured_system - elsif action_name == "tree_select" - tree_select_unprovisioned_configured_system - else - redirect_to(:action => "explorer") - end - end - - def tree_select_unprovisioned_configured_system - if unassigned_configuration_profile?(x_node) - params[:id] = "cs-#{params[:id]}" - tree_select - else - redirect_to(:action => "explorer") - end - end - - def class_for_provider_node - nodes = x_node.split('-') - case nodes.first - when "root" then ManageIQ::Providers::ConfigurationManager - when "fr" then ConfigurationProfile - when "cp", "cs" then ConfiguredSystem - when "xx" then - case nodes.second - when "fr" then ManageIQ::Providers::ConfigurationManager - when "csf" then ConfiguredSystem - end - else - nodes.include?("unassigned") ? ConfiguredSystem : ManageIQ::Providers::ConfigurationManager - end - end - - def configuration_manager_providers_tree_rec - find_record(class_for_provider_node, params[:id]) - end - - def configuration_manager_cs_filter_tree_rec - nodes = x_node.split('-') - case nodes.first - when "root", "xx" then find_record(ConfiguredSystem, params[:id]) - when "ms" then find_record(ConfiguredSystem, params[:id]) - end - end - - def show_record(_id = nil) - @display = params[:display] || "main" unless pagination_or_gtl_request? - @lastaction = "show" - - if @record.nil? - add_flash(_("Error: Record no longer exists in the database"), :error) - if request.xml_http_request? && params[:id] # Is this an Ajax request clicking on a node that no longer exists? - @delete_node = params[:id] # Set node to be removed from the tree - end - return - end - - return unless @display == 'main' - @showtype = "main" - end - - def validate_before_save? - true - end - - def provider_active_tree? - x_active_tree == :configuration_manager_providers_tree - end - helper_method(:provider_active_tree?) - - private - - def provider_foreman_pause - pause_or_resume_emss(:pause => true) - end - - def provider_foreman_resume - pause_or_resume_emss(:resume => true) - end - - def textual_group_list - [%i[properties environment os], %i[tenancy tags]] - end - helper_method :textual_group_list - - def provider_class - ManageIQ::Providers::Foreman::Provider - end - - def features - [ - { - :role => "providers_accord", - :role_any => true, - :name => :configuration_manager_providers, - :title => _("Providers") - }, - { - :role => "configured_systems_filter_accord", - :role_any => true, - :name => :configuration_manager_cs_filter, - :title => _("Configured Systems") - } - ].map { |hsh| ApplicationController::Feature.new_with_hash(hsh) } - end - - def get_node_info(treenodeid, show_list = true) - @sb[:action] = nil - @nodetype, id = parse_nodetype_and_id(valid_active_node(treenodeid)) - @show_list = show_list - - model = TreeBuilder.get_model_for_prefix(@nodetype) - if model == "Hash" - model = TreeBuilder.get_model_for_prefix(id) - id = nil - end - - options = case model - when "ManageIQ::Providers::Foreman::ConfigurationManager" - provider_list(id, model) - when "ConfigurationProfile" - configuration_profile_node(id, model) - when "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem", "ConfiguredSystem" - configured_system_list(id, model) - when "MiqSearch" - miq_search_node - else - if unassigned_configuration_profile?(treenodeid) - configuration_profile_node(id, model) - else - default_node - end - end - @right_cell_text += _(" (Names with \"%{search_text}\")") % {:search_text => @search_text} if @search_text.present? - @right_cell_text += @edit[:adv_search_applied][:text] if x_tree && x_tree[:tree] == :configuration_manager_cs_filter_tree && @edit && @edit[:adv_search_applied] - - if @view && @pages - {:view => @view, :pages => @pages} - else - options - end - end - - def provider_node(id, model) - @record = provider = find_record(ExtManagementSystem, id) - if provider.nil? - self.x_node = "root" - get_node_info("root") - else - @no_checkboxes = true - case @record.type - when "ManageIQ::Providers::Foreman::ConfigurationManager" - options = {:model => "ConfigurationProfile", :match_via_descendants => 'ConfiguredSystem', :named_scope => [[:with_manager, provider.id]]} - @show_list ? process_show_list(options) : options.merge!(update_options) - unassigned_profiles = add_unassigned_configuration_profile_record(provider.id) - options.merge!(unassigned_profiles) unless unassigned_profiles.nil? - record_model = ui_lookup(:model => self.class.model_to_name(model || TreeBuilder.get_model_for_prefix(@nodetype))) - @right_cell_text = _("Configuration Profiles under %{record_model} Provider \"%{name}\"") % { - :name => provider.name, - :record_model => record_model - } - end - end - options - end - - def configuration_profile_node(id, model) - @record = @configuration_profile_record = model ? find_record(ConfigurationProfile, id) : ConfigurationProfile.new - if @configuration_profile_record.nil? - self.x_node = "root" - get_node_info("root") - else - options = {:model => "ConfiguredSystem"} - options[:named_scope] = if empty_configuration_profile_record?(@configuration_profile_record) - [[:with_manager, id], [:without_configuration_profile_id]] - else - [[:with_configuration_profile_id, @configuration_profile_record.id]] - end - @show_list ? process_show_list(options) : options.merge!(update_options) - record_model = ui_lookup(:model => model || TreeBuilder.get_model_for_prefix(@nodetype)) - if @sb[:active_tab] == 'configured_systems' - configuration_profile_right_cell_text(model) - else - @showtype = 'main' - @pages = nil - @right_cell_text = _("%{model} \"%{name}\"") % {:name => @configuration_profile_record.name, :model => record_model} - end - end - options - end - - def default_node - return unless x_node == "root" - if provider_active_tree? - options = {:model => "ManageIQ::Providers::ConfigurationManager"} - @show_list ? process_show_list(options) : options.merge!(update_options) - @right_cell_text = _("All Configuration Management Providers") - elsif x_active_tree == :configuration_manager_cs_filter_tree - options = {:model => "ConfiguredSystem"} - @show_list ? process_show_list(options) : options.merge!(update_options) - @right_cell_text = _("All Configured Systems") - end - options - end - - def rebuild_trees(replace_trees) - build_replaced_trees(replace_trees, %i[configuration_manager_providers configuration_manager_cs_filter]) - end - - 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].include?(TreeBuilder.get_model_for_prefix(type)) - end - - def configuration_profile_record?(node = x_node) - type, _id = parse_nodetype_and_id(node) - type && %w[ConfigurationProfile].include?(TreeBuilder.get_model_for_prefix(type)) - end - - def foreman_provider_record?(node = x_node) - node = node.split("-").last if node.split("-").first == 'xx' - type, _id = node.split("-") - type && ["ManageIQ::Providers::Foreman::ConfigurationManager"].include?(TreeBuilder.get_model_for_prefix(type)) - end - - def provider_record?(node = x_node) - foreman_provider_record?(node) - end - - def search_text_type(node) - return "provider" if provider_record?(node) - return "configuration_profile" if configuration_profile_record?(node) - node - end - - def update_partials(record_showing, presenter) - if record_showing && valid_configured_system_record?(@configured_system_record) - get_tagdata(@record) - presenter.hide(:form_buttons_div) - presenter.update(:main_div, r[:partial => "layouts/textual_groups_generic"]) - elsif @in_a_form - partial_locals = {:controller => controller_name} - @right_cell_text = - if @sb[:action] == "#{controller_name}_add_provider" - _("Add a new Configuration Management Provider") - elsif @sb[:action] == "#{controller_name}_edit_provider" - _("Edit Provider") - end - partial = 'form' - presenter.update(:main_div, r[:partial => partial, :locals => partial_locals]) - elsif valid_configuration_profile_record?(@configuration_profile_record) - presenter.hide(:form_buttons_div) - presenter.update(:main_div, r[:partial => "configuration_profile", - :locals => {:controller => controller_name}]) - elsif ManageIQ::Providers::ConfigurationManager.none? && provider_active_tree? - presenter.update(:main_div, r[:partial => "layouts/empty", - :locals => {:add_message => _("Add a new Configuration Management Provider"), - :documentation => ::Settings.docs.configuration_provider}]) - else - presenter.update(:main_div, r[:partial => 'layouts/x_gtl']) - end - presenter.update(:breadcrumbs, r[:partial => 'layouts/breadcrumbs']) - - replace_search_box(presenter, :nameonly => provider_active_tree?) - end - - def group_summary_tab_selected? - @configuration_profile_record && @sb[:active_tab] == 'summary' - end - - def active_tab_configured_systems? - (%w[x_show x_search_by_name].include?(action_name) && configuration_profile_record?) || - unassigned_configuration_profile?(x_node) - end - - def unassigned_configuration_profile?(node) - _type, _pid, nodeinfo = parse_nodetype_and_id(node) - nodeinfo == "unassigned" - end - - def empty_configuration_profile_record?(configuration_profile_record) - configuration_profile_record.try(:id).nil? - end - - def valid_configuration_profile_record?(configuration_profile_record) - configuration_profile_record.try(:id) - end - - def list_row_id(row) - if row['name'] == _("Unassigned Profiles Group") && row['id'].nil? - "-#{row['manager_id']}-unassigned" - else - row['id'].to_s - end - end - - def configuration_profile_right_cell_text(model) - record_model = ui_lookup(:model => model || TreeBuilder.get_model_for_prefix(@nodetype)) - return if @sb[:active_tab] != 'configured_systems' - @right_cell_text = if valid_configuration_profile_record?(@configuration_profile_record) - _("Configured Systems under %{record_model} \"%{name}\"") % - {:record_model => record_model, - :name => @configuration_profile_record.name} - else - _("Configured Systems under Unassigned Profiles Group") - end - end - - def add_unassigned_configuration_profile_record(provider_id) - unprovisioned_configured_systems = - ConfiguredSystem.where(:manager_id => provider_id, :configuration_profile_id => nil).count - - return if unprovisioned_configured_systems.zero? - - unassigned_configuration_profile_desc = unassigned_configuration_profile_name = _("Unassigned Profiles Group") - unassigned_configuration_profile = ConfigurationProfile.new - unassigned_configuration_profile.manager_id = provider_id - unassigned_configuration_profile.name = unassigned_configuration_profile_name - unassigned_configuration_profile.description = unassigned_configuration_profile_desc - - unassigned_profile_row = { - 'x_show_id' => "-#{provider_id}-unassigned", - 'description' => unassigned_configuration_profile_desc, - 'total_configured_systems' => unprovisioned_configured_systems, - 'configuration_environment_name' => unassigned_configuration_profile.configuration_environment_name, - 'my_zone' => unassigned_configuration_profile.my_zone, - 'region_description' => unassigned_configuration_profile.region_description, - 'name' => unassigned_configuration_profile_name, - 'manager_id' => provider_id - } - - unless @view.table.kind_of?(Hash) - add_unassigned_configuration_profile_record_to_view(unassigned_profile_row, unassigned_configuration_profile) - end - { - :unassigned_profile_row => unassigned_profile_row, - :unassigned_configuration_profile => unassigned_configuration_profile - } - end - - def add_unassigned_configuration_profile_record_to_view(unassigned_profile_row, unassigned_configuration_profile) - @view.table.data.push(unassigned_profile_row) - @targets_hash[unassigned_profile_row['id']] = unassigned_configuration_profile - end - - def update_options(options = {}) - options ||= {} - options[:dbname] = case x_active_accord - when :configuration_manager_providers - case options[:model] - when 'ConfiguredSystem' - :cm_configured_systems - when 'ConfigurationProfile' - :cm_configuration_profiles - else - :cm_providers - end - when :configuration_manager_cs_filter - :cm_configured_systems - end - options[:gtl_dbname] = options[:dbname] - options - end - private :update_options - - def process_show_list(options = {}) - options.merge!(update_options(options)) - process_show_list_options(options) - super - end - - def breadcrumbs_options - { - :breadcrumbs => [ - {:title => _("Configuration")}, - {:title => _("Management")}, - ], - :record_title => :hostname, - } - end - - menu_section :conf -end diff --git a/app/controllers/restful_redirect_controller.rb b/app/controllers/restful_redirect_controller.rb index cc3a973f0c3..6483a029115 100644 --- a/app/controllers/restful_redirect_controller.rb +++ b/app/controllers/restful_redirect_controller.rb @@ -6,9 +6,7 @@ def index when 'ExtManagementSystem' record = ExtManagementSystem.find_by(:id => params[:id]) if record - if %w[ManageIQ::Providers::ConfigurationManager].include?(record.type) || record.type.starts_with?('ManageIQ::Providers::Foreman') - redirect_to(:controller => 'provider_foreman', :action => 'show', :id => params[:id]) - elsif %w[ManageIQ::Providers::AnsibleTower::AutomationManager].include?(record.type) + if %w[ManageIQ::Providers::AnsibleTower::AutomationManager].include?(record.type) redirect_to(:controller => 'automation_manager', :action => 'show', :id => params[:id]) elsif %w[ManageIQ::Providers::EmbeddedAnsible::AutomationManager].include?(record.type) redirect_to(:controller => 'ansible_playbook', :action => 'show_list') diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index e20988fa907..f55e6634cc3 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -218,8 +218,6 @@ def url_for_db(db, action = "show", item = nil) :show => @id) elsif @host && %w[Patch GuestApplication].include?(db) return url_for_only_path(:controller => "host", :action => @lastaction, :id => @host, :show => @id) - 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) return url_for_only_path(:controller => controller, :action => action, :id => @id) @@ -284,14 +282,9 @@ 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].include?(view.db) && - request.parameters[:controller] == "provider_foreman" - return url_for_only_path(:action => action, :id => nil) + "/" 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") - return url_for_only_path(:action => action, :id => nil) + "/" elsif %w[MiqWidget ConfigurationScript MiqReportResult].include?(view.db) && @@ -423,11 +416,10 @@ def db_to_controller(db, action = "show") controller = "ansible_credential" when "MiqWorker" controller = request.parameters[:controller] - when "OrchestrationStackOutput", "OrchestrationStackParameter", "OrchestrationStackResource", + when "ConfigurationProfile", "ConfiguredSystem", + "OrchestrationStackOutput", "OrchestrationStackParameter", "OrchestrationStackResource", "ManageIQ::Providers::CloudManager::OrchestrationStack", "ManageIQ::Providers::ConfigurationManager", - "ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile", - "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem", "ManageIQ::Providers::AnsibleTower::AutomationManager::Job", "ConfigurationScript" controller = request.parameters[:controller] when "ContainerVolume" @@ -808,7 +800,6 @@ def display_adv_search? orchestration_stack persistent_volume physical_server - provider_foreman resource_pool retired security_group @@ -928,11 +919,6 @@ def model_from_active_tree(tree) case tree when :automation_manager_cs_filter_tree "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem" - when :configuration_manager_cs_filter_tree - "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem" - when :configuration_manager_providers_tree - "ManageIQ::Providers::Foreman::ConfigurationManager" if x_node.include?("fr") - "ManageIQ::Providers::ConfigurationManager" if x_node == "root" when :instances_filter_tree "ManageIQ::Providers::CloudManager::Vm" when :images_filter_tree @@ -954,8 +940,6 @@ def configuration_manager_scripts_tree(tree) case tree when :automation_manager_cs_filter_tree, :automation_manager_providers_tree "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem" - when :configuration_manager_cs_filter_tree - "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem" when :configuration_scripts_tree "ConfigurationScript" end diff --git a/app/helpers/application_helper/page_layouts.rb b/app/helpers/application_helper/page_layouts.rb index c813b12c895..c2285b0e97b 100644 --- a/app/helpers/application_helper/page_layouts.rb +++ b/app/helpers/application_helper/page_layouts.rb @@ -225,7 +225,6 @@ def show_adv_search? orchestration_stack persistent_volume physical_server - provider_foreman resource_pool retired security_group diff --git a/app/helpers/application_helper/title.rb b/app/helpers/application_helper/title.rb index c351dffe02e..da7e589d744 100644 --- a/app/helpers/application_helper/title.rb +++ b/app/helpers/application_helper/title.rb @@ -75,8 +75,6 @@ def title_from_layout(layout) _("Reports") when "ops" _("Configuration") - when "provider_foreman" - _("Configuration Management") when "pxe" _("PXE") when "switch" diff --git a/app/helpers/application_helper/toolbar/configuration_managers_center.rb b/app/helpers/application_helper/toolbar/configuration_managers_center.rb index 8e80ccbc177..d13ab79457a 100644 --- a/app/helpers/application_helper/toolbar/configuration_managers_center.rb +++ b/app/helpers/application_helper/toolbar/configuration_managers_center.rb @@ -59,7 +59,7 @@ class ApplicationHelper::Toolbar::ConfigurationManagersCenter < ApplicationHelpe button( :configuration_manager_tag, 'pficon pficon-edit fa-lg', - N_('Edit Tags for this Foreman Provider'), + N_('Edit Tags for this Configuration Manager Provider'), N_('Edit Tags'), :url_parms => "main_div", :send_checked => true, diff --git a/app/helpers/application_helper/toolbar/configured_system/foreman/lifecycle_mixin.rb b/app/helpers/application_helper/toolbar/configured_system/foreman/lifecycle_mixin.rb deleted file mode 100644 index dc3b9a07f7a..00000000000 --- a/app/helpers/application_helper/toolbar/configured_system/foreman/lifecycle_mixin.rb +++ /dev/null @@ -1,24 +0,0 @@ -module ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::LifecycleMixin - def self.included(included_class) - included_class.button_group('provider_foreman_lifecycle', [ - included_class.select( - :provider_foreman_lifecycle_choice, - nil, - N_('Lifecycle'), - :enabled => true, - :items => [ - included_class.button( - :configured_system_provision, - 'pficon pficon-add-circle-o fa-lg', - N_('Provision Configured Systems'), - :url => "provision", - :url_parms => "main_div", - :send_checked => true, - :enabled => false, - :onwhen => "1+", - :klass => ApplicationHelper::Button::ConfiguredSystemProvision), - ] - ), - ]) - end -end diff --git a/app/helpers/application_helper/toolbar/configured_system/foreman/policy_mixin.rb b/app/helpers/application_helper/toolbar/configured_system/foreman/policy_mixin.rb deleted file mode 100644 index 278d75b464c..00000000000 --- a/app/helpers/application_helper/toolbar/configured_system/foreman/policy_mixin.rb +++ /dev/null @@ -1,23 +0,0 @@ -module ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::PolicyMixin - def self.included(included_class) - included_class.button_group('provider_foreman_policy', [ - included_class.select( - :provider_foreman_policy_choice, - nil, - N_('Policy'), - :items => [ - included_class.button( - :configured_system_tag, - 'pficon pficon-edit fa-lg', - N_('Edit Tags for this Configured System'), - N_('Edit Tags'), - :url => "tagging", - :url_parms => "main_div", - :send_checked => true, - :enabled => false, - :onwhen => "1+"), - ] - ), - ]) - end -end diff --git a/app/helpers/application_helper/toolbar/unassigned_profiles_group_center.rb b/app/helpers/application_helper/toolbar/unassigned_profiles_group_center.rb deleted file mode 100644 index 01c72109650..00000000000 --- a/app/helpers/application_helper/toolbar/unassigned_profiles_group_center.rb +++ /dev/null @@ -1,4 +0,0 @@ -class ApplicationHelper::Toolbar::UnassignedProfilesGroupCenter < ApplicationHelper::Toolbar::Basic - include ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::LifecycleMixin - include ApplicationHelper::Toolbar::ConfiguredSystem::Foreman::PolicyMixin -end diff --git a/app/helpers/application_helper/toolbar/x_foreman_configured_system_center.rb b/app/helpers/application_helper/toolbar/x_foreman_configured_system_center.rb deleted file mode 100644 index 4bfbbb5dad4..00000000000 --- a/app/helpers/application_helper/toolbar/x_foreman_configured_system_center.rb +++ /dev/null @@ -1,40 +0,0 @@ -class ApplicationHelper::Toolbar::XForemanConfiguredSystemCenter < ApplicationHelper::Toolbar::Basic - button_group('record_summary', [ - select( - :provider_foreman_lifecycle_choice, - nil, - t = N_('Lifecycle'), - t, - :enabled => true, - :items => [ - button( - :provider_foreman_configured_system_provision, - 'pficon pficon-add-circle-o fa-lg', - t = N_('Provision Configured System'), - t, - :url => "provision", - :url_parms => "main_div", - :send_checked => true, - :enabled => true), - ] - ), - select( - :provider_foreman_policy_choice, - nil, - t = N_('Policy'), - t, - :enabled => true, - :items => [ - button( - :configured_system_tag, - 'pficon pficon-edit fa-lg', - N_('Edit Tags for this Configured System'), - N_('Edit Tags'), - :url => "tagging", - :url_parms => "main_div", - :send_checked => true, - :enabled => true), - ] - ), - ]) -end diff --git a/app/helpers/application_helper/toolbar/x_provider_foreman_foreman_configured_system_center.rb b/app/helpers/application_helper/toolbar/x_provider_foreman_foreman_configured_system_center.rb deleted file mode 100644 index 9bde578ef66..00000000000 --- a/app/helpers/application_helper/toolbar/x_provider_foreman_foreman_configured_system_center.rb +++ /dev/null @@ -1,40 +0,0 @@ -class ApplicationHelper::Toolbar::XProviderForemanForemanConfiguredSystemCenter < ApplicationHelper::Toolbar::Basic - button_group('record_summary', [ - select( - :provider_foreman_lifecycle_choice, - nil, - t = N_('Lifecycle'), - t, - :enabled => true, - :items => [ - button( - :provider_foreman_configured_system_provision, - 'pficon pficon-add-circle-o fa-lg', - t = N_('Provision Configured System'), - t, - :url => "provision", - :url_parms => "main_div", - :send_checked => true, - :enabled => true), - ] - ), - select( - :provider_foreman_policy_choice, - nil, - t = N_('Policy'), - t, - :enabled => true, - :items => [ - button( - :configured_system_tag, - 'pficon pficon-edit fa-lg', - N_('Edit Tags for this Configured System'), - N_('Edit Tags'), - :url => "tagging", - :url_parms => "main_div", - :send_checked => true, - :enabled => true), - ] - ), - ]) -end diff --git a/app/helpers/application_helper/toolbar_chooser.rb b/app/helpers/application_helper/toolbar_chooser.rb index 8e0d463a745..c9d5ae0826a 100644 --- a/app/helpers/application_helper/toolbar_chooser.rb +++ b/app/helpers/application_helper/toolbar_chooser.rb @@ -17,8 +17,6 @@ def x_view_toolbar_filename nil elsif @layout == 'report' @report ? "report_view_tb" : nil - elsif @layout == 'provider_foreman' - @showtype == 'main' ? "x_summary_view_tb" : "x_gtl_view_tb" elsif %w[vm_infra vm_cloud].include?(@layout) @showtype == 'main' ? 'x_summary_view_tb' : nil elsif @layout == 'automation_manager' @@ -90,8 +88,6 @@ def center_toolbar_name_vm_or_template def center_toolbar_filename_explorer if %w[vm_cloud vm_infra vm_or_template].include?(@layout) center_toolbar_name_vm_or_template - elsif @layout == "provider_foreman" && %i[configuration_manager_providers_tree configuration_manager_cs_filter_tree].include?(x_active_tree) - center_toolbar_filename_configuration_manager_providers elsif @layout == "automation_manager" center_toolbar_filename_automation_manager elsif x_active_tree == :ae_tree @@ -530,16 +526,6 @@ def x_node_split x_node.split('-') end - def center_toolbar_filename_configuration_manager_providers - if x_active_tree == :configuration_manager_providers_tree - configuration_manager_providers_tree_center_tb(x_node_split) - elsif x_active_tree == :configuration_manager_cs_filter_tree - cs_filter_tree_center_tb(x_node_split) - elsif x_active_tree == :configuration_scripts_tree - configuration_scripts_tree_center_tb(x_node_split) - end - end - def center_toolbar_filename_automation_manager case x_active_tree when :automation_manager_providers_tree @@ -563,7 +549,6 @@ def configuration_manager_providers_tree_center_tb(nodes) when "cp" then "unassigned_profiles_group_center_tb" else "configuration_manager_providers_center_tb" end - else unassigned_configuration_profile_node(nodes) end end @@ -622,10 +607,6 @@ def inventory_group_center_tb end end - def unassigned_configuration_profile_node(nodes) - configuration_profile_center_tb if nodes[2] == "unassigned" - end - NO_GTL_VIEW_BUTTONS = %w[chargeback generic_object generic_object_definition @@ -636,7 +617,6 @@ def unassigned_configuration_profile_node(nodes) miq_policy miq_policy_rsop ops - provider_foreman pxe report].to_set.freeze diff --git a/app/helpers/provider_configuration_manager_helper.rb b/app/helpers/provider_configuration_manager_helper.rb deleted file mode 100644 index 0181756e392..00000000000 --- a/app/helpers/provider_configuration_manager_helper.rb +++ /dev/null @@ -1,41 +0,0 @@ -module ProviderConfigurationManagerHelper - include TextualMixins::TextualGroupTags - - def textual_group_properties - %i[hostname - ipmi_present - ipaddress - mac_address - provider_name - zone] - end - - def textual_hostname - {:label => _("Hostname"), - :icon => "ff ff-configured-system", - :value => @record.hostname, } - end - - def textual_ipmi_present - {:label => _("IPMI Present"), :value => @record.ipmi_present} - end - - def textual_ipaddress - {:label => _("IP Address"), :value => @record.ipaddress} - end - - def textual_mac_address - {:label => _("Mac address"), :value => @record.mac_address} - end - - def textual_provider_name - {:label => _("Provider"), - :image => @record.configuration_manager.decorate.fileicon, - :value => @record.configuration_manager.try(:name), - :explorer => true} - end - - def textual_zone - {:label => _("Zone"), :value => @record.configuration_manager.my_zone} - end -end diff --git a/app/helpers/provider_foreman_helper.rb b/app/helpers/provider_foreman_helper.rb deleted file mode 100644 index c5a3c3f7d79..00000000000 --- a/app/helpers/provider_foreman_helper.rb +++ /dev/null @@ -1,296 +0,0 @@ -module ProviderForemanHelper - include TextualMixins::TextualGroupTags - - def textual_group_properties - TextualGroup.new( - _("Properties"), - %i[hostname ipmi_present ipaddress mac_address configuration_profile_desc provider_name zone] - ) - end - - def textual_hostname - { - :label => _("Hostname"), - :icon => "ff ff-configured-system", - :value => @record.hostname, - } - end - - def textual_ipmi_present - {:label => _("IPMI Present"), :value => @record.ipmi_present} - end - - def textual_ipaddress - {:label => _("IP Address"), :value => @record.ipaddress} - end - - def textual_mac_address - {:label => _("Mac address"), :value => @record.mac_address} - end - - def textual_configuration_profile_desc - h = { - :label => _("Configuration Profile Description"), - :value => @record.configuration_profile.try(:description), - :explorer => true - } - h[:icon] = "fa fa-list-ul" if @record.configuration_profile - h - end - - def textual_provider_name - { - :label => _("Provider"), - :image => @record.configuration_manager.decorate.fileicon, - :value => @record.configuration_manager.try(:name), - :explorer => true - } - end - - def textual_zone - {:label => _("Zone"), :value => @record.configuration_manager.my_zone} - end - - def textual_group_environment - TextualGroup.new( - _("Environment"), - %i[configuration_environment_name configuration_domain_name configuration_realm_name] - ) - end - - def textual_configuration_environment_name - {:label => _("Environment"), :value => @record.configuration_profile.try(:configuration_environment_name)} - end - - def textual_configuration_domain_name - {:label => _("Domain"), :value => @record.configuration_profile.try(:configuration_domain_name)} - end - - def textual_configuration_realm_name - {:label => _("Realm"), :value => @record.configuration_profile.try(:configuration_realm_name)} - end - - def textual_group_os - TextualGroup.new( - _("Operating System"), - %i[ - configuration_compute_profile_name configuration_architecture_name operating_system_flavor_name - customization_script_medium_name customization_script_ptable_name - ] - ) - end - - def textual_configuration_compute_profile_name - {:label => _("Compute Profile"), :value => @record.configuration_profile.try(:configuration_compute_profile_name)} - end - - def textual_configuration_architecture_name - {:label => _("Architecture"), :value => @record.configuration_profile.try(:configuration_architecture_name)} - end - - def textual_operating_system_flavor_name - {:label => _("OS Information"), :value => @record.configuration_profile.try(:operating_system_flavor_name)} - end - - def textual_customization_script_medium_name - {:label => _("Medium"), :value => @record.configuration_profile.try(:customization_script_medium_name)} - end - - def textual_customization_script_ptable_name - {:label => _("Partition Table"), :value => @record.configuration_profile.try(:customization_script_ptable_name)} - end - - def textual_group_tenancy - TextualGroup.new(_("Tenancy"), %i[configuration_locations_name configuration_organizations_name]) - end - - def textual_configuration_locations_name - { - :label => _("Configuration Location"), - :value => (@record.configuration_profile.try(:configuration_locations) || []).collect(&:name).join(", ") - } - end - - def textual_configuration_organizations_name - { - :label => _("Configuration Organization"), - :value => (@record.configuration_profile.try(:configuration_organizations) || []).collect(&:name).join(", ") - } - end - - def textual_configuration_profile_group_properties - %i[configuration_profile_name - configuration_profile_region - configuration_profile_zone] - end - - def textual_configuration_profile_name - {:label => _("Name"), :value => @record.name} - end - - def textual_configuration_profile_region - {:label => _("Region"), :value => @record.region_description} - end - - def textual_configuration_profile_zone - {:label => _("Zone"), :value => @record.my_zone} - end - - def textual_configuration_profile_group_environment - %i[configuration_profile_environment - configuration_profile_domain - configuration_profile_puppet_realm] - end - - def textual_configuration_profile_environment - {:label => _("Environment"), :value => @record.configuration_environment_name} - end - - def textual_configuration_profile_domain - {:label => _("Domain"), :value => @record.configuration_domain_name} - end - - def textual_configuration_profile_puppet_realm - {:label => _("Puppet Realm"), :value => @record.configuration_realm_name} - end - - def textual_configuration_profile_group_os - %i[configuration_profile_compute_profile - configuration_profile_architecture - configuration_profile_os - configuration_profile_medium - configuration_profile_partition_table] - end - - def textual_configuration_profile_compute_profile - {:label => _("Compute Profile"), :value => @record.configuration_compute_profile_name} - end - - def textual_configuration_profile_architecture - {:label => _("Architecture"), :value => @record.configuration_architecture_name} - end - - def textual_configuration_profile_os - {:label => _("OS"), :value => @record.operating_system_flavor_name} - end - - def textual_configuration_profile_medium - {:label => _("Medium"), :value => @record.customization_script_medium_name} - end - - def textual_configuration_profile_partition_table - {:label => _("Partition Table"), :value => @record.customization_script_ptable_name} - end - - def textual_configuration_profile_group_tenancy - %i[configuration_profile_configuration_locations - configuration_profile_configuration_organizations] - end - - def textual_configuration_profile_configuration_locations - { - :label => _("Configuration Location"), - :value => @record.configuration_locations.collect(&:name).join(", ") - } - end - - def textual_configuration_profile_configuration_organizations - { - :label => _("Configuration Organization"), - :value => @record.configuration_organizations.collect(&:name).join(", ") - } - end - - def textual_inventory_group_properties - %i[inventory_group_name - inventory_group_region] - end - - def textual_inventory_group_name - {:label => _("Name"), :value => @record.name} - end - - def textual_inventory_group_region - {:label => _("Region"), :value => @record.region_description} - end - - def textual_inventory_group_architecture - {:label => _("Architecture"), :value => @record.configuration_architecture_name} - end - - def textual__inventory_group_oos - {:label => _("OS"), :value => @record.operating_system_flavor_name} - end - - def textual_inventory_group_medium - {:label => _("Medium"), :value => @record.customization_script_medium_name} - end - - def textual_inventory_group_partition_table - {:label => _("Partition Table"), :value => @record.customization_script_ptable_name} - end - - def textual_configuration_script_group_properties - %i[configuration_script_name - configuration_script_region] - end - - def textual_configuration_script_name - {:label => _("Name"), :value => @record.name} - end - - def textual_configuration_script_region - {:label => _("Region"), :value => @record.region_description} - end - - def textual_configuration_script_variables - textual_variables(@record.variables) - end - - def textual_configuration_script_survey - textual_survey_group(@record.survey_spec['spec']) - end - - def textual_configuration_script_group_os - %i[configuration_script_medium - configuration_script_partition_table] - end - - def textual_survey_group(items) - return unless items - h = {:title => _("Surveys"), - :headers => [_('Question Name'), _('Question Description'), _('Variable'), - _('Type'), _('Min'), _('Max'), _('Default'), _('Required'), _('Choices')], - :col_order => %w[question_name question_description variable type min max default required choices]} - h[:value] = items.collect do |item| - { - :title => item['index'], - :question_name => item['question_name'], - :question_description => item['question_description'], - :variable => item['variable'], - :type => item['type'], - :min => item['min'], - :max => item['max'], - :default => item['default'], - :required => item['required'], - :choices => item['choices'] - } - end - h - end - - def textual_variables(vars) - return unless vars - h = {:label => _("Variables"), - :headers => [_('Name'), _('Value')], - :col_order => %w[name value]} - h[:value] = vars.collect do |item| - { - :name => item[0].to_s, - :value => item[1].to_s - } - end - h - end -end -# diff --git a/app/presenters/menu/default_menu.rb b/app/presenters/menu/default_menu.rb index e4e64014d50..e8a9f639df9 100644 --- a/app/presenters/menu/default_menu.rb +++ b/app/presenters/menu/default_menu.rb @@ -13,7 +13,6 @@ def compute_menu_section def configuration_menu_section Menu::Section.new(:conf, N_("Configuration"), 'fa fa-cog', [ - Menu::Item.new('provider_foreman', N_('Management'), 'provider_foreman_explorer', {:feature => 'provider_foreman_explorer', :any => true}, '/provider_foreman/explorer'), Menu::Item.new('configuration_manager', N_('Providers'), 'configuration_manager', {:feature => 'configuration_manager_show_list'}, '/configuration_manager/show_list'), Menu::Item.new('configuration_profile', N_('Profiles'), 'configuration_profile', {:feature => 'configuration_profile_show_list'}, '/configuration_profile/show_list'), Menu::Item.new('configured_system', N_('Configured Systems'), 'configured_system', {:feature => 'configured_system_show_list'}, '/configured_system/show_list'), diff --git a/app/presenters/tree_builder.rb b/app/presenters/tree_builder.rb index 6cbb019e46a..0094671e229 100644 --- a/app/presenters/tree_builder.rb +++ b/app/presenters/tree_builder.rb @@ -476,10 +476,8 @@ def prefixed_title(prefix, title) "e" => "ExtManagementSystem", "ev" => "MiqEventDefinition", "c" => "EmsCluster", - "csf" => "ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem", "csa" => "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfiguredSystem", "f" => "EmsFolder", - "fr" => "ManageIQ::Providers::Foreman::ConfigurationManager", "g" => "MiqGroup", "gd" => "GuestDevice", "god" => "GenericObjectDefinition", diff --git a/app/presenters/tree_builder_configuration_manager.rb b/app/presenters/tree_builder_configuration_manager.rb deleted file mode 100644 index f080b4db4d3..00000000000 --- a/app/presenters/tree_builder_configuration_manager.rb +++ /dev/null @@ -1,58 +0,0 @@ -class TreeBuilderConfigurationManager < TreeBuilder - has_kids_for ManageIQ::Providers::ConfigurationManager, [:x_get_tree_cmf_kids] - has_kids_for ConfigurationProfile, [:x_get_tree_cpf_kids] - - private - - def tree_init_options - {:lazy => true} - end - - def root_options - { - :text => t = _("All Configuration Manager Providers"), - :tooltip => t - } - end - - # Get root nodes count/array for explorer tree - def x_get_tree_roots - count_only_or_objects_filtered(false, ManageIQ::Providers::ConfigurationManager, "name") - end - - def node_by_tree_id(id) - # Creating empty record to show items under unassigned profiles group - super(id) || ConfigurationProfile.new - end - - def x_get_tree_cmf_kids(object, count_only) - assigned_configuration_profile_objs = - count_only_or_objects_filtered(count_only, - ConfigurationProfile.where(:manager_id => object[:id]), - "name") - unassigned_configuration_profile_objs = - fetch_unassigned_configuration_profile_objects(count_only, object[:id]) - - assigned_configuration_profile_objs + unassigned_configuration_profile_objs - end - - # Note: a lot of logic / queries to determine if should display menu item - def fetch_unassigned_configuration_profile_objects(count_only, configuration_manager_id) - unprovisioned_configured_systems = ConfiguredSystem.where(:configuration_profile_id => nil, - :manager_id => configuration_manager_id) - unprovisioned_configured_systems_filtered = Rbac.filtered(unprovisioned_configured_systems) - if unprovisioned_configured_systems_filtered.count > 0 - unassigned_id = "#{configuration_manager_id}-unassigned" - unassigned_configuration_profile = - [ConfigurationProfile.new(:name => "Unassigned Profiles Group|#{unassigned_id}", - :manager_id => configuration_manager_id)] - end - count_only_or_objects(count_only, unassigned_configuration_profile || []) - end - - def x_get_tree_cpf_kids(object, count_only) - configured_systems = ConfiguredSystem.where(:configuration_profile_id => object[:id], - :manager_id => object[:manager_id]) - count_only_or_objects_filtered(count_only, configured_systems, "hostname") - end -end diff --git a/app/presenters/tree_builder_configuration_manager_configured_systems.rb b/app/presenters/tree_builder_configuration_manager_configured_systems.rb deleted file mode 100644 index 57e75f4ea72..00000000000 --- a/app/presenters/tree_builder_configuration_manager_configured_systems.rb +++ /dev/null @@ -1,24 +0,0 @@ -class TreeBuilderConfigurationManagerConfiguredSystems < TreeBuilderConfiguredSystems - def initialize(*args) - @root_class = 'ConfiguredSystem' - super(*args) - end - - private - - def root_options - { - :text => t = _("All Configured Systems"), - :tooltip => t - } - end - - def configured_systems - { - :id => "csf", - :text => t = _("%{name} Configured Systems") % {:name => ui_lookup(:ui_title => 'foreman')}, - :icon => "pficon pficon-folder-close", - :tip => t - } - end -end diff --git a/app/presenters/tree_builder_configured_systems.rb b/app/presenters/tree_builder_configured_systems.rb deleted file mode 100644 index ad37b7100b9..00000000000 --- a/app/presenters/tree_builder_configured_systems.rb +++ /dev/null @@ -1,20 +0,0 @@ -class TreeBuilderConfiguredSystems < TreeBuilder - include TreeBuilderFiltersMixin - - private - - def tree_init_options - {:allow_reselect => true} - end - - def x_get_tree_custom_kids(object, count_only) - count_only_or_filter_kids(@root_class, object, count_only) - end - - # Get root nodes count/array for explorer tree - def x_get_tree_roots - objects = [] - objects.push(configured_systems) - count_only_or_objects(false, objects + FILTERS.values) - end -end diff --git a/app/presenters/tree_node/node.rb b/app/presenters/tree_node/node.rb index 87727796ad3..a61fb6dffe4 100644 --- a/app/presenters/tree_node/node.rb +++ b/app/presenters/tree_node/node.rb @@ -31,7 +31,6 @@ def key else base_class = @object.class.base_model.name # i.e. Vm or MiqTemplate base_class = "Datacenter" if base_class == "EmsFolder" && @object.kind_of?(::Datacenter) - base_class = "ManageIQ::Providers::Foreman::ConfigurationManager" if @object.kind_of?(ManageIQ::Providers::Foreman::ConfigurationManager) base_class = "ManageIQ::Providers::AnsibleTower::AutomationManager" if @object.kind_of?(ManageIQ::Providers::AnsibleTower::AutomationManager) prefix = TreeBuilder.get_prefix_for_model(base_class) cid = @object.id diff --git a/app/views/provider_foreman/_configscript_service_dialog.html.haml b/app/views/provider_foreman/_configscript_service_dialog.html.haml deleted file mode 100644 index 26693d8e130..00000000000 --- a/app/views/provider_foreman/_configscript_service_dialog.html.haml +++ /dev/null @@ -1,17 +0,0 @@ -#form_div - #basic_info_div - = render :partial => "layouts/flash_msg" - - url = url_for_only_path(:action => "cs_form_field_changed", :id => @edit[:rec_id]) - .form-horizontal - .form-group - %label.col-md-2.control-label - = _('Service Dialog Name') - .col-md-8 - = text_field_tag("dialog_name", - "", - :autocomplete => 'off', - :diabled => false, - :class => "form-control", - :maxlength => 255, - "data-miq_observe" => {:interval => '.5', - :url => url}.to_json) diff --git a/app/views/provider_foreman/_configuration_profile.html.haml b/app/views/provider_foreman/_configuration_profile.html.haml deleted file mode 100644 index 1d9b5f80f09..00000000000 --- a/app/views/provider_foreman/_configuration_profile.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -#configuration_profile_form_tabs - %ul.nav.nav-tabs - = miq_tab_header('summary', @sb[:active_tab]) do - = _("Summary") - = miq_tab_header('configured_systems', @sb[:active_tab]) do - = _("Configured Systems") - .tab-content - = miq_tab_content('configured_systems', @sb[:active_tab]) do - - if @sb[:active_tab] == "configured_systems" - = render :partial => "layouts/x_gtl" - :javascript - ManageIQ.afterOnload = "if (miqDomElementExists('adv_searchbox_div')) $('#adv_searchbox_div').show();" - = miq_tab_content('summary', @sb[:active_tab]) do - - if @sb[:active_tab] == "summary" - = render :partial => "main_configuration_profile" - -:javascript - miq_tabs_init('#configuration_profile_form_tabs', '/provider_foreman/change_tab'); diff --git a/app/views/provider_foreman/_configuration_script.html.haml b/app/views/provider_foreman/_configuration_script.html.haml deleted file mode 100644 index 1e2e8495ee2..00000000000 --- a/app/views/provider_foreman/_configuration_script.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -= render :partial => "layouts/flash_msg" -.row - .col-md-12.col-lg-8 - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_configuration_script_group_properties), @record) - .col-md-12.col-lg-8 - = react 'TableListViewWrapper', TextualListview.data(textual_configuration_script_variables) - .col-md-12.col-lg-8 - - if @record.survey_spec['spec'] - = react 'TableListViewWrapper', TextualListview.data(textual_configuration_script_survey) diff --git a/app/views/provider_foreman/_form.html.haml b/app/views/provider_foreman/_form.html.haml deleted file mode 100644 index 0841f0eb0fb..00000000000 --- a/app/views/provider_foreman/_form.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -= render :partial => 'configuration_manager/shared_form' - -:javascript - ManageIQ.angular.app.value('configurationManagerFormId', '#{@provider_manager.id || "new"}'); - ManageIQ.angular.app.value('url', '/provider_foreman'); - ManageIQ.angular.app.value('modelName', 'providerForemanModel'); - miq_bootstrap('#form_div'); diff --git a/app/views/provider_foreman/_inventory_group.html.haml b/app/views/provider_foreman/_inventory_group.html.haml deleted file mode 100644 index 83c872f7c44..00000000000 --- a/app/views/provider_foreman/_inventory_group.html.haml +++ /dev/null @@ -1,18 +0,0 @@ -#inventory_group_form_tabs - %ul.nav.nav-tabs - = miq_tab_header('summary', @sb[:active_tab]) do - = _("Summary") - = miq_tab_header('configured_systems', @sb[:active_tab]) do - = _("Configured Systems") - .tab-content - = miq_tab_content('configured_systems', @sb[:active_tab]) do - - if @sb[:active_tab] == "configured_systems" - = render :partial => "layouts/x_gtl" - :javascript - ManageIQ.afterOnload = "if (miqDomElementExists('adv_searchbox_div')) $('#adv_searchbox_div').show();" - = miq_tab_content('summary', @sb[:active_tab]) do - - if @sb[:active_tab] == "summary" - = render :partial => "main_inventory_group" - -:javascript - miq_tabs_init('#inventory_group_form_tabs', '/provider_foreman/change_tab'); diff --git a/app/views/provider_foreman/_main_configuration_profile.html.haml b/app/views/provider_foreman/_main_configuration_profile.html.haml deleted file mode 100644 index cf142cc560d..00000000000 --- a/app/views/provider_foreman/_main_configuration_profile.html.haml +++ /dev/null @@ -1,8 +0,0 @@ -= render :partial => "layouts/flash_msg" -.row - .col-md-12.col-lg-6 - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_configuration_profile_group_properties), @record) - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Environment'), textual_configuration_profile_group_environment), @record) - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Operating System'), textual_configuration_profile_group_os), @record) - .col-md-12.col-lg-6 - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Tenancy'), textual_configuration_profile_group_tenancy), @record) diff --git a/app/views/provider_foreman/_main_inventory_group.html.haml b/app/views/provider_foreman/_main_inventory_group.html.haml deleted file mode 100644 index a30e4dd859b..00000000000 --- a/app/views/provider_foreman/_main_inventory_group.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -= render :partial => "layouts/flash_msg" -.row - .col-md-12.col-lg-6 - = react 'GenericGroupWrapper', expand_generic_group(TextualGroup.new(_('Properties'), textual_inventory_group_properties), @record) diff --git a/app/views/provider_foreman/explorer.html.haml b/app/views/provider_foreman/explorer.html.haml deleted file mode 100644 index 429d68ecb50..00000000000 --- a/app/views/provider_foreman/explorer.html.haml +++ /dev/null @@ -1,32 +0,0 @@ -- content_for :search do - = render(:partial => "layouts/x_adv_searchbox", :locals => {:nameonly => controller.provider_active_tree?}) - = render(:partial => 'layouts/quick_search') - -= render(:partial => 'shared/provider_paused', :locals => {:record => @record}) - --# These are the initial divs that will go inside center_cell_div -- if @configuration_profile_record - #main_div - - @pages = nil if @sb[:active_tab] == 'summary' - = render(:partial => 'provider_foreman/configuration_profile') -- elsif @inventory_group_record - #main_div - - @pages = nil if @sb[:active_tab] == 'summary' - = render(:partial => 'provider_foreman/inventory_group') - -- elsif @configured_system_record - #main_div - = render :partial => "layouts/textual_groups_generic" -- elsif @configuration_script_record - #main_div - = render(:partial => 'provider_foreman/configuration_script', :locals => {:controller => "provider_foreman"}) -- else - #main_div - - if ManageIQ::Providers::ConfigurationManager.none? && provider_active_tree? - = render :partial => 'layouts/empty', - :locals => {:add_message => _("Add a new Configuration Management Provider"), - :documentation => ::Settings.docs.configuration_provider} - - else - = render(:partial => 'layouts/x_gtl') - - diff --git a/app/views/provider_foreman/show.html.haml b/app/views/provider_foreman/show.html.haml deleted file mode 100644 index 1cbcf0e501d..00000000000 --- a/app/views/provider_foreman/show.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -= render(:partial => 'shared/provider_paused', :locals => {:record => @record}) - -#main_div - = render(:partial => 'layouts/x_gtl') diff --git a/product/views/ManageIQ_Providers_ConfigurationManager.yaml b/product/views/ManageIQ_Providers_ConfigurationManager.yaml index b48a21449dc..7919654548a 100644 --- a/product/views/ManageIQ_Providers_ConfigurationManager.yaml +++ b/product/views/ManageIQ_Providers_ConfigurationManager.yaml @@ -12,7 +12,7 @@ title: Providers # Menu name -name: ConfigurationManagerForeman +name: ConfigurationManager # Main DB table report is based on db: ManageIQ::Providers::ConfigurationManager diff --git a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager.yaml b/product/views/ManageIQ_Providers_Foreman_ConfigurationManager.yaml deleted file mode 100644 index 2525a1e367f..00000000000 --- a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager.yaml +++ /dev/null @@ -1,103 +0,0 @@ -# -# This is an MIQ Report configuration file -# Single value parameters are specified as: -# single_value_parm: value -# Multiple value parameters are specified as: -# multi_value_parm: -# - value 1 -# - value 2 -# - -# Report title -title: Providers - -# Menu name -name: ConfigurationManagerForeman - -# Main DB table report is based on -db: ManageIQ::Providers::Foreman::ConfigurationManager - -# Columns to fetch from the main table -cols: -- name -- url -- type -- last_refresh_date -- region_description -- authentication_status -- total_configuration_profiles -- total_configured_systems - -# Included tables (joined, has_one, has_many) and columns -include: - zone: - columns: - - name - endpoints: - columns: - - url - -# Included tables and columns for query performance -include_for_find: - -# Order of columns (from all tables) -col_order: -- name -- url -- type -- zone.name -- last_refresh_date -- region_description -- authentication_status -- total_configuration_profiles -- total_configured_systems - -# Column titles, in order -headers: -- Provider Name -- URL -- Type -- Zone -- Last Refresh Date -- Region Description -- Status -- Total Configuration Profiles -- Total Configured Systems - -col_formats: -- -- -- :model_name -- -- -- - -# Condition(s) string for the SQL query -conditions: - -# Order string for the SQL query -order: Ascending - -# Columns to sort the report on, in order -sortby: -- name - -# Group rows (y=yes,n=no,c=count) -group: n - -# Graph type -# Bar -# Column -# ColumnThreed -# ParallelThreedColumn -# Pie -# PieThreed -# StackedBar -# StackedColumn -# StackedThreedColumn - -graph: - -# Dimensions of graph (1 or 2) -# Note: specifying 2 for a single dimension graph may not return expected results -dims: diff --git a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfigurationProfile.yaml b/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfigurationProfile.yaml deleted file mode 100644 index 498cc1af6e1..00000000000 --- a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfigurationProfile.yaml +++ /dev/null @@ -1,83 +0,0 @@ -# -# This is an MIQ Report configuration file -# Single value parameters are specified as: -# single_value_parm: value -# Multiple value parameters are specified as: -# multi_value_parm: -# - value 1 -# - value 2 -# - -# Report title -title: ConfigurationProfile - -# Menu name -name: ConfigurationProfile - -# Main DB table report is based on -db: ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile - -# Columns to fetch from the main table -cols: -- description -- total_configured_systems -- configuration_environment_name -- my_zone -- region_description - -# Included tables (joined, has_one, has_many) and columns - -# Included tables and columns for query performance - -# Order of columns (from all tables) -col_order: -- description -- total_configured_systems -- configuration_environment_name -- my_zone -- region_description - -# Column titles, in order -headers: -- Description -- Total Configured Systems -- Environment -- Zone -- Region - -col_formats: -- -- -- -- -- - -# Condition(s) string for the SQL query -conditions: - -# Order string for the SQL query -order: Ascending - -# Columns to sort the report on, in order -sortby: -- description - -# Group rows (y=yes,n=no,c=count) -group: n - -# Graph type -# Bar -# Column -# ColumnThreed -# ParallelThreedColumn -# Pie -# PieThreed -# StackedBar -# StackedColumn -# StackedThreedColumn - -graph: - -# Dimensions of graph (1 or 2) -# Note: specifying 2 for a single dimension graph may not return expected results -dims: diff --git a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfiguredSystem.yaml b/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfiguredSystem.yaml deleted file mode 100644 index 7c20aefadef..00000000000 --- a/product/views/ManageIQ_Providers_Foreman_ConfigurationManager_ConfiguredSystem.yaml +++ /dev/null @@ -1,88 +0,0 @@ -# -# This is an MIQ Report configuration file -# Single value parameters are specified as: -# single_value_parm: value -# Multiple value parameters are specified as: -# multi_value_parm: -# - value 1 -# - value 2 -# - -# Report title -title: ConfiguredSystem - -# Menu name -name: ConfiguredSystems - -# Main DB table report is based on -db: ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem - -# Columns to fetch from the main table -cols: -- hostname -- type -- last_checkin -- build_state -- my_zone -- configuration_environment_name -- configuration_profile_name - -# Included tables (joined, has_one, has_many) and columns -include: - -# Order of columns (from all tables) -col_order: -- hostname -- type -- last_checkin -- build_state -- my_zone -- configuration_environment_name -- configuration_profile_name - -# Column titles, in order -headers: -- Hostname -- Type -- Last Checkin -- Build State -- Zone -- Environment -- Configuration Profile - -col_formats: -- -- :model_name -- -- -- - -# Condition(s) string for the SQL query -conditions: - -# Order string for the SQL query -order: Ascending - -# Columns to sort the report on, in order -sortby: -- hostname - -# Group rows (y=yes,n=no,c=count) -group: n - -# Graph type -# Bar -# Column -# ColumnThreed -# ParallelThreedColumn -# Pie -# PieThreed -# StackedBar -# StackedColumn -# StackedThreedColumn - -graph: - -# Dimensions of graph (1 or 2) -# Note: specifying 2 for a single dimension graph may not return expected results -dims: From c40dd5e5cc81894b88de3dcd36bf551a0127bcb9 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Tue, 24 Mar 2020 15:08:11 -0400 Subject: [PATCH 11/33] show gtl toolbar buttons on new screens --- app/helpers/application_helper.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index f55e6634cc3..39ad3fe217c 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1073,7 +1073,10 @@ def pdf_page_size_style cloud_volume_type condition configuration_job + configuration_manager + configuration_profile configuration_script_source + configured_system container container_build container_dashboard From a96ff9db860867a169e60a64189532555c0a6567 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Tue, 24 Mar 2020 16:15:39 -0400 Subject: [PATCH 12/33] Addressing rubocop warnings --- app/controllers/application_controller/explorer.rb | 2 +- app/controllers/configured_system_controller.rb | 4 ++-- app/helpers/configuration_manager_helper/textual_summary.rb | 4 +++- app/helpers/configured_system_helper/textual_summary.rb | 1 - app/presenters/menu/default_menu.rb | 6 +++--- app/views/configuration_manager/new.html.haml | 1 - 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller/explorer.rb b/app/controllers/application_controller/explorer.rb index 0dd7bd727a3..7326fcf78d6 100644 --- a/app/controllers/application_controller/explorer.rb +++ b/app/controllers/application_controller/explorer.rb @@ -43,7 +43,7 @@ def x_history 'start' => :s1, 'stop' => :s1, 'suspend' => :s1, 'reset' => :s1, 'terminate' => :s1, 'pause' => :s1, 'shelve' => :s1, 'shelve_offload' => :s1, 'chargeback' => :s1, - 'manager_pause' => :s1, 'manager_resume' => :s1, + 'manager_pause' => :s1, 'manager_resume' => :s1, # group 2 'clone' => :s2, 'compare' => :s2, 'drift' => :s2, diff --git a/app/controllers/configured_system_controller.rb b/app/controllers/configured_system_controller.rb index 85f52c83497..a57476bcbf8 100644 --- a/app/controllers/configured_system_controller.rb +++ b/app/controllers/configured_system_controller.rb @@ -45,8 +45,8 @@ def provision :escape => false) else render_flash(n_("No common configuration profiles available for the selected configured system", - "No common configuration profiles available for the selected configured systems", - provisioning_ids.size), :error) + "No common configuration profiles available for the selected configured systems", + provisioning_ids.size), :error) end end diff --git a/app/helpers/configuration_manager_helper/textual_summary.rb b/app/helpers/configuration_manager_helper/textual_summary.rb index ced56be2b08..a28e663a39e 100644 --- a/app/helpers/configuration_manager_helper/textual_summary.rb +++ b/app/helpers/configuration_manager_helper/textual_summary.rb @@ -8,11 +8,13 @@ def textual_group_properties def textual_description return nil if @record.try(:description).blank? + {:label => _("Description"), :value => @record.description} end def textual_region return nil if @record.provider_region.blank? + label_val = _('Region') {:label => label_val, :value => @record.provider_region} end @@ -23,6 +25,7 @@ def textual_hostname def textual_ipaddress return nil if @record.ipaddress.blank? + {:label => _("Discovered IP Address"), :value => @record.ipaddress} end @@ -69,5 +72,4 @@ def textual_group_status def textual_group_tags %i[tags] end - end diff --git a/app/helpers/configured_system_helper/textual_summary.rb b/app/helpers/configured_system_helper/textual_summary.rb index c22fdb61604..947ac1c3af8 100644 --- a/app/helpers/configured_system_helper/textual_summary.rb +++ b/app/helpers/configured_system_helper/textual_summary.rb @@ -117,5 +117,4 @@ def textual_configuration_organizations_name :value => (@record.configuration_profile.try(:configuration_organizations) || []).collect(&:name).join(", ") } end - end diff --git a/app/presenters/menu/default_menu.rb b/app/presenters/menu/default_menu.rb index e8a9f639df9..b0fa7315cbf 100644 --- a/app/presenters/menu/default_menu.rb +++ b/app/presenters/menu/default_menu.rb @@ -13,9 +13,9 @@ def compute_menu_section def configuration_menu_section Menu::Section.new(:conf, N_("Configuration"), 'fa fa-cog', [ - Menu::Item.new('configuration_manager', N_('Providers'), 'configuration_manager', {:feature => 'configuration_manager_show_list'}, '/configuration_manager/show_list'), - Menu::Item.new('configuration_profile', N_('Profiles'), 'configuration_profile', {:feature => 'configuration_profile_show_list'}, '/configuration_profile/show_list'), - Menu::Item.new('configured_system', N_('Configured Systems'), 'configured_system', {:feature => 'configured_system_show_list'}, '/configured_system/show_list'), + Menu::Item.new('configuration_manager', N_('Providers'), 'configuration_manager', {:feature => 'configuration_manager_show_list'}, '/configuration_manager/show_list'), + Menu::Item.new('configuration_profile', N_('Profiles'), 'configuration_profile', {:feature => 'configuration_profile_show_list'}, '/configuration_profile/show_list'), + Menu::Item.new('configured_system', N_('Configured Systems'), 'configured_system', {:feature => 'configured_system_show_list'}, '/configured_system/show_list'), ]) end diff --git a/app/views/configuration_manager/new.html.haml b/app/views/configuration_manager/new.html.haml index 28c2f407243..4b6255b467d 100644 --- a/app/views/configuration_manager/new.html.haml +++ b/app/views/configuration_manager/new.html.haml @@ -1,2 +1 @@ = render :partial => 'configuration_manager/shared_form' - From 88ae1db2def6905a7560b7437d24b1bbb7ee6eaa Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Tue, 24 Mar 2020 18:02:59 -0400 Subject: [PATCH 13/33] Fixed code to load listnav and advanced search for new screens. - also some further deletion of redundant code --- app/controllers/application_controller/advanced_search.rb | 5 +---- .../mixins/automation_manager_controller_mixin.rb | 2 +- app/controllers/mixins/sandbox.rb | 2 -- app/helpers/application_helper.rb | 2 -- app/helpers/application_helper/listnav.rb | 2 ++ app/helpers/application_helper/page_layouts.rb | 1 + 6 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/controllers/application_controller/advanced_search.rb b/app/controllers/application_controller/advanced_search.rb index 682da67a9c6..7a966adab0c 100644 --- a/app/controllers/application_controller/advanced_search.rb +++ b/app/controllers/application_controller/advanced_search.rb @@ -185,10 +185,7 @@ def adv_search_redraw_listnav_and_main end def adv_search_redraw_left_div - if x_active_tree.to_s == "configuration_manager_cs_filter_tree" - build_accordions_and_trees - load_or_clear_adv_search - elsif @edit[:in_explorer] || %w[storage_tree configuration_scripts_tree svcs_tree].include?(x_active_tree.to_s) + if @edit[:in_explorer] || %w[storage_tree configuration_scripts_tree svcs_tree].include?(x_active_tree.to_s) tree_type = x_active_tree.to_s.sub(/_tree/, '').to_sym builder = TreeBuilder.class_for_type(tree_type) tree = builder.new(x_active_tree, @sb) diff --git a/app/controllers/mixins/automation_manager_controller_mixin.rb b/app/controllers/mixins/automation_manager_controller_mixin.rb index 37a75d8d3b8..ea2d9b03083 100644 --- a/app/controllers/mixins/automation_manager_controller_mixin.rb +++ b/app/controllers/mixins/automation_manager_controller_mixin.rb @@ -251,7 +251,7 @@ def provider_list(id, model) def configured_system_list(id, model) return configured_system_node(id, model) if id - if x_active_tree == :configuration_manager_cs_filter_tree || x_active_tree == :automation_manager_cs_filter_tree + if x_active_tree == :automation_manager_cs_filter_tree options = {:model => model.to_s} @right_cell_text = _("All %{title} Configured Systems") % {:title => self.class.model_to_name(model)} process_show_list(options) diff --git a/app/controllers/mixins/sandbox.rb b/app/controllers/mixins/sandbox.rb index 7a7f8e1793e..1839c9a1c6d 100644 --- a/app/controllers/mixins/sandbox.rb +++ b/app/controllers/mixins/sandbox.rb @@ -49,8 +49,6 @@ def x_active_tree condition_tree containers_tree containers_filter_tree - configuration_manager_cs_filter_tree - configuration_manager_providers_tree customization_templates_tree datacenter_tree datastore_tree diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 39ad3fe217c..ab177081e82 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1187,9 +1187,7 @@ def tree_with_advanced_search? %i[ automation_manager_providers_tree automation_manager_cs_filter_tree - configuration_manager_cs_filter_tree configuration_scripts_tree - configuration_manager_providers_tree images_tree images_filter_tree instances_tree diff --git a/app/helpers/application_helper/listnav.rb b/app/helpers/application_helper/listnav.rb index c7158b21c2b..8fdb8d37e56 100644 --- a/app/helpers/application_helper/listnav.rb +++ b/app/helpers/application_helper/listnav.rb @@ -15,6 +15,8 @@ def render_listnav_filename cloud_volume_snapshot cloud_volume_type configuration_job + configuration_manager + configuration_profile configured_system container container_build diff --git a/app/helpers/application_helper/page_layouts.rb b/app/helpers/application_helper/page_layouts.rb index c2285b0e97b..43b364b8e1c 100644 --- a/app/helpers/application_helper/page_layouts.rb +++ b/app/helpers/application_helper/page_layouts.rb @@ -189,6 +189,7 @@ def show_adv_search? cloud_volume_snapshot cloud_volume_type configuration_job + configuration_manager configured_system container container_build From a22109d112a7006aefc69e106e36c2d369054aa1 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Tue, 24 Mar 2020 18:36:54 -0400 Subject: [PATCH 14/33] Fixed links on list view when viewing objects thru relationships. --- app/helpers/application_helper.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ab177081e82..03c0c0184e8 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -416,8 +416,7 @@ def db_to_controller(db, action = "show") controller = "ansible_credential" when "MiqWorker" controller = request.parameters[:controller] - when "ConfigurationProfile", "ConfiguredSystem", - "OrchestrationStackOutput", "OrchestrationStackParameter", "OrchestrationStackResource", + when "OrchestrationStackOutput", "OrchestrationStackParameter", "OrchestrationStackResource", "ManageIQ::Providers::CloudManager::OrchestrationStack", "ManageIQ::Providers::ConfigurationManager", "ManageIQ::Providers::AnsibleTower::AutomationManager::Job", "ConfigurationScript" From 5e1a1aab34eb366af84c37c46ff4a4f91d308f42 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Wed, 25 Mar 2020 09:11:07 -0400 Subject: [PATCH 15/33] Added filters/Advanced Search Configuration Managers and Profiles lists Removed nameonly search logic from views, this logic was only being used for Configuration Managers and Profiles non-explorer screens --- app/helpers/application_helper.rb | 8 -------- app/views/layouts/_center_div_with_listnav.html.haml | 2 +- 2 files changed, 1 insertion(+), 9 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 03c0c0184e8..4ea9b1eab12 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -648,14 +648,6 @@ def taskbar_in_header? end end - def nameonly_search? - nameonly_search_layouts = %w[ - configuration_manager - configuration_profile - ] - nameonly_search_layouts.include?(@layout) - end - # checking if any of the toolbar is visible def toolbars_visible? (@toolbars['history_tb'] || @toolbars['center_tb'] || @toolbars['view_tb']) && diff --git a/app/views/layouts/_center_div_with_listnav.html.haml b/app/views/layouts/_center_div_with_listnav.html.haml index 13cd6723062..429424290bc 100644 --- a/app/views/layouts/_center_div_with_listnav.html.haml +++ b/app/views/layouts/_center_div_with_listnav.html.haml @@ -18,7 +18,7 @@ = render :partial => 'layouts/tabs' .col-md-5 %br - = render :partial => 'layouts/searchbar', :locals => {:nameonly => nameonly_search?} + = render :partial => 'layouts/searchbar' .row .col-md-12 = yield From 2a09746cb45b7c0f9500754951aff6aeeedadb74 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Wed, 25 Mar 2020 09:59:13 -0400 Subject: [PATCH 16/33] Listnav and Summary screen updates - Added Relationships on Configuration Manager, Profile and Configure System summary screen listnavs - Updated Configured summary screen to show Relationships box. --- .../configured_system_controller.rb | 2 +- .../textual_summary.rb | 44 +++++++++++-------- .../listnav/_configuration_manager.html.haml | 12 +++++ .../listnav/_configuration_profile.html.haml | 11 +++++ .../listnav/_configured_system.html.haml | 10 +++++ 5 files changed, 60 insertions(+), 19 deletions(-) diff --git a/app/controllers/configured_system_controller.rb b/app/controllers/configured_system_controller.rb index a57476bcbf8..93edd867996 100644 --- a/app/controllers/configured_system_controller.rb +++ b/app/controllers/configured_system_controller.rb @@ -51,7 +51,7 @@ def provision end def textual_group_list - [%i[properties environment os], %i[tenancy tags]] + [%i[properties relationships environment], %i[os tenancy tags]] end helper_method :textual_group_list diff --git a/app/helpers/configured_system_helper/textual_summary.rb b/app/helpers/configured_system_helper/textual_summary.rb index 947ac1c3af8..e8c7229f7f1 100644 --- a/app/helpers/configured_system_helper/textual_summary.rb +++ b/app/helpers/configured_system_helper/textual_summary.rb @@ -4,7 +4,7 @@ module ConfiguredSystemHelper::TextualSummary def textual_group_properties TextualGroup.new( _("Properties"), - %i[hostname ipmi_present ipaddress mac_address configuration_profile_desc provider_name zone] + %i[hostname ipmi_present ipaddress mac_address zone] ) end @@ -28,27 +28,35 @@ def textual_mac_address {:label => _("Mac address"), :value => @record.mac_address} end - def textual_configuration_profile_desc - h = { - :label => _("Configuration Profile Description"), - :value => @record.configuration_profile.try(:description), - :explorer => true - } - h[:icon] = "fa fa-list-ul" if @record.configuration_profile - h + def textual_zone + {:label => _("Zone"), :value => @record.configuration_manager.my_zone} end - def textual_provider_name - { - :label => _("Provider"), - :image => @record.configuration_manager.decorate.fileicon, - :value => @record.configuration_manager.try(:name), - :explorer => true - } + def textual_group_relationships + TextualGroup.new( + _("Relationships"), + %i[configuration_manager configuration_profile] + ) end - def textual_zone - {:label => _("Zone"), :value => @record.configuration_manager.my_zone} + def textual_configuration_manager + configuration_manager = @record.configuration_manager + h = {:label => "Configuration Manager", :icon => "pficon pficon-configuration_manager", :value => (configuration_manager.nil? ? _("None") : configuration_manager.name)} + if configuration_manager && role_allows?(:feature => "configuration_manager_show") + h[:title] = _("Show this Configured System's Configuration Manager") + h[:link] = url_for_only_path(:controller => 'configuration_manager', :action => 'show', :id => configuration_manager) + end + h + end + + def textual_configuration_profile + configuration_profile = @record.configuration_profile + h = {:label => "Configuration Profile", :icon => "pficon pficon-configuration_profile", :value => (configuration_profile.nil? ? _("None") : configuration_profile.name)} + if configuration_profile && role_allows?(:feature => "configuration_profile_show") + h[:title] = _("Show this Configured System's Configuration Profile") + h[:link] = url_for_only_path(:controller => 'configuration_profile', :action => 'show', :id => configuration_profile) + end + h end def textual_group_environment diff --git a/app/views/layouts/listnav/_configuration_manager.html.haml b/app/views/layouts/listnav/_configuration_manager.html.haml index a3f84467f28..ff612b69c85 100644 --- a/app/views/layouts/listnav/_configuration_manager.html.haml +++ b/app/views/layouts/listnav/_configuration_manager.html.haml @@ -12,3 +12,15 @@ = miq_accordion_panel(_("Relationships"), false, "stack_rel") do %ul.nav.nav-pills.nav-stacked + - if role_allows?(:feature => "configuration_profile_show_list") + = li_link(:count => @record.number_of(:configuration_profiles), + :record_id => @record.id, + :tables => 'configuration_profiles', + :display => 'configuration_profiles', + :action => 'show') + - if role_allows?(:feature => "configured_system_show_list") + = li_link(:count => @record.number_of(:configured_systems), + :record_id => @record.id, + :tables => 'configured_systems', + :display => 'configured_systems', + :action => 'show') diff --git a/app/views/layouts/listnav/_configuration_profile.html.haml b/app/views/layouts/listnav/_configuration_profile.html.haml index a3f84467f28..080df554a6f 100644 --- a/app/views/layouts/listnav/_configuration_profile.html.haml +++ b/app/views/layouts/listnav/_configuration_profile.html.haml @@ -12,3 +12,14 @@ = miq_accordion_panel(_("Relationships"), false, "stack_rel") do %ul.nav.nav-pills.nav-stacked + - if role_allows?(:feature => "configuration_manager_show") && !@record.configuration_manager.nil? + %li + = link_to(_("Configuration Manager: %{name}") % {:name => @record.configuration_manager.name}, + {:controller => "configuration_manager", :action => 'show', :id => @record.configuration_manager.id}, + :title => _("Show parent Configuration Manager for this Configuration Profile")) + - if role_allows?(:feature => "configured_system_show_list") + = li_link(:count => @record.number_of(:configured_systems), + :record_id => @record.id, + :tables => 'configured_systems', + :display => 'configured_systems', + :action => 'show') diff --git a/app/views/layouts/listnav/_configured_system.html.haml b/app/views/layouts/listnav/_configured_system.html.haml index a3f84467f28..05a3a580724 100644 --- a/app/views/layouts/listnav/_configured_system.html.haml +++ b/app/views/layouts/listnav/_configured_system.html.haml @@ -12,3 +12,13 @@ = miq_accordion_panel(_("Relationships"), false, "stack_rel") do %ul.nav.nav-pills.nav-stacked + - if role_allows?(:feature => "configuration_manager_show") && !@record.configuration_manager.nil? + %li + = link_to(_("Configuration Manager: %{name}") % {:name => @record.configuration_manager.name}, + {:controller => "configuration_manager", :action => 'show', :id => @record.configuration_manager.id}, + :title => _("Show parent Configuration Manager for this Configured System")) + - if role_allows?(:feature => "configuration_profile_show") && !@record.configuration_profile.nil? + %li + = link_to(_("Configuration Profile: %{name}") % {:name => @record.configuration_profile.name}, + {:controller => "configuration_profile", :action => 'show', :id => @record.configuration_profile.id}, + :title => _("Show parent Configuration Profile for this Configured System")) From 694bf6ba45c8cfb8e823ee66968aaa1dad1e2515 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Wed, 25 Mar 2020 11:39:08 -0400 Subject: [PATCH 17/33] Fixed broken spec tests. - Adjusted spec tests to point to new controllers. - Removed redundant commented lines from application_helper --- app/helpers/application_helper.rb | 3 - .../advanced_search_spec.rb | 26 +- .../application_controller/explorer_spec.rb | 18 - .../mixins/manager_controller_mixin_spec.rb | 2 +- .../settings/rbac_roles_spec.rb | 8 +- .../provider_foreman_controller_spec.rb | 645 ------------------ .../restful_redirect_controller_spec.rb | 6 - .../toolbar_chooser_spec.rb | 23 +- spec/helpers/application_helper_spec.rb | 32 +- ...c.rb => automation_manager_helper_spec.rb} | 2 +- ... => configuration_manager_routing_spec.rb} | 24 +- .../listnav/_explorer_html.haml_spec.rb | 4 +- .../provider_foreman/show.html.haml_spec.rb | 13 - 13 files changed, 56 insertions(+), 750 deletions(-) rename spec/helpers/{provider_foreman_helper_spec.rb => automation_manager_helper_spec.rb} (97%) rename spec/routing/{provider_foreman_routing_spec.rb => configuration_manager_routing_spec.rb} (74%) delete mode 100644 spec/views/provider_foreman/show.html.haml_spec.rb diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 4ea9b1eab12..daf36b10ca9 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -238,9 +238,6 @@ def view_to_url(view, parent = nil) if controller == "ems_cloud" && action == "show" return ems_clouds_path end - # if controller == "ems_configuration" && action == "show" - # return configuration_managers_path - # end if controller == "ems_infra" && action == "show" return ems_infras_path end diff --git a/spec/controllers/application_controller/advanced_search_spec.rb b/spec/controllers/application_controller/advanced_search_spec.rb index 85599d2ac76..a50a8a6ce05 100644 --- a/spec/controllers/application_controller/advanced_search_spec.rb +++ b/spec/controllers/application_controller/advanced_search_spec.rb @@ -1,18 +1,20 @@ -describe ProviderForemanController, "::AdvancedSearch" do - before do - stub_user(:features => :all) - controller.instance_variable_set(:@sb, {}) - end +describe ConfigurationManagerController, "::AdvancedSearch" do + let(:expr) { ApplicationController::Filter::Expression.new("=" => exp, :token => 1) } + let(:exp) { {:field => "Some_field", :value => "123"} } - describe "#adv_search_redraw_left_div" do - before { controller.instance_variable_set(:@sb, :active_tree => :configuration_manager_cs_filter_tree) } + describe '#adv_search_button_saveid' do + before do + stub_user(:features => :all) + controller.instance_variable_set(:@edit, :new => {:expression => {"=" => exp}}, :new_search_name => 'filter', :expression => expr) + controller.instance_variable_set(:@expkey, :expression) + end - it "calls build_accordions_and_trees method in Config Mgmt Configured Systems when saving a filter" do - allow(controller).to receive(:adv_search_redraw_listnav_and_main) + subject { controller.instance_variable_get(:@edit)[:expression] } - expect(controller).to receive(:build_accordions_and_trees).and_call_original.once - expect(TreeBuilderConfigurationManagerConfiguredSystems).to receive(:new).and_call_original - controller.send(:adv_search_redraw_left_div) + it 'sets only @edit[@expkey][:exp_last_loaded]' do + controller.send(:adv_search_button_saveid) + expect(subject[:selected]).to be_nil + expect(subject[:exp_last_loaded]).to include(:name => "user_#{session[:userid]}_filter", :description => 'filter', :typ => 'user') end end end diff --git a/spec/controllers/application_controller/explorer_spec.rb b/spec/controllers/application_controller/explorer_spec.rb index a6f123e9020..f3d9149d78a 100644 --- a/spec/controllers/application_controller/explorer_spec.rb +++ b/spec/controllers/application_controller/explorer_spec.rb @@ -79,21 +79,3 @@ end end end - -describe ProviderForemanController do - describe '#replace_search_box' do - let(:presenter) { ExplorerPresenter.new(:active_tree => :configuration_manager_providers_tree) } - - it 'replaces advsearchModal' do - expect(presenter).to receive(:replace).with(:adv_searchbox_div, '') - expect(presenter).not_to receive(:replace).with(:advsearchModal, '') - controller.send(:replace_search_box, presenter, :nameonly => true) - end - - it 'does not replace advsearchModal' do - expect(presenter).to receive(:replace).with(:adv_searchbox_div, '') - expect(presenter).to receive(:replace).with(:advsearchModal, '') - controller.send(:replace_search_box, presenter) - end - end -end diff --git a/spec/controllers/mixins/manager_controller_mixin_spec.rb b/spec/controllers/mixins/manager_controller_mixin_spec.rb index 73bd78b016f..5ae1fa1bfad 100644 --- a/spec/controllers/mixins/manager_controller_mixin_spec.rb +++ b/spec/controllers/mixins/manager_controller_mixin_spec.rb @@ -1,6 +1,6 @@ describe Mixins::ManagerControllerMixin do describe '#replace_right_cell' do - let(:controller) { ProviderForemanController.new } + let(:controller) { AutomationManagerController.new } before do allow(controller).to receive(:leaf_record) diff --git a/spec/controllers/ops_controller/settings/rbac_roles_spec.rb b/spec/controllers/ops_controller/settings/rbac_roles_spec.rb index d7be0ef50ee..0e95d3ab2c4 100644 --- a/spec/controllers/ops_controller/settings/rbac_roles_spec.rb +++ b/spec/controllers/ops_controller/settings/rbac_roles_spec.rb @@ -2,7 +2,7 @@ before do EvmSpecHelper.seed_specific_product_features( %w(vm vm_compare vm_delete instance instance_delete image image_delete miq_template - miq_template_delete provider_foreman_explorer provider_foreman_view) + miq_template_delete configuration_manager_show_list) ) end @@ -41,10 +41,10 @@ end end context '"_tab_conf" feature node' do - it 'yields features including "provider_foreman_view"' do + it 'yields features including "configuration_manager_show_list"' do expect do |b| - controller.send(:recurse_sections_and_features, '_tab_conf', &b) - end.to yield_successive_args(["provider_foreman_explorer", include("provider_foreman_view")]) + controller.send(:recurse_sections_and_features, 'configuration_manager', &b) + end.to yield_successive_args(["configuration_manager", include("configuration_manager_show_list")]) end end context '"vm" feature node' do diff --git a/spec/controllers/provider_foreman_controller_spec.rb b/spec/controllers/provider_foreman_controller_spec.rb index a9ae38c5a5d..e69de29bb2d 100644 --- a/spec/controllers/provider_foreman_controller_spec.rb +++ b/spec/controllers/provider_foreman_controller_spec.rb @@ -1,645 +0,0 @@ -describe ProviderForemanController do - render_views - - let(:tags) { ["/managed/quota_max_memory/2048"] } - - before do - allow(controller).to receive(:data_for_breadcrumbs).and_return({}) - @zone = EvmSpecHelper.local_miq_server.zone - Tag.find_or_create_by(:name => tags.first) - - @provider = ManageIQ::Providers::Foreman::Provider.create(:name => "testForeman", :url => "10.8.96.102", :zone => @zone) - @config_mgr = ManageIQ::Providers::Foreman::ConfigurationManager.find_by(:provider_id => @provider.id) - @config_profile = ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile.create(:name => "testprofile", - :description => "testprofile", - :manager_id => @config_mgr.id) - @config_profile2 = ManageIQ::Providers::Foreman::ConfigurationManager::ConfigurationProfile.create(:name => "testprofile2", - :description => "testprofile2", - :manager_id => @config_mgr.id) - @configured_system = ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "test_configured_system", - :configuration_profile_id => @config_profile.id, - :manager_id => @config_mgr.id) - @configured_system2a = ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "test2a_configured_system", - :configuration_profile_id => @config_profile2.id, - :manager_id => @config_mgr.id) - @configured_system2b = ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "test2b_configured_system", - :configuration_profile_id => @config_profile2.id, - :manager_id => @config_mgr.id) - @configured_system_unprovisioned = - ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "configured_system_unprovisioned", - :configuration_profile_id => nil, - :manager_id => @config_mgr.id) - - @provider2 = ManageIQ::Providers::Foreman::Provider.create(:name => "test2Foreman", :url => "10.8.96.103", :zone => @zone) - @config_mgr2 = ManageIQ::Providers::Foreman::ConfigurationManager.find_by(:provider_id => @provider2.id) - @configured_system_unprovisioned2 = - ManageIQ::Providers::Foreman::ConfigurationManager::ConfiguredSystem.create(:hostname => "configured_system_unprovisioned2", - :configuration_profile_id => nil, - :manager_id => @config_mgr2.id) - controller.instance_variable_set(:@sb, :active_tree => :configuration_manager_providers_tree) - - [@configured_system, @configured_system2a, @configured_system2b, @configured_system_unprovisioned2].each do |cs| - cs.tag_with(tags, :namespace => '') - end - end - - it "renders index" do - stub_user(:features => :all) - get :index - expect(response.status).to eq(302) - expect(response).to redirect_to(:action => 'explorer') - end - - it "renders explorer" do - login_as user_with_feature(%w(providers_accord configured_systems_filter_accord)) - - get :explorer - accords = controller.instance_variable_get(:@accords) - expect(accords.size).to eq(2) - breadcrumbs = controller.instance_variable_get(:@breadcrumbs) - expect(breadcrumbs[0]).to include(:url => '/provider_foreman/show_list') - expect(response.status).to eq(200) - expect(response.body).to_not be_empty - end - - it "renders explorer sorted by url" do - login_as user_with_feature(%w(providers_accord configured_systems_filter_accord)) - FactoryBot.create(:provider_foreman, :name => "foremantest1", :url => "z_url") - FactoryBot.create(:provider_foreman, :name => "foremantest2", :url => "a_url") - - get :explorer, :params => {:sortby => '2'} - expect(response.status).to eq(200) - expect(response.body).to include("modelName: 'ManageIQ::Providers::ConfigurationManager'") - expect(response.body).to include("activeTree: 'configuration_manager_providers_tree'") - expect(response.body).to include("gtlType: 'list'") - expect(response.body).to include("isExplorer: 'true' === 'true' ? true : false") - expect(response.body).to include("showUrl: '/provider_foreman/x_show/'") - end - - context "renders explorer based on RBAC" do - it "renders explorer based on RBAC access to feature 'configured_system_tag'" do - login_as user_with_feature %w(configured_system_tag) - - get :explorer - accords = controller.instance_variable_get(:@accords) - expect(accords.size).to eq(1) - expect(accords[0][:name]).to eq("configuration_manager_cs_filter") - expect(response.status).to eq(200) - expect(response.body).to_not be_empty - end - - it "renders explorer based on RBAC access to feature 'provider_foreman_add_provider'" do - login_as user_with_feature %w(provider_foreman_add_provider) - - get :explorer - accords = controller.instance_variable_get(:@accords) - expect(accords.size).to eq(1) - expect(accords[0][:name]).to eq("configuration_manager_providers") - expect(response.status).to eq(200) - expect(response.body).to_not be_empty - end - end - - context "asserts correct privileges" do - before { login_as user_with_feature %w[configured_system_provision] } - - it "should not raise an error for feature that user has access to" do - expect { controller.send(:assert_privileges, "configured_system_provision") }.not_to raise_error - end - - it "should raise an error for feature that user has access to" do - expect { controller.send(:assert_privileges, "provider_foreman_add_provider") } - .to raise_error(MiqException::RbacPrivilegeException) - end - end - - it "renders show_list" do - stub_user(:features => :all) - get :show_list - expect(response.status).to eq(302) - expect(response.body).to_not be_empty - end - - it "renders a new page" do - post :new, :format => :js - expect(response.status).to eq(200) - end - - context "Verify the provisionable flag for CSs" do - it "Provision action should not be allowed only for a Configured System marked as not provisionable" do - allow(controller).to receive(:x_node).and_return("root") - allow(controller).to receive(:x_tree).and_return(:type => :filter) - controller.params = {:id => "configuration_manager_cs_filter"} - allow(controller).to receive(:replace_right_cell) - allow(controller).to receive(:render) - controller.params = {:id => @configured_system2a.id} - controller.send(:provision) - expect(controller.send(:flash_errors?)).to_not be_truthy - end - end - - it "#save_provider_foreman will not save with a duplicate name" do - ManageIQ::Providers::Foreman::Provider.create(:name => "test2Foreman", :url => "server1", :zone => @zone) - provider2 = ManageIQ::Providers::Foreman::Provider.new(:name => "test2Foreman", :url => "server2", :zone => @zone) - controller.instance_variable_set(:@provider, provider2) - allow(controller).to receive(:render_flash) - controller.save_provider - expect(assigns(:flash_array).last[:message]).to include("Name has already been taken") - end - - describe "#edit" do - before { stub_user(:features => :all) } - - it "renders the edit page when the configuration manager id is supplied" do - post :edit, :params => { :id => @config_mgr.id } - expect(response.status).to eq(200) - right_cell_text = controller.instance_variable_get(:@right_cell_text) - expect(right_cell_text).to eq("Edit Provider") - end - - it "should display the zone field" do - new_zone = FactoryBot.create(:zone) - controller.instance_variable_set(:@provider, @provider) - post :edit, :params => { :id => @config_mgr.id } - expect(response.status).to eq(200) - expect(response.body).to include("option value=\\\"#{new_zone.name}\\\"") - end - - it "should save the zone field" do - new_zone = FactoryBot.create(:zone) - controller.instance_variable_set(:@provider, @provider) - allow(controller).to receive(:leaf_record).and_return(false) - post :edit, :params => { :button => 'save', - :id => @config_mgr.id, - :zone => new_zone.name, - :url => @provider.url, - :verify_ssl => @provider.verify_ssl } - expect(response.status).to eq(200) - expect(@provider.zone).to eq(new_zone) - end - - it "should save the verify_ssl flag" do - controller.instance_variable_set(:@provider, @provider) - allow(controller).to receive(:leaf_record).and_return(false) - [true, false].each do |verify_ssl| - post :edit, :params => { :button => 'save', - :id => @config_mgr.id, - :url => @provider.url, - :verify_ssl => verify_ssl.to_s } - expect(response.status).to eq(200) - expect(@provider.verify_ssl).to eq(verify_ssl ? 1 : 0) - end - end - - it "renders the edit page when the configuration manager id is selected from a list view" do - post :edit, :params => { :miq_grid_checks => @config_mgr.id } - expect(response.status).to eq(200) - end - - it "renders the edit page when the configuration manager id is selected from a grid/tile" do - post :edit, :params => { "check_#{@config_mgr.id}" => "1" } - expect(response.status).to eq(200) - end - end - - describe "#refresh" do - before do - stub_user(:features => :all) - allow(controller).to receive(:x_node).and_return("root") - allow(controller).to receive(:rebuild_toolbars).and_return("true") - end - - it "renders the refresh flash message for Foreman" do - post :refresh, :params => {:miq_grid_checks => @config_mgr.id} - expect(response.status).to eq(200) - expect(assigns(:flash_array).first[:message]).to include("Refresh Provider initiated for 1 provider") - end - - it "refreshes the provider when the configuration manager id is supplied" do - allow(controller).to receive(:replace_right_cell) - post :refresh, :params => { :id => @config_mgr.id } - expect(assigns(:flash_array).first[:message]).to include("Refresh Provider initiated for 1 provider") - end - - it "it refreshes a provider when the configuration manager id is selected from a grid/tile" do - allow(controller).to receive(:replace_right_cell) - post :refresh, :params => { "check_#{@config_mgr.id}" => "1", - "check_#{@config_mgr2.id}" => "1" } - expect(assigns(:flash_array).first[:message]).to include("Refresh Provider initiated for 2 providers") - end - end - - context "renders right cell text" do - before do - right_cell_text = nil - login_as user_with_feature(%w(providers_accord configured_systems_filter_accord)) - controller.instance_variable_set(:@right_cell_text, right_cell_text) - allow(controller).to receive(:get_view_calculate_gtl_type) - allow(controller).to receive(:get_view_pages) - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:load_or_clear_adv_search) - allow(controller).to receive(:replace_search_box) - allow(controller).to receive(:update_partials) - allow(controller).to receive(:render) - - allow(controller).to receive(:items_per_page).and_return(20) - allow(controller).to receive(:gtl_type).and_return("list") - allow(controller).to receive(:current_page).and_return(1) - controller.send(:build_accordions_and_trees) - end - - it "renders right cell text for root node" do - key = ems_key_for_provider(@provider) - controller.send(:get_node_info, "root") - right_cell_text = controller.instance_variable_get(:@right_cell_text) - expect(right_cell_text).to eq("All Configuration Management Providers") - end - - it "renders right cell text for ConfigurationManagerForeman node" do - controller.instance_variable_set(:@in_report_data, true) - ems_id = ems_key_for_provider(@provider) - controller.params = {:id => ems_id} - controller.send(:tree_select) - right_cell_text = controller.instance_variable_get(:@right_cell_text) - expect(right_cell_text).to eq("Configuration Profiles under Foreman Provider \"testForeman Configuration Manager\"") - end - end - - it "builds foreman child tree" do - tree_builder = TreeBuilderConfigurationManager.new("root", controller.instance_variable_get(:@sb)) - objects = tree_builder.send(:x_get_tree_roots) - expected_objects = [@config_mgr, @config_mgr2] - expect(objects).to match_array(expected_objects) - end - - context "renders tree_select" do - before do - get :explorer - right_cell_text = nil - login_as user_with_feature(%w(providers_accord configured_systems_filter_accord)) - controller.instance_variable_set(:@right_cell_text, right_cell_text) - allow(controller).to receive(:get_view_calculate_gtl_type) - allow(controller).to receive(:get_view_pages) - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:load_or_clear_adv_search) - allow(controller).to receive(:replace_search_box) - allow(controller).to receive(:update_partials) - allow(controller).to receive(:render) - - allow(controller).to receive(:items_per_page).and_return(20) - allow(controller).to receive(:gtl_type).and_return("list") - allow(controller).to receive(:current_page).and_return(1) - controller.send(:build_accordions_and_trees) - end - - it "calls get_view with the associated dbname for the Configuration Management Providers accordion" do - stub_user(:features => :all) - allow(controller).to receive(:x_active_tree).and_return(:configuration_manager_providers_tree) - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_providers) - allow(controller).to receive(:build_listnav_search_list) - controller.params = {:id => "configuration_manager_providers_accord"} - expect(controller).to receive(:get_view).with("ManageIQ::Providers::ConfigurationManager", - :gtl_dbname => :cm_providers, :dbname => :cm_providers).and_call_original - controller.send(:accordion_select) - end - - it "calls get_view with the associated dbname for the Configuration Profiles list" do - stub_user(:features => :all) - allow(controller).to receive(:x_active_tree).and_return(:configuration_manager_providers_tree) - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_providers) - ems_id = ems_id_for_provider(@provider) - controller.instance_variable_set(:@in_report_data, true) - controller.params = {:id => ems_key_for_provider(@provider)} - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:apply_node_search_text) - expect(controller).to receive(:get_view).with("ConfigurationProfile", :match_via_descendants => "ConfiguredSystem", - :named_scope => [[:with_manager, ems_id]], - :dbname => :cm_configuration_profiles, - :gtl_dbname => :cm_configuration_profiles).and_call_original - controller.send(:tree_select) - end - - it "calls get_view with the associated dbname for the Configured Systems accordion" do - stub_user(:features => :all) - allow(controller).to receive(:x_active_tree).and_return(:configuration_manager_cs_filter_tree) - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_cs_filter) - allow(controller).to receive(:build_listnav_search_list) - controller.params = {:id => "configuration_manager_cs_filter_accord"} - expect(controller).to receive(:get_view).with("ConfiguredSystem", :gtl_dbname => :cm_configured_systems, :dbname => :cm_configured_systems).and_call_original - allow(controller).to receive(:build_listnav_search_list) - controller.send(:accordion_select) - end - end - - it "singularizes breadcrumb name" do - expect(controller.send(:breadcrumb_name, nil)).to eq("#{ui_lookup(:ui_title => "foreman")} Provider") - end - - it "renders tagging editor for a configured system" do - session[:tag_items] = [@configured_system.id] - session[:assigned_filters] = [] - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_cs_filter) - parent = FactoryBot.create(:classification) - FactoryBot.create(:classification_tag, :parent => parent) - FactoryBot.create(:classification_tag, :parent => parent) - post :tagging, :params => { :id => @configured_system.id, :format => :js } - expect(response.status).to eq(200) - end - - it "renders tagging editor for a configured system in the manager accordion" do - session[:assigned_filters] = [] - allow(controller).to receive(:x_active_accord).and_return(:configuration_manager_providers) - allow(controller).to receive(:x_node).and_return(config_profile_key(@config_profile)) - parent = FactoryBot.create(:classification) - FactoryBot.create(:classification_tag, :parent => parent) - FactoryBot.create(:classification_tag, :parent => parent) - post :tagging, :params => { :miq_grid_checks => [@configured_system.id], :id => @config_profile.id, :format => :js } - expect(response.status).to eq(200) - end - - it "renders tree_select as js" do - TreeBuilderConfigurationManager.new(:configuration_manager_providers_tree, controller.instance_variable_get(:@sb)) - - allow(controller).to receive(:process_show_list) - allow(controller).to receive(:add_unassigned_configuration_profile_record) - allow(controller).to receive(:replace_explorer_trees) - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:rebuild_toolbars) - allow(controller).to receive(:replace_search_box) - allow(controller).to receive(:update_partials) - - stub_user(:features => :all) - - key = ems_key_for_provider(@provider) - post :tree_select, :params => { :id => key, :format => :js } - expect(response.status).to eq(200) - end - - context "tree_select on provider foreman node" do - before do - login_as user_with_feature %w(provider_foreman_refresh_provider provider_foreman_edit_provider provider_foreman_delete_provider) - - allow(controller).to receive(:check_privileges) - allow(controller).to receive(:process_show_list) - allow(controller).to receive(:add_unassigned_configuration_profile_record) - allow(controller).to receive(:replace_explorer_trees) - allow(controller).to receive(:build_listnav_search_list) - allow(controller).to receive(:replace_search_box) - allow(controller).to receive(:x_active_tree).and_return(:configuration_manager_providers_tree) - end - - it "does not hide Configuration button in the toolbar" do - TreeBuilderConfigurationManager.new(:configuration_manager_providers_tree, controller.instance_variable_get(:@sb)) - key = ems_key_for_provider(@provider) - post :tree_select, :params => { :id => key } - expect(response.status).to eq(200) - expect(response.body).not_to include('