-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into e2e-bring-back-skipped-tests
- Loading branch information
Showing
37 changed files
with
17,662 additions
and
3,607 deletions.
There are no files selected for viewing
21 changes: 14 additions & 7 deletions
21
apps/web-mzima-client/src/app/core/guards/deployment-found.guard.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 |
---|---|---|
@@ -1,18 +1,25 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { CanActivate, Router } from '@angular/router'; | ||
import { CanActivate, Router, UrlTree } from '@angular/router'; | ||
import { SessionService } from '@services'; | ||
import { filter, Observable, switchMap, take } from 'rxjs'; | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class DeploymentFoundGuard implements CanActivate { | ||
constructor(private router: Router, private service: SessionService) {} | ||
|
||
canActivate() { | ||
const siteFound: boolean = this.service.siteFound; | ||
if (siteFound) { | ||
return true; | ||
} | ||
return this.router.parseUrl('/notfound'); | ||
canActivate(): Observable<boolean | UrlTree> { | ||
return this.service.configLoaded$.pipe( | ||
filter((configLoaded) => configLoaded !== undefined), | ||
take(1), | ||
switchMap((configLoaded) => { | ||
const siteFound: boolean = this.service.siteFound; | ||
if (configLoaded && siteFound) { | ||
return [true]; | ||
} | ||
return [this.router.parseUrl('/notfound')]; | ||
}), | ||
); | ||
} | ||
} |
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
Oops, something went wrong.