mirror of
https://github.com/bitwarden/browser.git
synced 2025-02-18 01:41:27 +01: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:
parent
36633bcb04
commit
99e0ead5fd
@ -215,15 +215,16 @@ export class VaultFilterService implements VaultFilterServiceAbstraction {
|
|||||||
storedFolders: FolderView[],
|
storedFolders: FolderView[],
|
||||||
org?: Organization
|
org?: Organization
|
||||||
): Promise<FolderView[]> {
|
): 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;
|
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 ciphers = await this.cipherService.getAllDecrypted();
|
||||||
const orgCiphers = ciphers.filter((c) => c.organizationId == org?.id);
|
const orgCiphers = ciphers.filter((c) => c.organizationId == org?.id);
|
||||||
return storedFolders.filter(
|
return storedFolders.filter(
|
||||||
(f) =>
|
(f) => orgCiphers.some((oc) => oc.folderId == f.id) || f.id == null
|
||||||
orgCiphers.filter((oc) => oc.folderId == f.id).length > 0 ||
|
|
||||||
ciphers.filter((c) => c.folderId == f.id).length < 1
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,17 +55,19 @@ export class VaultFilterService implements DeprecatedVaultFilterServiceAbstracti
|
|||||||
buildNestedFolders(organizationId?: string): Observable<DynamicTreeNode<FolderView>> {
|
buildNestedFolders(organizationId?: string): Observable<DynamicTreeNode<FolderView>> {
|
||||||
const transformation = async (storedFolders: FolderView[]) => {
|
const transformation = async (storedFolders: FolderView[]) => {
|
||||||
let folders: FolderView[];
|
let folders: FolderView[];
|
||||||
if (organizationId != null) {
|
|
||||||
|
// If no org or "My Vault" is selected, show all folders
|
||||||
|
if (organizationId == null || organizationId == "MyVault") {
|
||||||
|
folders = storedFolders;
|
||||||
|
} else {
|
||||||
|
// Otherwise, show only folders that have ciphers from the selected org and the "no folder" folder
|
||||||
const ciphers = await this.cipherService.getAllDecrypted();
|
const ciphers = await this.cipherService.getAllDecrypted();
|
||||||
const orgCiphers = ciphers.filter((c) => c.organizationId == organizationId);
|
const orgCiphers = ciphers.filter((c) => c.organizationId == organizationId);
|
||||||
folders = storedFolders.filter(
|
folders = storedFolders.filter(
|
||||||
(f) =>
|
(f) => orgCiphers.some((oc) => oc.folderId == f.id) || f.id == null
|
||||||
orgCiphers.filter((oc) => oc.folderId == f.id).length > 0 ||
|
|
||||||
ciphers.filter((c) => c.folderId == f.id).length < 1
|
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
folders = storedFolders;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const nestedFolders = await this.getAllFoldersNested(folders);
|
const nestedFolders = await this.getAllFoldersNested(folders);
|
||||||
return new DynamicTreeNode<FolderView>({
|
return new DynamicTreeNode<FolderView>({
|
||||||
fullList: folders,
|
fullList: folders,
|
||||||
|
Loading…
Reference in New Issue
Block a user