-
Notifications
You must be signed in to change notification settings - Fork 16
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
Add layerOrder in LegendWidget #433
Add layerOrder in LegendWidget #433
Conversation
This pull request has been linked to Shortcut Story #222396: Implement layerOrder in LegendWidget. |
Pull Request Test Coverage Report for Build 2514980517
💛 - Coveralls |
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 think the code is quite complex considering that we're covering a very simple use case.
packages/react-widgets/__tests__/widgets/utils/sortArrayByPropValues.test.js
Outdated
Show resolved
Hide resolved
packages/react-widgets/src/widgets/utils/sortArrayByPropValues.js
Outdated
Show resolved
Hide resolved
🔥 remove old files 🔥 remove dyn property ♻️ simplifying code ✨ ids not included in the order at the start
packages/react-widgets/__tests__/widgets/utils/sortLayersById.js
Outdated
Show resolved
Hide resolved
packages/react-widgets/__tests__/widgets/utils/sortLayersById.js
Outdated
Show resolved
Hide resolved
packages/react-widgets/__tests__/widgets/utils/sortLayersById.js
Outdated
Show resolved
Hide resolved
packages/react-widgets/__tests__/widgets/utils/sortLayersById.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Sergio Clebal <sclebal@cartodb.com>
Co-authored-by: Sergio Clebal <sclebal@cartodb.com>
- check the layerOrder length - move assert inside sort function - complete proptypes - rename test file
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.
LGTM, but please consider comment about _assert
…//github.com/CartoDB/carto-react into feature/ch222396/add-layerorder-legendwidget
Description
Shortcut: https://app.shortcut.com/cartoteam/story/222396/implement-layerorder-in-legendwidget
Background
Currently, the legends are rendered using the Object.values fn with the layers object where we store the layers config (store) in redux.
Problem
Object.values fn doesn't guarantee the order (Source), so we might have weird behaviour considering that the addLayer action is executed in the same order that the layer are executed in the layers/index.js file.
Solution
Add layerOrder: string[] prop in LegendWidget. layerOrder is an array of layer ids, when the Object.values is executed, the resulting array must be ordered following the layerOrder prop.
Add sortArrayByPropValues utils. Is a function to sort a list of objects based on a property values.
Type of change
Acceptance
Please describe how to validate the feature or fix
In your App
The specified layerOrder, from left to the right, should be the order we want from bottom to top in the legend display.
The elements should be sorted by id property, from bottom to top.
In carto-react
yarn run test
commandThe added test are related with the util sortArrayByPropValues .