2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
2016-11-21 07:59:52 +13:00
|
|
|
import FontAwesome from 'react-fontawesome'
|
2016-11-14 17:32:36 +13:00
|
|
|
import Icon from '../Icon'
|
|
|
|
|
import * as helpers from '../../helpers'
|
|
|
|
|
|
2016-11-19 13:06:08 +13:00
|
|
|
export default class AddToPlaylistModal extends React.Component{
|
2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
playlistSelected( playlist_uri ){
|
2016-11-19 13:06:08 +13:00
|
|
|
this.props.uiActions.addTracksToPlaylist( playlist_uri, this.props.tracks_uris )
|
2016-11-14 17:32:36 +13:00
|
|
|
this.props.uiActions.closeModal()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
if( !this.props.playlists ) return <div className="empty">No editable playlists</div>
|
|
|
|
|
var playlists = []
|
|
|
|
|
for( var i = 0; i < this.props.playlists.length; i++ ){
|
|
|
|
|
if( this.props.playlists[i].can_edit ) playlists.push( this.props.playlists[i] )
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
2016-11-21 07:59:52 +13:00
|
|
|
<div>
|
|
|
|
|
<h4>Add to playlist</h4>
|
2016-12-12 09:07:47 +13:00
|
|
|
<div className="list playlists">
|
2016-11-21 07:59:52 +13:00
|
|
|
{
|
|
|
|
|
playlists.map( playlist => {
|
|
|
|
|
return (
|
2016-12-12 09:07:47 +13:00
|
|
|
<div className="list-item playlist" key={playlist.uri} onClick={ () => this.playlistSelected(playlist.uri) }>
|
2016-11-21 07:59:52 +13:00
|
|
|
<FontAwesome className="source" name={helpers.sourceIcon(playlist.uri)} />
|
|
|
|
|
|
|
|
|
|
<span className="name">{ playlist.name }</span>
|
|
|
|
|
{ playlist.tracks ? <span className="grey-text"> { playlist.tracks.total } tracks</span> : null }
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</div>
|
2016-11-14 17:32:36 +13:00
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|