diff --git a/app/controllers/application_controller/ci_processing.rb b/app/controllers/application_controller/ci_processing.rb index ce76acd1acb..9ef23b1c3c7 100644 --- a/app/controllers/application_controller/ci_processing.rb +++ b/app/controllers/application_controller/ci_processing.rb @@ -215,15 +215,7 @@ def ownership_update # Retire 1 or more items (vms, stacks, services) def retirevms assert_privileges(params[:pressed]) - klass = get_class_from_controller_param(params[:controller]) - selected_items = find_checked_ids_with_rbac(klass) - if !%w(orchestration_stack service).include?(request.parameters["controller"]) && !%w(orchestration_stacks).include?(params[:display]) && - VmOrTemplate.find(selected_items).any? { |vm| !vm.supports_retire? } - add_flash(_("Set Retirement Date does not apply to selected %{model}") % - {:model => ui_lookup(:table => "miq_template")}, :error) - javascript_flash(:scroll_top => true) - return - end + # check to see if coming from show_list or drilled into vms from another CI if request.parameters[:controller] == "vm" || %w(all_vms instances vms).include?(params[:display]) rec_cls = "vm" @@ -235,6 +227,15 @@ def retirevms rec_cls = "orchestration_stack" bc_msg = _("Retire Orchestration Stack") end + klass = rec_cls ? rec_cls.camelize.constantize : get_class_from_controller_param(params[:controller]) + selected_items = find_checked_ids_with_rbac(klass) + if !%w(orchestration_stack service).include?(request.parameters["controller"]) && !%w(orchestration_stacks).include?(params[:display]) && + VmOrTemplate.find(selected_items).any? { |vm| !vm.supports_retire? } + add_flash(_("Set Retirement Date does not apply to selected %{model}") % + {:model => ui_lookup(:table => "miq_template")}, :error) + javascript_flash(:scroll_top => true) + return + end if selected_items.blank? session[:retire_items] = [params[:id]] elsif selected_items.empty?