feat(example): add logout confirmation#1287
Conversation
0f6713b to
86f4be8
Compare
| expect(fixture).toMatchSnapshot(); | ||
| }); | ||
|
|
||
| it('should have buttons that are applied [mat-dialog-close]', () => { |
There was a problem hiding this comment.
I think this test isn't needed, because we already have a snapshot above.
|
|
||
| describe('Logout Confirmation Dialog', () => { | ||
| let fixture: ComponentFixture<LogoutConfirmationDialogComponent>; | ||
| let instance: LogoutConfirmationDialogComponent; |
|
|
||
| return dialogRef.afterClosed(); | ||
| }), | ||
| filter(result => result === 'OK'), |
There was a problem hiding this comment.
Use LogoutConfirmationDialogResult.OK instead of the string 'OK'
There was a problem hiding this comment.
Thankyou! I'll use string enum instead.
| logoutConfirmation$ = this.actions$.pipe( | ||
| ofType(AuthActionTypes.LogoutConfirmation), | ||
| exhaustMap(() => { | ||
| const dialogRef = this.dialog.open< |
There was a problem hiding this comment.
I think the types aren't needed?
const dialogRef = this.dialog.open(LogoutConfirmationDialogComponent)There was a problem hiding this comment.
I think dialog can not infer result value.
Should we omit it?
There was a problem hiding this comment.
You're right, we can leave it as it is.
There was a problem hiding this comment.
Change LogoutConfirmatinoDialogResultTypes to boolean. See comment above in dialog component.
744d533 to
9a9373a
Compare
|
@timdeschryver |
| `, | ||
| }) | ||
| export class LogoutConfirmationDialogComponent { | ||
| successValue = LogoutConfirmationDialogResults.OK; |
There was a problem hiding this comment.
Instead of an enum, just map OK to true and Cancel to false. The dialog will also dismiss and return false by clicking outside its container.
| logoutConfirmation$ = this.actions$.pipe( | ||
| ofType(AuthActionTypes.LogoutConfirmation), | ||
| exhaustMap(() => { | ||
| const dialogRef = this.dialog.open< |
There was a problem hiding this comment.
Change LogoutConfirmatinoDialogResultTypes to boolean. See comment above in dialog component.
3f70aae to
5d0df04
Compare
|
@brandonroberts |
|
@koumatsumoto will you rebase this on master again? Thanks |
| @Component({ | ||
| template: ` | ||
| <h2 mat-dialog-title>Logout</h2> | ||
| <mat-dialog-content>Do you really want to logout?</mat-dialog-content> |
There was a problem hiding this comment.
Change to Are you sure you want to logout?
| <button mat-button [mat-dialog-close]="false">Cancel</button> | ||
| <button mat-button [mat-dialog-close]="true">OK</button> | ||
| </mat-dialog-actions> | ||
| `, |
There was a problem hiding this comment.
Add some styles to the component
:host {
display: block;
width: 100%;
max-width: 300px;
}
mat-dialog-actions {
display: flex;
justify-content: flex-end;
}
[mat-button] {
padding: 0;
}
|
|
||
| beforeEach(() => { | ||
| TestBed.configureTestingModule({ | ||
| imports: [MatButtonModule, MatDialogModule], |
There was a problem hiding this comment.
These imports aren't needed for the effects
refactor(example): add a line-break refactor(example): fix incorrect value
5d0df04 to
593f82a
Compare
|
@brandonroberts |
PR Checklist
Please check if your PR fulfills the following requirements:
PR Type
What kind of change does this PR introduce?
What is the current behavior?
Issue Number: #1271
What is the new behavior?
Show sample code for handling a confirmation prompt using an Actions and Effects with an Angular Material dialog.
Does this PR introduce a breaking change?
Other information
Closes #1271