mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 07:43:35 +00:00
[PM-2282] Make feature flags type safe (#8612)
Refactors the feature flags in ConfigService to be type safe. It also moves the default value to a centralized location rather than the caller defining it. This ensures consistency across the various places they are used.
This commit is contained in:
@@ -183,7 +183,7 @@ class FilelessImporterBackground implements FilelessImporterBackgroundInterface
|
||||
return;
|
||||
}
|
||||
|
||||
const filelessImportFeatureFlagEnabled = await this.configService.getFeatureFlag<boolean>(
|
||||
const filelessImportFeatureFlagEnabled = await this.configService.getFeatureFlag(
|
||||
FeatureFlag.BrowserFilelessImport,
|
||||
);
|
||||
const userAuthStatus = await this.authService.getAuthStatus();
|
||||
|
||||
@@ -58,7 +58,6 @@ export class OrganizationLayoutComponent implements OnInit, OnDestroy {
|
||||
|
||||
protected showPaymentMethodWarningBanners$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.ShowPaymentMethodWarningBanners,
|
||||
false,
|
||||
);
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -218,7 +218,6 @@ export class MemberDialogComponent implements OnDestroy {
|
||||
groups: groups$,
|
||||
flexibleCollectionsV1Enabled: this.configService.getFeatureFlag$(
|
||||
FeatureFlag.FlexibleCollectionsV1,
|
||||
false,
|
||||
),
|
||||
})
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
|
||||
@@ -44,12 +44,10 @@ export class AccountComponent {
|
||||
|
||||
protected flexibleCollectionsMigrationEnabled$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.FlexibleCollectionsMigration,
|
||||
false,
|
||||
);
|
||||
|
||||
flexibleCollectionsV1Enabled$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.FlexibleCollectionsV1,
|
||||
false,
|
||||
);
|
||||
|
||||
// FormGroup validators taken from server Organization domain object
|
||||
|
||||
@@ -90,7 +90,7 @@ export class UserKeyRotationService {
|
||||
request.emergencyAccessKeys = await this.emergencyAccessService.getRotatedKeys(newUserKey);
|
||||
request.resetPasswordKeys = await this.resetPasswordService.getRotatedKeys(newUserKey);
|
||||
|
||||
if (await this.configService.getFeatureFlag<boolean>(FeatureFlag.KeyRotationImprovements)) {
|
||||
if (await this.configService.getFeatureFlag(FeatureFlag.KeyRotationImprovements)) {
|
||||
await this.apiService.postUserKeyUpdate(request);
|
||||
} else {
|
||||
await this.rotateUserKeyAndEncryptedDataLegacy(request);
|
||||
|
||||
@@ -84,7 +84,6 @@ export class OrganizationSubscriptionCloudComponent implements OnInit, OnDestroy
|
||||
|
||||
this.showUpdatedSubscriptionStatusSection$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.AC1795_UpdatedSubscriptionStatusSection,
|
||||
false,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ export class UserLayoutComponent implements OnInit {
|
||||
|
||||
protected showPaymentMethodWarningBanners$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.ShowPaymentMethodWarningBanners,
|
||||
false,
|
||||
);
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -76,7 +76,7 @@ export enum CollectionDialogAction {
|
||||
})
|
||||
export class CollectionDialogComponent implements OnInit, OnDestroy {
|
||||
protected flexibleCollectionsV1Enabled$ = this.configService
|
||||
.getFeatureFlag$(FeatureFlag.FlexibleCollectionsV1, false)
|
||||
.getFeatureFlag$(FeatureFlag.FlexibleCollectionsV1)
|
||||
.pipe(first());
|
||||
|
||||
private destroy$ = new Subject<void>();
|
||||
|
||||
@@ -54,7 +54,6 @@ export class BulkDeleteDialogComponent {
|
||||
|
||||
private flexibleCollectionsV1Enabled$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.FlexibleCollectionsV1,
|
||||
false,
|
||||
);
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -60,9 +60,8 @@ export class VaultOnboardingComponent implements OnInit, OnChanges, OnDestroy {
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
this.showOnboardingAccess$ = await this.configService.getFeatureFlag$<boolean>(
|
||||
this.showOnboardingAccess$ = await this.configService.getFeatureFlag$(
|
||||
FeatureFlag.VaultOnboarding,
|
||||
false,
|
||||
);
|
||||
this.onboardingTasks$ = this.vaultOnboardingService.vaultOnboardingState$;
|
||||
await this.setOnboardingTasks();
|
||||
|
||||
@@ -148,7 +148,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
protected currentSearchText$: Observable<string>;
|
||||
protected flexibleCollectionsV1Enabled$ = this.configService.getFeatureFlag$(
|
||||
FeatureFlag.FlexibleCollectionsV1,
|
||||
false,
|
||||
);
|
||||
|
||||
private searchText$ = new Subject<string>();
|
||||
|
||||
@@ -60,7 +60,7 @@ export class AttachmentsComponent extends BaseAttachmentsComponent implements On
|
||||
async ngOnInit() {
|
||||
await super.ngOnInit();
|
||||
this.flexibleCollectionsV1Enabled = await firstValueFrom(
|
||||
this.configService.getFeatureFlag$(FeatureFlag.FlexibleCollectionsV1, false),
|
||||
this.configService.getFeatureFlag$(FeatureFlag.FlexibleCollectionsV1),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -70,10 +70,7 @@ export class BulkCollectionAssignmentDialogComponent implements OnDestroy, OnIni
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
const v1FCEnabled = await this.configService.getFeatureFlag(
|
||||
FeatureFlag.FlexibleCollectionsV1,
|
||||
false,
|
||||
);
|
||||
const v1FCEnabled = await this.configService.getFeatureFlag(FeatureFlag.FlexibleCollectionsV1);
|
||||
const org = await this.organizationService.get(this.params.organizationId);
|
||||
|
||||
if (org.canEditAllCiphers(v1FCEnabled)) {
|
||||
|
||||
@@ -193,7 +193,6 @@ export class VaultComponent implements OnInit, OnDestroy {
|
||||
|
||||
this._flexibleCollectionsV1FlagEnabled = await this.configService.getFeatureFlag(
|
||||
FeatureFlag.FlexibleCollectionsV1,
|
||||
false,
|
||||
);
|
||||
|
||||
const filter$ = this.routedVaultFilterService.filter$;
|
||||
|
||||
Reference in New Issue
Block a user