Skip to content
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

Merged
merged 5 commits into from
Aug 28, 2023
Merged

Refactor sap system selectors #1758

merged 5 commits into from
Aug 28, 2023

Conversation

arbulu89
Copy link
Contributor

@arbulu89 arbulu89 commented Aug 28, 2023

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

@@ -24,6 +24,11 @@ export const getClusterName = (clusterID) => (state) => {
return get(cluster, 'name', '');
};

export const getClusterByHost = (state, hostID) => {
Copy link
Contributor Author

@arbulu89 arbulu89 Aug 28, 2023

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

Copy link
Contributor

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(
Copy link
Contributor Author

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(
Copy link
Contributor Author

@arbulu89 arbulu89 Aug 28, 2023

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.

@arbulu89 arbulu89 added the env Create an ephimeral environment for the pr branch label Aug 28, 2023
@arbulu89 arbulu89 marked this pull request as ready for review August 28, 2023 13:34
Copy link
Contributor

@dottorblaster dottorblaster left a 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!

Comment on lines 45 to 46
(id, state) => getSapSystem(id)(state),
(id, state) =>
Copy link
Contributor

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@arbulu89 arbulu89 requested a review from dottorblaster August 28, 2023 15:08
Copy link
Contributor

@dottorblaster dottorblaster left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@rtorrero rtorrero left a 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

@arbulu89 arbulu89 force-pushed the refactor-sap-system-selectors branch from 5b15778 to d5ba3fb Compare August 28, 2023 16:15
@arbulu89 arbulu89 merged commit 50a668a into main Aug 28, 2023
@arbulu89 arbulu89 deleted the refactor-sap-system-selectors branch August 28, 2023 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore env Create an ephimeral environment for the pr branch tech debt
Development

Successfully merging this pull request may close these issues.

3 participants