From 3cc1a242c3f1bda0771cd659df9f123e8e890cb4 Mon Sep 17 00:00:00 2001 From: JEFFREY-Bonson Date: Fri, 6 Oct 2023 15:25:33 +0530 Subject: [PATCH] Fix for custom button action events --- app/controllers/application_controller/buttons.rb | 2 +- app/controllers/service_controller.rb | 11 +++++++++++ .../application_controller/buttons_spec.rb | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller/buttons.rb b/app/controllers/application_controller/buttons.rb index 53fac1467ffa..732e64ce1f84 100644 --- a/app/controllers/application_controller/buttons.rb +++ b/app/controllers/application_controller/buttons.rb @@ -203,7 +203,7 @@ def feature_by_action @sb[:action] if features_in_action.include?(@sb[:action]) end - BASE_MODEL_EXPLORER_CLASSES = [MiqGroup, MiqTemplate, Service, Tenant, User, Vm].freeze + BASE_MODEL_EXPLORER_CLASSES = [MiqGroup, MiqTemplate, Tenant, User, Vm].freeze def custom_button_done external_url = ExternalUrl.find_by( diff --git a/app/controllers/service_controller.rb b/app/controllers/service_controller.rb index 78123c7911ec..ae69f969a625 100644 --- a/app/controllers/service_controller.rb +++ b/app/controllers/service_controller.rb @@ -33,9 +33,20 @@ def button service_retire when 'service_retire_now' service_retire_now + when "custom_button" + @display == 'generic_objects' ? generic_object_custom_buttons : custom_buttons end end + def generic_object_custom_buttons + display_options = {} + ids = @lastaction == 'generic_object' ? @sb[:rec_id] : 'LIST' + display_options[:display] = @display + display_options[:record_id] = parse_nodetype_and_id(x_node).last + display_options[:display_id] = params[:id] if @lastaction == 'generic_object' + custom_buttons(ids, display_options) + end + def title _("My Services") end diff --git a/spec/controllers/application_controller/buttons_spec.rb b/spec/controllers/application_controller/buttons_spec.rb index eb34c19bd2c6..b6d7d2d75150 100644 --- a/spec/controllers/application_controller/buttons_spec.rb +++ b/spec/controllers/application_controller/buttons_spec.rb @@ -94,7 +94,7 @@ controller.send(:custom_buttons) expect(assigns(:right_cell_text)).to include(service.name) - expect(controller.instance_variable_get(:@explorer)).to be_truthy + expect(controller.instance_variable_get(:@explorer)).to be_falsy end end