import React, {Component, PropTypes} from 'react'; import {Tab, Tabs, TabList, TabPanel} from 'react-tabs'; import {shell} from 'electron'; import Modal from '../base/Modal'; import ModalBody from '../base/ModalBody'; import ModalHeader from '../base/ModalHeader'; import SettingsShortcuts from '../settings/SettingsShortcuts'; import SettingsAbout from '../settings/SettingsAbout'; import SettingsGeneral from '../settings/SettingsGeneral'; import SettingsImportExport from '../settings/SettingsImportExport'; import SettingsSync from '../settings/SettingsSync'; import * as models from '../../../models/index'; import {getAppVersion, getAppName} from '../../../common/constants'; import * as session from '../../../sync/session'; import * as sync from '../../../sync/index'; import {trackEvent} from '../../../analytics/index'; export const TAB_INDEX_EXPORT = 1; class SettingsModal extends Component { constructor (props) { super(props); this._currentTabIndex = -1; this.state = {} } _handleClose = () => { this.hide(); }; show (currentTabIndex = 0) { this.setState({currentTabIndex}); this.modal.show(); } hide () { this.modal.hide(); } toggle (currentTabIndex = 0) { this.setState({currentTabIndex}); this.modal.toggle(); } _handleTabSelect (currentTabIndex) { this.setState({currentTabIndex}); } render () { const { settings, handleExportAllToFile, handleExportWorkspaceToFile, handleImportFile, } = this.props; const {currentTabIndex} = this.state; return ( this.modal = m} tall={true} {...this.props}> {getAppName()} Preferences    v{getAppVersion()} this._handleTabSelect(i)} selectedIndex={currentTabIndex}> { models.settings.update(settings, {[key]: value}); trackEvent('Setting', 'Change', key) }} /> { handleExportAllToFile(); this.modal.hide() }} handleExportWorkspace={() => { handleExportWorkspaceToFile(); this.modal.hide() }} handleImport={() => { handleImportFile(); this.modal.hide() }} /> ); } } SettingsModal.propTypes = { // Functions handleExportWorkspaceToFile: PropTypes.func.isRequired, handleExportAllToFile: PropTypes.func.isRequired, handleImportFile: PropTypes.func.isRequired, // Properties settings: PropTypes.object.isRequired, }; export default SettingsModal;