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
Rework client-side script for connection form. #14052
Conversation
Before this, fields on the connection form were dynamically changed by adding and removing the "hide" CSS class. If a provider were to add a field that requires validation (e.g. InputRequired), or if a different field type was used (e.g. NumberField), the entire form would be unsaveable, even if the currently selected connection type had nothing to do with that provider. This change takes a different approach; upon loading, the DOM elements for all extra fields are saved into a Map, then removed from the DOM tree. When another connection type is selected, these elements are restored into the DOM.
Congratulations on your first Pull Request and welcome to the Apache Airflow community! If you have any issues or are unsure about any anything please check our Contribution Guide (https://github.com/apache/airflow/blob/master/CONTRIBUTING.rst)
|
This is significantly easier to read than the previous jQuery. We already have |
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.
Very nice work @yjwong! I just had one tiny suggestion.
Co-authored-by: Ryan Hamilton <ryan@ryanahamilton.com>
Applied the suggestion, thanks for the review @ryanahamilton! |
The PR is likely OK to be merged with just subset of tests for default Python and Database versions without running the full matrix of tests, because it does not modify the core of Airflow. If the committers decide that the full tests matrix is needed, they will add the label 'full tests needed'. Then you should rebase to the latest master or amend the last commit of the PR, and push it with --force-with-lease. |
Awesome work, congrats on your first merged pull request! |
Before this, fields on the connection form were dynamically changed by adding and removing the "hide" CSS class. If a provider were to add a field that requires validation (e.g. InputRequired), or if a different field type was used (e.g. NumberField), the entire form would be unsaveable, even if the currently selected connection type had nothing to do with that provider.
This change takes a different approach; upon loading, the DOM elements for all extra fields are saved into a Map, then removed from the DOM tree. When another connection type is selected, these elements are restored into the DOM.
With this change, we still can't use
wtforms.validators.InputRequired
because of server-side validation, however, a provider can subclassInputRequired
and conditionally validate based on connection type. Here's an example:closes: #13985
Note: I wasn't sure about the conventions for JavaScript files here; some lines had semicolons, some didn't. In my change, I just made sure that every line ended with a semicolon, but I didn't want to change the other lines to avoid creating too much noise.
Another thing I'm unsure about is Airflow's browser support policy. This change does away with a lot of jQuery use, instead opting for standard DOM APIs. In particular,
Array.from
is used, which means that this won't be supported by any version of Internet Explorer. Microsoft themselves are EOLing IE by 17th August 2021 for their own products, so not sure how much of an issue this is.