OCPBUGS-72598 | [OVE] Custom manifests are broken in local Assisted UI#3374
OCPBUGS-72598 | [OVE] Custom manifests are broken in local Assisted UI#3374asmasarw wants to merge 1 commit intoopenshift-assisted:masterfrom
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: asmasarw The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
📝 WalkthroughWalkthroughRefines step advancement logic in the cluster wizard context provider to prevent forced navigation away from the custom-manifests step while it is actively being filled. A condition check is added alongside clarifying comments to ensure proper step progression behavior. Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| if ( | ||
| !currentStepId || | ||
| (customManifestsStepNeedsToBeFilled && isStepAfter(currentStepId, requiredStepId)) | ||
| (currentStepId !== 'custom-manifests' && | ||
| customManifestsStepNeedsToBeFilled && | ||
| isStepAfter(currentStepId, requiredStepId)) |
There was a problem hiding this comment.
I dont understand the fix. This useEffect is triggered when user opens the wizard and settings are loaded/or settings are changed. How can this have some effect on copying content into custom manifests field ? the settings should be loaded already, right ?
That leaves out that uiSettings changed and maybe we dont calculate customManifestsStepNeedsToBeFilled properly ?
Can you explain what is the root cause that triggers the original condition which changes the current step?
There was a problem hiding this comment.
@rawagner - when user paste content it changes the uisettings indirectly - see explanations below.
Why does pasting in Custom Manifests reset the wizard to Cluster Details?
1. How does pasting cause the effect to run?
Pasting does not change "wizard settings" directly. It does trigger a chain that updates
uiSettings:
- User pastes in the CodeField →
setValue(text, true)(CodeField.tsx). - Formik
valueschange for the manifest YAML field. - CustomManifestsForm uses
useFormikAutoSave()(debounced ~1s). Whenvalueschange, it
callssubmitForm(). - handleSubmit in
CustomManifestsForm.tsxruns. For a new manifest (not yet saved), it:- Calls
ClustersAPI.createCustomManifest(...) - Then:
if (!uiSettings?.customManifestsAdded) { await updateUISettings({ customManifestsAdded: true }); }
- Calls
- So as a direct result of the paste → auto-save flow, we call
updateUISettings({ customManifestsAdded: true }). - That updates state in
useUISettings→uiSettingsgets a new reference. - ClusterWizardContextProvider uses
useUISettings()and has auseEffectthat depends on
[uiSettings, UISettingsLoading, UISettingsError]. - So when
uiSettingschanges (after the paste → auto-save → updateUISettings chain), the effect
runs.
So: settings are not “already loaded and never change.” Pasting triggers auto-save, which
explicitly updates uiSettings, and that is what triggers the effect.
2. What is the condition that changes the current step?
In ClusterWizardContextProvider.tsx, the effect does:
const customManifestsStepNeedsToBeFilled = !!(
uiSettings?.addCustomManifests && !uiSettings?.customManifestsAdded
);
const requiredStepId = getClusterWizardFirstStep(
locationState,
staticIpInfo,
cluster?.status,
cluster?.hosts,
customManifestsStepNeedsToBeFilled,
);
if (
!currentStepId ||
(customManifestsStepNeedsToBeFilled && isStepAfter(currentStepId, requiredStepId))
) {
setCurrentStepId(requiredStepId);
}So the step is changed when:
!currentStepId(initial step), orcustomManifestsStepNeedsToBeFilled && isStepAfter(currentStepId, requiredStepId)(user is
“ahead” of the required step and we force them back torequiredStepId).
There was a problem hiding this comment.
The AI nicely described the few lines of code we have here.. but didnt really answer anything :)
Lets take a closer look at the original condition
if (
!currentStepId ||
(customManifestsStepNeedsToBeFilled && isStepAfter(currentStepId, requiredStepId))
) {
setCurrentStepId(requiredStepId);
}the step changes if:
a) currentStepId is undefined -> in our case I believe it is it is
b) customManifestsStepNeedsToBeFilled is truthy and isStepAfter is truthy
customManifestsStepNeedsToBeFilled is
const customManifestsStepNeedsToBeFilled = !!(
uiSettings?.addCustomManifests && !uiSettings?.customManifestsAdded
);
it seems the bug is here - how can customManifestsStepNeedsToBeFilled be true, if we just added the custom manifest ?
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.