Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

131 upgrade to angular 17 #137

Merged
merged 5 commits into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions auth/auth.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,25 @@
* limitations under the License.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';


import { inject, Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivateFn, RouterStateSnapshot } from '@angular/router';

import { Observable } from 'rxjs';

import { AuthService } from './auth.service';


@Injectable()
export class AuthGuard {
export class AuthGuardService {

constructor(private readonly authService: AuthService) {
}


canActivate(activatedRoute: ActivatedRouteSnapshot, routerState: RouterStateSnapshot): Observable<boolean> {
return this.authService.queryAuthentication(routerState.url);
canActivate(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> {
return this.authService.queryAuthentication(state.url);
}
}

export const authGuardCanActivate: CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> => inject(AuthGuardService).canActivate(route, state);
4 changes: 2 additions & 2 deletions auth/auth.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { HTTP_INTERCEPTORS } from '@angular/common/http';
import { RouterModule, Routes } from '@angular/router';

import { AuthComponent } from './auth.component';
import { AuthGuard } from './auth.guard';
import { AuthGuardService } from './auth.guard';
import { AuthInterceptor } from './auth.interceptor';
import { CsrfInterceptor } from './csrf.interceptor';

Expand All @@ -40,5 +40,5 @@ export const AuthRoutingModules = [
export const AuthRoutingProviders = [
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true },
{ provide: HTTP_INTERCEPTORS, useClass: CsrfInterceptor, multi: true },
AuthGuard
AuthGuardService
];
8 changes: 5 additions & 3 deletions nav/confirm.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@
* limitations under the License.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, RouterStateSnapshot } from '@angular/router';
import { inject, Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanDeactivateFn, RouterStateSnapshot } from '@angular/router';

import { Observable } from 'rxjs';

import { RouteComponent } from './route.component';


@Injectable()
export class ConfirmGuard {
export class ConfirmGuardService {

canDeactivate(component: RouteComponent, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean> {
return component.canHide();
}
}

export const confirmGuardCanDeactivate: CanDeactivateFn<RouteComponent> = (component: RouteComponent, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot): Observable<boolean> => inject(ConfirmGuardService).canDeactivate(component, currentRoute, currentState, nextState);
10 changes: 5 additions & 5 deletions nav/nav.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
import { NgModule } from '@angular/core';
import { I18nModule } from '@zeta/i18n';

import { I18nModule } from '@zeta/i18n';
import { XcModule } from '@zeta/xc';

import { BrokenComponent } from './broken.component';
import { RuntimeContextSelectionComponent } from './modal/runtime-context-selection/runtime-context-selection.component';
import { RedirectGuard } from './redirect.guard';
import { RightGuard } from './right.guard';
import { RedirectGuardService } from './redirect.guard';
import { RightGuardService } from './right.guard';


@NgModule({
Expand All @@ -36,8 +36,8 @@ import { RightGuard } from './right.guard';
RuntimeContextSelectionComponent
],
providers: [
RightGuard,
RedirectGuard
RightGuardService,
RedirectGuardService
]
})
export class NavModule {
Expand Down
4 changes: 2 additions & 2 deletions nav/nav.routing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { RouterModule } from '@angular/router';

import { XynaRoutes } from './';
import { BrokenComponent } from './broken.component';
import { ConfirmGuard } from './confirm.guard';
import { ConfirmGuardService } from './confirm.guard';


const root = '**';
Expand All @@ -36,5 +36,5 @@ export const NavRoutingModules = [


export const NavRoutingProviders = [
ConfirmGuard
ConfirmGuardService
];
16 changes: 10 additions & 6 deletions nav/redirect.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
* limitations under the License.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
import { Component, Injectable, InjectionToken } from '@angular/core';
import { ActivatedRouteSnapshot, Router, RouterStateSnapshot } from '@angular/router';
import { Component, inject, Injectable, InjectionToken } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivateFn, CanDeactivateFn, Router, RouterStateSnapshot } from '@angular/router';

import { XynaRoute } from './';

Expand All @@ -25,7 +25,7 @@ export const RedirectGuardConfigToken = new InjectionToken<string>('RedirectGuar


@Injectable()
export class RedirectGuard {
export class RedirectGuardService {

/**
* maps the last visited url to a unique project key
Expand Down Expand Up @@ -104,14 +104,18 @@ export class RedirectGuard {
}
}

export const redirectGuardCanActivate: CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean => inject(RedirectGuardService).canActivate(route, state);

export const redirectGuardCanDeactivate: CanDeactivateFn<Component> = (component: Component, currentRoute: ActivatedRouteSnapshot, currentState: RouterStateSnapshot, nextState?: RouterStateSnapshot) => inject(RedirectGuardService).canDeactivate(component, currentRoute, currentState, nextState);


export function RedirectGuardFactory(router: Router, defaultRedirectUrl: string) {
return new RedirectGuard(router /*, defaultRedirectUrl*/);
return new RedirectGuardService(router /*, defaultRedirectUrl*/);
}


export function RedirectGuardProvider() {
return { provide: RedirectGuard, useFactory: RedirectGuardFactory, deps: [Router, RedirectGuardConfigToken] };
return { provide: RedirectGuardService, useFactory: RedirectGuardFactory, deps: [Router, RedirectGuardConfigToken] };
}


Expand All @@ -120,4 +124,4 @@ export function RedirectGuardConfigProvider(defaultRedirectUrl: string) {
}


export class RedirectComponent {}
export class RedirectComponent { }
12 changes: 7 additions & 5 deletions nav/right.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
* limitations under the License.
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
*/
import { Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, Router } from '@angular/router';

import { inject, Injectable } from '@angular/core';
import { ActivatedRouteSnapshot, CanActivateFn, Router, RouterStateSnapshot } from '@angular/router';

import { AuthService } from '../auth';
import { XynaRoute } from './xyna-routes';


@Injectable()
export class RightGuard {
export class RightGuardService {

constructor(private readonly authService: AuthService, private readonly router: Router) {
}


canActivate(activatedRoute: ActivatedRouteSnapshot): boolean {
canActivate(activatedRoute: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {
const data = (activatedRoute as XynaRoute).data;
const right = data.right;

Expand Down Expand Up @@ -82,3 +82,5 @@ export class RightGuard {
return url;
}
}

export const rightGuardCanActivate: CanActivateFn = (route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean => inject(RightGuardService).canActivate(route, state);
Loading
Loading