From c5026e58fff408a5bdf831d6c32fad39531260ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Budzy=C5=84ski?= Date: Sat, 4 Feb 2017 15:37:31 +0100 Subject: [PATCH] Download Item Removal Confirmation Fixes #2604 Updated test to handle confirm click - rename downloadDeleteConfirmationVisible to deleteConfirmationVisible - wrap spy code with try/finally to ensure proper cleanup - confirmDeleteButton is checked independently from deleteButton Auditors: @michalbe --- app/renderer/components/downloadItem.js | 18 +++++++- app/renderer/components/downloadsBar.js | 1 + docs/appActions.md | 12 ++++++ js/actions/appActions.js | 18 ++++++++ js/components/main.js | 1 + js/constants/appConstants.js | 2 + js/stores/appStore.js | 6 +++ less/downloadBar.less | 29 +++++++++++-- test/unit/app/renderer/downloadItemTest.js | 50 +++++++++++++++++++--- 9 files changed, 126 insertions(+), 11 deletions(-) diff --git a/app/renderer/components/downloadItem.js b/app/renderer/components/downloadItem.js index 9d3e948bca9..0c6f179aebc 100644 --- a/app/renderer/components/downloadItem.js +++ b/app/renderer/components/downloadItem.js @@ -21,6 +21,8 @@ class DownloadItem extends ImmutableComponent { this.onResumeDownload = this.onDownloadActionPerformed.bind(this, RESUME) this.onCancelDownload = this.onDownloadActionPerformed.bind(this, CANCEL) this.onClearDownload = this.onClearDownload.bind(this) + this.onShowDeleteConfirmation = this.onShowDeleteConfirmation.bind(this) + this.onHideDeleteConfirmation = this.onHideDeleteConfirmation.bind(this) this.onDeleteDownload = this.onDeleteDownload.bind(this) this.onRedownload = this.onRedownload.bind(this) this.onCopyLinkToClipboard = this.onCopyLinkToClipboard.bind(this) @@ -34,7 +36,14 @@ class DownloadItem extends ImmutableComponent { onClearDownload () { appActions.downloadCleared(this.props.downloadId) } + onShowDeleteConfirmation () { + appActions.showDownloadDeleteConfirmation() + } + onHideDeleteConfirmation () { + appActions.hideDownloadDeleteConfirmation() + } onDeleteDownload () { + appActions.hideDownloadDeleteConfirmation() appActions.downloadDeleted(this.props.downloadId) } onDownloadActionPerformed (downloadAction) { @@ -74,10 +83,17 @@ class DownloadItem extends ImmutableComponent { return + { + this.props.deleteConfirmationVisible + ?
Delete?
+ : null + }
{ downloadUtil.shouldAllowPause(this.props.download) @@ -111,7 +127,7 @@ class DownloadItem extends ImmutableComponent { } { downloadUtil.shouldAllowDelete(this.props.download) - ?