diff --git a/app/controllers/application_controller/ci_processing.rb b/app/controllers/application_controller/ci_processing.rb index 37469f14064d..63def71317bb 100644 --- a/app/controllers/application_controller/ci_processing.rb +++ b/app/controllers/application_controller/ci_processing.rb @@ -143,7 +143,7 @@ def process_elements(elements, klass, task, display_name = nil, order_field = ni end def explorer_controller? - %w[vm_cloud vm_infra vm_or_template infra_networking].include?(controller_name) + %w[vm_cloud vm_infra vm_or_template infra_networking automation_manager].include?(controller_name) end def process_element_destroy(element, klass, name) diff --git a/app/controllers/configuration_manager_controller.rb b/app/controllers/configuration_manager_controller.rb index 9beeab7a3fa3..b974d31ff578 100644 --- a/app/controllers/configuration_manager_controller.rb +++ b/app/controllers/configuration_manager_controller.rb @@ -67,58 +67,16 @@ def button 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 + private - 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?} + def self.model_to_name(provmodel) + Dictionary.gettext('configuration_manager', :type => :ui_title, :translate => false) 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" + def privilege_prefix + "configuration_manager" end - private - def refresh assert_privileges("configuration_manager_refresh_provider") manager_button_operation('refresh_ems', _('Refresh')) @@ -132,31 +90,6 @@ 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/mixins/automation_manager_controller_mixin.rb b/app/controllers/mixins/automation_manager_controller_mixin.rb index ea2d9b030830..b0c689d1889b 100644 --- a/app/controllers/mixins/automation_manager_controller_mixin.rb +++ b/app/controllers/mixins/automation_manager_controller_mixin.rb @@ -130,65 +130,6 @@ def accordion_select 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 diff --git a/app/controllers/mixins/manager_controller_mixin.rb b/app/controllers/mixins/manager_controller_mixin.rb index 82cb60464bef..a0b4a5d8cadb 100644 --- a/app/controllers/mixins/manager_controller_mixin.rb +++ b/app/controllers/mixins/manager_controller_mixin.rb @@ -86,13 +86,22 @@ def authentication_validate def new assert_privileges("#{privilege_prefix}_add_provider") + @explorer = true if explorer_controller? @provider_manager = concrete_model.new @server_zones = Zone.visible.in_my_region.order('lower(description)').pluck(:description, :name) @sb[:action] = params[:action] - render_form if @explorer + if @explorer + render_form + else + @in_a_form = true + @redirect_controller = "configuration_manager" + @refresh_partial = "new" + end end def edit + assert_privileges("#{privilege_prefix}_edit_provider") + @explorer = true if explorer_controller? @server_zones = Zone.visible.in_my_region.order('lower(description)').pluck(:description, :name) case params[:button] when "cancel" @@ -101,17 +110,24 @@ def edit 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 if @explorer + if @explorer + render_form + else + @in_a_form = true + @redirect_controller = "configuration_manager" + @redirect_id = @provider_manager.id + @refresh_partial = "edit" + end end end def delete assert_privileges("#{privilege_prefix}_delete_provider") + @explorer = true if explorer_controller? 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)) @@ -137,8 +153,8 @@ def delete end def refresh + @explorer = true if explorer_controller? assert_privileges("#{privilege_prefix}_refresh_provider") - @explorer = true manager_button_operation('refresh_ems', _('Refresh')) replace_right_cell if @explorer end diff --git a/app/controllers/mixins/sandbox.rb b/app/controllers/mixins/sandbox.rb index 1839c9a1c6d9..1bb08b9a4547 100644 --- a/app/controllers/mixins/sandbox.rb +++ b/app/controllers/mixins/sandbox.rb @@ -76,7 +76,6 @@ def x_active_tree protect_tree pxe_image_types_tree pxe_servers_tree - configuration_manager_providers_tree rbac_tree reports_tree roles_by_server_tree diff --git a/app/helpers/application_helper/toolbar_chooser.rb b/app/helpers/application_helper/toolbar_chooser.rb index c9d5ae0826a9..a4d05ceae2b4 100644 --- a/app/helpers/application_helper/toolbar_chooser.rb +++ b/app/helpers/application_helper/toolbar_chooser.rb @@ -537,21 +537,6 @@ def center_toolbar_filename_automation_manager end end - def configuration_manager_providers_tree_center_tb(nodes) - case nodes.first - when "root" then "configuration_manager_providers_center_tb" - when "fr", "at" then "configuration_manager_provider_center_tb" - when "cp" then configuration_profile_center_tb - when "f" then inventory_group_center_tb - when "xx" then - case nodes.last - when "f" then "configured_systems_center_tb" - when "cp" then "unassigned_profiles_group_center_tb" - else "configuration_manager_providers_center_tb" - end - end - end - def cs_filter_tree_center_tb(nodes) case nodes.first when "root", "ms", "xx", "csa", "csf" then "configured_systems_center_tb" diff --git a/app/presenters/tree_builder_configured_systems.rb b/app/presenters/tree_builder_configured_systems.rb new file mode 100644 index 000000000000..ad37b7100b9c --- /dev/null +++ b/app/presenters/tree_builder_configured_systems.rb @@ -0,0 +1,20 @@ +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/views/automation_manager/_form.html.haml b/app/views/automation_manager/_form.html.haml index 416736e8de77..1b3155809c2d 100644 --- a/app/views/automation_manager/_form.html.haml +++ b/app/views/automation_manager/_form.html.haml @@ -1,7 +1 @@ -= render :partial => 'configuration_manager/shared_form' - -:javascript - ManageIQ.angular.app.value('configurationManagerFormId', '#{@provider_manager.id || "new"}'); - ManageIQ.angular.app.value('url', '/automation_manager'); - ManageIQ.angular.app.value('modelName', 'automationManagerModel'); - miq_bootstrap('#form_div'); += render :partial => 'configuration_manager/shared_form', :locals => {:url => "/automation_manager", :model => "automationManagerModel"} diff --git a/app/views/configuration_manager/_shared_form.html.haml b/app/views/configuration_manager/_shared_form.html.haml index d170785d81ce..6e8c5fa1e354 100644 --- a/app/views/configuration_manager/_shared_form.html.haml +++ b/app/views/configuration_manager/_shared_form.html.haml @@ -94,6 +94,6 @@ :javascript ManageIQ.angular.app.value('configurationManagerFormId', '#{@provider_manager.id || "new"}'); - ManageIQ.angular.app.value('url', '/configuration_manager'); - ManageIQ.angular.app.value('modelName', 'configurationManagerModel'); + ManageIQ.angular.app.value('url', '#{url}'); + ManageIQ.angular.app.value('modelName', '#{model}'); miq_bootstrap('#form_div'); diff --git a/app/views/configuration_manager/edit.html.haml b/app/views/configuration_manager/edit.html.haml index 4b6255b467df..476d24d20d1a 100644 --- a/app/views/configuration_manager/edit.html.haml +++ b/app/views/configuration_manager/edit.html.haml @@ -1 +1 @@ -= render :partial => 'configuration_manager/shared_form' += render :partial => 'configuration_manager/shared_form', :locals => {:url => "/configuration_manager", :model => "configurationManagerModel"} diff --git a/app/views/configuration_manager/new.html.haml b/app/views/configuration_manager/new.html.haml index 4b6255b467df..476d24d20d1a 100644 --- a/app/views/configuration_manager/new.html.haml +++ b/app/views/configuration_manager/new.html.haml @@ -1 +1 @@ -= render :partial => 'configuration_manager/shared_form' += render :partial => 'configuration_manager/shared_form', :locals => {:url => "/configuration_manager", :model => "configurationManagerModel"}