Skip to content

Commit

Permalink
Changes to load and make buttons work on sub-lists.
Browse files Browse the repository at this point in the history
Changed to get buttons working when viewing list of Configured Systems thru relationships.
  • Loading branch information
h-kataria committed Apr 2, 2020
1 parent 0ae275c commit ccea893
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 28 deletions.
8 changes: 4 additions & 4 deletions app/controllers/configuration_manager_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
19 changes: 19 additions & 0 deletions app/controllers/configuration_profile_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 1 addition & 23 deletions app/controllers/configured_system_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 23 additions & 0 deletions app/controllers/mixins/manager_controller_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/application_helper/toolbar_chooser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2701,6 +2701,7 @@
show_list
),
:post => %w(
button
quick_search
reload
show
Expand Down

0 comments on commit ccea893

Please sign in to comment.