1
0
mirror of https://github.com/bitwarden/browser.git synced 2025-03-02 03:41:09 +01:00

Add collections to ciphers in export model. ()

* Add collections to ciphers in export model.

This enables immediately setting collections from the CLI on create.
The other location this code is used is on import of Bitwarden json data.
However, collectionId is explicitly nulled out here to be resolved
later at the server level.

* Linter fix
This commit is contained in:
Matt Gibson 2021-04-05 15:21:07 -05:00 committed by GitHub
parent b774c3e785
commit 08a856645b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,7 @@ export class Cipher {
static template(): Cipher {
const req = new Cipher();
req.organizationId = null;
req.collectionIds = null;
req.folderId = null;
req.type = CipherType.Login;
req.name = 'Item name';
@ -34,6 +35,10 @@ export class Cipher {
if (view.organizationId == null) {
view.organizationId = req.organizationId;
}
if (view.collectionIds || req.collectionIds) {
const set = new Set((view.collectionIds ?? []).concat(req.collectionIds ?? []));
view.collectionIds = [...set];
}
view.name = req.name;
view.notes = req.notes;
view.favorite = req.favorite;
@ -95,6 +100,7 @@ export class Cipher {
type: CipherType;
folderId: string;
organizationId: string;
collectionIds: string[];
name: string;
notes: string;
favorite: boolean;