-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(example): add logout confirmation (#1287)
Closes #1271
- Loading branch information
1 parent
466e2cd
commit ba8d300
Showing
9 changed files
with
215 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...p/src/app/auth/components/__snapshots__/logout-confirmation-dialog.component.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Logout Confirmation Dialog should compile 1`] = ` | ||
<ng-component> | ||
<h2 | ||
_ngcontent-c0="" | ||
class="mat-dialog-title" | ||
id="mat-dialog-title-0" | ||
mat-dialog-title="" | ||
> | ||
Logout | ||
</h2><mat-dialog-content | ||
_ngcontent-c0="" | ||
class="mat-dialog-content" | ||
> | ||
Are you sure you want to logout? | ||
</mat-dialog-content><mat-dialog-actions | ||
_ngcontent-c0="" | ||
class="mat-dialog-actions" | ||
> | ||
<button | ||
_ngcontent-c0="" | ||
aria-label="Close dialog" | ||
class="mat-button" | ||
mat-button="" | ||
ng-reflect-dialog-result="false" | ||
type="button" | ||
> | ||
<span | ||
class="mat-button-wrapper" | ||
> | ||
Cancel | ||
</span> | ||
<div | ||
class="mat-button-ripple mat-ripple" | ||
matripple="" | ||
ng-reflect-centered="false" | ||
ng-reflect-disabled="false" | ||
ng-reflect-trigger="[object HTMLButtonElement]" | ||
/> | ||
<div | ||
class="mat-button-focus-overlay" | ||
/> | ||
</button> | ||
<button | ||
_ngcontent-c0="" | ||
aria-label="Close dialog" | ||
class="mat-button" | ||
mat-button="" | ||
ng-reflect-dialog-result="true" | ||
type="button" | ||
> | ||
<span | ||
class="mat-button-wrapper" | ||
> | ||
OK | ||
</span> | ||
<div | ||
class="mat-button-ripple mat-ripple" | ||
matripple="" | ||
ng-reflect-centered="false" | ||
ng-reflect-disabled="false" | ||
ng-reflect-trigger="[object HTMLButtonElement]" | ||
/> | ||
<div | ||
class="mat-button-focus-overlay" | ||
/> | ||
</button> | ||
</mat-dialog-actions> | ||
</ng-component> | ||
`; |
22 changes: 22 additions & 0 deletions
22
projects/example-app/src/app/auth/components/logout-confirmation-dialog.component.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { ComponentFixture, TestBed } from '@angular/core/testing'; | ||
import { MatButtonModule, MatDialogModule } from '@angular/material'; | ||
import { LogoutConfirmationDialogComponent } from './logout-confirmation-dialog.component'; | ||
|
||
describe('Logout Confirmation Dialog', () => { | ||
let fixture: ComponentFixture<LogoutConfirmationDialogComponent>; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
imports: [MatButtonModule, MatDialogModule], | ||
declarations: [LogoutConfirmationDialogComponent], | ||
}); | ||
|
||
fixture = TestBed.createComponent(LogoutConfirmationDialogComponent); | ||
}); | ||
|
||
it('should compile', () => { | ||
fixture.detectChanges(); | ||
|
||
expect(fixture).toMatchSnapshot(); | ||
}); | ||
}); |
35 changes: 35 additions & 0 deletions
35
projects/example-app/src/app/auth/components/logout-confirmation-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Component } from '@angular/core'; | ||
|
||
/** | ||
* The dialog will close with true if user clicks the ok button, | ||
* otherwise it will close with undefined. | ||
*/ | ||
@Component({ | ||
template: ` | ||
<h2 mat-dialog-title>Logout</h2> | ||
<mat-dialog-content>Are you sure you want to logout?</mat-dialog-content> | ||
<mat-dialog-actions> | ||
<button mat-button [mat-dialog-close]="false">Cancel</button> | ||
<button mat-button [mat-dialog-close]="true">OK</button> | ||
</mat-dialog-actions> | ||
`, | ||
styles: [ | ||
` | ||
:host { | ||
display: block; | ||
width: 100%; | ||
max-width: 300px; | ||
} | ||
mat-dialog-actions { | ||
display: flex; | ||
justify-content: flex-end; | ||
} | ||
[mat-button] { | ||
padding: 0; | ||
} | ||
`, | ||
], | ||
}) | ||
export class LogoutConfirmationDialogComponent {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters