import {connect} from 'react-redux'; import React from 'react'; import Action from '../components/action-bar/Action'; import {addTorrent, startTorrent, stopTorrent} from '../actions/ClientActions'; import {displayModal} from '../actions/UIActions'; import {setTorrentsSort} from '../actions/UIActions'; import SortDropdown from '../components/action-bar/SortDropdown'; import uiSelector from '../selectors/uiSelector'; const methodsToBind = [ 'handleAddTorrents', 'handleSortChange', 'handleStart', 'handleStop' ]; class ActionBar extends React.Component { constructor() { super(); this.state = { selectedTorrents: [] }; methodsToBind.forEach((method) => { this[method] = this[method].bind(this); }); } handleAddTorrents() { this.props.dispatch(displayModal({ modal: 'add-torrents' })); } handleSortChange(sortBy) { this.props.dispatch(setTorrentsSort({ sortBy })); } handleStart() { this.props.dispatch(startTorrent(this.props.torrentList.selected)); } handleStop() { this.props.dispatch(stopTorrent(this.props.torrentList.selected)); } render() { return ( ); } } export default connect(uiSelector)(ActionBar);