mirror of
https://github.com/Alfresco/alfresco-content-app.git
synced 2025-07-31 17:38:28 +00:00
Prettier upgrade and e2e type checks (#1522)
* upgrade prettier * noImplicitAny rule * fix type * update tsconfig * upgrade to 150 print width
This commit is contained in:
@@ -23,11 +23,7 @@
|
||||
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
import {
|
||||
RouteReuseStrategy,
|
||||
DetachedRouteHandle,
|
||||
ActivatedRouteSnapshot
|
||||
} from '@angular/router';
|
||||
import { RouteReuseStrategy, DetachedRouteHandle, ActivatedRouteSnapshot } from '@angular/router';
|
||||
import { ComponentRef, Injectable } from '@angular/core';
|
||||
|
||||
interface RouteData {
|
||||
@@ -44,7 +40,7 @@ export class AppRouteReuseStrategy implements RouteReuseStrategy {
|
||||
private routeCache = new Map<string, RouteInfo>();
|
||||
|
||||
resetCache() {
|
||||
this.routeCache.forEach(value => {
|
||||
this.routeCache.forEach((value) => {
|
||||
this.deactivateComponent(value.handle);
|
||||
});
|
||||
this.routeCache.clear();
|
||||
@@ -60,10 +56,7 @@ export class AppRouteReuseStrategy implements RouteReuseStrategy {
|
||||
}
|
||||
}
|
||||
|
||||
shouldReuseRoute(
|
||||
future: ActivatedRouteSnapshot,
|
||||
curr: ActivatedRouteSnapshot
|
||||
): boolean {
|
||||
shouldReuseRoute(future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot): boolean {
|
||||
const ret = future.routeConfig === curr.routeConfig;
|
||||
if (ret) {
|
||||
this.addRedirectsRecursively(future); // update redirects
|
||||
@@ -91,9 +84,7 @@ export class AppRouteReuseStrategy implements RouteReuseStrategy {
|
||||
retrieve(route: ActivatedRouteSnapshot): DetachedRouteHandle {
|
||||
const url = this.getFullRouteUrl(route);
|
||||
const data = this.getRouteData(route);
|
||||
return data && data.reuse && this.routeCache.has(url)
|
||||
? this.routeCache.get(url).handle
|
||||
: null;
|
||||
return data && data.reuse && this.routeCache.has(url) ? this.routeCache.get(url).handle : null;
|
||||
}
|
||||
|
||||
private addRedirectsRecursively(route: ActivatedRouteSnapshot): void {
|
||||
@@ -101,40 +92,30 @@ export class AppRouteReuseStrategy implements RouteReuseStrategy {
|
||||
if (config) {
|
||||
if (!config.loadChildren) {
|
||||
const routeFirstChild = route.firstChild;
|
||||
const routeFirstChildUrl = routeFirstChild
|
||||
? this.getRouteUrlPaths(routeFirstChild).join('/')
|
||||
: '';
|
||||
const routeFirstChildUrl = routeFirstChild ? this.getRouteUrlPaths(routeFirstChild).join('/') : '';
|
||||
const childConfigs = config.children;
|
||||
if (childConfigs) {
|
||||
const childConfigWithRedirect = childConfigs.find(
|
||||
c => c.path === '' && !!c.redirectTo
|
||||
);
|
||||
const childConfigWithRedirect = childConfigs.find((c) => c.path === '' && !!c.redirectTo);
|
||||
if (childConfigWithRedirect) {
|
||||
childConfigWithRedirect.redirectTo = routeFirstChildUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
route.children.forEach(childRoute =>
|
||||
this.addRedirectsRecursively(childRoute)
|
||||
);
|
||||
route.children.forEach((childRoute) => this.addRedirectsRecursively(childRoute));
|
||||
}
|
||||
}
|
||||
|
||||
private getFullRouteUrl(route: ActivatedRouteSnapshot): string {
|
||||
return this.getFullRouteUrlPaths(route)
|
||||
.filter(Boolean)
|
||||
.join('/');
|
||||
return this.getFullRouteUrlPaths(route).filter(Boolean).join('/');
|
||||
}
|
||||
|
||||
private getFullRouteUrlPaths(route: ActivatedRouteSnapshot): string[] {
|
||||
const paths = this.getRouteUrlPaths(route);
|
||||
return route.parent
|
||||
? [...this.getFullRouteUrlPaths(route.parent), ...paths]
|
||||
: paths;
|
||||
return route.parent ? [...this.getFullRouteUrlPaths(route.parent), ...paths] : paths;
|
||||
}
|
||||
|
||||
private getRouteUrlPaths(route: ActivatedRouteSnapshot): string[] {
|
||||
return route.url.map(urlSegment => urlSegment.path);
|
||||
return route.url.map((urlSegment) => urlSegment.path);
|
||||
}
|
||||
|
||||
private getRouteData(route: ActivatedRouteSnapshot): RouteData {
|
||||
|
@@ -39,15 +39,11 @@ export class AppSharedRuleGuard implements CanActivate {
|
||||
this.isQuickShareEnabled$ = store.select(isQuickShareEnabled);
|
||||
}
|
||||
|
||||
canActivate(
|
||||
_: ActivatedRouteSnapshot
|
||||
): Observable<boolean> | Promise<boolean> | boolean {
|
||||
canActivate(_: ActivatedRouteSnapshot): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.isQuickShareEnabled$;
|
||||
}
|
||||
|
||||
canActivateChild(
|
||||
route: ActivatedRouteSnapshot
|
||||
): Observable<boolean> | Promise<boolean> | boolean {
|
||||
canActivateChild(route: ActivatedRouteSnapshot): Observable<boolean> | Promise<boolean> | boolean {
|
||||
return this.canActivate(route);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user