From 41a0cfd0a2d88ce07212a1f0d582d2df488d0a89 Mon Sep 17 00:00:00 2001 From: Chad Scharf <3904944+cscharf@users.noreply.github.com> Date: Wed, 8 Apr 2020 16:48:30 -0400 Subject: [PATCH] [Soft Delete] - Added trash and related functionality to web vault --- jslib | 2 +- src/app/app.module.ts | 3 + .../organizations/vault/add-edit.component.ts | 3 +- .../organizations/vault/ciphers.component.ts | 22 ++-- .../organizations/vault/vault.component.html | 10 +- .../organizations/vault/vault.component.ts | 39 +++++- src/app/services/event.service.ts | 6 + src/app/tools/cipher-report.component.ts | 4 + src/app/vault/add-edit.component.html | 123 ++++++++++-------- src/app/vault/bulk-delete.component.html | 6 +- src/app/vault/bulk-delete.component.ts | 7 +- src/app/vault/bulk-restore.component.html | 25 ++++ src/app/vault/bulk-restore.component.ts | 34 +++++ src/app/vault/ciphers.component.html | 20 ++- src/app/vault/ciphers.component.ts | 35 ++++- src/app/vault/groupings.component.html | 5 + src/app/vault/vault.component.html | 18 ++- src/app/vault/vault.component.ts | 52 +++++++- src/locales/en/messages.json | 82 ++++++++++++ 19 files changed, 397 insertions(+), 99 deletions(-) create mode 100644 src/app/vault/bulk-restore.component.html create mode 100644 src/app/vault/bulk-restore.component.ts diff --git a/jslib b/jslib index 72e3893f8e..3a10c1ff30 160000 --- a/jslib +++ b/jslib @@ -1 +1 @@ -Subproject commit 72e3893f8eee79f1e3678839aa194f1096c343ea +Subproject commit 3a10c1ff3027832953094b2f7edddb2361119b09 diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 7f3a0ed6df..1624fa7d84 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -145,6 +145,7 @@ import { AddEditComponent } from './vault/add-edit.component'; import { AttachmentsComponent } from './vault/attachments.component'; import { BulkDeleteComponent } from './vault/bulk-delete.component'; import { BulkMoveComponent } from './vault/bulk-move.component'; +import { BulkRestoreComponent } from './vault/bulk-restore.component'; import { BulkShareComponent } from './vault/bulk-share.component'; import { CiphersComponent } from './vault/ciphers.component'; import { CollectionsComponent } from './vault/collections.component'; @@ -257,6 +258,7 @@ registerLocaleData(localeZhTw, 'zh-TW'); BreachReportComponent, BulkDeleteComponent, BulkMoveComponent, + BulkRestoreComponent, BulkShareComponent, CalloutComponent, ChangeEmailComponent, @@ -375,6 +377,7 @@ registerLocaleData(localeZhTw, 'zh-TW'); AttachmentsComponent, BulkDeleteComponent, BulkMoveComponent, + BulkRestoreComponent, BulkShareComponent, CollectionsComponent, DeauthorizeSessionsComponent, diff --git a/src/app/organizations/vault/add-edit.component.ts b/src/app/organizations/vault/add-edit.component.ts index fe2c3c2c71..e19fd17629 100644 --- a/src/app/organizations/vault/add-edit.component.ts +++ b/src/app/organizations/vault/add-edit.component.ts @@ -94,6 +94,7 @@ export class AddEditComponent extends BaseAddEditComponent { if (!this.organization.isAdmin) { return super.deleteCipher(); } - return this.apiService.deleteCipherAdmin(this.cipherId); + return this.cipher.isDeleted ? this.apiService.deleteCipherAdmin(this.cipherId) + : this.apiService.putDeleteCipherAdmin(this.cipherId); } } diff --git a/src/app/organizations/vault/ciphers.component.ts b/src/app/organizations/vault/ciphers.component.ts index 63a3f9a7cf..ea990cd75a 100644 --- a/src/app/organizations/vault/ciphers.component.ts +++ b/src/app/organizations/vault/ciphers.component.ts @@ -41,7 +41,7 @@ export class CiphersComponent extends BaseCiphersComponent { async load(filter: (cipher: CipherView) => boolean = null) { if (!this.organization.isAdmin) { - await super.load(filter); + await super.load(filter, this.deleted); return; } this.accessEvents = this.organization.useEvents; @@ -65,13 +65,19 @@ export class CiphersComponent extends BaseCiphersComponent { } this.searchPending = false; let filteredCiphers = this.allCiphers; - if (this.filter != null) { - filteredCiphers = filteredCiphers.filter(this.filter); - } + if (this.searchText == null || this.searchText.trim().length < 2) { - this.ciphers = filteredCiphers; + this.ciphers = filteredCiphers.filter((c) => { + if (c.isDeleted !== this.deleted) { + return false; + } + return this.filter == null || this.filter(c); + }); } else { - this.ciphers = this.searchService.searchCiphersBasic(filteredCiphers, this.searchText); + if (this.filter != null) { + filteredCiphers = filteredCiphers.filter(this.filter); + } + this.ciphers = this.searchService.searchCiphersBasic(filteredCiphers, this.searchText, this.deleted); } await this.resetPaging(); } @@ -86,9 +92,9 @@ export class CiphersComponent extends BaseCiphersComponent { protected deleteCipher(id: string) { if (!this.organization.isAdmin) { - return super.deleteCipher(id); + return super.deleteCipher(id, this.deleted); } - return this.apiService.deleteCipherAdmin(id); + return this.deleted ? this.apiService.deleteCipherAdmin(id) : this.apiService.putDeleteCipherAdmin(id); } protected showFixOldAttachments(c: CipherView) { diff --git a/src/app/organizations/vault/vault.component.html b/src/app/organizations/vault/vault.component.html index 361f0a3efa..3f836dee51 100644 --- a/src/app/organizations/vault/vault.component.html +++ b/src/app/organizations/vault/vault.component.html @@ -1,9 +1,10 @@