From ae08bf4d7a113b1521ed98282845842b929d9a3c Mon Sep 17 00:00:00 2001 From: asmsuechan Date: Fri, 7 Jul 2017 19:31:03 +0900 Subject: [PATCH] Escape from addition a note when the note is in the trashbox --- browser/main/TopBar/index.js | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/browser/main/TopBar/index.js b/browser/main/TopBar/index.js index 66478ecf..5e56bede 100644 --- a/browser/main/TopBar/index.js +++ b/browser/main/TopBar/index.js @@ -9,6 +9,9 @@ import ee from 'browser/main/lib/eventEmitter' import ConfigManager from 'browser/main/lib/ConfigManager' import dataApi from 'browser/main/lib/dataApi' +const { remote } = require('electron') +const { dialog } = remote + const OSX = window.process.platform === 'darwin' class TopBar extends React.Component { @@ -41,7 +44,17 @@ class TopBar extends React.Component { } handleNewPostButtonClick (e) { - let { config } = this.props + let { config, location } = this.props + + if (location.pathname === '/trashed') { + dialog.showMessageBox(remote.getCurrentWindow(), { + type: 'warning', + message: 'Cannot create new note', + detail: 'You cannot create new note in trash box.', + buttons: ['OK'] + }) + return + } switch (config.ui.defaultNote) { case 'MARKDOWN_NOTE':