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

68 lines
1.6 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 { hashHistory } from 'react-router'
2017-01-27 16:13:11 +13:00
import FontAwesome from 'react-fontawesome'
2016-10-26 16:55:47 +13:00
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'
import GridItem from './GridItem'
2017-01-27 16:13:11 +13:00
class PlaylistGrid extends React.Component{
2016-10-26 16:55:47 +13:00
2017-10-10 13:05:28 +13:00
constructor(props){
2016-10-26 16:55:47 +13:00
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(){
2017-10-10 13:05:28 +13:00
if (!this.props.playlists ) return null
var className = "grid playlist-grid"
2017-09-03 16:10:32 +12:00
if (this.props.className) className += ' '+this.props.className
if (this.props.single_row) className += ' single-row'
return (
<div className={className}>
{
this.props.playlists.map(playlist => {
return (
<GridItem
key={playlist.uri}
type="playlist"
item={playlist}
show_source_icon={this.props.show_source_icon}
onClick={e => {hashHistory.push(global.baseURL+'playlist/'+encodeURIComponent(playlist.uri))}}
onContextMenu={e => this.handleContextMenu(e,playlist)}
/>
)}
)
}
</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)