diff --git a/apps/desktop/src/vault/app/vault-v3/vault-filter/filters/organization-filter.component.html b/apps/desktop/src/vault/app/vault-v3/vault-filter/filters/organization-filter.component.html index 74ba38ebb8c..5de23af8e4e 100644 --- a/apps/desktop/src/vault/app/vault-v3/vault-filter/filters/organization-filter.component.html +++ b/apps/desktop/src/vault/app/vault-v3/vault-filter/filters/organization-filter.component.html @@ -1,30 +1,13 @@ @if (show()) { @for (organization of organizations().children ?? []; track organization.node.id) { - @if (getOrgCollections(organization.node.id)?.children?.length > 0) { - - @if (!hideCollections() && collections() != null) { - @for (c of getOrgCollections(organization.node.id)?.children ?? []; track c.node.id) { - - } - } - - } @else { - - } + @if (!organization.node.enabled) { >(); protected readonly activeFilter = input(); protected readonly activeOrganizationDataOwnership = input(false); protected readonly activeSingleOrganizationPolicy = input(false); - protected readonly hideCollections = input(false); - protected readonly collections = input>(); protected readonly show = computed(() => { const hiddenDisplayModes: DisplayMode[] = [ @@ -65,36 +61,11 @@ export class OrganizationFilterComponent { return; } + this.vaultFilterService.setOrganizationFilter(organization.node); const filter = this.activeFilter(); if (filter) { filter.selectedOrganizationNode = organization; } } - - private readonly collectionsByOrganization = computed(() => { - const collections = this.collections(); - const map = new Map>(); - const orgs = this.organizations()?.children; - - if (!collections || !orgs) { - return map; - } - - for (const org of orgs) { - const filteredCollections = collections.children.filter( - (node) => node.node.organizationId === org.node.id, - ); - - const headNode = new TreeNode(collections.node, null); - headNode.children = filteredCollections; - map.set(org.node.id, headNode); - } - - return map; - }); - - protected getOrgCollections(organizationId: OrganizationId): TreeNode { - return this.collectionsByOrganization().get(organizationId) ?? null; - } } diff --git a/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.html b/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.html index 3eff45102e8..a782fe6c30e 100644 --- a/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.html +++ b/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.html @@ -5,18 +5,34 @@ } @else { - - - + + + @if (showCollectionsFilter()) { + + @for (collection of (collections$ | async)?.children ?? []; track collection.node.id) { + + } + + } + @for (folder of (folders$ | async)?.children ?? []; track folder.node.id) { diff --git a/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.ts b/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.ts index 96c50b23582..3cb75e26a98 100644 --- a/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.ts +++ b/apps/desktop/src/vault/app/vault-v3/vault-filter/vault-filter.component.ts @@ -1,5 +1,5 @@ import { CommonModule } from "@angular/common"; -import { Component, inject, OnInit, output } from "@angular/core"; +import { Component, inject, OnInit, output, computed, signal } from "@angular/core"; import { firstValueFrom, Observable, Subject, takeUntil } from "rxjs"; import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction"; @@ -11,7 +11,7 @@ import { CipherArchiveService } from "@bitwarden/common/vault/abstractions/ciphe import { FolderService } from "@bitwarden/common/vault/abstractions/folder/folder.service.abstraction"; import { PremiumUpgradePromptService } from "@bitwarden/common/vault/abstractions/premium-upgrade-prompt.service"; import { TreeNode } from "@bitwarden/common/vault/models/domain/tree-node"; -import { NavigationModule, DialogService } from "@bitwarden/components"; +import { NavigationModule, DialogService, A11yTitleDirective } from "@bitwarden/components"; import { I18nPipe } from "@bitwarden/ui-common"; import { OrganizationFilter, @@ -26,6 +26,7 @@ import { import { DesktopRoutedVaultFilterBridgeService } from "../../../../app/services/desktop-routed-vault-filter-bridge.service"; import { DesktopPremiumUpgradePromptService } from "../../../../services/desktop-premium-upgrade-prompt.service"; +import { CollectionFilterComponent } from "./filters/collection-filter.component"; import { FolderFilterComponent } from "./filters/folder-filter.component"; import { OrganizationFilterComponent } from "./filters/organization-filter.component"; import { StatusFilterComponent } from "./filters/status-filter.component"; @@ -43,7 +44,9 @@ import { TypeFilterComponent } from "./filters/type-filter.component"; OrganizationFilterComponent, StatusFilterComponent, TypeFilterComponent, + CollectionFilterComponent, FolderFilterComponent, + A11yTitleDirective, ], providers: [ { @@ -62,7 +65,7 @@ export class VaultFilterComponent implements OnInit { private dialogService: DialogService = inject(DialogService); private componentIsDestroyed$ = new Subject(); - protected activeFilter: VaultFilter; + protected readonly activeFilter = signal(null); protected onFilterChange = output(); private activeUserId: UserId; @@ -75,6 +78,10 @@ export class VaultFilterComponent implements OnInit { protected folders$: Observable>; protected cipherTypes$: Observable>; + protected readonly showCollectionsFilter = computed(() => { + return this.organizations$ != null && !this.activeFilter()?.isMyVaultSelected; + }); + private async setActivePolicies() { this.activeOrganizationDataOwnershipPolicy = await firstValueFrom( this.policyService.policyAppliesToUser$( @@ -108,7 +115,7 @@ export class VaultFilterComponent implements OnInit { this.routedVaultFilterBridgeService.activeFilter$ .pipe(takeUntil(this.componentIsDestroyed$)) .subscribe((filter) => { - this.activeFilter = filter; + this.activeFilter.set(filter); }); this.isLoaded = true;