-
Notifications
You must be signed in to change notification settings - Fork 234
COMPASS 235 DV: Full range component #551
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
Conversation
Still needs Decimal128 and probably could use some spot checks and playing with it. |
081125b
to
602a61a
Compare
Pushed a small change to make the rule fit into a single line and make them look a bit nicer. Couple of things I noticed from using the rule builder:
I haven't had a chance yet to go through the full code, but I need to get some 💤. I'm not too worried, we can always ship validation without this rule category and add it in a point release later, it's not a blocker for validation to go out. |
Currently failing a few tests.
|
Start by turning on the range component in the GUI again. Also unskip tests that only work properly when integrated due to the nature of the test API we have built.
Fixes warning with 'none' dropdown state: /Users/pzrq/Projects/compass/node_modules/fbjs/lib/warning.js:36 Warning: Failed prop type: Required prop `value` was not specified in `RangeInput`. in RangeInput (created by RuleCategoryRange) in RuleCategoryRange (created by Rule) in form (created by Form) in Form (created by Rule) in td (created by Rule) in tr (created by Rule) in Rule (created by RuleBuilder) in tbody (created by RuleBuilder) in table (created by Table) in Table (created by RuleBuilder) in div (created by Col) in Col (created by RuleBuilder) in div (created by Row) in Row (created by RuleBuilder) in div (created by Grid) in Grid (created by Editable) in div (created by Editable) in div (created by Editable) in div (created by Editable) in Editable (created by RuleBuilder) in RuleBuilder (created by Validation) in div (created by Grid) in Grid (created by Validation) in div (created by Validation) in Validation (created by ConnectedValidation) in StoreConnector (created by ConnectedValidation) in ConnectedValidationprintWarning @ /Users/pzrq/Projects/compass/node_modules/fbjs/lib/warning.js:36
parseFloat does not take a second argument, unlike parseInt :)
It can't possibly work with the combined range input unless you added multiple IDs somehow which would be a much bigger component refactoring.
So it appears to start in an invalid state if switching from a 'none' state.
It seems to confuse the component, leading to a bizarre cache issue. The best kind of bug fix - when deleting code makes things work better :)
So I can reuse it shortly.
So we can put the common user error of mixing up the lower and upper bounds into the category of being reported by our Compass GUI, but still allow the user to proceed if they choose to.
parseFloat will truncate them later, but the user doesn't see it unless they switch to JSON view or reload the page...this is at least a little better in that they are warned, not sure what the behaviour should really be though. Not sure how to unit test this one as it's deep in the validation logic so it would be somewhere deep in Enzyme if it is testable.
f5dafa2
to
e6453c3
Compare
I think we got the form validation correct now. Here's a video. Basic idea:
|
Just needed to drop the comboValidationState.
@rueckstiess |
@pzrq could you do another round of tests and try to break this latest version? It should be pretty solid now, forms only get validated after the user focused and blurred a field. |
@rueckstiess Apart from CI tests and Decimal128 support regressing (and |
After discussion, we've decided to drop Decimal128 in the range view until users request it, but support it in the JSON view, see https://jira.mongodb.org/browse/COMPASS-294 That just leaves updating the TravisCI tests. |
👍 Woot, finally done. |
* Add JSDoc of proposed coupling between RangeInput validationStates * COMPASS 235: DV - Full range component Start by turning on the range component in the GUI again. Also unskip tests that only work properly when integrated due to the nature of the test API we have built. * Add RuleCategoryRange unit and Rule integration tests * Add failing test for the empty range state * Update RangeInput.value to no longer be isRequired Fixes warning with 'none' dropdown state: /Users/pzrq/Projects/compass/node_modules/fbjs/lib/warning.js:36 Warning: Failed prop type: Required prop `value` was not specified in `RangeInput`. in RangeInput (created by RuleCategoryRange) in RuleCategoryRange (created by Rule) in form (created by Form) in Form (created by Rule) in td (created by Rule) in tr (created by Rule) in Rule (created by RuleBuilder) in tbody (created by RuleBuilder) in table (created by Table) in Table (created by RuleBuilder) in div (created by Col) in Col (created by RuleBuilder) in div (created by Row) in Row (created by RuleBuilder) in div (created by Grid) in Grid (created by Editable) in div (created by Editable) in div (created by Editable) in div (created by Editable) in Editable (created by RuleBuilder) in RuleBuilder (created by Validation) in div (created by Grid) in Grid (created by Validation) in div (created by Validation) in Validation (created by ConnectedValidation) in StoreConnector (created by ConnectedValidation) in ConnectedValidationprintWarning @ /Users/pzrq/Projects/compass/node_modules/fbjs/lib/warning.js:36 * Mostly working, but for some reason renders the stale value... * Refactor componentWillMount into the constructor https://facebook.github.io/react/docs/react-component.html#componentwillmount * Refactor onRangeInputBlur to the end of validate * Remove 10 from parseFloat parseFloat does not take a second argument, unlike parseInt :) * Drop unused RangeInput.onChange prop It can't possibly work with the combined range input unless you added multiple IDs somehow which would be a much bigger component refactoring. * Be clearer which store * Call validate after changing the dropdownOp value So it appears to start in an invalid state if switching from a 'none' state. * Remove componentWillReceiveProps It seems to confuse the component, leading to a bizarre cache issue. The best kind of bug fix - when deleting code makes things work better :) * ESlint * Fix race where validationState is not allowed to be empty string react-bootstrap/react-bootstrap#1926 * Finally, playing with the (unvalidated) component works correctly * Refactor into validateCombinedParams So I can reuse it shortly. * Finally get comboValidationState working So we can put the common user error of mixing up the lower and upper bounds into the category of being reported by our Compass GUI, but still allow the user to proceed if they choose to. * Add a regex to warn the user they cannot enter expressions like 10+5 parseFloat will truncate them later, but the user doesn't see it unless they switch to JSON view or reload the page...this is at least a little better in that they are warned, not sure what the behaviour should really be though. Not sure how to unit test this one as it's deep in the validation logic so it would be somewhere deep in Enzyme if it is testable. * Handle and test the 0 case correctly Thankfully the server already did, good thing I tried to record a demo video and check: > db.runCommand({collMod: 'validation', validator: {"age": {$gt:0, $lt:500}}}); { "ok" : 1 } > db.getCollectionInfos()[1].options.validator { "age" : { "$lt" : 500, "$gt" : 0 } } # Server also supports null which we don't because it gets mangled between my code and Thomas' code so meh until someone cares for it > db.runCommand({collMod: 'validation', validator: {"age": {$gt:null, $lt:500}}}); { "ok" : 1 } > db.getCollectionInfos()[1].options.validator { "age" : { "$gt" : null, "$lt" : 500 } } * Improve comments This particular state is no longer rejected by the Rule Builder GUI, just shown highlighted in red as something we highly doubt a user would intentionally create, for the reasons outlined in `npm run ci` like the range being empty or easily hard-code-able as an application-level constant. * Add better regex to handle exponential float forms * Fix translating regexes fail (the |, vertical bar ASCII code 0x7c should not be accepted) Though incoming hadron-type-checker should resolve this more completely (its DECIMAL_128_REGEX still accepts arbitrarily large exponents which it should not, but it's better than this one was). * Add some Decimal128 tests * Handle Decimal128 and drop clunky parseFloat uses * Be more explicit that combined ranges of Decimal128s are not validated * shrink range inputs, remove title labels. * 👕 fix linter issue. * don’t validate initially, fix tests. * form validation. such difficult. * [wip] up and downwards validation almost working * fixing some edge cases, updating tests. * Restore tests so accepts/rejects is clearer Just needed to drop the comboValidationState. * make rule id consistent (based on index of rule). * store cancel always needs to call _updateState() * range: disable bson type casting * cancelChanges no longer takes a boolean. * validation rewritten. only use single validate() method * use componentWillReceiveProps where props are forked. * force a redraw when cancel was pressed via key change * 👕 fixing eslint issues. * Drop HP_VERSION until COMPASS-294 * 💚 fix tests.
No description provided.