Skip to content

Commit

Permalink
Fixes #37174 - Honor selected organizations in hg form
Browse files Browse the repository at this point in the history
when generating options for lifecycle environment field.
  • Loading branch information
adamruzicka authored and wbclark committed Jun 26, 2024
1 parent b6169e4 commit 4e9b6fb
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions app/assets/javascripts/katello/hosts/host_and_hostgroup_edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,19 @@ KT.hosts.fetchEnvironments = function () {
select.find('option').remove();
if (content_source_id) {
var url = tfm.tools.foremanUrl('/katello/api/capsules/' + content_source_id);
var orgId = $('#host_organization_id').val();
var orgIds = $("#hostgroup_organization_ids").val();
if(orgIds === undefined || orgIds === null || orgIds.length === 0) {
orgIds = [$("#host_organization_id").val()];
};
orgIds = orgIds.map(id => Number(id));
$.get(url, function (content_source) {
$.each(content_source.lifecycle_environments, function(index, env) {
// Don't show environments that aren't in the selected org. See jQuery.each() docs
if (orgId && env.organization_id != orgId) return true;
option = $("<option />").val(env.id).text(env.name);
select.append(option);
});
select.trigger('change');
$.each(content_source.lifecycle_environments, function(index, env) {
// Don't show environments that aren't in the selected org. See jQuery.each() docs
if (!orgIds.includes(env.organization_id)) return true;
option = $("<option />").val(env.id).text(env.name);
select.append(option);
});
select.trigger('change');
});
}
};
Expand Down

0 comments on commit 4e9b6fb

Please sign in to comment.