2016-10-26 16:55:47 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
2017-01-27 16:13:11 +13:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { createStore, bindActionCreators } from 'redux'
|
|
|
|
|
import { Link } from 'react-router'
|
|
|
|
|
import FontAwesome from 'react-fontawesome'
|
2016-10-26 16:55:47 +13:00
|
|
|
|
2017-01-27 16:13:11 +13:00
|
|
|
import Thumbnail from './Thumbnail'
|
|
|
|
|
|
|
|
|
|
import * as uiActions from '../services/ui/actions'
|
|
|
|
|
|
|
|
|
|
class PlaylistGrid extends React.Component{
|
2016-10-26 16:55:47 +13:00
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-27 16:13:11 +13:00
|
|
|
handleContextMenu(e,item){
|
|
|
|
|
e.preventDefault()
|
|
|
|
|
var data = {
|
|
|
|
|
uris: [item.uri],
|
|
|
|
|
item: item
|
|
|
|
|
}
|
|
|
|
|
this.props.uiActions.showContextMenu( e, data, 'playlist', 'click' )
|
|
|
|
|
}
|
|
|
|
|
|
2016-10-26 16:55:47 +13:00
|
|
|
render(){
|
2016-11-08 13:36:13 +13:00
|
|
|
if( !this.props.playlists ) return null
|
|
|
|
|
|
|
|
|
|
var className = "grid playlist-grid"
|
|
|
|
|
if( this.props.className ) className += ' '+this.props.className
|
|
|
|
|
return (
|
|
|
|
|
<div className={className}>
|
|
|
|
|
{
|
|
|
|
|
this.props.playlists.map(
|
2017-01-27 16:13:11 +13:00
|
|
|
(playlist, index) => {
|
|
|
|
|
return (
|
|
|
|
|
<Link
|
|
|
|
|
className="grid-item"
|
|
|
|
|
to={global.baseURL+'playlist/'+playlist.uri}
|
|
|
|
|
key={index}
|
|
|
|
|
onContextMenu={e => this.handleContextMenu(e,playlist)}>
|
|
|
|
|
<Thumbnail size="medium" images={playlist.images} />
|
|
|
|
|
<div className="name">{ playlist.name }</div>
|
|
|
|
|
<div className="secondary">
|
|
|
|
|
{ playlist.tracks_total ? playlist.tracks_total+' tracks' : <span>0 tracks</span> }
|
|
|
|
|
{ playlist.can_edit ? <FontAwesome name="edit" /> : null }
|
|
|
|
|
</div>
|
|
|
|
|
</Link>
|
|
|
|
|
)
|
2016-11-08 13:36:13 +13:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2016-10-26 16:55:47 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-27 16:13:11 +13:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(PlaylistGrid)
|
|
|
|
|
|