1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-23 11:56:00 +01:00

[Soft Delete] soft-delete by default

This commit is contained in:
Chad Scharf 2020-04-14 14:32:43 -04:00
parent 49f1fac3ed
commit 5dd9963618
3 changed files with 9 additions and 8 deletions

View File

@ -39,10 +39,10 @@ export class DeleteCommand {
}
try {
if (cmd.trash) {
await this.cipherService.softDeleteWithServer(id);
} else {
if (cmd.permanent) {
await this.cipherService.deleteWithServer(id);
} else {
await this.cipherService.softDeleteWithServer(id);
}
return Response.success();
} catch (e) {

View File

@ -58,6 +58,7 @@ export class ListCommand {
private async listCiphers(cmd: program.Command) {
let ciphers: CipherView[];
cmd.trash = cmd.trash || false;
if (cmd.url != null && cmd.url.trim() !== '') {
ciphers = await this.cipherService.getAllDecryptedForUrl(cmd.url);
} else {
@ -66,7 +67,7 @@ export class ListCommand {
if (cmd.folderid != null || cmd.collectionid != null || cmd.organizationid != null) {
ciphers = ciphers.filter((c) => {
if (cmd.trash && !c.isDeleted) {
if (cmd.trash !== c.isDeleted) {
return false;
}
if (cmd.folderid != null) {
@ -104,11 +105,11 @@ export class ListCommand {
return false;
});
} else if (cmd.search == null || cmd.search.trim() === '') {
ciphers = ciphers.filter((c) => (cmd.trash || false) === c.isDeleted);
ciphers = ciphers.filter((c) => cmd.trash === c.isDeleted);
}
if (cmd.search != null && cmd.search.trim() !== '') {
ciphers = this.searchService.searchCiphersBasic(ciphers, cmd.search, cmd.trash || false);
ciphers = this.searchService.searchCiphersBasic(ciphers, cmd.search, cmd.trash);
}
const res = new ListResponse(ciphers.map((o) => new CipherResponse(o)));

View File

@ -396,7 +396,7 @@ export class Program extends BaseProgram {
.command('delete <object> <id>')
.option('--itemid <itemid>', 'Attachment\'s item id.')
.option('--organizationid <organizationid>', 'Organization id for an organization object.')
.option('-t, --trash', 'Places the item in the trash instead of permanently deleting it (item only).')
.option('-p, --permanent', 'Permanently deletes the item instead of soft-deleting it (item only).')
.description('Delete an object from the vault.')
.on('--help', () => {
writeLn('\n Objects:');
@ -413,7 +413,7 @@ export class Program extends BaseProgram {
writeLn(' Examples:');
writeLn('');
writeLn(' bw delete item 7063feab-4b10-472e-b64c-785e2b870b92');
writeLn(' bw delete item 89c21cd2-fab0-4f69-8c6e-ab8a0168f69a --trash');
writeLn(' bw delete item 89c21cd2-fab0-4f69-8c6e-ab8a0168f69a --permanent');
writeLn(' bw delete folder 5cdfbd80-d99f-409b-915b-f4c5d0241b02');
writeLn(' bw delete attachment b857igwl1dzrs2 --itemid 310d5ffd-e9a2-4451-af87-ea054dce0f78');
writeLn('', true);