Skip to content

Fixes #38317 - Create host form - Remember value of content_source_id #11353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stejskalleos
Copy link
Contributor

@stejskalleos stejskalleos commented Mar 26, 2025

What are the changes introduced in this pull request?

If the host form is not submitted successfully, the content source is reset, and unexpected changes are made in the OS Media Selection.

Considerations taken when implementing this change?

https://issues.redhat.com/browse/SAT-18646
theforeman/foreman#10495

What are the testing steps for this pull request?

Preconditions:

  • Have an OS with installation media AND synced content for provisioning.
  • Do not use a host group for the form.

Steps to reproduce

  • Go to Create Host UI from.
  • Select Content source, Environment, and content view.
  • In the OS tab, select architecture, OS, and Media Selection: Synced content.
  • Select Synced Content.
  • Submit form.

Before patch
Form is going to show errors, and also will reset or change the following fields:

After patch

  • Content source is still selected
  • Media selection is unchanged

@stejskalleos stejskalleos marked this pull request as ready for review March 26, 2025 15:33
@stejskalleos
Copy link
Contributor Author

@jeremylenz @ianballou hi folks, can anybody take a look please?

@ianballou
Copy link
Member

We'll find a reviewer for this soon.

@lfu
Copy link
Member

lfu commented Apr 2, 2025

This patch is addressing two fields that should be persisted when an error is thrown upon submit and displayed in the form: Content source and Media Selection.
Tested with 3 servers without the patch. Media Selection was always persisted and kept set as Synced content. Only Content source was not persisted.
Added some comments.
Some test coverage is really appreciated.

@@ -161,7 +161,7 @@ def content_options(host, selected_id, object_type, options = {})
accessible_content_proxies(host)
end
accessible_content_objects.each do |content_object|
selected = selected_id == content_object.id ? 'selected' : ''
selected = "#{selected_id}" == "#{content_object.id}" ? 'selected' : ''
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

selected_id should be kept as integer.

@@ -22,8 +22,14 @@
<%= select_tag cs_select_id, content_source_options(@hostgroup, :include_blank => blank_or_inherit_with_id(f, :content_source)), :data => {"spinner_path" => spinner_path},
:class => 'form-control', :name => cs_select_name %>
<% else %>
<%= hidden_field_tag 'host[content_facet_attributes][content_source_id]', fetch_content_source(@host).try(:id) %>
<%= select_tag cs_select_id, content_source_options(@host, :selected_host_group => @hostgroup || @host.hostgroup, :include_blank => blank_or_inherit_with_id(f, :content_source)), :data => {"spinner_path" => spinner_path}, :class => 'form-control', :name => cs_select_name, :disabled => cv_lce_disabled? %>
<% content_source_id = fetch_content_source(@host).try(:id) || params.dig("host", "content_facet_attributes", "content_source_id") %>
Copy link
Member

@lfu lfu Apr 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<% content_source_id = fetch_content_source(@host).try(:id) || params.dig("host", "content_facet_attributes", "content_source_id")&.to_i %>

Here we could ensure content_source_id as integer.

@stejskalleos
Copy link
Contributor Author

@lfu, thanks for the review. The host form is right now in a "funky state." I'm moving the PR to the draft state until all the related issues are fixed.

@stejskalleos stejskalleos marked this pull request as draft April 4, 2025 09:07
@lfu
Copy link
Member

lfu commented May 19, 2025

@stejskalleos Any update? I'd like to move the associated Jira card out of review if it's not going to be updated any soon.

@stejskalleos
Copy link
Contributor Author

Hi,
There have been no updates yet. I cannot make my katello-dev environment work, so I cannot continue with this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants