You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streampipes.apache.org by ze...@apache.org on 2026/03/24 11:17:36 UTC
(streampipes) 07/24: migrate core guards to inject()
This is an automated email from the ASF dual-hosted git repository.
zehnder pushed a commit to branch 4287-migrate-angular-ui-from-constructor-injection-to-inject
in repository https://gitbox.apache.org/repos/asf/streampipes.git
commit e55fc796adedf4d2545d666cb38ee81dc4dc6bd2
Author: Philipp Zehnder <te...@users.noreply.github.com>
AuthorDate: Tue Mar 24 09:57:53 2026 +0100
migrate core guards to inject()
---
ui/src/app/core/auth/guards/auth.can-activate-children.guard.ts | 4 ++--
ui/src/app/core/auth/guards/page-auth.can-activate.guard.ts | 4 ++--
ui/src/app/core/setup/guards/configured.can-activate.guard.ts | 7 +++++--
.../core/setup/guards/registration-allowed.can-activate.guard.ts | 8 +++-----
.../setup/guards/restore-password-allowed.can-activate.guard.ts | 8 +++-----
5 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/ui/src/app/core/auth/guards/auth.can-activate-children.guard.ts b/ui/src/app/core/auth/guards/auth.can-activate-children.guard.ts
index a9440317a4..8ff7fc0c09 100644
--- a/ui/src/app/core/auth/guards/auth.can-activate-children.guard.ts
+++ b/ui/src/app/core/auth/guards/auth.can-activate-children.guard.ts
@@ -16,7 +16,7 @@
*
*/
-import { Injectable } from '@angular/core';
+import { Injectable, inject } from '@angular/core';
import {
ActivatedRouteSnapshot,
CanActivateChild,
@@ -28,7 +28,7 @@ import { AuthService } from '../../../services/auth.service';
@Injectable({ providedIn: 'root' })
export class AuthCanActivateChildrenGuard implements CanActivateChild {
- constructor(private authService: AuthService) {}
+ private authService = inject(AuthService);
canActivateChild(
childRoute: ActivatedRouteSnapshot,
diff --git a/ui/src/app/core/auth/guards/page-auth.can-activate.guard.ts b/ui/src/app/core/auth/guards/page-auth.can-activate.guard.ts
index 93f14bb7f1..e87c2151ec 100644
--- a/ui/src/app/core/auth/guards/page-auth.can-activate.guard.ts
+++ b/ui/src/app/core/auth/guards/page-auth.can-activate.guard.ts
@@ -25,11 +25,11 @@ import {
RouterStateSnapshot,
} from '@angular/router';
import { AuthService } from '../../../services/auth.service';
-import { Injectable } from '@angular/core';
+import { Injectable, inject } from '@angular/core';
@Injectable({ providedIn: 'root' })
export class PageAuthGuard implements CanActivate, CanActivateChild {
- constructor(private authService: AuthService) {}
+ private authService = inject(AuthService);
canActivate(
route: ActivatedRouteSnapshot,
diff --git a/ui/src/app/core/setup/guards/configured.can-activate.guard.ts b/ui/src/app/core/setup/guards/configured.can-activate.guard.ts
index 341a37b9c8..573e265416 100644
--- a/ui/src/app/core/setup/guards/configured.can-activate.guard.ts
+++ b/ui/src/app/core/setup/guards/configured.can-activate.guard.ts
@@ -16,14 +16,17 @@
*
*/
-import { Injectable } from '@angular/core';
+import { Injectable, inject } from '@angular/core';
import { Router, UrlTree } from '@angular/router';
import { AuthService } from '../../../services/auth.service';
import { BaseConfiguredCanActivateGuard } from './base-configured.can-activate.guard';
@Injectable({ providedIn: 'root' })
export class ConfiguredCanActivateGuard extends BaseConfiguredCanActivateGuard {
- constructor(router: Router, authService: AuthService) {
+ constructor() {
+ const router = inject(Router);
+ const authService = inject(AuthService);
+
super(router, authService);
}
diff --git a/ui/src/app/core/setup/guards/registration-allowed.can-activate.guard.ts b/ui/src/app/core/setup/guards/registration-allowed.can-activate.guard.ts
index 62e64b0fe7..22963fe820 100644
--- a/ui/src/app/core/setup/guards/registration-allowed.can-activate.guard.ts
+++ b/ui/src/app/core/setup/guards/registration-allowed.can-activate.guard.ts
@@ -16,7 +16,7 @@
*
*/
-import { Injectable } from '@angular/core';
+import { Injectable, inject } from '@angular/core';
import {
ActivatedRouteSnapshot,
Router,
@@ -29,10 +29,8 @@ import { map } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class RegistrationAllowedCanActivateGuard {
- constructor(
- private router: Router,
- private loginService: LoginService,
- ) {}
+ private router = inject(Router);
+ private loginService = inject(LoginService);
canActivate(
route: ActivatedRouteSnapshot,
diff --git a/ui/src/app/core/setup/guards/restore-password-allowed.can-activate.guard.ts b/ui/src/app/core/setup/guards/restore-password-allowed.can-activate.guard.ts
index 1240e471ab..1e06442176 100644
--- a/ui/src/app/core/setup/guards/restore-password-allowed.can-activate.guard.ts
+++ b/ui/src/app/core/setup/guards/restore-password-allowed.can-activate.guard.ts
@@ -16,7 +16,7 @@
*
*/
-import { Injectable } from '@angular/core';
+import { Injectable, inject } from '@angular/core';
import {
ActivatedRouteSnapshot,
Router,
@@ -29,10 +29,8 @@ import { map } from 'rxjs/operators';
@Injectable({ providedIn: 'root' })
export class RestorePasswordAllowedCanActivateGuard {
- constructor(
- private router: Router,
- private loginService: LoginService,
- ) {}
+ private router = inject(Router);
+ private loginService = inject(LoginService);
canActivate(
route: ActivatedRouteSnapshot,