Skip to content

Conversation

@atscott
Copy link
Contributor

@atscott atscott commented Feb 8, 2022

Returning UrlTree from a guard was a convenient new feature added to
the Router. However, it does not have feature-parity with the old
router.navigate(...); return false; pattern. The most common use-case
for this feature is to redirect to a new page without updating the URL
from the initially attempted navigation. For example, rendering a 404
page when the user does not have access privelages to a route.

Fixes #27148

@ngbot ngbot bot modified the milestone: Backlog Feb 8, 2022
@atscott atscott added the target: minor This PR is targeted for the next minor release label Feb 8, 2022
@atscott atscott force-pushed the urltreeguardoptions branch 7 times, most recently from 3ac4a45 to 69e0965 Compare February 9, 2022 01:32
@atscott atscott force-pushed the urltreeguardoptions branch from 69e0965 to 026813a Compare February 9, 2022 17:17
@mary-poppins

This comment was marked as outdated.

@atscott
Copy link
Contributor Author

atscott commented Feb 9, 2022

Results from running migration the migration internally: cl/427481595

@atscott atscott force-pushed the urltreeguardoptions branch from 026813a to bfca0cf Compare February 9, 2022 18:22
@atscott atscott requested a review from AndrewKushnir February 9, 2022 18:54
@atscott atscott marked this pull request as ready for review February 9, 2022 18:54
@pullapprove pullapprove bot requested review from alxhub and crisbeto February 9, 2022 18:54
@atscott atscott added action: review The PR is still awaiting reviews from at least one requested reviewer and removed state: WIP labels Feb 9, 2022
@atscott
Copy link
Contributor Author

atscott commented Feb 9, 2022

presubmit

Copy link
Contributor

@AndrewKushnir AndrewKushnir left a comment

Choose a reason for hiding this comment

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

Looks great, just added a few comments.

@atscott atscott force-pushed the urltreeguardoptions branch 3 times, most recently from e19d04e to 78ca5eb Compare February 15, 2022 00:56
@angular-robot angular-robot bot removed area: docs Related to the documentation area: build & ci Related the build and CI infrastructure of the project labels Feb 20, 2024
@atscott atscott force-pushed the urltreeguardoptions branch 2 times, most recently from aaab2ac to c7a13d5 Compare February 20, 2024 17:52
@angular-robot angular-robot bot added the detected: breaking change PR contains a commit with a breaking change label Feb 20, 2024
@atscott atscott force-pushed the urltreeguardoptions branch from c7a13d5 to 94aca9f Compare February 20, 2024 17:55
@atscott atscott marked this pull request as ready for review February 20, 2024 18:11
@atscott atscott force-pushed the urltreeguardoptions branch from 94aca9f to 42d58d3 Compare February 22, 2024 01:08
@atscott atscott added target: major This PR is targeted for the next major release and removed target: minor This PR is targeted for the next minor release labels Feb 22, 2024
…rOptions` from guards

Returning `UrlTree` from a guard was a convenient new feature added to
the `Router`. However, it does not have feature-parity with the old
`router.navigate(...); return false;` pattern. The most common use-case
for this feature is to redirect to a new page _without_ updating the URL
from the initially attempted navigation. For example, rendering a 404
page when the user does not have access privelages to a route.

Fixes angular#17004
Fixes angular#27148

BREAKING CHANGE: Guards can now return `RedirectCommand` for redirects
in addition to `UrlTree`. Code which expects only `boolean` or `UrlTree`
values in `Route` types will need to be adjusted.
@atscott atscott force-pushed the urltreeguardoptions branch from 42d58d3 to 850c3b8 Compare February 28, 2024 22:13
Copy link
Member

@alxhub alxhub left a comment

Choose a reason for hiding this comment

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

Reviewed-for: public-api

@pullapprove pullapprove bot requested a review from jessicajaniuk March 11, 2024 19:05
Copy link
Contributor

@jessicajaniuk jessicajaniuk left a comment

Choose a reason for hiding this comment

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

reviewed-for: public-api

@atscott atscott added action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note action: global presubmit The PR is in need of a google3 global presubmit and removed action: review The PR is still awaiting reviews from at least one requested reviewer action: merge The PR is ready for merge by the caretaker merge: caretaker note Alert the caretaker performing the merge to check the PR for an out of normal action needed or note labels Mar 11, 2024
@atscott
Copy link
Contributor Author

atscott commented Mar 12, 2024

@atscott atscott added action: merge The PR is ready for merge by the caretaker and removed action: global presubmit The PR is in need of a google3 global presubmit labels Mar 12, 2024
@atscott
Copy link
Contributor Author

atscott commented Mar 12, 2024

This PR was merged into the repository by commit 8735af0.

@atscott atscott closed this in 8735af0 Mar 12, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Apr 12, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: router detected: breaking change PR contains a commit with a breaking change detected: feature PR contains a feature commit target: major This PR is targeted for the next major release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NavigationExtras when returning URLTree from guard

8 participants