mirror of
https://github.com/bitwarden/browser
synced 2025-12-12 22:33:35 +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
|
// @ts-strict-ignore
|
||||||
import { SelectionModel } from "@angular/cdk/collections";
|
import { SelectionModel } from "@angular/cdk/collections";
|
||||||
import { Component, EventEmitter, Input, Output } from "@angular/core";
|
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 { Observable, combineLatest, map, of, startWith, switchMap } from "rxjs";
|
||||||
|
|
||||||
import { CollectionView, Unassigned, CollectionAdminView } from "@bitwarden/admin-console/common";
|
import { CollectionView, Unassigned, CollectionAdminView } from "@bitwarden/admin-console/common";
|
||||||
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
import { Organization } from "@bitwarden/common/admin-console/models/domain/organization";
|
||||||
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
import { CipherAuthorizationService } from "@bitwarden/common/vault/services/cipher-authorization.service";
|
||||||
|
import {
|
||||||
|
RestrictedCipherType,
|
||||||
|
RestrictedItemTypesService,
|
||||||
|
} from "@bitwarden/common/vault/services/restricted-item-types.service";
|
||||||
import {
|
import {
|
||||||
CipherViewLike,
|
CipherViewLike,
|
||||||
CipherViewLikeUtils,
|
CipherViewLikeUtils,
|
||||||
@@ -85,8 +90,12 @@ export class VaultItemsComponent<C extends CipherViewLike> {
|
|||||||
protected canDeleteSelected$: Observable<boolean>;
|
protected canDeleteSelected$: Observable<boolean>;
|
||||||
protected canRestoreSelected$: Observable<boolean>;
|
protected canRestoreSelected$: Observable<boolean>;
|
||||||
protected disableMenu$: 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(
|
this.canDeleteSelected$ = this.selection.changed.pipe(
|
||||||
startWith(null),
|
startWith(null),
|
||||||
switchMap(() => {
|
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(
|
this.canRestoreSelected$ = this.selection.changed.pipe(
|
||||||
startWith(null),
|
startWith(null),
|
||||||
switchMap(() => {
|
switchMap(() => {
|
||||||
@@ -342,9 +356,12 @@ export class VaultItemsComponent<C extends CipherViewLike> {
|
|||||||
|
|
||||||
private refreshItems() {
|
private refreshItems() {
|
||||||
const collections: VaultItem<C>[] = this.collections.map((collection) => ({ collection }));
|
const collections: VaultItem<C>[] = this.collections.map((collection) => ({ collection }));
|
||||||
const ciphers: VaultItem<C>[] = this.ciphers.map((cipher) => ({
|
const ciphers: VaultItem<C>[] = this.ciphers
|
||||||
cipher,
|
.filter(
|
||||||
}));
|
(cipher) =>
|
||||||
|
!this.restrictedItemTypesService.isCipherRestricted(cipher, this.restrictedTypes),
|
||||||
|
)
|
||||||
|
.map((cipher) => ({ cipher }));
|
||||||
const items: VaultItem<C>[] = [].concat(collections).concat(ciphers);
|
const items: VaultItem<C>[] = [].concat(collections).concat(ciphers);
|
||||||
|
|
||||||
// All ciphers are selectable, collections only if they can be edited or deleted
|
// All ciphers are selectable, collections only if they can be edited or deleted
|
||||||
|
|||||||
@@ -139,6 +139,7 @@ export default {
|
|||||||
provide: RestrictedItemTypesService,
|
provide: RestrictedItemTypesService,
|
||||||
useValue: {
|
useValue: {
|
||||||
restricted$: of([]), // No restricted item types for this story
|
restricted$: of([]), // No restricted item types for this story
|
||||||
|
isCipherRestricted: () => false, // No restrictions for this story
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user