import fs from 'fs' import React, {Component, PropTypes} from 'react' import {bindActionCreators} from 'redux' import {connect} from 'react-redux' import Dropdown from '../components/base/Dropdown' import * as RequestGroupActions from '../redux/modules/requestGroups' import * as db from '../database' import importData from '../lib/import' class WorkspaceDropdown extends Component { _importDialog () { const dialog = require('electron').remote.dialog; const options = { properties: ['openFile'], filters: [{ name: 'Insomnia Imports', extensions: ['json'] }] }; dialog.showOpenDialog(options, paths => { paths.map(path => { fs.readFile(path, 'utf8', (err, data) => { err || importData(data); }) }) }); } render () { const {actions, loading, ...other} = this.props; return ( ) } } WorkspaceDropdown.propTypes = { loading: PropTypes.bool.isRequired, actions: PropTypes.shape({ showEnvironmentEditModal: PropTypes.func.isRequired }) }; function mapStateToProps (state) { return { actions: state.actions, loading: state.global.loading }; } function mapDispatchToProps (dispatch) { return { actions: bindActionCreators(RequestGroupActions, dispatch) } } export default connect( mapStateToProps, mapDispatchToProps )(WorkspaceDropdown);