Bug #16805

Host group change on host edit does not reload parameters etc.

Added by Dominic Cleal 11 months ago. Updated 11 months ago.

Assigned To:Dominic Cleal
Category:Host creation
Target version:-
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/3920
Story points-
Velocity based estimate-
Release1.13.1Release relationshipAuto


When editing a host and changing its host group, the parameters tab isn't reloaded with data coming from the new host group. If you save the host and revisit the page, the host group parameters are now shown.

The implementation of handleHostgroupChangeEdit in host_edit.js suggests that it should via the third part of this conditional:

244 function handleHostgroupChangeEdit(element, host_id, host_changed) {
  1   if (host_changed){
  2     update_form(element,{data:"&host[id]="+host_id})
  3   } else if (host_changed == undefined) { // hostgroup changes parent
  4     update_form(element)
  5   } else { // edit host
  6     set_inherited_value(element);
  7     update_puppetclasses(element);
  8     reload_host_params();
  9   }
 10 }

Instead when the host group is changed, the second part (designed for the hostgroup#edit form, changing parent) is followed instead. This stems from the "data-type-changed" attribute being missing on the host form, due to Rails bug https://github.com/rails/rails/issues/24220, fixed in 5.0.0. In app/views/hosts/_form.html.erb, @host.type_changed? may return nil, it should be !!@host.type_changed?.

Associated revisions

Revision 2322228d
Added by Dominic Cleal 11 months ago

fixes #16805 - reload host parameters on host group change

On Rails 4.2, `Host#type_changed?` may return nil due to bug #24220
causing data-type-changed to be missing from the host form and the JS
in handleHostgroupChangeEdit to assume host#edit is a hostgroup form.
Now that data-type-changed is always present, the full reload of
parameters occurs when the host group is changed on a host.


#1 Updated by Dominic Cleal 11 months ago

  • Status changed from New to Assigned
  • Assigned To set to Dominic Cleal

#2 Updated by The Foreman Bot 11 months ago

  • Status changed from Assigned to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/3920 added

#3 Updated by Dominic Cleal 11 months ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#4 Updated by Dominic Cleal 11 months ago

  • Release set to 1.13.1

Also available in: Atom PDF