-
-
Notifications
You must be signed in to change notification settings - Fork 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
refactor(schematics):entity schematics should update the state to plural #1596
refactor(schematics):entity schematics should update the state to plural #1596
Conversation
Preview docs changes for 46c246b at https://previews.ngrx.io/pr1596-46c246b/ |
Preview docs changes for dbde8bc at https://previews.ngrx.io/pr1596-dbde8bc/ |
Need help here don't know why CI is getting failed for e2e testing. |
Preview docs changes for 2ceba07 at https://previews.ngrx.io/pr1596-2ceba07/ |
@santoshyadav198613 , the failing e2e test isn't related to your change. |
The problem is that we are caching the cypress installation in the wrong build step. |
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 be isolated to @ngrx/entity
for now. And it needs some tests for common scenarios.
But this code is part of common function inside schematics-core , can you guide me how should we handle it? |
You create a test for a generated schematic and check that the output is what you expect. For example, your test would use the entity schematic to generate a |
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.
Should we use the pluralize
method at this point?
Because I'm a bit afraid this would lead to inconsistencies, for example, while scaffolding the effects we append the name with an s.
Ok let me check it. |
ok will update and let you know. |
…or(schematics)-Entity-schematics-should-update-the-state-with-a-plural-instead-of-a-singular
Hi @brandonroberts , Added a test case for the scenario this is what i have done. |
@brandonroberts and @timdeschryver let me know about the usage of plural function should i remove it. |
Preview docs changes for ca25fe4 at https://previews.ngrx.io/pr1596-ca25fe4/ |
Hi @brandonroberts , |
@santoshyadav198613 we don't want to modify existing behavior for other areas. Instead, add an |
I'm a bit hesitant to add What about keeping this PR scoped to making the entities pluralized (adding an |
@timdeschryver yes, scoping this to entities is what I had in mind also. |
Thanks @brandonroberts , |
…or(schematics)-Entity-schematics-should-update-the-state-with-a-plural-instead-of-a-singular
Preview docs changes for ed6655d at https://previews.ngrx.io/pr1596-ed6655d/ |
Preview docs changes for 1510211 at https://previews.ngrx.io/pr1596-1510211/ |
Preview docs changes for 757d04e at https://previews.ngrx.io/pr1596-757d04e/ |
Hi @brandonroberts and @timdeschryver , |
Preview docs changes for 0b4a3a2 at https://previews.ngrx.io/pr1596-0b4a3a2/ |
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.
Pretty close. Few more changes
@@ -90,11 +90,13 @@ export function addReducerToStateInterface( | |||
return new NoopChange(); | |||
} | |||
|
|||
let state = stringUtils.camelize(options.name); |
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.
let state = stringUtils.camelize(options.name); | |
const state = options.plural ? stringUtils.pluralize(options.name) : stringUtils.camelize(options.name); |
Let's use the pluralize method instead of tacking on an s
.
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
'innerHTML'.pluralize() // 'InnerHTMLs' | ||
'action_name'.pluralize() // 'actionNames' | ||
'css-class-name'.pluralize() // 'cssClassNames' | ||
'regex'.capitalize() // 'regexes' |
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.
'regex'.capitalize() // 'regexes' | |
'regex'.pluralize() // 'regexes' |
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
'action_name'.pluralize() // 'actionNames' | ||
'css-class-name'.pluralize() // 'cssClassNames' | ||
'regex'.capitalize() // 'regexes' | ||
'user'.capitalize() // 'users' |
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.
'user'.capitalize() // 'users' | |
'user'.pluralize() // 'users' |
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
@@ -110,6 +110,25 @@ export function capitalize(str: string): string { | |||
return str.charAt(0).toUpperCase() + str.substr(1); | |||
} | |||
|
|||
/** | |||
Returns the Pluralize form of a string |
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.
Returns the Pluralize form of a string | |
Returns the plural form of a string |
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
Preview docs changes for 4eb91da at https://previews.ngrx.io/pr1596-4eb91da/ |
Hi @brandonroberts @timdeschryver , |
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
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
currently the state variable is singular updating the same to plural
Closes #1412
What is the new behavior?
Does this PR introduce a breaking change?
Other information