-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
chore: Preserve native filters selection after refresh #15583
chore: Preserve native filters selection after refresh #15583
Conversation
Codecov Report
@@ Coverage Diff @@
## master #15583 +/- ##
==========================================
+ Coverage 76.99% 77.02% +0.02%
==========================================
Files 978 979 +1
Lines 51493 51506 +13
Branches 6951 6946 -5
==========================================
+ Hits 39649 39671 +22
+ Misses 11620 11611 -9
Partials 224 224
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
ee923db
to
68ace90
Compare
68ace90
to
e2575fe
Compare
/testenv up FEATURE_DASHBOARD_NATIVE_FILTERS=true |
@kgabryje Ephemeral environment spinning up at http://52.27.157.190:8080. Credentials are |
*/ | ||
import { cloneDeep } from 'lodash'; | ||
|
||
export default function replaceUndefinedByNull(object: Object) { |
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 run cloneDeep
on every level of recursion - I think doing it once, in the first level of recursion, would be enough. However, I'd like to propose a different solution:
const replacer = (key, val) => {
if (val === undefined) return null;
return val;
}
const replaceUndefinedByNull = (object) => JSON.parse(JSON.stringify(object, replacer));
I'm not sure if it would be faster than your solution (we could time it to verify), but I think it's easier to understand. WDYT?
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 totally agree with the unnecessary cloneDeep
. Will fix that.
About the JSON serialization/deserialization I prefer the cloneDeep
because it's faster. We already have benchmarks on this topic:
https://stackoverflow.com/questions/122102/what-is-the-most-efficient-way-to-deep-clone-an-object-in-javascript
https://jsben.ch/bWfk9
@@ -128,6 +131,7 @@ const dataMaskReducer = produce( | |||
[], | |||
cleanState, | |||
draft, | |||
undefined, |
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.
Why do we need pass undefined
here explicitely?
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 was a result of a previous refactor where I had an additional parameter but ended up reverting. Will remove it. Nice catch!
2 issues that I noticed:
Screen.Recording.2021-07-12.at.12.21.20.mov |
e2575fe
to
9a7650a
Compare
@kgabryje Fixed the issues. |
/testenv up FEATURE_DASHBOARD_NATIVE_FILTERS=true |
@michael-s-molina Ephemeral environment spinning up at http://34.215.175.94:8080. Credentials are |
9a7650a
to
b654aee
Compare
/testenv up FEATURE_DASHBOARD_NATIVE_FILTERS=true |
@michael-s-molina Ephemeral environment spinning up at http://34.214.105.118:8080. Credentials are |
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.
Approved with non-blocking test request, thanks!
return result; | ||
} | ||
|
||
export default function replaceUndefinedByNull(object: Object) { |
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.
Tests for this would be nice
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.
Yes! Will do it in a follow-up PR. Thanks for the review!
Ephemeral environment shutdown and build artifacts deleted. |
SUMMARY
Preserve native filters selection after refresh.
@jinghua-qa @junlincc @rosemarie-chiu @rusackas
BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
screen-recording-2021-07-08-at-74912-am_jwOvpeQb.mp4
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION