From f1dc8c639aec2440288b3321442133c9f864de20 Mon Sep 17 00:00:00 2001 From: Harpreet Kataria Date: Mon, 30 Mar 2020 18:44:03 -0400 Subject: [PATCH] Changes to load and make buttons work on sub-lists. Changed to get buttons working when viewing list of Configured Systems thru relationships. --- .../configuration_manager_controller.rb | 8 +++---- .../configuration_profile_controller.rb | 19 +++++++++++++++ .../configured_system_controller.rb | 24 +------------------ .../mixins/manager_controller_mixin.rb | 23 ++++++++++++++++++ .../application_helper/toolbar_chooser.rb | 2 +- config/routes.rb | 1 + 6 files changed, 49 insertions(+), 28 deletions(-) diff --git a/app/controllers/configuration_manager_controller.rb b/app/controllers/configuration_manager_controller.rb index b974d31ff578..7a861263ff2e 100644 --- a/app/controllers/configuration_manager_controller.rb +++ b/app/controllers/configuration_manager_controller.rb @@ -26,16 +26,16 @@ def self.display_methods 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 + params[:display] = @display if %w[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" + if params[:pressed].starts_with?("configured_system_") # Handle buttons from sub-items screen + tag(ConfiguredSystem) if params[:pressed] == "configured_system_tag" + provision if params[:pressed] == "configured_system_provision" end case params[:pressed] diff --git a/app/controllers/configuration_profile_controller.rb b/app/controllers/configuration_profile_controller.rb index 9c45e8fe0e09..808c142b6c84 100644 --- a/app/controllers/configuration_profile_controller.rb +++ b/app/controllers/configuration_profile_controller.rb @@ -17,6 +17,25 @@ def self.display_methods %w[configured_systems] end + def button + @edit = session[:edit] # Restore @edit for adv search box + params[:display] = @display if %w[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 + + if params[:pressed].starts_with?("configured_system_") # Handle buttons from sub-items screen + tag(ConfiguredSystem) if params[:pressed] == "configured_system_tag" + provision if params[:pressed] == "configured_system_provision" + end + + if @refresh_div == "main_div" && @lastaction == "show_list" + replace_gtl_main_div + else + render_flash unless performed? + end + end + private def breadcrumbs_options diff --git a/app/controllers/configured_system_controller.rb b/app/controllers/configured_system_controller.rb index 93edd8679963..9fae4b4d6b5d 100644 --- a/app/controllers/configured_system_controller.rb +++ b/app/controllers/configured_system_controller.rb @@ -3,6 +3,7 @@ class ConfiguredSystemController < ApplicationController include Mixins::GenericShowMixin include Mixins::GenericSessionMixin include Mixins::BreadcrumbsMixin + include Mixins::ManagerControllerMixin before_action :check_privileges before_action :get_session_data @@ -27,29 +28,6 @@ def button private - def provision - assert_privileges("configured_system_provision") - 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 - 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 relationships environment], %i[os tenancy tags]] end diff --git a/app/controllers/mixins/manager_controller_mixin.rb b/app/controllers/mixins/manager_controller_mixin.rb index a0b4a5d8cadb..48554de054ae 100644 --- a/app/controllers/mixins/manager_controller_mixin.rb +++ b/app/controllers/mixins/manager_controller_mixin.rb @@ -180,6 +180,29 @@ def form_fields private + def provision + assert_privileges("configured_system_provision") + 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 if explorer_controller? + 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 + 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 sync_form_to_instance @provider.name = params[:name] @provider.url = params[:url] diff --git a/app/helpers/application_helper/toolbar_chooser.rb b/app/helpers/application_helper/toolbar_chooser.rb index a4d05ceae2b4..b86e5e068c60 100644 --- a/app/helpers/application_helper/toolbar_chooser.rb +++ b/app/helpers/application_helper/toolbar_chooser.rb @@ -399,7 +399,7 @@ def center_toolbar_filename_storage def center_toolbar_filename_classic # Original non vmx view code follows # toolbar buttons on sub-screens - to_display = %w[availability_zones cloud_networks cloud_object_store_containers cloud_subnets + to_display = %w[availability_zones cloud_networks cloud_object_store_containers cloud_subnets configured_systems cloud_tenants cloud_volumes ems_clusters flavors floating_ips host_aggregates hosts network_ports network_routers orchestration_stacks resource_pools security_groups storages middleware_deployments diff --git a/config/routes.rb b/config/routes.rb index 0d32eac0b9a4..b55ec2943494 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -2701,6 +2701,7 @@ show_list ), :post => %w( + button quick_search reload show