mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 13:53:34 +00:00
[PM-24313] remove PM9111ExtensionPersistAddEditForm flag (#15929)
* remove the PM9111ExtensionPersistAddEditForm flag and associated logic
This commit is contained in:
@@ -48,7 +48,6 @@ export enum FeatureFlag {
|
|||||||
|
|
||||||
/* Vault */
|
/* Vault */
|
||||||
PM8851_BrowserOnboardingNudge = "pm-8851-browser-onboarding-nudge",
|
PM8851_BrowserOnboardingNudge = "pm-8851-browser-onboarding-nudge",
|
||||||
PM9111ExtensionPersistAddEditForm = "pm-9111-extension-persist-add-edit-form",
|
|
||||||
PM19941MigrateCipherDomainToSdk = "pm-19941-migrate-cipher-domain-to-sdk",
|
PM19941MigrateCipherDomainToSdk = "pm-19941-migrate-cipher-domain-to-sdk",
|
||||||
PM22134SdkCipherListView = "pm-22134-sdk-cipher-list-view",
|
PM22134SdkCipherListView = "pm-22134-sdk-cipher-list-view",
|
||||||
PM22136_SdkCipherEncryption = "pm-22136-sdk-cipher-encryption",
|
PM22136_SdkCipherEncryption = "pm-22136-sdk-cipher-encryption",
|
||||||
@@ -95,7 +94,6 @@ export const DefaultFeatureFlagValue = {
|
|||||||
|
|
||||||
/* Vault */
|
/* Vault */
|
||||||
[FeatureFlag.PM8851_BrowserOnboardingNudge]: FALSE,
|
[FeatureFlag.PM8851_BrowserOnboardingNudge]: FALSE,
|
||||||
[FeatureFlag.PM9111ExtensionPersistAddEditForm]: FALSE,
|
|
||||||
[FeatureFlag.CipherKeyEncryption]: FALSE,
|
[FeatureFlag.CipherKeyEncryption]: FALSE,
|
||||||
[FeatureFlag.EndUserNotifications]: FALSE,
|
[FeatureFlag.EndUserNotifications]: FALSE,
|
||||||
[FeatureFlag.PM19941MigrateCipherDomainToSdk]: FALSE,
|
[FeatureFlag.PM19941MigrateCipherDomainToSdk]: FALSE,
|
||||||
|
|||||||
@@ -227,8 +227,6 @@ export class CipherFormComponent implements AfterViewInit, OnInit, OnChanges, Ci
|
|||||||
// Force change detection so that all child components are destroyed and re-created
|
// Force change detection so that all child components are destroyed and re-created
|
||||||
this.changeDetectorRef.detectChanges();
|
this.changeDetectorRef.detectChanges();
|
||||||
|
|
||||||
await this.cipherFormCacheService.init();
|
|
||||||
|
|
||||||
this.updatedCipherView = new CipherView();
|
this.updatedCipherView = new CipherView();
|
||||||
this.originalCipherView = null;
|
this.originalCipherView = null;
|
||||||
this.cipherForm = this.formBuilder.group<CipherForm>({});
|
this.cipherForm = this.formBuilder.group<CipherForm>({});
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import { signal } from "@angular/core";
|
|||||||
import { TestBed } from "@angular/core/testing";
|
import { TestBed } from "@angular/core/testing";
|
||||||
|
|
||||||
import { ViewCacheService } from "@bitwarden/angular/platform/view-cache";
|
import { ViewCacheService } from "@bitwarden/angular/platform/view-cache";
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
|
||||||
import { CipherFormCacheService } from "./default-cipher-form-cache.service";
|
import { CipherFormCacheService } from "./default-cipher-form-cache.service";
|
||||||
@@ -12,39 +11,30 @@ describe("CipherFormCacheService", () => {
|
|||||||
let testBed: TestBed;
|
let testBed: TestBed;
|
||||||
const cacheSignal = signal<CipherView | null>(null);
|
const cacheSignal = signal<CipherView | null>(null);
|
||||||
const getCacheSignal = jest.fn().mockReturnValue(cacheSignal);
|
const getCacheSignal = jest.fn().mockReturnValue(cacheSignal);
|
||||||
const getFeatureFlag = jest.fn().mockResolvedValue(false);
|
|
||||||
const cacheSetMock = jest.spyOn(cacheSignal, "set");
|
const cacheSetMock = jest.spyOn(cacheSignal, "set");
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
getCacheSignal.mockClear();
|
getCacheSignal.mockClear();
|
||||||
getFeatureFlag.mockClear();
|
|
||||||
cacheSetMock.mockClear();
|
cacheSetMock.mockClear();
|
||||||
|
|
||||||
testBed = TestBed.configureTestingModule({
|
testBed = TestBed.configureTestingModule({
|
||||||
providers: [
|
providers: [
|
||||||
{ provide: ViewCacheService, useValue: { signal: getCacheSignal } },
|
{ provide: ViewCacheService, useValue: { signal: getCacheSignal } },
|
||||||
{ provide: ConfigService, useValue: { getFeatureFlag } },
|
|
||||||
CipherFormCacheService,
|
CipherFormCacheService,
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("feature enabled", () => {
|
describe("Cache Service", () => {
|
||||||
beforeEach(async () => {
|
|
||||||
getFeatureFlag.mockResolvedValue(true);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("`getCachedCipherView` returns the cipher", async () => {
|
it("`getCachedCipherView` returns the cipher", async () => {
|
||||||
cacheSignal.set({ id: "cipher-4" } as CipherView);
|
cacheSignal.set({ id: "cipher-4" } as CipherView);
|
||||||
service = testBed.inject(CipherFormCacheService);
|
service = testBed.inject(CipherFormCacheService);
|
||||||
await service.init();
|
|
||||||
|
|
||||||
expect(service.getCachedCipherView()).toEqual({ id: "cipher-4" });
|
expect(service.getCachedCipherView()).toEqual({ id: "cipher-4" });
|
||||||
});
|
});
|
||||||
|
|
||||||
it("updates the signal value", async () => {
|
it("updates the signal value", async () => {
|
||||||
service = testBed.inject(CipherFormCacheService);
|
service = testBed.inject(CipherFormCacheService);
|
||||||
await service.init();
|
|
||||||
|
|
||||||
service.cacheCipherView({ id: "cipher-5" } as CipherView);
|
service.cacheCipherView({ id: "cipher-5" } as CipherView);
|
||||||
|
|
||||||
@@ -55,7 +45,6 @@ describe("CipherFormCacheService", () => {
|
|||||||
it("sets `initializedWithValue` to true when there is a cached cipher", async () => {
|
it("sets `initializedWithValue` to true when there is a cached cipher", async () => {
|
||||||
cacheSignal.set({ id: "cipher-3" } as CipherView);
|
cacheSignal.set({ id: "cipher-3" } as CipherView);
|
||||||
service = testBed.inject(CipherFormCacheService);
|
service = testBed.inject(CipherFormCacheService);
|
||||||
await service.init();
|
|
||||||
|
|
||||||
expect(service.initializedWithValue).toBe(true);
|
expect(service.initializedWithValue).toBe(true);
|
||||||
});
|
});
|
||||||
@@ -63,35 +52,9 @@ describe("CipherFormCacheService", () => {
|
|||||||
it("sets `initializedWithValue` to false when there is not a cached cipher", async () => {
|
it("sets `initializedWithValue` to false when there is not a cached cipher", async () => {
|
||||||
cacheSignal.set(null);
|
cacheSignal.set(null);
|
||||||
service = testBed.inject(CipherFormCacheService);
|
service = testBed.inject(CipherFormCacheService);
|
||||||
await service.init();
|
|
||||||
|
|
||||||
expect(service.initializedWithValue).toBe(false);
|
expect(service.initializedWithValue).toBe(false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("featured disabled", () => {
|
|
||||||
beforeEach(async () => {
|
|
||||||
cacheSignal.set({ id: "cipher-1" } as CipherView);
|
|
||||||
getFeatureFlag.mockResolvedValue(false);
|
|
||||||
cacheSetMock.mockClear();
|
|
||||||
|
|
||||||
service = testBed.inject(CipherFormCacheService);
|
|
||||||
await service.init();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("sets `initializedWithValue` to false", () => {
|
|
||||||
expect(service.initializedWithValue).toBe(false);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("`getCachedCipherView` returns null", () => {
|
|
||||||
expect(service.getCachedCipherView()).toBeNull();
|
|
||||||
});
|
|
||||||
|
|
||||||
it("does not update the signal value", () => {
|
|
||||||
service.cacheCipherView({ id: "cipher-2" } as CipherView);
|
|
||||||
|
|
||||||
expect(cacheSignal.set).not.toHaveBeenCalled();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,8 +1,6 @@
|
|||||||
import { inject, Injectable } from "@angular/core";
|
import { inject, Injectable } from "@angular/core";
|
||||||
|
|
||||||
import { ViewCacheService } from "@bitwarden/angular/platform/view-cache";
|
import { ViewCacheService } from "@bitwarden/angular/platform/view-cache";
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
|
||||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||||
|
|
||||||
const CIPHER_FORM_CACHE_KEY = "cipher-form-cache";
|
const CIPHER_FORM_CACHE_KEY = "cipher-form-cache";
|
||||||
@@ -10,10 +8,6 @@ const CIPHER_FORM_CACHE_KEY = "cipher-form-cache";
|
|||||||
@Injectable()
|
@Injectable()
|
||||||
export class CipherFormCacheService {
|
export class CipherFormCacheService {
|
||||||
private viewCacheService: ViewCacheService = inject(ViewCacheService);
|
private viewCacheService: ViewCacheService = inject(ViewCacheService);
|
||||||
private configService: ConfigService = inject(ConfigService);
|
|
||||||
|
|
||||||
/** True when the `PM9111ExtensionPersistAddEditForm` flag is enabled */
|
|
||||||
private featureEnabled: boolean = false;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When true the `CipherFormCacheService` a cipher was stored in cache when the service was initialized.
|
* When true the `CipherFormCacheService` a cipher was stored in cache when the service was initialized.
|
||||||
@@ -34,27 +28,10 @@ export class CipherFormCacheService {
|
|||||||
this.initializedWithValue = !!this.cipherCache();
|
this.initializedWithValue = !!this.cipherCache();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Must be called once before interacting with the cached cipher, otherwise methods will be noop.
|
|
||||||
*/
|
|
||||||
async init() {
|
|
||||||
this.featureEnabled = await this.configService.getFeatureFlag(
|
|
||||||
FeatureFlag.PM9111ExtensionPersistAddEditForm,
|
|
||||||
);
|
|
||||||
|
|
||||||
if (!this.featureEnabled) {
|
|
||||||
this.initializedWithValue = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the cache with the new CipherView.
|
* Update the cache with the new CipherView.
|
||||||
*/
|
*/
|
||||||
cacheCipherView(cipherView: CipherView): void {
|
cacheCipherView(cipherView: CipherView): void {
|
||||||
if (!this.featureEnabled) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create a new shallow reference to force the signal to update
|
// Create a new shallow reference to force the signal to update
|
||||||
// By default, signals use `Object.is` to determine equality
|
// By default, signals use `Object.is` to determine equality
|
||||||
// Docs: https://angular.dev/guide/signals#signal-equality-functions
|
// Docs: https://angular.dev/guide/signals#signal-equality-functions
|
||||||
@@ -65,10 +42,6 @@ export class CipherFormCacheService {
|
|||||||
* Returns the cached CipherView when available.
|
* Returns the cached CipherView when available.
|
||||||
*/
|
*/
|
||||||
getCachedCipherView(): CipherView | null {
|
getCachedCipherView(): CipherView | null {
|
||||||
if (!this.featureEnabled) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.cipherCache();
|
return this.cipherCache();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user