From 3bba5442bdec1528256944ffef5a6a7907693842 Mon Sep 17 00:00:00 2001 From: Maurits Lourens Date: Thu, 21 Dec 2017 15:57:27 +0100 Subject: [PATCH] show delete confirmation dialog --- browser/main/Detail/MarkdownNoteDetail.js | 10 ++++++++++ browser/main/Detail/SnippetNoteDetail.js | 11 +++++++++++ browser/main/modals/PreferencesModal/UiTab.js | 13 ++++++++++++- 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/browser/main/Detail/MarkdownNoteDetail.js b/browser/main/Detail/MarkdownNoteDetail.js index 6b7b8fd4..a85cc12c 100644 --- a/browser/main/Detail/MarkdownNoteDetail.js +++ b/browser/main/Detail/MarkdownNoteDetail.js @@ -176,6 +176,7 @@ class MarkdownNoteDetail extends React.Component { handleTrashButtonClick (e) { const { note } = this.state const { isTrashed } = note + const { config } = this.props if (isTrashed) { const dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), { @@ -199,6 +200,15 @@ class MarkdownNoteDetail extends React.Component { ee.once('list:moved', dispatchHandler) }) } else { + if (config.ui.confirmDeletion) { + const dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), { + type: 'warning', + message: 'Confirm note deletion', + detail: 'Are you sure you want to move the note to the trash?', + buttons: ['Confirm', 'Cancel'] + }) + if (dialogueButtonIndex === 1) return + } note.isTrashed = true this.setState({ diff --git a/browser/main/Detail/SnippetNoteDetail.js b/browser/main/Detail/SnippetNoteDetail.js index bec6573b..8c5feac6 100644 --- a/browser/main/Detail/SnippetNoteDetail.js +++ b/browser/main/Detail/SnippetNoteDetail.js @@ -175,6 +175,7 @@ class SnippetNoteDetail extends React.Component { handleTrashButtonClick (e) { const { note } = this.state const { isTrashed } = note + const { config } = this.props if (isTrashed) { const dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), { @@ -198,6 +199,16 @@ class SnippetNoteDetail extends React.Component { ee.once('list:moved', dispatchHandler) }) } else { + if (config.ui.confirmDeletion) { + const dialogueButtonIndex = dialog.showMessageBox(remote.getCurrentWindow(), { + type: 'warning', + message: 'Confirm note deletion', + detail: 'Are you sure you want to move the note to the trash?', + buttons: ['Confirm', 'Cancel'] + }) + if (dialogueButtonIndex === 1) return + } + note.isTrashed = true this.setState({ diff --git a/browser/main/modals/PreferencesModal/UiTab.js b/browser/main/modals/PreferencesModal/UiTab.js index 42afd8f4..5ed77199 100644 --- a/browser/main/modals/PreferencesModal/UiTab.js +++ b/browser/main/modals/PreferencesModal/UiTab.js @@ -62,6 +62,7 @@ class UiTab extends React.Component { ui: { theme: this.refs.uiTheme.value, showCopyNotification: this.refs.showCopyNotification.checked, + confirmDeletion: this.refs.confirmDeletion.checked, disableDirectWrite: this.refs.uiD2w != null ? this.refs.uiD2w.checked : false @@ -161,6 +162,16 @@ class UiTab extends React.Component { Show "Saved to Clipboard" notification when copying +
+ +
{ global.process.platform === 'win32' ?
@@ -170,7 +181,7 @@ class UiTab extends React.Component { refs='uiD2w' disabled={OSX} type='checkbox' - /> + />  Disable Direct Write(It will be applied after restarting)