mirror of
https://github.com/andwati/zitadel.git
synced 2026-11-19 11:45:12 +00:00
chore!: Introduce ZITADEL v3 (#9645)
This PR summarizes multiple changes specifically only available with ZITADEL v3: - feat: Web Keys management (https://github.com/zitadel/zitadel/pull/9526) - fix(cmd): ensure proper working of mirror (https://github.com/zitadel/zitadel/pull/9509) - feat(Authz): system user support for permission check v2 (https://github.com/zitadel/zitadel/pull/9640) - chore(license): change from Apache to AGPL (https://github.com/zitadel/zitadel/pull/9597) - feat(console): list v2 sessions (https://github.com/zitadel/zitadel/pull/9539) - fix(console): add loginV2 feature flag (https://github.com/zitadel/zitadel/pull/9682) - fix(feature flags): allow reading "own" flags (https://github.com/zitadel/zitadel/pull/9649) - feat(console): add Actions V2 UI (https://github.com/zitadel/zitadel/pull/9591) BREAKING CHANGE - feat(webkey): migrate to v2beta API (https://github.com/zitadel/zitadel/pull/9445) - chore!: remove CockroachDB Support (https://github.com/zitadel/zitadel/pull/9444) - feat(actions): migrate to v2beta API (https://github.com/zitadel/zitadel/pull/9489) --------- Co-authored-by: Livio Spring <[email protected]> Co-authored-by: Stefan Benz <[email protected]> Co-authored-by: Silvan <[email protected]> Co-authored-by: Ramon <[email protected]> Co-authored-by: Elio Bischof <[email protected]> Co-authored-by: Kenta Yamaguchi <[email protected]> Co-authored-by: Harsha Reddy <[email protected]> Co-authored-by: Livio Spring <[email protected]> Co-authored-by: Max Peintner <[email protected]> Co-authored-by: Iraq <[email protected]> Co-authored-by: Florian Forster <[email protected]> Co-authored-by: Tim Möhlmann <[email protected]> Co-authored-by: Copilot <[email protected]> Co-authored-by: Max Peintner <[email protected]>
This commit is contained in:
co-authored by
Livio Spring
Stefan Benz
Silvan
Ramon
Elio Bischof
Kenta Yamaguchi
Harsha Reddy
Livio Spring
Max Peintner
Iraq
Florian Forster
Tim Möhlmann
Copilot
Max Peintner
parent
d14a23ae7e
commit
07ce3b6905
@@ -1,29 +1,29 @@
|
||||
<div class="feature-row" *ngIf="$any(toggleStates)[toggleStateKey]">
|
||||
<span>{{ 'SETTING.FEATURES.' + toggleStateKey.toUpperCase() | translate }}</span>
|
||||
<div class="feature-row" *ngIf="toggleState$ | async as toggleState">
|
||||
<span>{{ 'SETTING.FEATURES.' + (toggleStateKey | uppercase) | translate }}</span>
|
||||
<div class="row">
|
||||
<mat-button-toggle-group
|
||||
class="theme-toggle"
|
||||
class="buttongroup"
|
||||
[(ngModel)]="$any(toggleStates)[toggleStateKey].state"
|
||||
(change)="onToggleChange()"
|
||||
[(ngModel)]="toggleState.enabled"
|
||||
(change)="toggleChange.emit(toggleState)"
|
||||
name="displayview"
|
||||
>
|
||||
<mat-button-toggle [value]="ToggleState.DISABLED">
|
||||
<mat-button-toggle [value]="false">
|
||||
<div class="toggle-row">
|
||||
<span>{{ 'SETTING.FEATURES.STATES.DISABLED' | translate }}</span>
|
||||
|
||||
<div
|
||||
*ngIf="!enabled && isInherited"
|
||||
*ngIf="!toggleState.enabled && (isInherited$ | async)"
|
||||
class="current-dot"
|
||||
matTooltip="{{ 'SETTING.FEATURES.INHERITEDINDICATOR_DESCRIPTION.DISABLED' | translate }}"
|
||||
></div>
|
||||
</div>
|
||||
</mat-button-toggle>
|
||||
<mat-button-toggle [value]="ToggleState.ENABLED">
|
||||
<mat-button-toggle [value]="true">
|
||||
<div class="toggle-row">
|
||||
<span>{{ 'SETTING.FEATURES.STATES.ENABLED' | translate }}</span>
|
||||
<div
|
||||
*ngIf="enabled && isInherited"
|
||||
*ngIf="toggleState.enabled && (isInherited$ | async)"
|
||||
class="current-dot"
|
||||
matTooltip="{{ 'SETTING.FEATURES.INHERITEDINDICATOR_DESCRIPTION.ENABLED' | translate }}"
|
||||
></div>
|
||||
@@ -34,7 +34,7 @@
|
||||
<ng-content></ng-content>
|
||||
<cnsl-info-section
|
||||
class="feature-info"
|
||||
*ngIf="'SETTING.FEATURES.' + toggleStateKey.toUpperCase() + '_DESCRIPTION' | translate as i18nDescription"
|
||||
*ngIf="'SETTING.FEATURES.' + (toggleStateKey | uppercase) + '_DESCRIPTION' | translate as i18nDescription"
|
||||
>{{ i18nDescription }}</cnsl-info-section
|
||||
>
|
||||
</div>
|
||||
|
||||
@@ -1,16 +1,14 @@
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { AsyncPipe, NgIf, UpperCasePipe } from '@angular/common';
|
||||
import { ChangeDetectionStrategy, Component, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
import { CopyToClipboardModule } from '../../directives/copy-to-clipboard/copy-to-clipboard.module';
|
||||
import { CopyRowComponent } from '../copy-row/copy-row.component';
|
||||
import { InfoSectionModule } from 'src/app/modules/info-section/info-section.module';
|
||||
import { ToggleState, ToggleStateKeys, ToggleStates } from '../features/features.component';
|
||||
import { ToggleStateKeys, ToggleStates } from '../features/features.component';
|
||||
import { MatButtonToggleModule } from '@angular/material/button-toggle';
|
||||
import { FormsModule } from '@angular/forms';
|
||||
import { GetInstanceFeaturesResponse } from '@zitadel/proto/zitadel/feature/v2/instance_pb';
|
||||
import { FeatureFlag, Source } from '@zitadel/proto/zitadel/feature/v2/feature_pb';
|
||||
import { Source } from '@zitadel/proto/zitadel/feature/v2/feature_pb';
|
||||
import { ReplaySubject } from 'rxjs';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
@@ -19,37 +17,29 @@ import { FeatureFlag, Source } from '@zitadel/proto/zitadel/feature/v2/feature_p
|
||||
styleUrls: ['./feature-toggle.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
imports: [
|
||||
CommonModule,
|
||||
FormsModule,
|
||||
TranslateModule,
|
||||
MatButtonModule,
|
||||
InfoSectionModule,
|
||||
MatTooltipModule,
|
||||
CopyToClipboardModule,
|
||||
CopyRowComponent,
|
||||
MatButtonToggleModule,
|
||||
UpperCasePipe,
|
||||
TranslateModule,
|
||||
FormsModule,
|
||||
MatTooltipModule,
|
||||
InfoSectionModule,
|
||||
AsyncPipe,
|
||||
NgIf,
|
||||
],
|
||||
})
|
||||
export class FeatureToggleComponent {
|
||||
@Input() featureData: Partial<GetInstanceFeaturesResponse> = {};
|
||||
@Input() toggleStates: Partial<ToggleStates> = {};
|
||||
@Input() toggleStateKey: string = '';
|
||||
@Output() toggleChange = new EventEmitter<void>();
|
||||
|
||||
protected ToggleState = ToggleState;
|
||||
protected Source = Source;
|
||||
|
||||
get isInherited(): boolean {
|
||||
const source = this.featureData[this.toggleStateKey as ToggleStateKeys]?.source;
|
||||
return source == Source.SYSTEM || source == Source.UNSPECIFIED;
|
||||
export class FeatureToggleComponent<TKey extends ToggleStateKeys, TValue extends ToggleStates[TKey]> {
|
||||
@Input({ required: true }) toggleStateKey!: TKey;
|
||||
@Input({ required: true })
|
||||
set toggleState(toggleState: TValue) {
|
||||
// we copy the toggleState so we can mutate it
|
||||
this.toggleState$.next(structuredClone(toggleState));
|
||||
}
|
||||
|
||||
get enabled() {
|
||||
// TODO: remove casting as not all features are a FeatureFlag
|
||||
return (this.featureData[this.toggleStateKey as ToggleStateKeys] as FeatureFlag)?.enabled;
|
||||
}
|
||||
@Output() readonly toggleChange = new EventEmitter<TValue>();
|
||||
|
||||
onToggleChange() {
|
||||
this.toggleChange.emit();
|
||||
}
|
||||
protected readonly Source = Source;
|
||||
protected readonly toggleState$ = new ReplaySubject<TValue>(1);
|
||||
protected readonly isInherited$ = this.toggleState$.pipe(
|
||||
map(({ source }) => source == Source.SYSTEM || source == Source.UNSPECIFIED),
|
||||
);
|
||||
}
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
<cnsl-feature-toggle
|
||||
*ngIf="toggleState$ | async as toggleState"
|
||||
toggleStateKey="loginV2"
|
||||
[toggleState]="toggleState"
|
||||
(toggleChange)="toggleState$.next($event); !$event.enabled && toggleChanged.emit($event)"
|
||||
>
|
||||
<cnsl-form-field *ngIf="toggleState.enabled">
|
||||
<cnsl-label>{{ 'SETTING.FEATURES.LOGINV2_BASEURI' | translate }}</cnsl-label>
|
||||
<input cnslInput [formControl]="baseUri" />
|
||||
<button
|
||||
matTooltip="{{ 'ACTIONS.SAVE' | translate }}"
|
||||
mat-icon-button
|
||||
[disabled]="baseUri.invalid"
|
||||
color="primary"
|
||||
type="submit"
|
||||
(click)="
|
||||
toggleChanged.emit({
|
||||
source: toggleState.source,
|
||||
enabled: toggleState.enabled,
|
||||
baseUri: baseUri.value,
|
||||
})
|
||||
"
|
||||
>
|
||||
<i class="las la-save"></i>
|
||||
</button>
|
||||
</cnsl-form-field>
|
||||
</cnsl-feature-toggle>
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
import { ChangeDetectionStrategy, Component, DestroyRef, EventEmitter, Input, Output } from '@angular/core';
|
||||
import { FeatureToggleComponent } from '../feature-toggle.component';
|
||||
import { ToggleStates } from 'src/app/components/features/features.component';
|
||||
import { distinctUntilKeyChanged, ReplaySubject } from 'rxjs';
|
||||
import { FormControl, ReactiveFormsModule, Validators } from '@angular/forms';
|
||||
import { AsyncPipe, NgIf } from '@angular/common';
|
||||
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
|
||||
import { InputModule } from 'src/app/modules/input/input.module';
|
||||
import { HasRolePipeModule } from 'src/app/pipes/has-role-pipe/has-role-pipe.module';
|
||||
import { MatButtonModule } from '@angular/material/button';
|
||||
import { TranslateModule } from '@ngx-translate/core';
|
||||
import { MatTooltipModule } from '@angular/material/tooltip';
|
||||
|
||||
@Component({
|
||||
standalone: true,
|
||||
selector: 'cnsl-login-v2-feature-toggle',
|
||||
templateUrl: './login-v2-feature-toggle.component.html',
|
||||
imports: [
|
||||
FeatureToggleComponent,
|
||||
AsyncPipe,
|
||||
NgIf,
|
||||
ReactiveFormsModule,
|
||||
InputModule,
|
||||
HasRolePipeModule,
|
||||
MatButtonModule,
|
||||
TranslateModule,
|
||||
MatTooltipModule,
|
||||
],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class LoginV2FeatureToggleComponent {
|
||||
@Input({ required: true })
|
||||
set toggleState(toggleState: ToggleStates['loginV2']) {
|
||||
this.toggleState$.next(toggleState);
|
||||
}
|
||||
@Output()
|
||||
public toggleChanged = new EventEmitter<ToggleStates['loginV2']>();
|
||||
|
||||
protected readonly toggleState$ = new ReplaySubject<ToggleStates['loginV2']>(1);
|
||||
protected readonly baseUri = new FormControl('', { nonNullable: true, validators: [Validators.required] });
|
||||
|
||||
constructor(destroyRef: DestroyRef) {
|
||||
this.toggleState$.pipe(distinctUntilKeyChanged('baseUri'), takeUntilDestroyed(destroyRef)).subscribe(({ baseUri }) => {
|
||||
this.baseUri.setValue(baseUri);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -13,26 +13,20 @@
|
||||
<p class="events-desc cnsl-secondary-text">{{ 'DESCRIPTIONS.SETTINGS.FEATURES.DESCRIPTION' | translate }}</p>
|
||||
|
||||
<ng-template cnslHasRole [hasRole]="['iam.restrictions.write']">
|
||||
<button color="warn" (click)="resetSettings()" mat-stroked-button>
|
||||
<button color="warn" (click)="resetFeatures()" mat-stroked-button>
|
||||
{{ 'SETTING.FEATURES.RESET' | translate }}
|
||||
</button>
|
||||
</ng-template>
|
||||
|
||||
<cnsl-card *ngIf="toggleStates && featureData">
|
||||
<cnsl-card *ngIf="toggleStates$ | async as toggleStates">
|
||||
<div class="features">
|
||||
<cnsl-feature-toggle
|
||||
*ngFor="let key of toggleStateKeys"
|
||||
[featureData]="featureData"
|
||||
[toggleStates]="toggleStates"
|
||||
*ngFor="let key of FEATURE_KEYS"
|
||||
[toggleStateKey]="key"
|
||||
(toggleChange)="validateAndSave()"
|
||||
[toggleState]="toggleStates[key]"
|
||||
(toggleChange)="saveFeatures(key, $event)"
|
||||
></cnsl-feature-toggle>
|
||||
<cnsl-login-v2-feature-toggle [toggleState]="toggleStates.loginV2" (toggleChanged)="saveFeatures('loginV2', $event)" />
|
||||
</div>
|
||||
</cnsl-card>
|
||||
</div>
|
||||
|
||||
<ng-template #sourceLabel let-source="source" let-last="last">
|
||||
<span class="state" *ngIf="source === Source.SOURCE_SYSTEM">
|
||||
{{ 'SETTING.FEATURES.SOURCE.' + source | translate }}
|
||||
</span>
|
||||
</ng-template>
|
||||
|
||||
@@ -19,16 +19,14 @@ import {
|
||||
GetInstanceFeaturesResponse,
|
||||
SetInstanceFeaturesRequestSchema,
|
||||
} from '@zitadel/proto/zitadel/feature/v2/instance_pb';
|
||||
import { FeatureFlag, Source } from '@zitadel/proto/zitadel/feature/v2/feature_pb';
|
||||
import { Source } from '@zitadel/proto/zitadel/feature/v2/feature_pb';
|
||||
import { MessageInitShape } from '@bufbuild/protobuf';
|
||||
import { firstValueFrom, Observable, ReplaySubject, shareReplay, switchMap } from 'rxjs';
|
||||
import { filter, map, startWith } from 'rxjs/operators';
|
||||
import { LoginV2FeatureToggleComponent } from '../feature-toggle/login-v2-feature-toggle/login-v2-feature-toggle.component';
|
||||
|
||||
export enum ToggleState {
|
||||
ENABLED = 'ENABLED',
|
||||
DISABLED = 'DISABLED',
|
||||
}
|
||||
|
||||
// TODO: to add a new feature, add the key here and in the FEATURE_KEYS array
|
||||
const FEATURE_KEYS: ToggleStateKeys[] = [
|
||||
// to add a new feature, add the key here and in the FEATURE_KEYS array
|
||||
const FEATURE_KEYS = [
|
||||
'actions',
|
||||
'consoleUseV2UserApi',
|
||||
'debugOidcParentError',
|
||||
@@ -36,23 +34,24 @@ const FEATURE_KEYS: ToggleStateKeys[] = [
|
||||
'enableBackChannelLogout',
|
||||
// 'improvedPerformance',
|
||||
'loginDefaultOrg',
|
||||
// 'loginV2',
|
||||
'oidcLegacyIntrospection',
|
||||
'oidcSingleV1SessionTermination',
|
||||
'oidcTokenExchange',
|
||||
'oidcTriggerIntrospectionProjections',
|
||||
'permissionCheckV2',
|
||||
'userSchema',
|
||||
// 'webKey',
|
||||
];
|
||||
|
||||
type FeatureState = { source: Source; state: ToggleState };
|
||||
export type ToggleStateKeys = Exclude<keyof GetInstanceFeaturesResponse, 'details' | '$typeName' | '$unknown'>;
|
||||
'webKey',
|
||||
] as const;
|
||||
|
||||
export type ToggleState = { source: Source; enabled: boolean };
|
||||
export type ToggleStates = {
|
||||
[key in ToggleStateKeys]: FeatureState;
|
||||
[key in (typeof FEATURE_KEYS)[number]]: ToggleState;
|
||||
} & {
|
||||
loginV2: ToggleState & { baseUri: string };
|
||||
};
|
||||
|
||||
export type ToggleStateKeys = keyof ToggleStates;
|
||||
|
||||
@Component({
|
||||
imports: [
|
||||
CommonModule,
|
||||
@@ -68,6 +67,7 @@ export type ToggleStates = {
|
||||
MatTooltipModule,
|
||||
HasRoleModule,
|
||||
FeatureToggleComponent,
|
||||
LoginV2FeatureToggleComponent,
|
||||
],
|
||||
standalone: true,
|
||||
selector: 'cnsl-features',
|
||||
@@ -75,16 +75,15 @@ export type ToggleStates = {
|
||||
styleUrls: ['./features.component.scss'],
|
||||
})
|
||||
export class FeaturesComponent {
|
||||
protected featureData: GetInstanceFeaturesResponse | undefined;
|
||||
|
||||
protected toggleStates: ToggleStates | undefined;
|
||||
protected Source: any = Source;
|
||||
protected ToggleState: any = ToggleState;
|
||||
private readonly refresh$ = new ReplaySubject<true>(1);
|
||||
protected readonly toggleStates$: Observable<ToggleStates>;
|
||||
protected readonly Source = Source;
|
||||
protected readonly FEATURE_KEYS = FEATURE_KEYS;
|
||||
|
||||
constructor(
|
||||
private featureService: NewFeatureService,
|
||||
private breadcrumbService: BreadcrumbService,
|
||||
private toast: ToastService,
|
||||
private readonly featureService: NewFeatureService,
|
||||
private readonly breadcrumbService: BreadcrumbService,
|
||||
private readonly toast: ToastService,
|
||||
) {
|
||||
const breadcrumbs = [
|
||||
new Breadcrumb({
|
||||
@@ -95,74 +94,84 @@ export class FeaturesComponent {
|
||||
];
|
||||
this.breadcrumbService.setBreadcrumb(breadcrumbs);
|
||||
|
||||
this.getFeatures();
|
||||
this.toggleStates$ = this.getToggleStates().pipe(shareReplay({ refCount: true, bufferSize: 1 }));
|
||||
}
|
||||
|
||||
public validateAndSave() {
|
||||
const req: MessageInitShape<typeof SetInstanceFeaturesRequestSchema> = {
|
||||
actions: this.toggleStates?.actions?.state === ToggleState.ENABLED,
|
||||
consoleUseV2UserApi: this.toggleStates?.consoleUseV2UserApi?.state === ToggleState.ENABLED,
|
||||
debugOidcParentError: this.toggleStates?.debugOidcParentError?.state === ToggleState.ENABLED,
|
||||
disableUserTokenEvent: this.toggleStates?.disableUserTokenEvent?.state === ToggleState.ENABLED,
|
||||
enableBackChannelLogout: this.toggleStates?.enableBackChannelLogout?.state === ToggleState.ENABLED,
|
||||
loginDefaultOrg: this.toggleStates?.loginDefaultOrg?.state === ToggleState.ENABLED,
|
||||
oidcLegacyIntrospection: this.toggleStates?.oidcLegacyIntrospection?.state === ToggleState.ENABLED,
|
||||
oidcSingleV1SessionTermination: this.toggleStates?.oidcSingleV1SessionTermination?.state === ToggleState.ENABLED,
|
||||
oidcTokenExchange: this.toggleStates?.oidcTokenExchange?.state === ToggleState.ENABLED,
|
||||
oidcTriggerIntrospectionProjections:
|
||||
this.toggleStates?.oidcTriggerIntrospectionProjections?.state === ToggleState.ENABLED,
|
||||
permissionCheckV2: this.toggleStates?.permissionCheckV2?.state === ToggleState.ENABLED,
|
||||
userSchema: this.toggleStates?.userSchema?.state === ToggleState.ENABLED,
|
||||
// webKey: this.toggleStates?.webKey?.state === ToggleState.ENABLED,
|
||||
};
|
||||
|
||||
this.featureService
|
||||
.setInstanceFeatures(req)
|
||||
.then(() => {
|
||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
}
|
||||
|
||||
private getFeatures() {
|
||||
this.featureService.getInstanceFeatures().then((instanceFeaturesResponse) => {
|
||||
this.featureData = instanceFeaturesResponse;
|
||||
this.toggleStates = this.createToggleStates(this.featureData);
|
||||
});
|
||||
private getToggleStates() {
|
||||
return this.refresh$.pipe(
|
||||
startWith(true),
|
||||
switchMap(async () => {
|
||||
try {
|
||||
return await this.featureService.getInstanceFeatures();
|
||||
} catch (error) {
|
||||
this.toast.showError(error);
|
||||
return undefined;
|
||||
}
|
||||
}),
|
||||
filter(Boolean),
|
||||
map((res) => this.createToggleStates(res)),
|
||||
);
|
||||
}
|
||||
|
||||
private createToggleStates(featureData: GetInstanceFeaturesResponse): ToggleStates {
|
||||
const toggleStates: Partial<ToggleStates> = {};
|
||||
|
||||
FEATURE_KEYS.forEach((key) => {
|
||||
// TODO: Fix this type cast as not all keys are present as FeatureFlag
|
||||
const feature = featureData[key] as unknown as FeatureFlag;
|
||||
toggleStates[key] = {
|
||||
source: feature?.source || Source.SYSTEM,
|
||||
state: !!feature?.enabled ? ToggleState.ENABLED : ToggleState.DISABLED,
|
||||
};
|
||||
});
|
||||
|
||||
return toggleStates as ToggleStates;
|
||||
return FEATURE_KEYS.reduce(
|
||||
(acc, key) => {
|
||||
const feature = featureData[key];
|
||||
acc[key] = {
|
||||
source: feature?.source ?? Source.SYSTEM,
|
||||
enabled: !!feature?.enabled,
|
||||
};
|
||||
return acc;
|
||||
},
|
||||
{
|
||||
// to add special feature flags they have to be mapped here
|
||||
loginV2: {
|
||||
source: featureData.loginV2?.source ?? Source.SYSTEM,
|
||||
enabled: !!featureData.loginV2?.required,
|
||||
baseUri: featureData.loginV2?.baseUri ?? '',
|
||||
},
|
||||
} as ToggleStates,
|
||||
);
|
||||
}
|
||||
|
||||
public resetSettings(): void {
|
||||
this.featureService
|
||||
.resetInstanceFeatures()
|
||||
.then(() => {
|
||||
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
|
||||
setTimeout(() => {
|
||||
this.getFeatures();
|
||||
}, 1000);
|
||||
})
|
||||
.catch((error) => {
|
||||
this.toast.showError(error);
|
||||
});
|
||||
public async saveFeatures<TKey extends ToggleStateKeys, TValue extends ToggleStates[TKey]>(key: TKey, value: TValue) {
|
||||
const toggleStates = { ...(await firstValueFrom(this.toggleStates$)), [key]: value };
|
||||
|
||||
const req = FEATURE_KEYS.reduce<MessageInitShape<typeof SetInstanceFeaturesRequestSchema>>((acc, key) => {
|
||||
acc[key] = toggleStates[key].enabled;
|
||||
return acc;
|
||||
}, {});
|
||||
|
||||
// to save special flags they have to be handled here
|
||||
req.loginV2 = {
|
||||
required: toggleStates.loginV2.enabled,
|
||||
baseUri: toggleStates.loginV2.baseUri,
|
||||
};
|
||||
|
||||
try {
|
||||
await this.featureService.setInstanceFeatures(req);
|
||||
|
||||
// needed because of eventual consistency
|
||||
await new Promise((res) => setTimeout(res, 1000));
|
||||
this.refresh$.next(true);
|
||||
|
||||
this.toast.showInfo('POLICY.TOAST.SET', true);
|
||||
} catch (error) {
|
||||
this.toast.showError(error);
|
||||
}
|
||||
}
|
||||
|
||||
public get toggleStateKeys() {
|
||||
return Object.keys(this.toggleStates ?? {});
|
||||
public async resetFeatures() {
|
||||
try {
|
||||
await this.featureService.resetInstanceFeatures();
|
||||
|
||||
// needed because of eventual consistency
|
||||
await new Promise((res) => setTimeout(res, 1000));
|
||||
this.refresh$.next(true);
|
||||
|
||||
this.toast.showInfo('POLICY.TOAST.RESETSUCCESS', true);
|
||||
} catch (error) {
|
||||
this.toast.showError(error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user