-
Notifications
You must be signed in to change notification settings - Fork 235
feat(@mongodb-js/compass-query-bar): Add prop to toggle visibility of sorts square bracket placeholders CLOUDP-97063 #2388
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
|
||
License tags: MIT | ||
|
||
License files: |
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.
This should not be changed manually, seems like something might've gone wrong during the merge/rebase?
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.
Yap, seems like that is what happened.
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.
Left a comment suggesting a different approach for the change you're planning to introduce. It would be also interesting to learn what environment doesn't support arrays as sort option, it seems to be supported by the node driver for some time now
this.props[option] : this.props[`${option}String`]; | ||
|
||
const label = OPTION_DEFINITION[option].label || option; | ||
const placeholder = option === 'sort' && !supportSquareBracketSorts ? OPTION_DEFINITION[option].nonSquareBracketPlaceholder : OPTION_DEFINITION[option].placeholder; |
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.
I don't think it's the approach to allow for the behavior you want, this api feels very specific and hard to scale (what if next you would want to change a label on another field, how many of those custom props for any of them will end up in this component interface?). Maybe something more generic that treats OPTION_DEFINITION
as default options and allows to override them with props might be more appropriate here
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.
Got it! Will fix this and push again
f083b38
to
09b610f
Compare
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.
Thanks for addressing the feedback! The new implementation is definitely much better, but I still have a note about it. If you feel like chatting about it, definitely feel free to reach out.
I would also still encourage you to check with the team why this change is needed as array sort option should be a supported way of filtering and more or less the only one that would allow to get an expected sort result when object keys are number-like (e.g., {"3": 1, "2": 1, "1": -1}
)
this.props[option] : this.props[`${option}String`]; | ||
|
||
const label = OPTION_DEFINITION[option].label || option; | ||
const placeholder = option === 'sort' && sortOptionPlaceholder ? sortOptionPlaceholder : OPTION_DEFINITION[option].placeholder; |
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.
We're totally getting close here, that's a much nicer implementation, but in a way have the same issue the previous implementation had, it only allows to override the placeholder for one specific filed which is not really intuitive and that's the main problem I see here.
If we are changing this part of the code, I think we might as well allow those placeholder overrides for all fields. Check out how the value and validation status are derived for the fields a few lines above:
compass/packages/compass-query-bar/src/components/query-bar/query-bar.jsx
Lines 209 to 217 in 04db91c
// for filter only, also validate feature flag directives | |
const hasError = option === 'filter' | |
? !(filterValid || featureFlag) | |
: !this.props[`${option}Valid`]; | |
// checkbox options use the value directly, text inputs use the | |
// `<option>String` prop. | |
const value = OPTION_DEFINITION[option].type === 'boolean' ? | |
this.props[option] : this.props[`${option}String`]; |
I think we might want to do something similar here for consistency, for example:
const placeholder = option === 'sort' && sortOptionPlaceholder ? sortOptionPlaceholder : OPTION_DEFINITION[option].placeholder; | |
const placeholder = this.props[`${option}Placeholder`] || OPTION_DEFINITION[option].placeholder; |
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.
Got it!
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.
Great work, thanks!
37188c5
to
9e41bcc
Compare
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
Description
This PR adds the ability for one to hide the square sorts place holder in the sort option of the query bar. This feature makes it possible for one to be clear about the type of sorts that are supported in the query bar. For example, in the case that the square brackets are not supported, one can hide the sort square brackets placeholder.
Checklist
Motivation and Context
Open Questions
Dependents
Types of changes