import React, { PropTypes } from 'react'; import { connect } from 'react-redux'; import { bindActionCreators } from 'redux'; import { Link } from 'react-router'; import ReactGA from 'react-ga'; import Modal from './Modal'; import Icon from '../../components/Icon'; import SpotifyAuthenticationFrame from '../../components/Fields/SpotifyAuthenticationFrame'; import LastfmAuthenticationFrame from '../../components/Fields/LastfmAuthenticationFrame'; import * as coreActions from '../../services/core/actions'; import * as uiActions from '../../services/ui/actions'; import * as helpers from '../../helpers'; class InitialSetup extends React.Component{ constructor(props){ super(props); this.state = { username: 'Anonymous', allow_reporting: this.props.allow_reporting, host: this.props.host, port: this.props.port, ssl: this.props.ssl } } componentDidMount(){ this.props.uiActions.setWindowTitle("Welcome to Iris"); } handleSubmit(e){ e.preventDefault(); var self = this; // Force local username change, even if remote connection absent/failed this.props.pusherActions.setUsername(this.state.username, true); this.props.uiActions.set({ initial_setup_complete: true, allow_reporting: this.state.allow_reporting }); this.props.mopidyActions.set({ host: this.state.host, port: this.state.port, ssl: this.state.ssl }); this.setState({saving: true}); // Wait a second to allow changes to apply to store setTimeout(function(){ // We've changed a connection setting, so need to reload if (self.state.host !== self.props.host || self.state.port !== self.props.port || self.state.ssl !== self.props.ssl){ window.location.reload(true); // Safe to just close modal } else { self.props.uiActions.closeModal(); } }, 1000); return false; } render(){ return (

Get started

this.handleSubmit(e)}>
Username
this.setState({username: e.target.value.replace(/\W/g, '')})} value={this.state.username } />
A non-unique string used to identify this client (no special characters)
Host
this.setState({host: e.target.value})} value={ this.state.host } />
Port
this.setState({port: e.target.value})} value={ this.state.port } />
{helpers.isHosted() ? null :

This anonymous usage data is important in identifying errors and potential features that make Iris better for everyone. Want to know more? Read the privacy policy{!this.state.allow_reporting ? Are you sure you don't want to support this? : null}.

}
) } } const mapStateToProps = (state, ownProps) => { return { allow_reporting: state.core.allow_reporting, host: state.mopidy.host, port: state.mopidy.port, ssl: state.mopidy.ssl } } const mapDispatchToProps = (dispatch) => { return { coreActions: bindActionCreators(coreActions, dispatch), uiActions: bindActionCreators(uiActions, dispatch) } } export default connect(mapStateToProps, mapDispatchToProps)(InitialSetup)