mirror of
https://github.com/bitwarden/browser
synced 2025-12-15 15:53:27 +00:00
Added capability on psono importer to add sub-folders (#7602)
This commit is contained in:
@@ -350,7 +350,11 @@ export abstract class BaseImporter {
|
||||
}
|
||||
}
|
||||
|
||||
protected processFolder(result: ImportResult, folderName: string) {
|
||||
protected processFolder(
|
||||
result: ImportResult,
|
||||
folderName: string,
|
||||
addRelationship: boolean = true,
|
||||
) {
|
||||
if (this.isNullOrWhitespace(folderName)) {
|
||||
return;
|
||||
}
|
||||
@@ -374,7 +378,10 @@ export abstract class BaseImporter {
|
||||
result.folders.push(f);
|
||||
}
|
||||
|
||||
result.folderRelationships.push([result.ciphers.length, folderIndex]);
|
||||
//Some folders can have sub-folders but no ciphers directly, we should not add to the folderRelationships array
|
||||
if (addRelationship) {
|
||||
result.folderRelationships.push([result.ciphers.length, folderIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
protected convertToNoteIfNeeded(cipher: CipherView) {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||
import { FieldType, SecureNoteType, CipherType } from "@bitwarden/common/vault/enums";
|
||||
import { CipherView } from "@bitwarden/common/vault/models/view/cipher.view";
|
||||
import { SecureNoteView } from "@bitwarden/common/vault/models/view/secure-note.view";
|
||||
@@ -39,17 +40,28 @@ export class PsonoJsonImporter extends BaseImporter implements Importer {
|
||||
return Promise.resolve(result);
|
||||
}
|
||||
|
||||
private parseFolders(result: ImportResult, folders: FoldersEntity[]) {
|
||||
private parseFolders(result: ImportResult, folders: FoldersEntity[], parentName?: string) {
|
||||
if (folders == null || folders.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
folders.forEach((folder) => {
|
||||
if (folder.items == null || folder.items.length == 0) {
|
||||
const folderHasItems = folder.items != null && folder.items.length > 0;
|
||||
const folderHasSubfolders = folder.folders != null && folder.folders.length > 0;
|
||||
|
||||
if (!folderHasItems && !folderHasSubfolders) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.processFolder(result, folder.name);
|
||||
if (!Utils.isNullOrWhitespace(parentName)) {
|
||||
folder.name = parentName + "/" + folder.name;
|
||||
}
|
||||
|
||||
if (folderHasSubfolders) {
|
||||
this.parseFolders(result, folder.folders, folder.name);
|
||||
}
|
||||
|
||||
this.processFolder(result, folder.name, folderHasItems);
|
||||
|
||||
this.handleItemParsing(result, folder.items);
|
||||
});
|
||||
|
||||
@@ -14,7 +14,8 @@ export interface PsonoJsonExport {
|
||||
|
||||
export interface FoldersEntity {
|
||||
name: string;
|
||||
items: PsonoItemTypes[] | null;
|
||||
items?: PsonoItemTypes[] | null;
|
||||
folders?: FoldersEntity[] | null;
|
||||
}
|
||||
|
||||
export interface RecordBase {
|
||||
|
||||
Reference in New Issue
Block a user