import React, { PropTypes } from 'react' import { connect } from 'react-redux' import { Link, hashHistory } from 'react-router' import { bindActionCreators } from 'redux' import FontAwesome from 'react-fontawesome' import SpotifyAuthenticationFrame from '../components/SpotifyAuthenticationFrame' import ConfirmationButton from '../components/ConfirmationButton' import PusherConnectionList from '../components/PusherConnectionList' import URISchemesList from '../components/URISchemesList' import VersionManager from '../components/VersionManager' import Header from '../components/Header' import Thumbnail from '../components/Thumbnail' import * as uiActions from '../services/ui/actions' import * as pusherActions from '../services/pusher/actions' import * as mopidyActions from '../services/mopidy/actions' import * as spotifyActions from '../services/spotify/actions' class Debug extends React.Component{ constructor(props) { super(props); this.state = { mopidy_call: 'playlists.asList', mopidy_data: '{}', pusher_data: '{}' } } componentDidMount(){ if( this.props.connectionid ){ var data = { action: "broadcast", data: { type: 'browser_notification', title: "Title", body: "Test notification", icon: "http://lorempixel.com/100/100/nature/" } } this.setState({ pusher_data: JSON.stringify(data) }) } } callMopidy(e){ e.preventDefault() this.props.mopidyActions.debug( this.state.mopidy_call, JSON.parse(this.state.mopidy_data) ) } callPusher(e){ e.preventDefault() this.props.pusherActions.debug( JSON.parse(this.state.pusher_data) ) } render(){ var actions = ( ) return (

User interface

Emulation
Debug data

Mopidy

this.callMopidy(e)}>
Call
this.setState({ mopidy_call: e.target.value })} value={ this.state.mopidy_call } />
Data

Pusher

this.callPusher(e)}>
Data

Response

						{ this.props.debug_response ? JSON.stringify(this.props.debug_response, null, 2) : null }
					
); } } /** * Export our component * * We also integrate our global store, using connect() **/ const mapStateToProps = (state, ownProps) => { return { connectionid: state.pusher.connectionid, emulate_touch: state.ui.emulate_touch, log_actions: state.ui.log_actions, debug_info: state.ui.debug_info, debug_response: state.ui.debug_response } } const mapDispatchToProps = (dispatch) => { return { uiActions: bindActionCreators(uiActions, dispatch), pusherActions: bindActionCreators(pusherActions, dispatch), mopidyActions: bindActionCreators(mopidyActions, dispatch), spotifyActions: bindActionCreators(spotifyActions, dispatch) } } export default connect(mapStateToProps, mapDispatchToProps)(Debug)