mirror of
https://github.com/bitwarden/browser
synced 2025-12-11 22:03:36 +00:00
[PM-21794] - remove RemoveCardItemTypePolicy flag (#16450)
* remove restricted item types flag * fix RestrictedItemTypesService constructor
This commit is contained in:
@@ -884,7 +884,6 @@ export default class MainBackground {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.restrictedItemTypesService = new RestrictedItemTypesService(
|
this.restrictedItemTypesService = new RestrictedItemTypesService(
|
||||||
this.configService,
|
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.organizationService,
|
this.organizationService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
|
|||||||
@@ -689,7 +689,6 @@ export class ServiceContainer {
|
|||||||
);
|
);
|
||||||
|
|
||||||
this.restrictedItemTypesService = new RestrictedItemTypesService(
|
this.restrictedItemTypesService = new RestrictedItemTypesService(
|
||||||
this.configService,
|
|
||||||
this.accountService,
|
this.accountService,
|
||||||
this.organizationService,
|
this.organizationService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
|
|||||||
@@ -1,10 +1,6 @@
|
|||||||
import { Component } from "@angular/core";
|
import { Component } from "@angular/core";
|
||||||
import { Observable } from "rxjs";
|
|
||||||
|
|
||||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
|
||||||
|
|
||||||
import { SharedModule } from "../../../../shared";
|
import { SharedModule } from "../../../../shared";
|
||||||
import { BasePolicyEditDefinition, BasePolicyEditComponent } from "../base-policy-edit.component";
|
import { BasePolicyEditDefinition, BasePolicyEditComponent } from "../base-policy-edit.component";
|
||||||
@@ -14,10 +10,6 @@ export class RestrictedItemTypesPolicy extends BasePolicyEditDefinition {
|
|||||||
description = "restrictedItemTypePolicyDesc";
|
description = "restrictedItemTypePolicyDesc";
|
||||||
type = PolicyType.RestrictedItemTypes;
|
type = PolicyType.RestrictedItemTypes;
|
||||||
component = RestrictedItemTypesPolicyComponent;
|
component = RestrictedItemTypesPolicyComponent;
|
||||||
|
|
||||||
display$(organization: Organization, configService: ConfigService): Observable<boolean> {
|
|
||||||
return configService.getFeatureFlag$(FeatureFlag.RemoveCardItemTypePolicy);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
|||||||
@@ -692,7 +692,7 @@ const safeProviders: SafeProvider[] = [
|
|||||||
safeProvider({
|
safeProvider({
|
||||||
provide: RestrictedItemTypesService,
|
provide: RestrictedItemTypesService,
|
||||||
useClass: RestrictedItemTypesService,
|
useClass: RestrictedItemTypesService,
|
||||||
deps: [ConfigService, AccountService, OrganizationServiceAbstraction, PolicyServiceAbstraction],
|
deps: [AccountService, OrganizationServiceAbstraction, PolicyServiceAbstraction],
|
||||||
}),
|
}),
|
||||||
safeProvider({
|
safeProvider({
|
||||||
provide: PasswordStrengthServiceAbstraction,
|
provide: PasswordStrengthServiceAbstraction,
|
||||||
|
|||||||
@@ -48,7 +48,6 @@ export enum FeatureFlag {
|
|||||||
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",
|
||||||
CipherKeyEncryption = "cipher-key-encryption",
|
CipherKeyEncryption = "cipher-key-encryption",
|
||||||
RemoveCardItemTypePolicy = "pm-16442-remove-card-item-type-policy",
|
|
||||||
|
|
||||||
/* Platform */
|
/* Platform */
|
||||||
IpcChannelFramework = "ipc-channel-framework",
|
IpcChannelFramework = "ipc-channel-framework",
|
||||||
@@ -90,7 +89,6 @@ export const DefaultFeatureFlagValue = {
|
|||||||
/* Vault */
|
/* Vault */
|
||||||
[FeatureFlag.CipherKeyEncryption]: FALSE,
|
[FeatureFlag.CipherKeyEncryption]: FALSE,
|
||||||
[FeatureFlag.PM19941MigrateCipherDomainToSdk]: FALSE,
|
[FeatureFlag.PM19941MigrateCipherDomainToSdk]: FALSE,
|
||||||
[FeatureFlag.RemoveCardItemTypePolicy]: FALSE,
|
|
||||||
[FeatureFlag.PM22134SdkCipherListView]: FALSE,
|
[FeatureFlag.PM22134SdkCipherListView]: FALSE,
|
||||||
[FeatureFlag.PM22136_SdkCipherEncryption]: FALSE,
|
[FeatureFlag.PM22136_SdkCipherEncryption]: FALSE,
|
||||||
|
|
||||||
|
|||||||
@@ -52,12 +52,7 @@ describe("RestrictedItemTypesService", () => {
|
|||||||
organizationService.organizations$.mockReturnValue(of([org1, org2]));
|
organizationService.organizations$.mockReturnValue(of([org1, org2]));
|
||||||
policyService.policiesByType$.mockReturnValue(of([]));
|
policyService.policiesByType$.mockReturnValue(of([]));
|
||||||
|
|
||||||
service = new RestrictedItemTypesService(
|
service = new RestrictedItemTypesService(accountService, organizationService, policyService);
|
||||||
configService,
|
|
||||||
accountService,
|
|
||||||
organizationService,
|
|
||||||
policyService,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it("emits empty array when feature flag is disabled", async () => {
|
it("emits empty array when feature flag is disabled", async () => {
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import { PolicyService } from "@bitwarden/common/admin-console/abstractions/poli
|
|||||||
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
import { PolicyType } from "@bitwarden/common/admin-console/enums";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
||||||
import { getOptionalUserId } from "@bitwarden/common/auth/services/account.service";
|
import { getOptionalUserId } from "@bitwarden/common/auth/services/account.service";
|
||||||
import { FeatureFlag } from "@bitwarden/common/enums/feature-flag.enum";
|
|
||||||
import { ConfigService } from "@bitwarden/common/platform/abstractions/config/config.service";
|
|
||||||
import { CipherType } from "@bitwarden/common/vault/enums";
|
import { CipherType } from "@bitwarden/common/vault/enums";
|
||||||
|
|
||||||
import { uuidAsString } from "../../platform/abstractions/sdk/sdk.service";
|
import { uuidAsString } from "../../platform/abstractions/sdk/sdk.service";
|
||||||
@@ -25,51 +23,43 @@ export class RestrictedItemTypesService {
|
|||||||
* - cipherType: each type restricted by at least one org-level policy
|
* - cipherType: each type restricted by at least one org-level policy
|
||||||
* - allowViewOrgIds: org IDs that allow viewing that type
|
* - allowViewOrgIds: org IDs that allow viewing that type
|
||||||
*/
|
*/
|
||||||
readonly restricted$: Observable<RestrictedCipherType[]> = this.configService
|
readonly restricted$: Observable<RestrictedCipherType[]> =
|
||||||
.getFeatureFlag$(FeatureFlag.RemoveCardItemTypePolicy)
|
this.accountService.activeAccount$.pipe(
|
||||||
.pipe(
|
getOptionalUserId,
|
||||||
switchMap((flagOn) => {
|
switchMap((userId) => {
|
||||||
if (!flagOn) {
|
if (userId == null) {
|
||||||
return of([]);
|
return of([]); // No user logged in, no restrictions
|
||||||
}
|
}
|
||||||
return this.accountService.activeAccount$.pipe(
|
return combineLatest([
|
||||||
getOptionalUserId,
|
this.organizationService.organizations$(userId),
|
||||||
switchMap((userId) => {
|
this.policyService.policiesByType$(PolicyType.RestrictedItemTypes, userId),
|
||||||
if (userId == null) {
|
]).pipe(
|
||||||
return of([]); // No user logged in, no restrictions
|
map(([orgs, enabledPolicies]) => {
|
||||||
}
|
// Helper to extract restricted types, defaulting to [Card]
|
||||||
return combineLatest([
|
const restrictedTypes = (p: (typeof enabledPolicies)[number]) =>
|
||||||
this.organizationService.organizations$(userId),
|
(p.data as CipherType[]) ?? [CipherType.Card];
|
||||||
this.policyService.policiesByType$(PolicyType.RestrictedItemTypes, userId),
|
|
||||||
]).pipe(
|
|
||||||
map(([orgs, enabledPolicies]) => {
|
|
||||||
// Helper to extract restricted types, defaulting to [Card]
|
|
||||||
const restrictedTypes = (p: (typeof enabledPolicies)[number]) =>
|
|
||||||
(p.data as CipherType[]) ?? [CipherType.Card];
|
|
||||||
|
|
||||||
// Union across all enabled policies
|
// Union across all enabled policies
|
||||||
const allRestrictedTypes = Array.from(
|
const allRestrictedTypes = Array.from(
|
||||||
new Set(enabledPolicies.flatMap(restrictedTypes)),
|
new Set(enabledPolicies.flatMap(restrictedTypes)),
|
||||||
);
|
|
||||||
|
|
||||||
return allRestrictedTypes.map((cipherType) => {
|
|
||||||
// Determine which orgs allow viewing this type
|
|
||||||
const allowViewOrgIds = orgs
|
|
||||||
.filter((org) => {
|
|
||||||
const orgPolicy = enabledPolicies.find((p) => p.organizationId === org.id);
|
|
||||||
// no policy for this org => allows everything
|
|
||||||
if (!orgPolicy) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
// if this type not in their restricted list => they allow it
|
|
||||||
return !restrictedTypes(orgPolicy).includes(cipherType);
|
|
||||||
})
|
|
||||||
.map((org) => org.id);
|
|
||||||
|
|
||||||
return { cipherType, allowViewOrgIds };
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
return allRestrictedTypes.map((cipherType) => {
|
||||||
|
// Determine which orgs allow viewing this type
|
||||||
|
const allowViewOrgIds = orgs
|
||||||
|
.filter((org) => {
|
||||||
|
const orgPolicy = enabledPolicies.find((p) => p.organizationId === org.id);
|
||||||
|
// no policy for this org => allows everything
|
||||||
|
if (!orgPolicy) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
// if this type not in their restricted list => they allow it
|
||||||
|
return !restrictedTypes(orgPolicy).includes(cipherType);
|
||||||
|
})
|
||||||
|
.map((org) => org.id);
|
||||||
|
|
||||||
|
return { cipherType, allowViewOrgIds };
|
||||||
|
});
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
}),
|
}),
|
||||||
@@ -78,7 +68,6 @@ export class RestrictedItemTypesService {
|
|||||||
);
|
);
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private configService: ConfigService,
|
|
||||||
private accountService: AccountService,
|
private accountService: AccountService,
|
||||||
private organizationService: OrganizationService,
|
private organizationService: OrganizationService,
|
||||||
private policyService: PolicyService,
|
private policyService: PolicyService,
|
||||||
|
|||||||
Reference in New Issue
Block a user