import React from 'react'; import LoadingIndicatorDots from '../icons/LoadingIndicatorDots'; import ModalActions from './ModalActions'; import SettingsStore from '../../stores/SettingsStore'; const METHODS_TO_BIND = ['handleStartTorrentsToggle']; export default class AddTorrents extends React.Component { constructor() { super(); this.state = { startTorrentsOnLoad: true }; METHODS_TO_BIND.forEach((method) => { this[method] = this[method].bind(this); }); } componentWillMount() { let startTorrentsOnLoad = SettingsStore.getSettings('startTorrentsOnLoad'); if (startTorrentsOnLoad !== true) { this.setState({startTorrentsOnLoad: false}); } } getActions() { let icon = null; let primaryButtonText = 'Add Torrent'; if (this.props.isAddingTorrents) { icon = ; primaryButtonText = 'Adding...'; } return [ { checked: this.state.startTorrentsOnLoad, clickHandler: this.handleStartTorrentsToggle, content: 'Start Torrent', triggerDismiss: false, type: 'checkbox' }, { clickHandler: null, content: 'Cancel', triggerDismiss: true, type: 'secondary' }, { clickHandler: this.props.onAddTorrentsClick, content: ( {icon} {primaryButtonText} ), supplementalClassName: icon != null ? 'has-icon' : '', triggerDismiss: false, type: 'primary' } ]; } handleStartTorrentsToggle(value) { SettingsStore.saveSettings({id: 'startTorrentsOnLoad', data: value}); if (!!this.props.onStartTorrentsToggle) { this.props.onStartTorrentsToggle(value); } } render() { return ( ); } }