From e646fd91e2292a51a99da7bddd4fca642d9e4f2b Mon Sep 17 00:00:00 2001 From: Leos Stejskal Date: Mon, 13 Nov 2023 12:04:04 +0100 Subject: [PATCH] Fixes BZ#2238952 - Selecting host group change form URL --- app/helpers/discovered_hosts_helper.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/app/helpers/discovered_hosts_helper.rb b/app/helpers/discovered_hosts_helper.rb index 74db45d2..4d446f1e 100644 --- a/app/helpers/discovered_hosts_helper.rb +++ b/app/helpers/discovered_hosts_helper.rb @@ -94,8 +94,15 @@ def provision_button(host, authorization_options) end def host_path(host) - return super unless controller_name == 'discovered_hosts' - discovered_host_path(host) + return discovered_host_path(host) if controller_name == 'discovered_hosts' + # This is a hack to fix the hostgroup selection on the discovered host edit page + # The hostgroup onChange action is replacing the form url from `/discovered_hosts/:id` + # to `/hosts/:id``, which is not correct (in this case) and it breaks the form submission + return discovered_host_path(host) if controller_name == 'hosts' && + action_name == 'process_hostgroup' && + Host::Discovered.find_by(id: host[:id]) + + super end def discovery_doc_version