-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Label override flags for dbAuth generator #6440
Conversation
@cannikin In principle this meets the requirements of the initial #3555 description. However, if it's okay I would ask what you and others may think regarding the following points:
|
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 for getting started on this PR. I left a few comments/suggestions. You're more than welcome to disagree with my suggestions 🙂 Just please tell me why in that case.
Co-authored-by: Tobbe Lundberg <[email protected]>
Co-authored-by: Tobbe Lundberg <[email protected]>
Thanks @Tobbe, your suggestions were much better and I think the |
Another PR already?? You're in the zone now! 🙂 I do worry a bit that people will confuse setting these two labels with the actual names of the fields in the database. You're already free to make those whatever you want, you just have to let Redwood know what you called them in
|
Wrong PR for the comment |
Thanks @cannikin, some thoughts in reply:
In general I'd love to get a better idea of what direction you're all moving the CLI in to ensure the whole system is as homogenous as possible with any contributions I do try to make. |
So the first thing you'd run as a user is Could |
I'd recommend you read this issue thread. It's mostly about the initial |
I agree so this would make the users workflow be something like:
How does that seem? People against the use of prompts will probably cry with that suggestion. |
I liked it all the way up to the second set of prompts 😂 When would one ever want to select something different there? Give me a good usecase and I'm easily convinced those prompts are a good idea too :) |
I originally split the two commands, thinking that 50% of people would want the api-side of dbAuth, but completely create the login pages from scratch, and the other 50% would just want to use our generated ones and customize them. At this point, I wouldn't be surprised if 99% of people just run the generate pages command right after the setup command anyway. If we're adding prompts for the labels, we could just prompt If they don't, they can run the |
I think this leaves us with a possible consensus of both generators have prompts for labels and Only thing blocking that is getting prompts to work nicely 😂 |
You might not know this yet @Josh-Walker-GM, but we're rebuilding our whole auth subsystem, including setup commands. Right now dbAuth is getting some special treatment in our code, but that won't be the case moving forward. So whatever extra capabilities we give to dbAuth setup, we also must give (the possibility of) to other auth setup commands. So when you have a solution in mind that you think might work, also take a look at this PR #5985 and see how you could integrate the same solution there. |
@Tobbe Okay I'll bear this in mind. Can I ask where is best to ask/discuss things related to the current CLI tools - Listr, prompt etc? |
It depends... 😁 (Doesn't it always?) |
You're also always free to join one of our contributors meetups and talk about your idea there. The next one is Oct 6th (unfortunately I won't be able to make that one) https://community.redwoodjs.com/t/contributors-meetups-a-next-step-for-redwoodjs-participation/2470 |
I'll put this PR on hold until the CLI repercussions brought about by #6442 are clear. |
Given this is going to rely on prompting as a core feature my plan is to wait for #6444 before continuing. |
useEffect(() => { | ||
usernameRef?.current?.focus() | ||
${usernameCamelCase}Ref?.current?.focus() | ||
}, []) | ||
|
||
const onSubmit = async (data: { username: 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.
I think we could do ${usernameCamelCase}
here, right? (And of course also when we pass it to forgotPassword
)
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.
Yeah I totally agree. I've implemented changes along these lines in d79294a.
Hmm, maybe we should take an all-or-nothing approach here then? And just leave all of the code alone and only update the text as you had it initially. But I'm not convinced Next step after this PR is to do something similar for
Knee-jerk reaction is that it should be doable. Do you want to spend more time one trying to figure it out? If you do, you could share what you've tried and I we can both look at it |
Okay I'll spend a little more time on updating the code changes too then.
You made the good point a while back that doing this would probably require the new packages which provide auth support to take the same options as the redwood dbAuth one does. This would be an unwanted requirement on these packages? Would we be okay with only the redwood dbAuth setup supporting such options? Definitely some thought needed for changes to that side.
Your second point makes me realise we would only want this comment to be added based on the state of the API. Say a user already updates the API first and then goes to do the UI using the generators these comments would be incorrect. Perhaps it's better to simply not have them? EDIT: Also having code like |
Just for my own sanity I went back and checked the changes to the docs. They are still correctly updated in my opinion. I don't think we need to specifically mention anything about the variables getting names which are consistent with the labels. Thanks again @Tobbe for the suggestion to rename the variables, a big improvement I think. |
Definitely fine for only dbAuth to support this, as long as it's possible to add support to other providers too in the future if there's any appetite for it |
After that I think this is good? |
Okay ready to look this thing over! What state are we in, is this still good? Works with the decoupled auth updates? |
Not 100% confident on the decoupled auth stuff, I'll do a quick test on the latest canary to check it all still works. Other than that I think I'm happy with it. EDIT: |
* initial ability to pass label arguements * Added remaining parameters to auth template files * Added no default value check in order to pass tests * Apply suggestions: reduce templateVars duplication Co-authored-by: Tobbe Lundberg <[email protected]> * Apply suggestions: replace ternary Co-authored-by: Tobbe Lundberg <[email protected]> * Added missing templateVars declaration * Renamed template vars * Renamed flags to include 'label', added prompts and used listr2 tasks for user interrogation * Updated yarn.lock * Added default values within function * Updated web authn page template - not tested * Moved WebAuthn into listr * Some tidying up * Fix default webauthn flag value check * Added enquirer option and other minor fixes * Added tests for prompts * Add web.app to the mocked getPaths * Fix password label and add listr2 options to task handler * Added snapshot tests * Added --username-label and --password-label flags to the docs for rw g dbAuth * Normalise paths within tests * Added test for custom labels and webauthn enabled * Add flags to prevent test project creation prompting the user * Updated test project fixtures * update snapshots and set mockfiles before test describe * Customised auth variables similar to labels * updated test fixtures * Update test snapshots * Updated to use customised variable names based on label option * Add missing dbAuth command test Co-authored-by: Tobbe Lundberg <[email protected]> Co-authored-by: Rob Cameron <[email protected]>
* initial ability to pass label arguements * Added remaining parameters to auth template files * Added no default value check in order to pass tests * Apply suggestions: reduce templateVars duplication Co-authored-by: Tobbe Lundberg <[email protected]> * Apply suggestions: replace ternary Co-authored-by: Tobbe Lundberg <[email protected]> * Added missing templateVars declaration * Renamed template vars * Renamed flags to include 'label', added prompts and used listr2 tasks for user interrogation * Updated yarn.lock * Added default values within function * Updated web authn page template - not tested * Moved WebAuthn into listr * Some tidying up * Fix default webauthn flag value check * Added enquirer option and other minor fixes * Added tests for prompts * Add web.app to the mocked getPaths * Fix password label and add listr2 options to task handler * Added snapshot tests * Added --username-label and --password-label flags to the docs for rw g dbAuth * Normalise paths within tests * Added test for custom labels and webauthn enabled * Add flags to prevent test project creation prompting the user * Updated test project fixtures * update snapshots and set mockfiles before test describe * Customised auth variables similar to labels * updated test fixtures * Update test snapshots * Updated to use customised variable names based on label option * Add missing dbAuth command test Co-authored-by: Tobbe Lundberg <[email protected]> Co-authored-by: Rob Cameron <[email protected]>
….com:redwoodjs/redwood into feat/dc-kc-decoupled-auth-setup-improvements * 'feat/dc-kc-decoupled-auth-setup-improvements' of github.com:redwoodjs/redwood: chore(deps): update dependency nx to v15.3.2 (#7114) chore(deps): update dependency redis to v4.5.1 (#7115) fix: add missing deps to cli helpers (#7117) Adds ability to delete a cache entry (#7016) Label override flags for dbAuth generator (#6440) fix(deps): update dependency systeminformation to v5.16.6 (#7108) feat: Generator rollbacks (#6947) fix(deps): update dependency @types/node to v16.18.8 (#7107) chore(deps): update dependency supertokens-node to v12.1.3 (#7105)
Resolves #3555
Description
Adds optional flags
username-label
andpassword-label
which set the form labels in theSignupPage
,LoginPage
,ForgotPasswordPage
andResetPasswordPage
generated via theyarn rw g dbAuth
command.Adds prompts to get these labels from the user if not already passed in by the flags. Prompt default values are
Username
andPassword
Example of the CLI prompting:
These label values are also used to determine the name of the variables within the generated files. This means if you request that
username-label
beemail
then variables likeusernameRef
becomeemailRef
. Thanks to @Tobbe for this good idea!Outstanding