From 4d0ecf915b3d2f36f9cc7dfb1b728497930e2d31 Mon Sep 17 00:00:00 2001 From: Max Peintner Date: Fri, 11 Jul 2025 09:43:49 +0200 Subject: [PATCH] fix console types, eliminate webkey feature --- .../components/features/features.component.ts | 2 +- ...actions-two-add-target-dialog.component.ts | 2 +- .../oidc-webkeys/oidc-webkeys.component.ts | 45 ++----------------- .../user-create-v2.component.ts | 2 +- .../detail-form/detail-form.component.ts | 4 +- .../user-table/user-table.component.ts | 8 ++-- 6 files changed, 13 insertions(+), 50 deletions(-) diff --git a/console/src/app/components/features/features.component.ts b/console/src/app/components/features/features.component.ts index 8e8c0f9106..72e1234653 100644 --- a/console/src/app/components/features/features.component.ts +++ b/console/src/app/components/features/features.component.ts @@ -139,7 +139,7 @@ export class FeaturesComponent { }, {}); // to save special flags they have to be handled here - req.loginV2 = { + req['loginV2'] = { required: toggleStates.loginV2.enabled, baseUri: toggleStates.loginV2.baseUri, }; diff --git a/console/src/app/modules/actions-two/actions-two-add-target/actions-two-add-target-dialog.component.ts b/console/src/app/modules/actions-two/actions-two-add-target/actions-two-add-target-dialog.component.ts index 7d3ad0e86c..642bc9c134 100644 --- a/console/src/app/modules/actions-two/actions-two-add-target/actions-two-add-target-dialog.component.ts +++ b/console/src/app/modules/actions-two/actions-two-add-target/actions-two-add-target-dialog.component.ts @@ -89,7 +89,7 @@ export class ActionTwoAddTargetDialogComponent { nanos: 0, }; - const targetType: Extract['targetType'], { case: TargetTypes }> = + const targetType: MessageInitShape['targetType'] = type === 'restWebhook' ? { case: type, value: { interruptOnError } } : type === 'restCall' diff --git a/console/src/app/modules/policies/oidc-webkeys/oidc-webkeys.component.ts b/console/src/app/modules/policies/oidc-webkeys/oidc-webkeys.component.ts index 65197b4ad4..16d3f056c1 100644 --- a/console/src/app/modules/policies/oidc-webkeys/oidc-webkeys.component.ts +++ b/console/src/app/modules/policies/oidc-webkeys/oidc-webkeys.component.ts @@ -22,9 +22,8 @@ const CACHE_WARNING_MS = 5 * 60 * 1000; // 5 minutes templateUrl: './oidc-webkeys.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class OidcWebKeysComponent implements OnInit { +export class OidcWebKeysComponent { protected readonly refresh = new Subject(); - protected readonly webKeysEnabled$: Observable; protected readonly webKeys$: Observable; protected readonly inactiveWebKeys$: Observable; protected readonly nextWebKeyCandidate$: Observable; @@ -34,17 +33,12 @@ export class OidcWebKeysComponent implements OnInit { constructor( private readonly webKeysService: WebKeysService, - private readonly featureService: NewFeatureService, private readonly toast: ToastService, private readonly timestampToDatePipe: TimestampToDatePipe, private readonly dialog: MatDialog, private readonly destroyRef: DestroyRef, - private readonly router: Router, - private readonly route: ActivatedRoute, ) { - this.webKeysEnabled$ = this.getWebKeysEnabled().pipe(shareReplay({ refCount: true, bufferSize: 1 })); - - const webKeys$ = this.getWebKeys(this.webKeysEnabled$).pipe(shareReplay({ refCount: true, bufferSize: 1 })); + const webKeys$ = this.getWebKeys().pipe(shareReplay({ refCount: true, bufferSize: 1 })); this.webKeys$ = webKeys$.pipe(map((webKeys) => webKeys.filter((webKey) => webKey.state !== State.INACTIVE))); this.inactiveWebKeys$ = webKeys$.pipe(map((webKeys) => webKeys.filter((webKey) => webKey.state === State.INACTIVE))); @@ -52,34 +46,7 @@ export class OidcWebKeysComponent implements OnInit { this.nextWebKeyCandidate$ = this.getNextWebKeyCandidate(this.webKeys$); } - ngOnInit(): void { - // redirect away from this page if web keys are not enabled - // this also preloads the web keys enabled state - this.webKeysEnabled$.pipe(takeUntilDestroyed(this.destroyRef)).subscribe(async (webKeysEnabled) => { - if (webKeysEnabled) { - return; - } - await this.router.navigate([], { - relativeTo: this.route, - queryParamsHandling: 'merge', - queryParams: { - id: null, - }, - }); - }); - } - - private getWebKeysEnabled() { - return defer(() => this.featureService.getInstanceFeatures()).pipe( - map((features) => features.webKey?.enabled ?? false), - catchError((err) => { - this.toast.showError(err); - return of(false); - }), - ); - } - - private getWebKeys(webKeysEnabled$: Observable) { + private getWebKeys() { return this.refresh.pipe( startWith(true), switchMap(() => { @@ -87,12 +54,6 @@ export class OidcWebKeysComponent implements OnInit { }), map(({ webKeys }) => webKeys), catchError(async (err) => { - const webKeysEnabled = await firstValueFrom(webKeysEnabled$); - // suppress errors if web keys are not enabled - if (!webKeysEnabled) { - return []; - } - this.toast.showError(err); return []; }), diff --git a/console/src/app/pages/users/user-create/user-create-v2/user-create-v2.component.ts b/console/src/app/pages/users/user-create/user-create-v2/user-create-v2.component.ts index b92c112357..7c5d5a0e7f 100644 --- a/console/src/app/pages/users/user-create/user-create-v2/user-create-v2.component.ts +++ b/console/src/app/pages/users/user-create/user-create-v2/user-create-v2.component.ts @@ -204,7 +204,7 @@ export class UserCreateV2Component implements OnInit { if (authenticationFactor.factor === 'initialPassword') { const { password } = authenticationFactor.form.getRawValue(); - humanReq.passwordType = { + humanReq['passwordType'] = { case: 'password', value: { password, diff --git a/console/src/app/pages/users/user-detail/detail-form/detail-form.component.ts b/console/src/app/pages/users/user-detail/detail-form/detail-form.component.ts index ce72f00271..2a136e7e4a 100644 --- a/console/src/app/pages/users/user-detail/detail-form/detail-form.component.ts +++ b/console/src/app/pages/users/user-detail/detail-form/detail-form.component.ts @@ -8,12 +8,14 @@ import { Gender, HumanProfile, HumanProfileSchema } from '@zitadel/proto/zitadel import { filter, startWith } from 'rxjs/operators'; import { takeUntilDestroyed } from '@angular/core/rxjs-interop'; import { Profile } from '@zitadel/proto/zitadel/user_pb'; -import { create } from '@bufbuild/protobuf'; +//@ts-ignore +import { create } from '@zitadel/client'; function toHumanProfile(profile: HumanProfile | Profile): HumanProfile { if (profile.$typeName === 'zitadel.user.v2.HumanProfile') { return profile; } + return create(HumanProfileSchema, { givenName: profile.firstName, familyName: profile.lastName, diff --git a/console/src/app/pages/users/user-list/user-table/user-table.component.ts b/console/src/app/pages/users/user-list/user-table/user-table.component.ts index 6ff0d2cd67..cc5d753f36 100644 --- a/console/src/app/pages/users/user-list/user-table/user-table.component.ts +++ b/console/src/app/pages/users/user-list/user-table/user-table.component.ts @@ -36,10 +36,10 @@ import { AuthenticationService } from 'src/app/services/authentication.service'; import { GrpcAuthService } from 'src/app/services/grpc-auth.service'; import { UserState as UserStateV1 } from 'src/app/proto/generated/zitadel/user_pb'; -type Query = Exclude< - Exclude['queries'], undefined>[number]['query'], - undefined ->; +type ListUsersRequest = MessageInitShape; +type QueriesArray = NonNullable; +type QueryWrapper = QueriesArray extends readonly (infer T)[] ? T : never; +type Query = NonNullable; @Component({ selector: 'cnsl-user-table',