1
0
mirror of https://github.com/bitwarden/browser synced 2026-02-18 02:19:18 +00:00

[PM-25685][PM-31077] - Migrate all Folder models (#17077)

* enforce strict types on folders

* fix folder api service

* fix tests

* fix test

* fix type issue

* fix test

* add extra checks for folders. add specs

* fix folder.id checks

* fix id logic

* remove unecessary check

* name name and id optional in folder model

* fix tests

* Update folder and folderview

* fix folder with id export

* fix tests

* fix tests

* more defensive typing

* fix tests

* no need to check for presence

* check for empty name in folder toDomain

* fixes to folder

* initialize id in folder constructor. fix failing tests

* remove optional param to folder constructor

* fix folder

* fix test

* remove remaining checks for null folder id

* fix logic

* pass null for empty folder ids

* make id more explicit

* fix failing test

* fix failing test

* fix "No Folder" filter
This commit is contained in:
Jordan Aasen
2026-02-12 13:52:29 -08:00
committed by GitHub
parent 1be55763a3
commit 2a72d2e74d
27 changed files with 157 additions and 113 deletions

View File

@@ -143,6 +143,17 @@ describe("VaultFilter", () => {
expect(result).toBe(true);
});
it("should return true when filtering on unassigned folder via empty string id", () => {
const filterFunction = createFilterFunction({
selectedFolder: true,
selectedFolderId: "",
});
const result = filterFunction(cipher);
expect(result).toBe(true);
});
});
describe("given an organizational cipher (with organization and collections)", () => {

View File

@@ -63,10 +63,19 @@ export class VaultFilter {
if (this.cipherType != null && cipherPassesFilter) {
cipherPassesFilter = CipherViewLikeUtils.getType(cipher) === this.cipherType;
}
if (this.selectedFolder && this.selectedFolderId == null && cipherPassesFilter) {
cipherPassesFilter = cipher.folderId == null;
if (
this.selectedFolder &&
(this.selectedFolderId == null || this.selectedFolderId === "") &&
cipherPassesFilter
) {
cipherPassesFilter = cipher.folderId == null || cipher.folderId === "";
}
if (this.selectedFolder && this.selectedFolderId != null && cipherPassesFilter) {
if (
this.selectedFolder &&
this.selectedFolderId != null &&
this.selectedFolderId !== "" &&
cipherPassesFilter
) {
cipherPassesFilter = cipher.folderId === this.selectedFolderId;
}
if (this.selectedCollection && this.selectedCollectionId == null && cipherPassesFilter) {

View File

@@ -83,7 +83,7 @@ export class VaultFilterService implements DeprecatedVaultFilterServiceAbstracti
const ciphers = await this.cipherService.getAllDecrypted(userId);
const orgCiphers = ciphers.filter((c) => c.organizationId == organizationId);
folders = storedFolders.filter(
(f) => orgCiphers.some((oc) => oc.folderId == f.id) || f.id == null,
(f) => orgCiphers.some((oc) => oc.folderId == f.id) || !f.id,
);
}