From 30272b0c0c7c7055e1d5ec0a659eb1d9d773982a Mon Sep 17 00:00:00 2001 From: Gregory Schier Date: Wed, 17 Aug 2016 13:58:44 -0700 Subject: [PATCH] Fixed settings tab reset and removed about menu for windows --- app/app.js | 39 ++++++++++--------- app/components/modals/SettingsModal.js | 52 ++++++++++++++++++-------- 2 files changed, 58 insertions(+), 33 deletions(-) diff --git a/app/app.js b/app/app.js index aa13bf7de..808284194 100644 --- a/app/app.js +++ b/app/app.js @@ -176,22 +176,27 @@ app.on('ready', () => { mainWindow = null; }); - var template = [{ - label: "Application", - role: "window", - submenu: [{ - label: "About Application", - selector: "orderFrontStandardAboutPanel:" - }, { - type: "separator" - }, { - label: "Quit", - accelerator: "Command+Q", - click: function() { - app.quit(); - } - }] - }, { + var template = []; + if (IS_MAC) { + template.push({ + label: "Application", + role: "window", + submenu: [{ + label: "About Application", + selector: "orderFrontStandardAboutPanel:" + }, { + type: "separator" + }, { + label: "Quit", + accelerator: "Command+Q", + click: function() { + app.quit(); + } + }] + }) + } + + template = template.concat([{ label: "Edit", submenu: [{ label: "Undo", @@ -273,7 +278,7 @@ app.on('ready', () => { electron.shell.openExternal('http://insomnia.rest'); } }] - }]; + }]); if (IS_DEV) { template.push({ diff --git a/app/components/modals/SettingsModal.js b/app/components/modals/SettingsModal.js index 228fee98c..491238cb7 100644 --- a/app/components/modals/SettingsModal.js +++ b/app/components/modals/SettingsModal.js @@ -18,12 +18,22 @@ import {getAppName, getAppLongName} from '../../lib/appInfo'; class SettingsTabs extends Component { + constructor (props) { + super(props); + this._currentTabIndex = -1; + this._currentVersion = null; + } + _importFile () { const workspace = this._getActiveWorkspace(this.props); this.props.actions.global.importFile(workspace); this.props.hide(); } + _handleTabSelect (selectedIndex) { + this._currentTabIndex = selectedIndex; + } + _exportAll () { this.props.actions.global.exportFile(); this.props.hide(); @@ -46,26 +56,33 @@ class SettingsTabs extends Component { return workspace; } + componentWillReceiveProps ({selectedIndex, version}) { + if (this._currentVersion !== version) { + this._currentTabIndex = selectedIndex; + this._currentVersion = version; + } + } + render () { - const {entities, selectedIndex} = this.props; + const {entities} = this.props; const settings = entities.settings[Object.keys(entities.settings)[0]]; return ( - = 0 ? selectedIndex : 0}> + this._handleTabSelect(i)} selectedIndex={this._currentTabIndex}> - + - + - + - + - + @@ -248,7 +265,8 @@ SettingsTabs.propTypes = { }), // Optional - selectedIndex: PropTypes.number + selectedIndex: PropTypes.number, + version: PropTypes.number }; function mapStateToProps (state) { @@ -280,16 +298,14 @@ class SettingsModal extends Component { constructor (props) { super(props); this.state = { - selectedIndex: 0 + version: 0, + selectedIndex: -1 } } _setIndex (selectedIndex) { - if (selectedIndex >= 0) { - this.setState({selectedIndex}); - } else { - this.setState({selectedIndex: 0}); - } + const version = this.state.version + 1; + this.setState({selectedIndex, version}); } show (selectedIndex = 0) { @@ -303,7 +319,7 @@ class SettingsModal extends Component { } render () { - const {selectedIndex} = this.state; + const {selectedIndex, version} = this.state; return ( this.modal = m} tall={true} {...this.props}> @@ -313,7 +329,11 @@ class SettingsModal extends Component { v{getAppVersion()} - this.modal.hide()} selectedIndex={selectedIndex}/> + this.modal.hide()} + selectedIndex={selectedIndex} + />