From f5320197ab7d89b0b3960d530123d938d2cb8b31 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Wed, 1 Feb 2017 23:32:07 +0900 Subject: [PATCH 1/9] Remove options to be deprecated --- src/browser/components/SettingsPage.jsx | 23 +---------------------- test/specs/browser/settings_test.js | 8 ++++---- 2 files changed, 5 insertions(+), 26 deletions(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index 4e5e6bdd..c8143508 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -198,16 +198,6 @@ const SettingsPage = React.createClass({ ); var options = []; - if (process.platform === 'win32' || process.platform === 'linux') { - options.push( - {'Hide menu bar (Press Alt to show menu bar)'}); - } if (process.platform === 'darwin' || process.platform === 'linux') { options.push( {'Start app on login.'}); } - if (process.platform === 'darwin' || process.platform === 'linux') { + if (process.platform === 'linux') { options.push( {this.state.trayWasVisible || !this.state.showTrayIcon ? 'Leave app running in notification area when the window is closed' : 'Leave app running in notification area when the window is closed (available on next restart)'}); } - if (process.platform === 'win32') { - options.push( - {'Toggle window visibility when clicking on the tray icon.'}); - } - if (process.platform === 'darwin' || process.platform === 'win32') { options.push( { - describe('Hide Menu Bar', () => { + describe.skip('Hide Menu Bar', () => { it('should appear on win32 or linux', () => { const expected = (process.platform === 'win32' || process.platform === 'linux'); env.addClientCommands(this.app.client); @@ -152,8 +152,8 @@ describe('browser/settings.html', function desc() { }); describe('Minimize to tray', () => { - it('should appear on darwin or linux', () => { - const expected = (process.platform === 'darwin' || process.platform === 'linux'); + it('should appear on linux', () => { + const expected = (process.platform === 'linux'); env.addClientCommands(this.app.client); return this.app.client. loadSettingsPage(). @@ -161,7 +161,7 @@ describe('browser/settings.html', function desc() { }); }); - describe('Toggle window visibility when clicking on the tray icon', () => { + describe.skip('Toggle window visibility when clicking on the tray icon', () => { it('should appear on win32', () => { const expected = (process.platform === 'win32'); env.addClientCommands(this.app.client); From 77110a7a36f9576afb32e70e0c038a0aab1cdf42 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Thu, 2 Feb 2017 00:04:48 +0900 Subject: [PATCH 2/9] Update the order and messages of app options --- src/browser/components/SettingsPage.jsx | 126 +++++++++++++++--------- 1 file changed, 79 insertions(+), 47 deletions(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index c8143508..8d57df30 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -1,6 +1,6 @@ const React = require('react'); const ReactDOM = require('react-dom'); -const {Button, Checkbox, Col, FormGroup, FormControl, ControlLabel, Grid, Navbar, Row} = require('react-bootstrap'); +const {Button, Checkbox, Col, FormGroup, FormControl, ControlLabel, Grid, HelpBlock, Navbar, Row} = require('react-bootstrap'); const {ipcRenderer, remote} = require('electron'); const AutoLaunch = require('auto-launch'); @@ -99,7 +99,7 @@ const SettingsPage = React.createClass({ }, handleChangeDisableWebSecurity() { this.setState({ - disablewebsecurity: !this.refs.disablewebsecurity.props.checked + disablewebsecurity: this.refs.disablewebsecurity.props.checked }); }, handleChangeHideMenuBar() { @@ -198,6 +198,70 @@ const SettingsPage = React.createClass({ ); var options = []; + + // MacOS has an option in the Dock, to set the app to autostart, so we choose to not support this option for OSX + if (process.platform === 'win32' || process.platform === 'linux') { + options.push( + {'Start app on login'} + + {'Enabling automatically starts the app when you log in to your machine.'} + {' '} + {'The app will initially start minimized and appear on the taskbar.'} + + ); + } + + options.push( + {'Display secure content only'} + + {'Enabling allows only secure (HTTPS/SSL) content.'} + {' '} + {'Disabling allows the app to display non-secure (HTTP) content such as images.'} + + ); + + if (process.platform === 'darwin' || process.platform === 'win32') { + options.push( + {'Show red badge on taskbar icon to indicate unread messages'} + + {'Regardless of this setting, mentions are always indicated with a red badge and item count on the taskbar icon.'} + + ); + } + + if (process.platform === 'win32' || process.platform === 'linux') { + options.push( + {'Flash taskbar icon when a new message is received'} + + {'Taskbar icon flashes for a few seconds when a new message is received.'} + + ); + } + if (process.platform === 'darwin' || process.platform === 'linux') { options.push( {process.platform === 'darwin' ? - 'Show icon on menu bar (need to restart the application)' : - 'Show icon in notification area (need to restart the application)'}); + 'Show Mattermost icon in the menu bar' : + 'Show icon in the notification area'} + + {'Setting takes effect after restarting the app.'} + + ); } if (process.platform === 'linux') { options.push( @@ -226,26 +294,6 @@ const SettingsPage = React.createClass({ ); } - options.push( - {'Allow mixed content (Enabling allows both secure and insecure content, images and scripts to render and execute. Disabling allows only secure content.)'}); - - //OSX has an option in the Dock, to set the app to autostart, so we choose to not support this option for OSX - if (process.platform === 'win32' || process.platform === 'linux') { - options.push( - {'Start app on login.'}); - } if (process.platform === 'linux') { options.push( @@ -256,29 +304,13 @@ const SettingsPage = React.createClass({ disabled={!this.state.showTrayIcon || !this.state.trayWasVisible} checked={this.state.minimizeToTray} onChange={this.handleChangeMinimizeToTray} - >{this.state.trayWasVisible || !this.state.showTrayIcon ? 'Leave app running in notification area when the window is closed' : 'Leave app running in notification area when the window is closed (available on next restart)'}); - } - - if (process.platform === 'darwin' || process.platform === 'win32') { - options.push( - {'Show red badge on taskbar icon to indicate unread messages. Regardless of this setting, mentions are always indicated with a red badge and item count on the taskbar icon.'}); - } - - if (process.platform === 'win32' || process.platform === 'linux') { - options.push( - {'Flash the taskbar icon when a new message is received.'}); + > + {'Leave app running in notification area when application window is closed'} + + {'Enabling will leave the app running in the notification center when app window is closed.'} + {this.state.trayWasVisible || !this.state.showTrayIcon ? '' : ' Setting takes effect after restarting the app.'} + + ); } const settingsPage = { From 648827003692fb16ab7b72afe61a38219d857d33 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Thu, 2 Feb 2017 00:26:04 +0900 Subject: [PATCH 3/9] Update tests for latest options --- test/specs/browser/settings_test.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/specs/browser/settings_test.js b/test/specs/browser/settings_test.js index 6a2ebb55..855999a1 100644 --- a/test/specs/browser/settings_test.js +++ b/test/specs/browser/settings_test.js @@ -89,10 +89,10 @@ describe('browser/settings.html', function desc() { }); }); - describe('Allow mixed content', () => { + describe('Display secure content only', () => { [true, false].forEach((v) => { it(`should be saved and loaded: ${v}`, () => { - const webPreferences = v ? 'allowDisplayingInsecureContent' : ''; + const webPreferences = v ? '' : 'allowDisplayingInsecureContent'; env.addClientCommands(this.app.client); return this.app.client. @@ -107,7 +107,7 @@ describe('browser/settings.html', function desc() { click('#btnSave'). pause(1000).then(() => { const savedConfig = JSON.parse(fs.readFileSync(env.configFilePath, 'utf8')); - savedConfig.disablewebsecurity.should.equal(v); + savedConfig.disablewebsecurity.should.equal(!v); }). getAttribute('.mattermostView', 'webpreferences').then((disablewebsecurity) => { // confirm actual behavior // disablewebsecurity is an array of String @@ -141,7 +141,7 @@ describe('browser/settings.html', function desc() { }); }); - describe('Show tray icon', () => { + describe('Show icon in menu bar / notification area', () => { it('should appear on darwin or linux', () => { const expected = (process.platform === 'darwin' || process.platform === 'linux'); env.addClientCommands(this.app.client); @@ -151,7 +151,7 @@ describe('browser/settings.html', function desc() { }); }); - describe('Minimize to tray', () => { + describe('Leave app running in notification area when application window is closed', () => { it('should appear on linux', () => { const expected = (process.platform === 'linux'); env.addClientCommands(this.app.client); @@ -171,7 +171,7 @@ describe('browser/settings.html', function desc() { }); }); - describe('Flash taskbar icon on new messages', () => { + describe('Flash taskbar icon when a new message is received', () => { it('should appear on win32 and linux', () => { const expected = (process.platform === 'win32' || process.platform === 'linux'); env.addClientCommands(this.app.client); @@ -181,7 +181,7 @@ describe('browser/settings.html', function desc() { }); }); - describe('Show red icon for unread', () => { + describe('Show red badge on taskbar icon to indicate unread messages', () => { it('should appear on darwin or win32', () => { const expected = (process.platform === 'darwin' || process.platform === 'win32'); env.addClientCommands(this.app.client); From 59c0da51bbbbb25e741805f1b7b745593e4c6b80 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Thu, 2 Feb 2017 00:55:56 +0900 Subject: [PATCH 4/9] Improve appearance of tray icon theme selection --- src/browser/components/SettingsPage.jsx | 41 ++++++++++++++++--------- 1 file changed, 27 insertions(+), 14 deletions(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index 8d57df30..faaa991d 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -1,6 +1,6 @@ const React = require('react'); const ReactDOM = require('react-dom'); -const {Button, Checkbox, Col, FormGroup, FormControl, ControlLabel, Grid, HelpBlock, Navbar, Row} = require('react-bootstrap'); +const {Button, Checkbox, Col, FormGroup, FormControl, ControlLabel, Grid, HelpBlock, Navbar, Radio, Row} = require('react-bootstrap'); const {ipcRenderer, remote} = require('electron'); const AutoLaunch = require('auto-launch'); @@ -280,19 +280,32 @@ const SettingsPage = React.createClass({ } if (process.platform === 'linux') { options.push( - - {'Icon theme (Need to restart the application)'} - - - - - ); + + {'Icon theme: '} + { + this.setState({trayIconTheme: 'light'}); + }} + >{'Light'} + {' '} + { + this.setState({trayIconTheme: 'dark'}); + }} + >{'Dark'} + + ); } if (process.platform === 'linux') { From faeccdb8a26f752dcec45c34b176956bf51b43d4 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Thu, 2 Feb 2017 01:19:46 +0900 Subject: [PATCH 5/9] Fix eslint error --- src/browser/components/SettingsPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index faaa991d..bd98a055 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -1,6 +1,6 @@ const React = require('react'); const ReactDOM = require('react-dom'); -const {Button, Checkbox, Col, FormGroup, FormControl, ControlLabel, Grid, HelpBlock, Navbar, Radio, Row} = require('react-bootstrap'); +const {Button, Checkbox, Col, FormGroup, Grid, HelpBlock, Navbar, Radio, Row} = require('react-bootstrap'); const {ipcRenderer, remote} = require('electron'); const AutoLaunch = require('auto-launch'); From 62488e62b9817332875534b34b7e04aaf96b39b3 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Fri, 3 Feb 2017 21:15:07 +0900 Subject: [PATCH 6/9] Fix title case --- src/browser/components/SettingsPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index bd98a055..39c1da6a 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -363,7 +363,7 @@ const SettingsPage = React.createClass({ var optionsRow = (options.length > 0) ? ( -

{'App options'}

+

{'App Options'}

{ options.map((opt, i) => ( {opt} From 035800387bf9bae5c61bcf68a845a1d85a167063 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Fri, 10 Feb 2017 21:33:52 +0900 Subject: [PATCH 7/9] Remove deprecated features - Hide menu bar (Windows, Linux) - Toggle window visility when clicking on the tray icon (Windows) - Minimize to tray (Mac) --- src/browser/components/SettingsPage.jsx | 16 ---------------- src/common/settings.js | 2 -- src/main.js | 15 --------------- 3 files changed, 33 deletions(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index 39c1da6a..884be5b3 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -61,13 +61,11 @@ const SettingsPage = React.createClass({ handleSave() { var config = { teams: this.state.teams, - hideMenuBar: this.state.hideMenuBar, showTrayIcon: this.state.showTrayIcon, trayIconTheme: this.state.trayIconTheme, disablewebsecurity: this.state.disablewebsecurity, version: settings.version, minimizeToTray: this.state.minimizeToTray, - toggleWindowOnTrayIconClick: this.state.toggleWindowOnTrayIconClick, notifications: { flashWindow: this.state.notifications.flashWindow }, @@ -75,10 +73,6 @@ const SettingsPage = React.createClass({ }; settings.writeFileSync(this.props.configFile, config); if (process.platform === 'win32' || process.platform === 'linux') { - var currentWindow = remote.getCurrentWindow(); - currentWindow.setAutoHideMenuBar(config.hideMenuBar); - currentWindow.setMenuBarVisibility(!config.hideMenuBar); - var autostart = this.state.autostart; appLauncher.isEnabled().then((enabled) => { if (enabled && !autostart) { @@ -102,11 +96,6 @@ const SettingsPage = React.createClass({ disablewebsecurity: this.refs.disablewebsecurity.props.checked }); }, - handleChangeHideMenuBar() { - this.setState({ - hideMenuBar: !this.refs.hideMenuBar.props.checked - }); - }, handleChangeShowTrayIcon() { var shouldShowTrayIcon = !this.refs.showTrayIcon.props.checked; this.setState({ @@ -136,11 +125,6 @@ const SettingsPage = React.createClass({ minimizeToTray: shouldMinimizeToTray }); }, - handleChangeToggleWindowOnTrayIconClick() { - this.setState({ - toggleWindowOnTrayIconClick: !this.refs.toggleWindowOnTrayIconClick.props.checked - }); - }, toggleShowTeamForm() { this.setState({ showAddTeamForm: !this.state.showAddTeamForm diff --git a/src/common/settings.js b/src/common/settings.js index 2a921dbb..cde9cc8c 100644 --- a/src/common/settings.js +++ b/src/common/settings.js @@ -16,12 +16,10 @@ function loadDefault(version) { case 1: return { teams: [], - hideMenuBar: false, showTrayIcon: false, trayIconTheme: 'light', disablewebsecurity: true, minimizeToTray: false, - toggleWindowOnTrayIconClick: false, version: 1, notifications: { flashWindow: 0 // 0 = flash never, 1 = only when idle (after 10 seconds), 2 = always diff --git a/src/main.js b/src/main.js index 556f5c07..f74fa7e3 100644 --- a/src/main.js +++ b/src/main.js @@ -254,16 +254,6 @@ app.on('window-all-closed', () => { } }); -// For win32, auto-hide menu bar. -app.on('browser-window-created', (event, window) => { - if (process.platform === 'win32' || process.platform === 'linux') { - if (config.hideMenuBar) { - window.setAutoHideMenuBar(true); - window.setMenuBarVisibility(false); - } - } -}); - // For OSX, show hidden mainWindow when clicking dock icon. app.on('activate', () => { mainWindow.show(); @@ -366,8 +356,6 @@ app.on('ready', () => { if (process.platform === 'darwin') { app.dock.show(); } - } else if ((process.platform === 'win32') && config.toggleWindowOnTrayIconClick) { - mainWindow.minimize(); } else { mainWindow.focus(); } @@ -561,9 +549,6 @@ app.on('ready', () => { break; case 'darwin': hideWindow(mainWindow); - if (config.minimizeToTray) { - app.dock.hide(); - } break; default: } From 4d2a95cd32bc5a6131f102b1f2e7482ef6535e1a Mon Sep 17 00:00:00 2001 From: Jason Blais Date: Sun, 12 Feb 2017 17:26:34 -0500 Subject: [PATCH 8/9] Update help text on Settings page --- src/browser/components/SettingsPage.jsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/browser/components/SettingsPage.jsx b/src/browser/components/SettingsPage.jsx index 884be5b3..112d477c 100644 --- a/src/browser/components/SettingsPage.jsx +++ b/src/browser/components/SettingsPage.jsx @@ -194,7 +194,7 @@ const SettingsPage = React.createClass({ onChange={this.handleChangeAutoStart} >{'Start app on login'} - {'Enabling automatically starts the app when you log in to your machine.'} + {'If enabled, the app starts automatically when you log in to your machine.'} {' '} {'The app will initially start minimized and appear on the taskbar.'} @@ -210,9 +210,9 @@ const SettingsPage = React.createClass({ onChange={this.handleChangeDisableWebSecurity} >{'Display secure content only'} - {'Enabling allows only secure (HTTPS/SSL) content.'} + {'If enabled, the app only displays secure (HTTPS/SSL) content.'} {' '} - {'Disabling allows the app to display non-secure (HTTP) content such as images.'} + {'If disabled, the app displays secure and non-secure (HTTP) content such as images.'} ); @@ -241,7 +241,7 @@ const SettingsPage = React.createClass({ onChange={this.handleFlashWindow} >{'Flash taskbar icon when a new message is received'} - {'Taskbar icon flashes for a few seconds when a new message is received.'} + {'If enabled, taskbar icon flashes for a few seconds when a new message is received.'} ); } @@ -304,7 +304,7 @@ const SettingsPage = React.createClass({ > {'Leave app running in notification area when application window is closed'} - {'Enabling will leave the app running in the notification center when app window is closed.'} + {'If enabled, the app stays running in the notification area after app window is closed.'} {this.state.trayWasVisible || !this.state.showTrayIcon ? '' : ' Setting takes effect after restarting the app.'} ); From e1a2175bcd20d42035bf93613fedc99c75e4b767 Mon Sep 17 00:00:00 2001 From: Yuya Ochiai Date: Fri, 17 Feb 2017 00:09:45 +0900 Subject: [PATCH 9/9] Extend clickable area of checkbox --- src/browser/css/settings.css | 4 ++++ src/browser/settings.html | 1 + 2 files changed, 5 insertions(+) create mode 100644 src/browser/css/settings.css diff --git a/src/browser/css/settings.css b/src/browser/css/settings.css new file mode 100644 index 00000000..c3c824b0 --- /dev/null +++ b/src/browser/css/settings.css @@ -0,0 +1,4 @@ + +.checkbox > label { + width: 100%; +} diff --git a/src/browser/settings.html b/src/browser/settings.html index 20e2183f..e8aef706 100644 --- a/src/browser/settings.html +++ b/src/browser/settings.html @@ -6,6 +6,7 @@ Settings +