-
Notifications
You must be signed in to change notification settings - Fork 15
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
Refactor sap system selectors #1758
Conversation
@@ -24,6 +24,11 @@ export const getClusterName = (clusterID) => (state) => { | |||
return get(cluster, 'name', ''); | |||
}; | |||
|
|||
export const getClusterByHost = (state, hostID) => { |
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.
Moved from index.js
. Now it uses lodash find function
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.
YEEEEEEEAH
[ | ||
(id, state) => getSapSystem(id)(state), | ||
(id, state) => | ||
enrichInstances( |
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'm not sure if adding this operation here is a good idea, or it should better go in the body of the function
export const getDatabase = (id) => (state) => | ||
state.databasesList.databases.find((database) => id === database.id); | ||
|
||
export const getEnrichedSapSystemDetails = createSelector( |
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.
In essence, the next getEnrichedSapSystemDetails
and getEnrichedDatabaseDetails
functions have been the major change in the whole PR.
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.
Just a thing then we can merge. Awesome work, thank you so much!
(id, state) => getSapSystem(id)(state), | ||
(id, state) => |
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.
Can you switch this to (state, id)
form? Usually state
comes as the first parameter when you use createSelector
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 can and I will!
Thank you for the tip
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.
Done
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
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 @arbulu89, this looks much clearer now
5b15778
to
d5ba3fb
Compare
Description
Refactor sap systems/databases selectors to use
createSelector
. This will enable to update SapSystemsOverview and DatabasesOverview views to make storybook addition easy.Besides that, I have moved the functions to a new
sapSystems
file, used lodash in some operations and removed the camelCase transformation that is only used in these selectors.How was this tested?
Tests added after refactoring