From c2eafba442d04a612926c2828824eee1f749c5f5 Mon Sep 17 00:00:00 2001
From: Chad Scharf <3904944+cscharf@users.noreply.github.com>
Date: Mon, 13 Apr 2020 15:13:10 -0400
Subject: [PATCH] [Soft Delete] - Added trash to desktop app
---
jslib | 2 +-
src/app/vault/ciphers.component.html | 4 +--
src/app/vault/groupings.component.html | 5 +++
src/app/vault/vault.component.html | 5 +--
src/app/vault/vault.component.ts | 50 +++++++++++++++++++-------
src/app/vault/view.component.html | 15 ++++++--
src/locales/en/messages.json | 28 +++++++++++++++
7 files changed, 89 insertions(+), 20 deletions(-)
diff --git a/jslib b/jslib
index 72e3893f..e9db8442 160000
--- a/jslib
+++ b/jslib
@@ -1 +1 @@
-Subproject commit 72e3893f8eee79f1e3678839aa194f1096c343ea
+Subproject commit e9db844285e21525f5152e782063f04e02543553
diff --git a/src/app/vault/ciphers.component.html b/src/app/vault/ciphers.component.html
index 4c97530f..55faedc2 100644
--- a/src/app/vault/ciphers.component.html
+++ b/src/app/vault/ciphers.component.html
@@ -39,8 +39,8 @@
diff --git a/src/app/vault/groupings.component.html b/src/app/vault/groupings.component.html
index 4f47e43c..2104dec5 100644
--- a/src/app/vault/groupings.component.html
+++ b/src/app/vault/groupings.component.html
@@ -13,6 +13,11 @@
{{'favorites' | i18n}}
+
+
+ {{'trash' | i18n}}
+
+
{{'types' | i18n}}
diff --git a/src/app/vault/vault.component.html b/src/app/vault/vault.component.html
index 98ab31d7..93938ac9 100644
--- a/src/app/vault/vault.component.html
+++ b/src/app/vault/vault.component.html
@@ -2,7 +2,7 @@
+ (onCollectionClicked)="filterCollection($event.id)" (onTrashClicked)="filterDeleted()">
+ (onViewCipherPasswordHistory)="viewCipherPasswordHistory($event)" (onRestoredCipher)="restoredCipher($event)"
+ (onDeletedCipher)="deletedCipher($event)">
this.functionWithChangeDetection(() => {
- this.editCipher(cipher);
- }),
- }));
- menu.append(new remote.MenuItem({
- label: this.i18nService.t('clone'),
- click: () => this.functionWithChangeDetection(() => {
- this.cloneCipher(cipher);
- }),
- }));
+ if (!cipher.isDeleted) {
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('edit'),
+ click: () => this.functionWithChangeDetection(() => {
+ this.editCipher(cipher);
+ }),
+ }));
+ menu.append(new remote.MenuItem({
+ label: this.i18nService.t('clone'),
+ click: () => this.functionWithChangeDetection(() => {
+ this.cloneCipher(cipher);
+ }),
+ }));
+ }
switch (cipher.type) {
case CipherType.Login:
@@ -402,6 +408,13 @@ export class VaultComponent implements OnInit, OnDestroy {
await this.ciphersComponent.refresh();
}
+ async restoredCipher(cipher: CipherView) {
+ this.cipherId = null;
+ this.action = null;
+ this.go();
+ await this.ciphersComponent.refresh();
+ }
+
editCipherAttachments(cipher: CipherView) {
if (this.modal != null) {
this.modal.close();
@@ -498,6 +511,15 @@ export class VaultComponent implements OnInit, OnDestroy {
this.go();
}
+ async filterDeleted() {
+ this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchTrash');
+ this.ciphersComponent.deleted = true;
+ await this.ciphersComponent.reload(null, true);
+ this.clearFilters();
+ this.deleted = true;
+ this.go();
+ }
+
async filterCipherType(type: CipherType) {
this.ciphersComponent.searchPlaceholder = this.i18nService.t('searchType');
await this.ciphersComponent.reload((c) => c.type === type);
@@ -630,6 +652,7 @@ export class VaultComponent implements OnInit, OnDestroy {
this.addCollectionIds = null;
this.addType = null;
this.addOrganizationId = null;
+ this.deleted = false;
}
private go(queryParams: any = null) {
@@ -641,6 +664,7 @@ export class VaultComponent implements OnInit, OnDestroy {
type: this.type,
folderId: this.folderId,
collectionId: this.collectionId,
+ deleted: this.deleted ? true : null,
};
}
diff --git a/src/app/vault/view.component.html b/src/app/vault/view.component.html
index b197353a..8752b096 100644
--- a/src/app/vault/view.component.html
+++ b/src/app/vault/view.component.html
@@ -273,10 +273,21 @@
diff --git a/src/locales/en/messages.json b/src/locales/en/messages.json
index 2fe5e3eb..a932ec9b 100644
--- a/src/locales/en/messages.json
+++ b/src/locales/en/messages.json
@@ -1292,5 +1292,33 @@
"lock": {
"message": "Lock",
"description": "Verb form: to make secure or inaccesible by"
+ },
+ "trash": {
+ "message": "Trash",
+ "description": "Noun: a special folder to hold deleted items"
+ },
+ "searchTrash": {
+ "message": "Search trash"
+ },
+ "permanentlyDeleteItem": {
+ "message": "Permanently Delete Item"
+ },
+ "permanentlyDeleteItemConfirmation": {
+ "message": "Are you sure you want to permanently delete this item?"
+ },
+ "permanentlyDeletedItem": {
+ "message": "Permanently Deleted item"
+ },
+ "restoreItem": {
+ "message": "Restore Item"
+ },
+ "restoreItemConfirmation": {
+ "message": "Are you sure you want to restore this item?"
+ },
+ "restoredItem": {
+ "message": "Restored Item"
+ },
+ "permanentlyDelete": {
+ "message": "Permanently Delete"
}
}