diff --git a/apps/web/src/app/vault/components/vault-items/vault-items.component.ts b/apps/web/src/app/vault/components/vault-items/vault-items.component.ts index e82b03a8815..79ba9a6d2e1 100644 --- a/apps/web/src/app/vault/components/vault-items/vault-items.component.ts +++ b/apps/web/src/app/vault/components/vault-items/vault-items.component.ts @@ -2,11 +2,16 @@ // @ts-strict-ignore import { SelectionModel } from "@angular/cdk/collections"; import { Component, EventEmitter, Input, Output } from "@angular/core"; +import { takeUntilDestroyed } from "@angular/core/rxjs-interop"; import { Observable, combineLatest, map, of, startWith, switchMap } from "rxjs"; import { CollectionView, Unassigned, CollectionAdminView } from "@bitwarden/admin-console/common"; import { Organization } from "@bitwarden/common/admin-console/models/domain/organization"; import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service"; +import { + RestrictedCipherType, + RestrictedItemTypesService, +} from "@bitwarden/common/vault/services/restricted-item-types.service"; import { CipherViewLike, CipherViewLikeUtils, @@ -85,8 +90,12 @@ export class VaultItemsComponent { protected canDeleteSelected$: Observable; protected canRestoreSelected$: Observable; protected disableMenu$: Observable; + private restrictedTypes: RestrictedCipherType[] = []; - constructor(protected cipherAuthorizationService: CipherAuthorizationService) { + constructor( + protected cipherAuthorizationService: CipherAuthorizationService, + private restrictedItemTypesService: RestrictedItemTypesService, + ) { this.canDeleteSelected$ = this.selection.changed.pipe( startWith(null), switchMap(() => { @@ -114,6 +123,11 @@ export class VaultItemsComponent { }), ); + this.restrictedItemTypesService.restricted$.pipe(takeUntilDestroyed()).subscribe((types) => { + this.restrictedTypes = types; + this.refreshItems(); + }); + this.canRestoreSelected$ = this.selection.changed.pipe( startWith(null), switchMap(() => { @@ -342,9 +356,12 @@ export class VaultItemsComponent { private refreshItems() { const collections: VaultItem[] = this.collections.map((collection) => ({ collection })); - const ciphers: VaultItem[] = this.ciphers.map((cipher) => ({ - cipher, - })); + const ciphers: VaultItem[] = this.ciphers + .filter( + (cipher) => + !this.restrictedItemTypesService.isCipherRestricted(cipher, this.restrictedTypes), + ) + .map((cipher) => ({ cipher })); const items: VaultItem[] = [].concat(collections).concat(ciphers); // All ciphers are selectable, collections only if they can be edited or deleted diff --git a/apps/web/src/app/vault/components/vault-items/vault-items.stories.ts b/apps/web/src/app/vault/components/vault-items/vault-items.stories.ts index 785c07fb634..78c4d21dede 100644 --- a/apps/web/src/app/vault/components/vault-items/vault-items.stories.ts +++ b/apps/web/src/app/vault/components/vault-items/vault-items.stories.ts @@ -139,6 +139,7 @@ export default { provide: RestrictedItemTypesService, useValue: { restricted$: of([]), // No restricted item types for this story + isCipherRestricted: () => false, // No restrictions for this story }, }, ],