2016-12-12 09:07:47 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { Link } from 'react-router'
|
|
|
|
|
import { createStore, bindActionCreators } from 'redux'
|
|
|
|
|
|
|
|
|
|
import * as uiActions from '../../services/ui/actions'
|
|
|
|
|
import * as helpers from '../../helpers'
|
|
|
|
|
|
|
|
|
|
import Icon from '../Icon'
|
|
|
|
|
|
|
|
|
|
class SendAuthorizationModal extends React.Component{
|
|
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleClick(e, connectionid){
|
|
|
|
|
e.preventDefault()
|
2017-01-09 09:29:56 +13:00
|
|
|
this.props.pusherActions.sendAuthorization( connectionid, this.props.authorization, this.props.me )
|
2016-12-12 09:07:47 +13:00
|
|
|
this.props.uiActions.closeModal()
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
2016-12-12 16:16:17 +13:00
|
|
|
<h4 className="no-bottom-padding">Share Spotify authentication</h4>
|
2017-01-04 15:30:51 +13:00
|
|
|
<h3 className="grey-text">Send your authentication tokens to another client. When the recipient client imports this, their Iris will have full access to your Spotify account ({this.props.me.id}).</h3>
|
2016-12-12 09:07:47 +13:00
|
|
|
<div className="list pusher-connection-list">
|
|
|
|
|
{
|
|
|
|
|
this.props.connections.map( (connection, index) => {
|
2017-01-04 15:24:13 +13:00
|
|
|
|
|
|
|
|
// don't list OUR connection
|
|
|
|
|
if (connection.connectionid == this.props.connectionid) return null
|
|
|
|
|
|
2016-12-12 09:07:47 +13:00
|
|
|
return (
|
2017-01-30 16:59:37 +13:00
|
|
|
<div className='list-item small connection' key={connection.connectionid} onClick={ e => this.handleClick(e, connection.connectionid) }>
|
2016-12-12 09:07:47 +13:00
|
|
|
{ connection.username }
|
|
|
|
|
|
|
|
|
|
<span className="grey-text">({ connection.ip })</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return {
|
|
|
|
|
me: state.spotify.me,
|
|
|
|
|
authorization: state.spotify.authorization,
|
2017-01-04 15:24:13 +13:00
|
|
|
connectionid: state.pusher.connectionid,
|
2016-12-12 09:07:47 +13:00
|
|
|
connections: state.pusher.connections
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(SendAuthorizationModal)
|