Skip to content

Fixes #39167 - set category when REX feature is present#1024

Merged
Lukshio merged 3 commits intotheforeman:masterfrom
MariaAga:wizard-rex-feature-fix
Mar 25, 2026
Merged

Fixes #39167 - set category when REX feature is present#1024
Lukshio merged 3 commits intotheforeman:masterfrom
MariaAga:wizard-rex-feature-fix

Conversation

@MariaAga
Copy link
Copy Markdown
Member

Job wizard does not pre-fill REX feature category and job template when they are in the url

Added also some memo to selectors since while debugging this issues I saw that the component re-renders every few seconds for no reason. selectors stabilization was AI assisted.
The setCategory was removed #1016 , but should have instead been updated to a ref to allow REX feature pre-fill.

I tested this PR on rex feature usage (Doesnt have to be errata, can also be install package -customized Remote Execution, or other REX features that are customized). Tested on rerun, and on a normal new job.

Description of problem:

In the Manage Errata tab, when applying errata to a specific host using customized Remote Execution, the job category is not being correctly resolved as Katello, but displayed as Ansible Commands.

Steps to Reproduce:

  1. Navigate to Satellite WebUI--> Hosts --> All Hosts
  2. Select 1 or 2 Hosts --> Manage Content --> Errata --> Select Errata --> Click on Next --> Selected errata will be applied to 1 host - via customized remote execution --> Click on Apply.
  3. Job category showing Ansible Commands and Job Template is Empty.

Actual behavior:

When applying errata to a specific host using customized Remote Execution, the job category is incorrectly resolved as Ansible Command.

Expected behavior:
The job category should be displayed as Katello instead of Ansible Command when applying errata.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes Job Wizard prefill behavior so that when a Remote Execution (REX) feature (and its job template) is provided via the URL, the wizard also resolves and preselects the correct job category (e.g., Katello instead of Ansible Commands). It also reduces unnecessary rerenders by stabilizing selector return references and memoizing the Category/Template step container.

Changes:

  • Memoize the Category/Template connected step component to reduce rerenders.
  • Stabilize several JobWizard selectors via reselect and stable empty fallbacks.
  • Update JobWizard defaults application to update category from the fetched job template’s job_category, enabling correct REX feature prefill behavior.
  • Adjust JobWizard test fixtures/mocks to support additional template IDs.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
webpack/JobWizard/steps/CategoryAndTemplate/index.js Memoizes the connected Category/Template step export to reduce rerenders.
webpack/JobWizard/tests/fixtures.js Expands fixture data and mock API responses to cover multiple templates/categories.
webpack/JobWizard/JobWizardSelectors.js Adds selector memoization and stable fallbacks to reduce referential churn in useSelector.
webpack/JobWizard/JobWizard.js Updates wizard defaults application so fetched template data can drive category selection (REX feature URL prefill).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +94 to +96
if (categoryRef.current !== job_category) {
setCategory(job_category);
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

The new logic that updates the wizard category based on the fetched job template’s job_category (important for REX feature URL prefill) doesn’t appear to have a regression test. There are already URL-autofill tests for feature=...; please add an assertion covering that the Category step preselects the expected category when the feature resolves a job template in a different category (e.g., Katello vs Ansible Commands).

Copilot uses AI. Check for mistakes.
export const selectRouterSearch = state => {
const { search } = selectRouterLocation(state);
const { search } = selectRouterLocation(state) || {};
return URI.parseQuery(search);
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

selectRouterSearch calls URI.parseQuery with search which can be undefined when router location is missing/empty; URI.js may interpret that as the literal string "undefined" and produce an unexpected query object. Consider defaulting search to an empty string before parsing (and/or returning an empty object when search is falsy).

Suggested change
return URI.parseQuery(search);
return URI.parseQuery(search || '');

Copilot uses AI. Check for mistakes.
Comment on lines 213 to 223
@@ -202,7 +218,7 @@ export const mockApi = api => {
action.url.search() ===
'?search=job_category%3D%22Puppet%22&per_page=all'
? [pupptetJobTemplate]
: [jobTemplate],
: wizardJobTemplatesMockList,
},
});
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

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

In the JOB_TEMPLATES mock, non-Puppet category searches return wizardJobTemplatesMockList, which currently includes a Puppet template. That diverges from the real API behavior (results should be filtered by the requested job_category) and can let category/template selection regressions slip through tests. Consider filtering wizardJobTemplatesMockList based on the search query param (or returning an Ansible-only list for non-Puppet searches).

Copilot uses AI. Check for mistakes.
@Lukshio Lukshio self-assigned this Mar 20, 2026
Copy link
Copy Markdown
Contributor

@Lukshio Lukshio left a comment

Choose a reason for hiding this comment

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

I tried version without reselect and it works well, so I would like to not include another lib

@Lukshio
Copy link
Copy Markdown
Contributor

Lukshio commented Mar 25, 2026

Changes looks, good, thanks @MariaAga

@Lukshio Lukshio merged commit 0588a71 into theforeman:master Mar 25, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants