From ef7d60687b12159c0f08b1681b45419db1cd0605 Mon Sep 17 00:00:00 2001 From: Ryan Huffman Date: Fri, 8 Jan 2016 14:54:48 -0800 Subject: [PATCH] Add prompt dialog before shutting down --- console/src/main.js | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/console/src/main.js b/console/src/main.js index e9463def83..9cf43dc758 100644 --- a/console/src/main.js +++ b/console/src/main.js @@ -4,7 +4,7 @@ var electron = require('electron'); var app = electron.app; // Module to control application life. var BrowserWindow = electron.BrowserWindow; - +var dialog = electron.dialog; var Menu = require('menu'); var Tray = require('tray'); var shell = require('shell'); @@ -44,19 +44,26 @@ const osType = os.type(); var isShuttingDown = false; function shutdown() { if (!isShuttingDown) { - isShuttingDown = true; - logWindow.close(); - homeServer.stop(); - - var timeoutID = setTimeout(app.quit, 5000); - homeServer.on('state-update', function(processGroup) { - if (processGroup.state == ProcessGroupStates.STOPPED) { - clearTimeout(timeoutID); - app.quit(); - } + var idx = dialog.showMessageBox({ + type: 'question', + buttons: ['Yes', 'No'], + message: 'Are you sure you want to quit?' }); + if (idx == 0) { + isShuttingDown = true; + logWindow.close(); + homeServer.stop(); - updateTrayMenu(null); + var timeoutID = setTimeout(app.quit, 5000); + homeServer.on('state-update', function(processGroup) { + if (processGroup.state == ProcessGroupStates.STOPPED) { + clearTimeout(timeoutID); + app.quit(); + } + }); + + updateTrayMenu(null); + } } }