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(router): add CanDeactivate next state argument #13560

Merged
merged 1 commit into from
Dec 27, 2016

Conversation

DzmitryShylovich
Copy link
Contributor

Closes #9853

@@ -186,7 +186,8 @@ export interface CanActivateChild {
* canDeactivate(
* component: TeamComponent,
* route: ActivatedRouteSnapshot,
Copy link
Contributor

Choose a reason for hiding this comment

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

currentRoute

useValue: (c: TeamCmp, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
useValue: (c: TeamCmp, a: ActivatedRouteSnapshot, b: RouterStateSnapshot,
nextState: RouterStateSnapshot) => {
expect(nextState).toBeAnInstanceOf(RouterStateSnapshot);
Copy link
Contributor

Choose a reason for hiding this comment

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

we need a proper test

@@ -1624,7 +1625,9 @@ describe('Integration', () => {
TestBed.configureTestingModule({
providers: [{
provide: 'CanDeactivate',
useValue: (c: TeamCmp, a: ActivatedRouteSnapshot, b: RouterStateSnapshot) => {
useValue: (c: TeamCmp, a: ActivatedRouteSnapshot, b: RouterStateSnapshot,
Copy link
Contributor

Choose a reason for hiding this comment

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

consistency b vs nextState

@vicb vicb added area: router action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews pr_state: LGTM labels Dec 20, 2016
@vicb
Copy link
Contributor

vicb commented Dec 20, 2016

I'm not very clear on the use case but this is what should be tested in the integration test.

@DzmitryShylovich
Copy link
Contributor Author

@vicb

should be tested in the integration test.

done

canDeactivate(
component: TeamCmp, currentRoute: ActivatedRouteSnapshot,
currentState: RouterStateSnapshot, nextState: RouterStateSnapshot): boolean {
expect(currentState.url).toEqual('/team/22');
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe use a log and assert the content in test test ?

@vicb
Copy link
Contributor

vicb commented Dec 20, 2016

Could you please:

  • address the comment in the tests,
  • add a description of what this feature is in the commit comment.

Thanks !

@DzmitryShylovich
Copy link
Contributor Author

@vicb done

@vicb
Copy link
Contributor

vicb commented Dec 21, 2016

Could you please reword it as

Adds a `nextState` argument to access the future url from `CanDeactivate`.

BEFORE:
    
    canDeactivate(component: T, route: ActivatedRouteSnapshot, state: RouterStateSnapshot)
        : Observable<boolean>|Promise<boolean>|boolean;

AFTER:

    canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot,
                  nextState?: RouterStateSnapshot): Observable<boolean>|Promise<boolean>|boolean;

@DzmitryShylovich
Copy link
Contributor Author

@vicb could u reword it on merge? :)

@vicb
Copy link
Contributor

vicb commented Dec 21, 2016

I would but I'm not merging this week

@nheidloff
Copy link

This seems promising. I hope it will be merged soon. Thanks @DzmitryShylovich

Adds a `nextState` argument to access the future url from `CanDeactivate`.

BEFORE:

    canDeactivate(component: T, route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean>|Promise<boolean>|boolean;

AFTER:

    canDeactivate(component: T, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean>|Promise<boolean>|boolean;

Closes angular#9853
@DzmitryShylovich
Copy link
Contributor Author

DzmitryShylovich commented Dec 21, 2016

@vicb

I would but I'm not merging this week

oke, I did it

@vicb vicb added action: merge The PR is ready for merge by the caretaker and removed action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews labels Dec 27, 2016
@hansl hansl merged commit 69fa3bb into angular:master Dec 27, 2016
@DzmitryShylovich DzmitryShylovich deleted the gh/9853 branch December 27, 2016 22:15
@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 Sep 10, 2019
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 cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Router 3] CanDeactivate target route
5 participants