-
Notifications
You must be signed in to change notification settings - Fork 683
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 create-account route to use appShell to get provided requisite properties #1430
Conversation
This pull request is automatically deployed with Now. Latest deployment for this branch: https://venia-git-fix-create-account-link.magento-research1.now.sh |
@dpatil-magento not sure why this is failing to build -- I ran the failing command locally and it worked. :( |
@sirugh Looks like the backing instance is down. Checking this now - https://venia-cicd-lrov2hi-mfwmkrjfqvbjk.us-4.magentosite.cloud/ |
|
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.
Excellent thank you!
@sirugh After creating account on https://venia-qbl9lrsc0.now.sh/create-account, I see js error. Also, whats the expected behavior if Customer is already logged in and then access create-account direct URL? cc @soumya-ashok @awilcoxa as its related to UX. |
I'll look into the bug @dpatil-magento. Also it looks like we have two paths to |
@sirugh the /create-account page already exists when guest user place an order and then click on Create Account button. |
First off, I see this as being such an edge case where someone takes the trouble to save the create account URL and then tries to visit it via the URL especially on shopping sites where they really don't want to create an account in the first place unless there's a compelling reason. However, if we do want to cover this scenario, we could have the following cases for the sign-in/create account experience If the user has created an account and is signed in, the footer within the main nav. shows that, like in this mockup - https://magento.invisionapp.com/share/KMT00QQH79C If the user has an account but is signed out and visits the create account page, then they should be able to create an account with an email other than the one they're using, and if they try to use the existing email, display the appropriate error. Does that answer the question? |
@soumya-ashok as @dpatil-magento showed there are two routes to create an account.
I don't think we're talking about a situation where a user is navigating directly to |
@sirugh I see. One of the comments above said "navigates directly to the create account URL", so I thought that meant they were going to it outside of the path provided. |
# An object that returns true if the NODE_ENV environment variable is set | ||
# to 'development'. Used as a test in other configurations in this file. | ||
# Returns false otherwise. | ||
isDevelopment: |
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.
Unused properties, AFAICT.
- matches: request.url.pathname | ||
pattern: '^/create-account' | ||
use: index | ||
use: appShell |
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.
Instead of having two routes, index
vs appShell
or hardcodedAppShell
vs urlResolvedAppShell
as @zetlen and I discussed, I went with this method in which I re-used the single appShell
. The benefit being that I did not have to rewrite much of the foundation that appShell already provides.
const htmlDataset = document.querySelector('html').dataset; | ||
const { imageOptimizingOrigin } = htmlDataset; | ||
// Protect against potential falsy values for `mediaBackend`. | ||
const mediaBackend = htmlDataset.mediaBackend || 'https://backend.test/media/'; |
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 fixes a bug identified where mediaBackend
was an empty string which destructures as ""
instead of being falsy.
TBH I'm not sure why we have a default value here anyways -- seems like it just gets rewritten in the makeUrl code.
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, there shouldn't be a default here.
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.
Ok -- rather than remove the default, @zetlen and I discussed and it is out of scope. That being said we should probably rewrite makeUrl
or at least fix this to not need a fallback (ie. console.error and THEN use a default.
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 just added a warning if it's falsy to at least indicate a problem.
@@ -33,11 +33,10 @@ response: | |||
- matches: request.url.pathname | |||
pattern: '^/(graphql|rest)(/|$)' | |||
use: proxy | |||
# Requests to create an account are handled by the top-level 'index' | |||
# object, which returns a generic app shell | |||
# Requests to create an account are handled by the 'appShell' object. | |||
- matches: request.url.pathname |
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.
Also, it's not clear to me why lines 37-39 are required. I would have assumed we could just resolve similar to how we resolve /search.html
, but if I remove these lines I get failures like unable to load "<url>/dist/create-account"
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.
Actually, you've uncovered an optimization opportunity in the resource
definition. Matches are evaluated top to bottom, so we want the hardcoded matches to be above the matches that check urlResolver
. When we know ahead of time that the hardcoded URL will not be resolved with urlResolver, we want to avoid evaluating urlResolver, since it's actually placing a graphQL query. There's gotta be a simpler way to do that in the future.
For now, to prevent merge conflicts, let's just move all the match clauses against literal URL paths to the top of the conditional stack, and all the matches against urlResolver
under them. That helps us avoid an additional request.
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.
Ok, moved.
@sirugh QA Pass, can be merged once review is approved. |
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 reorder some conditionals to avoid unnecessary urlResolver
calls and go forward with it. I realize that this means testing against the same URL patterns in multiple places. We can fix that later. Thanks for all your help.
const htmlDataset = document.querySelector('html').dataset; | ||
const { imageOptimizingOrigin } = htmlDataset; | ||
// Protect against potential falsy values for `mediaBackend`. | ||
const mediaBackend = htmlDataset.mediaBackend || 'https://backend.test/media/'; |
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, there shouldn't be a default here.
@@ -33,11 +33,10 @@ response: | |||
- matches: request.url.pathname | |||
pattern: '^/(graphql|rest)(/|$)' | |||
use: proxy | |||
# Requests to create an account are handled by the top-level 'index' | |||
# object, which returns a generic app shell | |||
# Requests to create an account are handled by the 'appShell' object. | |||
- matches: request.url.pathname |
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.
Actually, you've uncovered an optimization opportunity in the resource
definition. Matches are evaluated top to bottom, so we want the hardcoded matches to be above the matches that check urlResolver
. When we know ahead of time that the hardcoded URL will not be resolved with urlResolver, we want to avoid evaluating urlResolver, since it's actually placing a graphQL query. There's gotta be a simpler way to do that in the future.
For now, to prevent merge conflicts, let's just move all the match clauses against literal URL paths to the top of the conditional stack, and all the matches against urlResolver
under them. That helps us avoid an additional request.
a18b5f6
to
7c83336
Compare
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 is good now.
Description
The create-account page (and probably other pages) was broken. Upward used
index
when serving/create-account
.index
uses generic-shell.mst, which uses default-initial-contents.st, which referencesassets.svg.logo
. This means that anything using default-initial-contents.mst must also include the asset manifest.Related Issue
Closes #1429.
Verification Steps
<url>/create-account
. It should show the create account page.Screenshots / Screen Captures (if appropriate)
Proposed Labels for Change Type/Package
Checklist: