Files
Iris/src/js/components/PlaylistGrid.js

76 lines
1.9 KiB
JavaScript
Raw Normal View History

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'
2017-03-27 08:29:18 +13:00
import * as helpers from '../helpers'
2017-01-27 16:13:11 +13:00
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()
2017-01-29 16:34:17 +13:00
var data = {
e: e,
context: 'playlist',
2017-01-27 16:13:11 +13:00
uris: [item.uri],
items: [item]
2017-01-27 16:13:11 +13:00
}
2017-01-29 16:34:17 +13:00
this.props.uiActions.showContextMenu(data)
2017-01-27 16:13:11 +13:00
}
2016-10-26 16:55:47 +13:00
render(){
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} />
2017-03-27 08:29:18 +13:00
<div className="name">
{playlist.name}
{this.props.show_source_icon ? <FontAwesome name={helpers.sourceIcon(playlist.uri)} className="source" fixedWidth /> : null}
</div>
2017-01-27 16:13:11 +13:00
<div className="secondary">
2017-03-27 08:29:18 +13:00
{playlist.tracks_total ? playlist.tracks_total+' tracks' : <span>0 tracks</span>}
2017-01-27 16:13:11 +13:00
</div>
</Link>
)
}
)
}
</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)