mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 21:33:27 +00:00
[PM-23478] - Can view org's cards in AC (#15669)
* properly filter restricted item types in AC * fix storybook
This commit is contained in:
@@ -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<C extends CipherViewLike> {
|
||||
protected canDeleteSelected$: Observable<boolean>;
|
||||
protected canRestoreSelected$: Observable<boolean>;
|
||||
protected disableMenu$: Observable<boolean>;
|
||||
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<C extends CipherViewLike> {
|
||||
}),
|
||||
);
|
||||
|
||||
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<C extends CipherViewLike> {
|
||||
|
||||
private refreshItems() {
|
||||
const collections: VaultItem<C>[] = this.collections.map((collection) => ({ collection }));
|
||||
const ciphers: VaultItem<C>[] = this.ciphers.map((cipher) => ({
|
||||
cipher,
|
||||
}));
|
||||
const ciphers: VaultItem<C>[] = this.ciphers
|
||||
.filter(
|
||||
(cipher) =>
|
||||
!this.restrictedItemTypesService.isCipherRestricted(cipher, this.restrictedTypes),
|
||||
)
|
||||
.map((cipher) => ({ cipher }));
|
||||
const items: VaultItem<C>[] = [].concat(collections).concat(ciphers);
|
||||
|
||||
// All ciphers are selectable, collections only if they can be edited or deleted
|
||||
|
||||
@@ -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
|
||||
},
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user