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'
|
|
|
|
|
|
2017-04-15 05:43:29 +12:00
|
|
|
class AuthorizationModal_Send extends React.Component{
|
2016-12-12 09:07:47 +13:00
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-21 08:58:49 +13:00
|
|
|
handleClick(e, connection_id){
|
2016-12-12 09:07:47 +13:00
|
|
|
e.preventDefault()
|
2017-02-21 08:58:49 +13:00
|
|
|
this.props.pusherActions.sendAuthorization( connection_id, this.props.authorization, this.props.me )
|
2016-12-12 09:07:47 +13:00
|
|
|
this.props.uiActions.closeModal()
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
2017-02-21 08:58:49 +13:00
|
|
|
var connections = []
|
|
|
|
|
for (var connection_id in this.props.connections){
|
|
|
|
|
if (this.props.connections.hasOwnProperty(connection_id)) {
|
|
|
|
|
connections.push(this.props.connections[connection_id])
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-12-12 09:07:47 +13:00
|
|
|
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>
|
2017-01-31 08:44:12 +13:00
|
|
|
<div className="list small pusher-connection-list">
|
2016-12-12 09:07:47 +13:00
|
|
|
{
|
2017-02-21 08:58:49 +13:00
|
|
|
connections.map( (connection, index) => {
|
2017-01-04 15:24:13 +13:00
|
|
|
|
|
|
|
|
// don't list OUR connection
|
2017-02-21 08:58:49 +13:00
|
|
|
if (connection.connection_id == this.props.connection_id) return null
|
2017-01-04 15:24:13 +13:00
|
|
|
|
2016-12-12 09:07:47 +13:00
|
|
|
return (
|
2017-02-21 08:58:49 +13:00
|
|
|
<div className='list-item connection' key={connection.connection_id} onClick={ e => this.handleClick(e, connection.connection_id) }>
|
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-02-21 08:58:49 +13:00
|
|
|
connection_id: state.pusher.connection_id,
|
2016-12-12 09:07:47 +13:00
|
|
|
connections: state.pusher.connections
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-15 05:43:29 +12:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AuthorizationModal_Send)
|