diff --git a/CHANGELOG.md b/CHANGELOG.md index b7aef4f9..f43fa55d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,16 @@ - Add the option to show the icon on menu bar. (requires libappindicator1 on Ubuntu) +## Release v1.2.1 (Beta) + +### Fixes +- Fixed issue to remove "Electron" from appearing in the title bar on startup. + +### Improvements +- Added a dialog to confirm use of non-http(s) protocols prior to opening links. For example, clicking on a link to `file://test` will open a dialog to confirm the user intended to open a file. +- Added a right-click menu option for tray icon to open the Desktop application on Windows and OS X. + + ## Release v1.2.0 (Beta) - **Released:** 2016-05-17 diff --git a/circle/make_draft.sh b/circle/make_draft.sh index dd0d7373..a9a1fe2f 100755 --- a/circle/make_draft.sh +++ b/circle/make_draft.sh @@ -52,5 +52,5 @@ deploy win64 zip deploy osx tar.gz deploy linux-ia32 tar.gz deploy linux-x64 tar.gz -upload mattermost-desktop-$RELEASE_TAG-i386 release/mattermost-desktop-$RELEASE_TAG-i386.deb -upload mattermost-desktop-$RELEASE_TAG-amd64 release/mattermost-desktop-$RELEASE_TAG-amd64.deb +upload mattermost-desktop-$RELEASE_TAG-linux-i386.deb release/mattermost-desktop-$RELEASE_TAG-i386.deb +upload mattermost-desktop-$RELEASE_TAG-linux-amd64.deb release/mattermost-desktop-$RELEASE_TAG-amd64.deb diff --git a/package.json b/package.json index 75bb231d..c3bd81d1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "mattermost-desktop", "productName": "Mattermost", - "version": "1.2.0", + "version": "1.2.1", "description": "Mattermost Desktop application for Windows, Mac and Linux", "main": "main.js", "author": { diff --git a/src/browser/index.jsx b/src/browser/index.jsx index 6b75658a..6f74cf94 100644 --- a/src/browser/index.jsx +++ b/src/browser/index.jsx @@ -317,6 +317,7 @@ var MattermostView = React.createClass({ var currentURL = url.parse(webview.getURL()); var destURL = url.parse(e.url); if (destURL.protocol !== 'http:' && destURL.protocol !== 'https:') { + ipcRenderer.send('confirm-protocol', destURL.protocol, e.url); return; } if (currentURL.host === destURL.host) { diff --git a/src/main.js b/src/main.js index 0bec6b97..2efb71f0 100644 --- a/src/main.js +++ b/src/main.js @@ -16,6 +16,7 @@ const path = require('path'); var settings = require('./common/settings'); var certificateStore = require('./main/certificateStore').load(path.resolve(app.getPath('userData'), 'certificate.json')); var appMenu = require('./main/menus/app'); +const allowProtocolDialog = require('./main/allowProtocolDialog'); var argv = require('yargs').argv; @@ -164,6 +165,8 @@ app.on('login', function(event, webContents, request, authInfo, callback) { mainWindow.webContents.send('login-request', request, authInfo); }); +allowProtocolDialog.init(mainWindow); + // This method will be called when Electron has finished // initialization and is ready to create browser windows. app.on('ready', function() { @@ -171,11 +174,12 @@ app.on('ready', function() { // set up tray icon trayIcon = new Tray(trayImages.normal); trayIcon.setToolTip(app.getName()); - var tray_menu = require('./main/menus/tray').createDefault(); - trayIcon.setContextMenu(tray_menu); trayIcon.on('click', function() { mainWindow.focus(); }); + trayIcon.on('right-click', () => { + trayIcon.popUpContextMenu(); + }); trayIcon.on('balloon-click', function() { mainWindow.focus(); }); @@ -221,7 +225,7 @@ app.on('ready', function() { // On HiDPI Windows environment, the taskbar icon is pixelated. So this line is necessary. window_options.icon = path.resolve(__dirname, 'resources/appicon.png'); } - window_options.fullScreenable = true; + window_options.title = app.getName(); mainWindow = new BrowserWindow(window_options); mainWindow.setFullScreenable(true); // fullscreenable option has no effect. if (window_options.maximized) { @@ -234,6 +238,12 @@ app.on('ready', function() { // and load the index.html of the app. mainWindow.loadURL('file://' + __dirname + '/browser/index.html'); + // set up context menu for tray icon + if (shouldShowTrayIcon()) { + const tray_menu = require('./main/menus/tray').createDefault(mainWindow); + trayIcon.setContextMenu(tray_menu); + } + // Open the DevTools. // mainWindow.openDevTools(); diff --git a/src/main/allowProtocolDialog.js b/src/main/allowProtocolDialog.js new file mode 100644 index 00000000..24bca268 --- /dev/null +++ b/src/main/allowProtocolDialog.js @@ -0,0 +1,61 @@ +'use strict'; + +const { + app, + dialog, + ipcMain +} = require('electron'); +const path = require('path'); +const fs = require('fs'); + +const allowedProtocolFile = path.resolve(app.getPath('userData'), 'allowedProtocols.json') +var allowedProtocols = []; + +function init(mainWindow) { + fs.readFile(allowedProtocolFile, 'utf-8', (err, data) => { + if (!err) { + allowedProtocols = JSON.parse(data); + } + initDialogEvent(mainWindow); + }); +} + +function initDialogEvent(mainWindow) { + ipcMain.on('confirm-protocol', (event, protocol, URL) => { + if (allowedProtocols.indexOf(protocol) !== -1) { + require('shell').openExternal(URL); + return; + } + dialog.showMessageBox(mainWindow, { + title: 'Non http(s) protocol', + message: `${protocol} link requires an external application.`, + detail: `The requested link is ${URL} . Do you want to continue?`, + type: 'warning', + buttons: [ + 'Yes', + `Yes (Save ${protocol} as allowed)`, + 'No' + ], + cancelId: 2, + noLink: true + }, (response) => { + switch (response) { + case 1: + allowedProtocols.push(protocol); + fs.writeFile(allowedProtocolFile, JSON.stringify(allowedProtocols), (err) => { + if (err) console.error(err); + }); + // fallthrough + case 0: + require('shell').openExternal(URL); + break; + default: + break; + } + }); + }); +} + +module.exports = { + init: init +}; diff --git a/src/main/menus/tray.js b/src/main/menus/tray.js index 58e70e08..a537c408 100644 --- a/src/main/menus/tray.js +++ b/src/main/menus/tray.js @@ -1,18 +1,25 @@ 'use strict'; -const electron = require('electron'); -const Menu = electron.Menu; -const MenuItem = electron.MenuItem; +const { + app, + Menu, + MenuItem +} = require('electron'); -var createDefault = function() { - var menu = new Menu(); - menu.append(new MenuItem({ +function createDefault(mainWindow) { + return Menu.buildFromTemplate([{ + label: `Open ${app.getName()}`, + click: () => { + mainWindow.show(); + } + }, { + type: 'separator' + }, { label: 'Quit', click: function(item) { - require('app').quit(); + app.quit(); } - })); - return menu; + }]); } module.exports = { diff --git a/src/package.json b/src/package.json index c4cfeba4..4121a3b1 100644 --- a/src/package.json +++ b/src/package.json @@ -1,7 +1,7 @@ { "name": "mattermost-desktop", "productName": "Mattermost", - "version": "1.2.0", + "version": "1.2.1", "description": "Mattermost Desktop application for Windows, Mac and Linux", "main": "main.js", "author": {