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

Router manager queue #3540

Merged
merged 68 commits into from
Sep 21, 2019

Conversation

grimasod
Copy link
Contributor

@grimasod grimasod commented Sep 13, 2019

Related issues

closes #3454

Short description and why it's useful

Efficiently add routes to Vue Router, with optional priority for theme routes

Screenshots of visual changes before/after (if there are any)

Which environment this relates to

Check your case. In case of any doubts please read about Release Cycle

  • Test version (https://test.storefrontcloud.io) - this is a new feature or improvement for Vue Storefront. I've created branch from develop branch and want to merge it back to develop
  • RC version (https://next.storefrontcloud.io) - this is a stabilisation fix for Release Candidate of Vue Storefront. I've created branch from release branch and want to merge it back to release
  • Stable version (https://demo.storefrontcloud.io) - this is an important fix for current stable version. I've created branch from hotfix or master branch and want to merge it back to hotfix

Upgrade Notes and Changelog

  • No upgrade steps required (100% backward compatibility and no breaking changes)
  • I've updated the Upgrade notes and Changelog on how to port existing VS sites with this new feature

IMPORTANT NOTICE - Remember to update CHANGELOG.md with description of your change

Contribution and currently important rules acceptance

@grimasod
Copy link
Contributor Author

Still in progress

@pkarw
Copy link
Collaborator

pkarw commented Sep 13, 2019

Cool, looks like a step into right direction!

@pkarw pkarw added the not ready for merge PR is holded. Needs some clarifications or things that need to be finished. label Sep 13, 2019
@grimasod
Copy link
Contributor Author

i'm not sure about this idea - ... - so the question is what for is this change?

I found inconsistencies causing routes to be registered twice. Specifically in Category and Product Vuex actions, they register mappings with localizedDispatcherRoute, which adds a leading slash. It was easier to add the one exception for mappingFallback. And routes need the '/ when adde to the router. But if this causes other problems, or you think it's a bad idea, I can change the catalog actions instead.

@grimasod
Copy link
Contributor Author

We have to do one or the other. Without any change there's a mismatch when the page is reloaded on a category or product page and nothing is loaded

@patzick
Copy link
Collaborator

patzick commented Sep 19, 2019

@grimasod could you merge the master branch into this branch also? I started to merge master-> develop and I have multiple conflicts around route manager. And you provided more changes here so I think best way would be to merge master here, test everything with QA and merge into develop as a final solution. What do you say? I'll do CR right after merge if you would let me know that it's done :)

@grimasod
Copy link
Contributor Author

All tested...

  • checking if url/mappingFallback is not being called (debugger or logger) - to make sure registerMappings still works just fine

Tested - mappingFallback only runs when the initial page load is a category or product page

  • checking swithcing the URL between multistore instances (/de -> /it based urls etc)

Tested - all multistore urls load correctly

  • checking in the console for hydration errors

Tested - there are the same issues on Category and Products pages as the Develop branch

  • checking the route not found errors in the console

Tested - no errors reported

  • page not found,

Tested - default, IT, DE, all work correctly

  • if it;s possible to check if the routes are not duplicated (debugger or log)

Tested - both client and server appear correct, with no duplication

  • check the number of addRoutes call to make sure this optimization gives us proper value

Tested - addRoutes runs once on server and once on client during initial page load. Then once when each new dynamic route is opened for the first time

@grimasod
Copy link
Contributor Author

@patzick I can try, after we resolve the last issue.

I have merged Develop into this branch every day, with all the other changes that have been made there. I also combined the 1.10.3 router changes into this branch, so hopefully this has all the updates already

@patzick
Copy link
Collaborator

patzick commented Sep 19, 2019

@grimasod great, that's why I'd like to do this thru your branch as it contains the most accurate final version :)

@pkarw
Copy link
Collaborator

pkarw commented Sep 19, 2019

Hey @grimasod thanks for the tests you executed; looking cool; when it will be ready for merge?

David Grimason added 4 commits September 20, 2019 10:10
…into feature/router-manager-queue

# Conflicts:
#	CHANGELOG.md
#	core/client-entry.ts
#	core/i18n/package.json
#	core/lib/multistore.ts
#	core/lib/router-manager.ts
#	core/modules/catalog/store/category/actions.ts
#	core/modules/catalog/store/product/actions.ts
#	core/modules/url/helpers/index.ts
#	core/modules/url/router/beforeEach.ts
#	core/modules/url/store/actions.ts
#	core/server-entry.ts
#	docs/package.json
#	lerna.json
#	package.json
#	src/themes/default-amp/package.json
#	src/themes/default/components/core/blocks/SearchPanel/SearchPanel.vue
#	src/themes/default/components/core/blocks/SidebarMenu/SidebarMenu.vue
#	src/themes/default/components/theme/blocks/AsyncSidebar/AsyncSidebar.vue
#	src/themes/default/package.json
#	src/themes/default/resource/banners/de_promoted_offers.json
#	test/unit/package.json
@grimasod grimasod changed the title [WIP] Router manager queue Router manager queue Sep 20, 2019
@grimasod
Copy link
Contributor Author

@patzick I've merged Master. I hope I got it right! :)
@pkarw It's ready now.

I realized the multistore route names do need the store prefix, like "it-home", so they can be customized in the theme route definitions when not using appendStoreCode

@patzick patzick added the QA - Ready for tests This is notification for testers, that improvement is ready to be tested and verified. label Sep 20, 2019
@pkarw
Copy link
Collaborator

pkarw commented Sep 20, 2019

Cool! Thanks! @patzick and @andrzejewsky will take care of CR and tests along with @alinadivante - it’s pretty crucial change

@alinadivante
Copy link
Collaborator

Ok, I've already started testing this branch :) There is the same problem which I reported here #3579
@andrzejewsky will handle these errors

@alinadivante
Copy link
Collaborator

There is a small problem with /page-not-found
I see the difference between Server-side and Client-side..
go to http://localhost:3000/it and click on About us (Magento CMS) link from footer - - the page was not found.
Now refresh http://localhost:3000/it/i/about-us and you will see that pictures from Visualizza i prodotti più venduti disappear
image

image

@alinadivante
Copy link
Collaborator

alinadivante commented Sep 20, 2019

Second problem regarding differences between server side and client side:

  1. Open http://localhost:3000
  2. Log in
  3. Go to my profile
  4. Log out - I'm redirected to Home page and logged out correctly
    now:
  5. Open http://localhost:3000
  6. Log in
  7. Go to my profile
  8. Refresh the page
  9. Log out - I'm redirected to Home page, but I'm not logged out

logout

Copy link
Collaborator

@patzick patzick left a comment

Choose a reason for hiding this comment

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

Everything here works well, really nice job @grimasod! To not hold this PR anymore, QA issues will be addressed in separate PR. Thanks! :)

@@ -196,9 +195,14 @@ export function adjustMultistoreApiUrl (url: string): string {
}

export function localizedDispatcherRoute (routeObj: LocalizedRoute | string, storeCode: string): LocalizedRoute | string {
const appendStoreCodePrefix = config.storeViews[storeCode] ? config.storeViews[storeCode].appendStoreCode : false
const { storeCode: currentStoreCode, appendStoreCode } = currentStoreView()
if (!storeCode || !config.storeViews[storeCode]) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

i've fixed tests mostly by adding here || !config.storeViews[storeCode]. It prevents us from switching to not existing storeView also

@patzick patzick merged commit 64d4631 into vuestorefront:develop Sep 21, 2019
@grimasod grimasod deleted the feature/router-manager-queue branch September 26, 2019 00:49
@alinadivante alinadivante added QA approved after merge Testers will add this label after positive check on merged changes and removed QA - Ready for tests This is notification for testers, that improvement is ready to be tested and verified. labels Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not ready for merge PR is holded. Needs some clarifications or things that need to be finished. QA approved after merge Testers will add this label after positive check on merged changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants