-
Notifications
You must be signed in to change notification settings - Fork 356
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
Added promise debounce library (with updated typescript) and async validation in Catalog form #5284
Conversation
@miq-bot add_label hammer/no, services, react, enhancement |
Awesome!! great job! |
My only worry is that the author will stop supporting that package in near future. But the code seems simple enough to just steal it and move it mi MIQ 😄 We should also mention that if you want the validation to fail you need to return some value (for our components its the error message) from promise and if it should pass you return Another thing that we should mention is that using promise based validator with normal function ones, the promise base will "break" them. Meaning that even if classic validator fails, the promise one will be completed when the promise is and that will most likely be after the normal ones which will render them useless. So your async validation will need some extra logic (adding required validation to promise resolution for instance). So what we could do is to actually export the validation functions from data driven forms and use them in promises. Or we can check if some validator is a promise and the hook rest of the validators to run when its resolved, but that another logic for something that will be used rarely. |
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.
@rvsia The validation works but there is a small issue. The validator is triggers even if you change different form field. I would add some memoize function that will remember the last input value and if its the same as current just return the old error message. This way we won't be making extra requests.
Example here: https://codesandbox.io/s/wyq72qxly5
see the simpleMemoize
function
Otherwise looks good.
@Hyperkid123 Data-driven forms updated and it works correctly! |
Checked commits rvsia/manageiq-ui-classic@946234d~...60dd4eb with ruby 2.3.3, rubocop 0.52.1, haml-lint 0.20.0, and yamllint 1.10.0 |
Description
Services > Catalogs > Catalogs > Configuration > New/Edit
(it controlls if name is available)Before
After
@terezanovotna