Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow editing and other actions on selected Host Aggregate #6267

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 3 additions & 9 deletions app/controllers/host_aggregate_controller.rb
Expand Up @@ -158,11 +158,7 @@ def update_finished
def delete_host_aggregates
assert_privileges("host_aggregate_delete")

host_aggregates = if @lastaction == "show_list" || (@lastaction == "show" && @layout != "host_aggregate")
find_checked_items
else
[params[:id]]
end
host_aggregates = checked_or_params

if host_aggregates.empty?
add_flash(_("No Host Aggregates were selected for deletion."), :error)
Expand All @@ -183,14 +179,12 @@ def delete_host_aggregates

# refresh the list if applicable
if @lastaction == "show_list"
show_list
@refresh_partial = "layouts/gtl"
elsif @lastaction == "show" && @layout == "host_aggregate"
@single_delete = true unless flash_errors?
if @flash_array.nil?
add_flash(_("The selected Host Aggregate was deleted"))
end
end
flash_to_session
redirect_to(:action => 'show_list')
end

def add_host_select
Expand Down
18 changes: 7 additions & 11 deletions app/controllers/mixins/ems_common.rb
Expand Up @@ -253,10 +253,10 @@ def button
when "host_provide" then providehosts
# Host Aggregates
when 'host_aggregate_new' then javascript_redirect(:action => 'new')
when 'host_aggregate_edit' then javascript_redirect(:action => 'edit', :id => checked_item_id)
when 'host_aggregate_delete' then delete_host_aggregates
when 'host_aggregate_add_host' then javascript_redirect(:action => 'add_host_select', :id => checked_item_id)
when 'host_aggregate_remove_host' then javascript_redirect(:action => 'remove_host_select', :id => checked_item_id)
when 'host_aggregate_edit' then javascript_redirect(:action => 'edit', :id => checked_or_params, :controller => 'host_aggregate')
when 'host_aggregate_delete' then javascript_redirect(:action => 'delete_host_aggregates', :id => params[:id], :miq_grid_checks => params[:miq_grid_checks], :controller => 'host_aggregate')
when 'host_aggregate_add_host' then javascript_redirect(:action => 'add_host_select', :id => checked_or_params, :controller => 'host_aggregate')
when 'host_aggregate_remove_host' then javascript_redirect(:action => 'remove_host_select', :id => checked_or_params, :controller => 'host_aggregate')
when 'host_aggregate_tag' then tag(HostAggregate)
# Storages
when "storage_delete" then deletestorages
Expand Down Expand Up @@ -302,8 +302,8 @@ def button
"#{pfx}_evacuate"].include?(params[:pressed]) &&
@flash_array.nil?

unless ["host_edit", "#{pfx}_edit", "#{pfx}_miq_request_new", "#{pfx}_clone",
"#{pfx}_migrate", "#{pfx}_publish", 'vm_rename', 'flavor_create', 'flavor_delete'].include?(params[:pressed])
unless ["host_edit", 'host_aggregate_edit', 'host_aggregate_add_host', 'host_aggregate_remove_host', 'host_aggregate_delete', "#{pfx}_edit", "#{pfx}_miq_request_new",
"#{pfx}_clone", "#{pfx}_migrate", "#{pfx}_publish", 'vm_rename', 'flavor_create', 'flavor_delete'].include?(params[:pressed])
@refresh_div = "main_div"
@refresh_partial = "layouts/gtl"
show # Handle EMS buttons
Expand Down Expand Up @@ -408,10 +408,6 @@ def button

if single_delete_test
single_delete_redirect
elsif params[:pressed] == "host_aggregate_edit"
javascript_redirect :controller => "host_aggregate",
:action => "edit",
:id => find_record_with_rbac(HostAggregate, checked_or_params)
elsif params[:pressed] == "cloud_tenant_edit"
javascript_redirect :controller => "cloud_tenant",
:action => "edit",
Expand Down Expand Up @@ -460,7 +456,7 @@ def button
elsif params[:pressed].ends_with?("_edit") ||
["#{pfx}_miq_request_new", "#{pfx}_clone", "#{pfx}_migrate", "#{pfx}_publish"].include?(params[:pressed]) ||
params[:pressed] == 'vm_rename' && @flash_array.nil?
render_or_redirect_partial(pfx)
render_or_redirect_partial(pfx) unless performed?
else
if @refresh_div == "main_div" && @lastaction == "show_list"
replace_gtl_main_div
Expand Down
2 changes: 2 additions & 0 deletions config/routes.rb
Expand Up @@ -243,6 +243,7 @@
:host_aggregate => {
:get => %w(
add_host_select
delete_host_aggregates
download_data
download_summary_pdf
edit
Expand All @@ -261,6 +262,7 @@
add_host
add_host_select
button
delete_host_aggregates
listnav_search_selected
create
protect
Expand Down