1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-15 15:53:27 +00:00

[EC-1037] [EC-742] Cleanup vault folder filter logic (#4700)

* [EC-1037] Cleanup vault folder filter logic

- "All vaults" and "My vault" should always show all folders
- Organization vault should only show non-empty folders and the "No folder" folder
- Ensures the "Folders" filter section is always visible

* Update apps/web/src/vault/individual-vault/vault-filter/services/vault-filter.service.ts

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>

* Update libs/angular/src/vault/vault-filter/services/vault-filter.service.ts

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>

---------

Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com>
This commit is contained in:
Shane Melton
2023-02-15 12:55:25 -08:00
committed by GitHub
parent 36633bcb04
commit 99e0ead5fd
2 changed files with 13 additions and 10 deletions

View File

@@ -215,15 +215,16 @@ export class VaultFilterService implements VaultFilterServiceAbstraction {
storedFolders: FolderView[],
org?: Organization
): Promise<FolderView[]> {
if (org?.id == null) {
// If no org or "My Vault" is selected, show all folders
if (org?.id == null || org?.id == "MyVault") {
return storedFolders;
}
// Otherwise, show only folders that have ciphers from the selected org and the "no folder" folder
const ciphers = await this.cipherService.getAllDecrypted();
const orgCiphers = ciphers.filter((c) => c.organizationId == org?.id);
return storedFolders.filter(
(f) =>
orgCiphers.filter((oc) => oc.folderId == f.id).length > 0 ||
ciphers.filter((c) => c.folderId == f.id).length < 1
(f) => orgCiphers.some((oc) => oc.folderId == f.id) || f.id == null
);
}