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

feat: expose Promise result of the Angular navigation in RoutingService #12795

Merged
merged 15 commits into from
Jun 22, 2021

Conversation

Platonn
Copy link
Contributor

@Platonn Platonn commented Jun 16, 2021

Exposed Promise result of the Angular navigation in methods of the RoutingService: go() and goByUrl().
Now Angular Router is called directly from the RoutingService, but not from ngrx effects anymore. Dropped the effects as well as the actions triggering them.

Added migration docs and schematics for the breaking changes.

By the way, added the missing param NavigationExtras in RoutingService.goByUrl.

BREAKING CHANGES
The following ngrx actions have been removed:

  • RoutingActions.RouteGo (and RoutingActions.ROUTER_GO)
  • RoutingActions.RouteGoByUrlAction (and RoutingActions.ROUTER_GO_BY_URL)
  • RoutingActions.RouteBackAction (and RoutingActions.ROUTER_BACK)
  • RoutingActions.RouteForwardAction (and RoutingActions.ROUTER_FORWARD).
    Please use instead the methods of the RoutingService, respectively: go(), goByUrl(), back(), forward().

closes #12789

@Platonn Platonn requested review from a team June 16, 2021 08:51
@cypress
Copy link

cypress bot commented Jun 16, 2021



Test summary

586 0 17 0Flakiness 1


Run details

Project spartacus
Status Passed
Commit 37f16ce ℹ️
Started Jun 22, 2021 10:35 AM
Ended Jun 22, 2021 10:47 AM
Duration 12:08 💡
OS Linux Ubuntu - 18.04
Browser Electron 89

View run in Cypress Dashboard ➡️


Flakiness

cypress/integration/accessibility/group-skipping.e2e-spec.ts Flakiness
1 Group Skipping - Checkout > reviewOrder > should tab through group skippers

This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@Platonn Platonn requested a review from a team June 16, 2021 10:03
@@ -1207,6 +1208,15 @@ related labels outside of checkout and the checkout lib is not used, you will ne
`RoutingService.go` - Removed 2nd argument `query`. Use `extras.queryParams` instead.
`RoutingService.navigate` - Removed 2nd argument `query`. Use `extras.queryParams` instead.

### RoutingActions ngrx
The following ngrx actions has been deprecated:
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't be have been deprecated, as actions is a plural form? But I'm not an expert ;)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for noticing. Btw. They are not only deprecated. I decided to remove them (in later commit).
Thanks again and I'll update the docs and schematics comment.

{
node: ROUTING_ACTIONS,
importPath: SPARTACUS_CORE,
comment: `The following '${ROUTING_ACTIONS}' has been removed: '${ROUTE_GO_ACTION}', '${ROUTE_GO_BY_URL_ACTION}', '${ROUTE_BACK_ACTION}' and '${ROUTE_FORWARD_ACTION}'. Please just use the methods of the ${ROUTING_SERVICE}, respectively: 'go()', 'goByUrl()', 'back()' and 'forward()'.`,
Copy link
Contributor

@Matejk00 Matejk00 Jun 22, 2021

Choose a reason for hiding this comment

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

Same as above

@@ -20,5 +22,8 @@ export const ROUTING_SERVICE_MIGRATION: ConstructorDeprecation = {
{ className: SEMANTIC_PATH_SERVICE, importPath: SPARTACUS_CORE },
{ className: ROUTING_PARAMS_SERVICE, importPath: SPARTACUS_CORE },
],
addParams: [{ className: ROUTER, importPath: ANGULAR_ROUTER }],
Copy link
Contributor

Choose a reason for hiding this comment

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

Regarding to line 17, I noticed that we are missing a comment with a file location. Is it optional? Or can we add // projects/core/src/routing/facade/routing.service.ts to this file to be consistent with other migrations.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks. Indeed, I overlooked it. Will add.

- `RoutingActions.RouteForwardAction` (and `RoutingActions.ROUTER_FORWARD`).

Please just use the methods of the `RoutingService`, respectively: `go()`, `goByUrl()`, `back()`, `forward()`.

Copy link
Contributor

@Matejk00 Matejk00 Jun 22, 2021

Choose a reason for hiding this comment

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

In my opinion it's worth to mention here about changes in those methods. For example that they are returning promise, some of them have now additional params etc.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In the migration doc, I'd focus on explaining breaking changes to customers and giving hints how to fix them.

  • Changing the return type of methods from void to Promise, is not breaking. It's a new feature btw.
  • Only optional parameters were added to one method - so it's also not breaking.

@Platonn Platonn temporarily deployed to dev June 22, 2021 10:20 Inactive
@github-actions
Copy link
Contributor

Hosting service deployment

🚀 Spartacus deployed to https://d1e02mf4dp6upr.cloudfront.net

@Platonn Platonn merged commit 051d195 into develop Jun 22, 2021
@Platonn Platonn deleted the feature/GH-12789 branch June 22, 2021 10:54
@Platonn Platonn temporarily deployed to dev June 22, 2021 10:55 Inactive
@github-actions
Copy link
Contributor

Public API changes

✔️ Nothing changed in analyzed entry points.

⚠️ Some entry points are currently impossible to analyze.

Read more
  • @spartacus/asm/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/cart/saved-cart/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/checkout/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/organization/administration/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/organization/order-approval - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/product-configurator/rulebased - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/storefinder/core - ERROR: "import * as ___ from ___;" is not supported yet for local files.
  • @spartacus/storefront - ERROR: The expression contains an import() type, which is not yet supported by API Extractor:
  • @spartacus/user/account/components - ERROR: The expression contains an import() type, which is not yet supported by API Extractor:
  • @spartacus/user/profile/components - ERROR: The expression contains an import() type, which is not yet supported by API Extractor:

💰 How to debug problems?

Read more

Problem with import() type

It happens when type is deduced by TS based on code and at the same time the deduced type is not present in the file.
In this specific case to support api-extractor it's worth to add type declaration explicitly.

Debugging steps:

  • go to the bot action logs
  • find api-extractor logs for broken library
  • check in which file and line the problems exists
  • build the library locally and check content of the file mentioned in logs (look for import()
  • add explicit type to problematic source code
  • build the library once again and verify that the import( is no longer present
  • commit and push the code with defined type

Problem with import * as ___

Api-extractor doesn't support this namespace syntax.
Check if you really need to use namespace in the library. Try to avoid namespaces when possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Expose Promise result of the Angular navigation in RoutingService
3 participants