Skip to content

Commit

Permalink
fix(stark-ui): add logout button on the Session Timeout Warning dialog
Browse files Browse the repository at this point in the history
ISSUES CLOSED: #1731
  • Loading branch information
mhenkens committed Sep 20, 2022
1 parent 3dd16dd commit 2474767
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const translationsEn: object = {
LOGIN: "Log in again"
},
SESSION_TIMEOUT: {
CLOSE_SESSION: "Logout",
SECONDS: " seconds.",
STAY_CONNECTED: "Stay connected",
TITLE: "Session about to expire",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const translationsFr: object = {
LOGIN: "Connexion"
},
SESSION_TIMEOUT: {
CLOSE_SESSION: "Se déconnecter",
SECONDS: " secondes.",
STAY_CONNECTED: "Rester connecté",
TITLE: "Session sur le point d'expirer",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export const translationsNl: object = {
LOGIN: "Opnieuw aanmelden"
},
SESSION_TIMEOUT: {
CLOSE_SESSION: "Afmelden",
SECONDS: " seconden vervallen.",
STAY_CONNECTED: "Blijf verbonden",
TITLE: "Sessie verlopen",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ <h1 mat-dialog-title translate>STARK.SESSION_TIMEOUT.TITLE</h1>
<button mat-raised-button color="primary" (click)="keepSession()" aria-label="Close Dialog">
<span translate>STARK.SESSION_TIMEOUT.STAY_CONNECTED</span>
</button>
<button mat-raised-button (click)="closeSession()" aria-label="Close Dialog">
<span translate>STARK.SESSION_TIMEOUT.CLOSE_SESSION</span>
</button>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,14 @@ describe("SessionTimeoutWarningDialogComponent", () => {
expect(mockDialogRef.close).toHaveBeenCalledWith("keep-logged");
}));
});

describe("closeSession", () => {
it("should close the windows when the button is clicked", fakeAsync(() => {
component.ngOnInit();
component.closeSession();

expect(mockDialogRef.close).toHaveBeenCalledTimes(1);
expect(mockDialogRef.close).toHaveBeenCalledWith("close-session");
}));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,8 @@ export class StarkSessionTimeoutWarningDialogComponent implements OnInit {
public keepSession(): void {
this.dialogRef.close("keep-logged");
}

public closeSession(): void {
this.dialogRef.close("close-session");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@ export class StarkSessionTimeoutWarningDialogEffects implements OnRunEffects {
})
.afterClosed()
.subscribe((result: string) => {
if (result && result === "keep-logged") {
this.sessionService.resumeUserActivityTracking();
if (result) {
if (result === "keep-logged") {
this.sessionService.resumeUserActivityTracking();
} else if (result === "close-session") {
this.sessionService.logout();
}
}
});
})
Expand Down

0 comments on commit 2474767

Please sign in to comment.