TextEditorToolbarContainer.js
1 import React, {Component} from 'react'; 2 import {connect} from 'react-redux'; 3 import PropTypes from 'prop-types'; 4 import TextEditorToolbar from '../components/TextEditorToolbar'; 5 6 import { 7 saveFile as saveFileAction, 8 removeFile as removeFileAction 9 } from '../actions'; 10 11 class TextEditorToolbarContainer extends Component { 12 save() { 13 this.props.saveFile(this.props.currentFile); 14 } 15 16 remove() { 17 this.props.removeFile(this.props.currentFile); 18 } 19 20 render() { 21 return <TextEditorToolbar isContract={this.props.isContract} 22 toggleShowHiddenFiles={this.props.toggleShowHiddenFiles} 23 openAsideTab={this.props.openAsideTab} 24 save={() => this.save()} 25 remove={() => this.remove()} 26 activeTab={this.props.activeTab} />; 27 } 28 } 29 30 TextEditorToolbarContainer.propTypes = { 31 currentFile: PropTypes.object, 32 isContract: PropTypes.bool, 33 saveFile: PropTypes.func, 34 removeFile: PropTypes.func, 35 toggleShowHiddenFiles: PropTypes.func, 36 openAsideTab: PropTypes.func, 37 activeTab: PropTypes.string 38 }; 39 40 export default connect( 41 null, 42 { 43 saveFile: saveFileAction.request, 44 removeFile: removeFileAction.request 45 }, 46 )(TextEditorToolbarContainer);