-
Notifications
You must be signed in to change notification settings - Fork 58
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
Wizard: Refactor hostname and blueprint name inputs (HMS-5616) #2872
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
@@ Coverage Diff @@
## main #2872 +/- ##
=======================================
Coverage 81.91% 81.91%
=======================================
Files 209 209
Lines 23570 23577 +7
Branches 2330 2333 +3
=======================================
+ Hits 19307 19314 +7
Misses 4234 4234
Partials 29 29
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch, the validation should not appear when there is no hostname.
I’m not sure about the approach, though. In this PR we’re hiding the validation by returning an error object with a fieldname of ‘default’. That technically works and is supported by the HookValidatedInput but it just feels kind of surprising/counter-intuitive.
I think it feels counter-intuitive because <HookValidatedInput>
does not surface validation on pristine state components. So there is already an existing pattern for not displaying validation – that’s what I intuitively would expect to use. In other words, set isPristine to true when the field’s value returns to the default state (in this case, ‘’).
This might be a good opportunity to refactor a little bit. The double nested ternary operator is hard to understand. It definitely does support this ‘feature’ where if the fieldName is ‘default’ then but let’s take a step back and ask… should it? Maybe we can get rid of the nested ternary and the concept of a ‘default’ state. Having to manage both ‘default’ and ‘isPristine’ feels duplicitous.
In all the validation hooks, it only seems to be used in one other place, and there is a comment specifically calling it out as a hacky solution…
Therefore, I am a little hesitant to introduce this new pattern to the code base. I’d prefer refactoring a bit. What do you think?
after some investigation, the solution that I did here https://github.com/osbuild/image-builder-frontend/pull/2844/files#diff-5206f54a601e8c56290e1a412fbf3f35172f16b892c7674852c91b4ea846bcd9R62 |
I saw your comment here #2844 |
7f3c4c0
to
32f8bba
Compare
d861369
to
61d3608
Compare
a5d24be
to
631ddf5
Compare
nice catch @regexowl , I am looking at stage, if user delete the value in Blueprint name we should see an error be cecause it's mandatory field, am I wrong? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be rebased on top of #2922?
432e6a3
to
1691115
Compare
72d375a
to
8092a84
Compare
/jira-epic HMS-5294 |
3c1248a
to
a6005d8
Compare
afd4c5e
to
3d83f3b
Compare
db2394a
to
4020dcf
Compare
This commit Implement refactor of HookValidatedInput for hostname and blueprint name fields, addressing the following bugs: 1) Fixes a bug where the validation symbol persisted after a user deleted the value in the hostname field. 2) Fixes a bug where the validation symbol persisted after a user deleted the value in the blueprint name field. These changes improve code maintainability and provide a more consistent user experience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you! ✨ And the blueprint name bug is a really nice catch! 🐛
This commit Implement refactor of HookValidatedInput for hostname and blueprint name
fields, addressing the following bugs:
These changes improve code maintainability and provide a more consistent user experience.
FIX ISSUE: 2917, #2971
JIRA: HMS-5616