Foreman UI: propably bug in js in 3.2.0

Problem:
When you try to override host global parameters override parameter is cleared when you click to override secondone.

Click on host, then Edit → Parameters. You must have some global parameters there.
Click on override (works fine for firstone).
Click on override for second one → It cleared first override

Expected outcome:
When clicking on override it should just add new parameter with default values, not cleared previous override.

Foreman and Proxy versions:
3.2.0

Hey @rvojcik !
I can see it happening also on my end,
sound like some legacy jQuery fun :slight_smile:

2 Likes

Hopefully that helps: Fixes #34747 - override_param should consider direction by Ron-Lavi · Pull Request #9180 · theforeman/foreman · GitHub
@MariaAga, @evgeni mind testing it out?

3 Likes

@Ron_Lavi thanks a lot :slight_smile:

Hi,

I’m running Foreman 3.2 and stumbled upon this fix for the Host Parameter issue. Following the link in Fixes #34747, I’ve updated the file …

/usr/share/foreman/app/assets/javascripts/parameter_override.js

function override_param(item) {
  var param = $(item)
    .closest('tr')
    .addClass('override-param');
  var n = param.find('[id^=name_]').text();
  var parameter_type_val = param.find('[id^=parameter_type_]').text();
  var param_value = param.find('[id^=value_]');
  var v = param_value.val();

  $('#parameters')
    .find('.btn-primary')
    .click();
  var new_param = $('#parameters')
    .find('.fields')
    .last();
  var addParameterButton = $('#parameters').find('.btn-primary');
  addParameterButton.click();
  var directionOfAddedItems = addParameterButton.attr('direction');
  var new_param = $('#parameters').find('.fields');
  if(directionOfAddedItems === 'append'){
    new_param = new_param.last();
  } else {
    new_param = new_param.first();
  }
  new_param.find('[id$=_name]').val(n);
  new_param.find('[id$=_parameter_type]').val(parameter_type_val);
  new_param
    .find('[id$=_value]')
    .val(v == param_value.data('hidden-value') ? '' : v);
  if (param_value.hasClass('masked-input')) {
    var alink = new_param.find('span.fa-eye-slash').closest('a'),
      hiddenValueCheckBox = new_param.find('.set_hidden_value');
    hiddenValueCheckBox.prop('checked', true);
    hiddenValueCheckBox.val('1');
    alink.click();
  }
}

Rebooted the Foreman server and tried provisoning again but the same issue with over-riding the host parameters still exists.

Just wondering if I’ve missed anything out?

Thanks.

1 Like

Just an FYI I’ve upgraded from 3.2.0 to 3.2.1 and the issue has been fixed.

Cheers.

3 Likes