Merge branch 'release/v1.2.1'
This commit is contained in:
commit
bd25d254d3
10
CHANGELOG.md
10
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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": {
|
||||
|
|
|
@ -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) {
|
||||
|
|
16
src/main.js
16
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();
|
||||
|
||||
|
|
61
src/main/allowProtocolDialog.js
Normal file
61
src/main/allowProtocolDialog.js
Normal file
|
@ -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
|
||||
};
|
|
@ -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 = {
|
||||
|
|
|
@ -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": {
|
||||
|
|
Loading…
Reference in a new issue