diff --git a/src/app/common/services/experimental-guard.service.ts b/src/app/common/services/experimental-guard.service.ts index 5750f5fa4..237541cb7 100644 --- a/src/app/common/services/experimental-guard.service.ts +++ b/src/app/common/services/experimental-guard.service.ts @@ -1,20 +1,35 @@ -import { CanActivate, ActivatedRouteSnapshot } from '@angular/router'; +import { CanActivate, ActivatedRouteSnapshot, Router } from '@angular/router'; import { Injectable } from '@angular/core'; -import { AppConfigService } from '@alfresco/adf-core'; +import { AppConfigService, StorageService } from '@alfresco/adf-core'; import { environment } from '../../../environments/environment'; @Injectable() export class ExperimentalGuard implements CanActivate { - constructor(private config: AppConfigService) {} + constructor( + private config: AppConfigService, + private storage: StorageService, + private router: Router + ) {} canActivate(route: ActivatedRouteSnapshot) { const key = `experimental.${route.data.ifExperimentalKey}`; const value = this.config.get(key); + const override = this.storage.getItem(key); + + if (override === 'true') { + return true; + } if (!environment.production) { - return value === true || value === 'true'; + if (value === true || value === 'true') { + return true; + } + + this.router.navigate(['/']); } + this.router.navigate(['/']); + return false; } }