2016-10-18 21:57:29 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
2017-01-27 13:24:36 +13:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { createStore, bindActionCreators } from 'redux'
|
|
|
|
|
import { hashHistory } from 'react-router'
|
|
|
|
|
import FontAwesome from 'react-fontawesome'
|
2016-10-18 21:57:29 +13:00
|
|
|
|
2017-01-27 13:24:36 +13:00
|
|
|
import Thumbnail from './Thumbnail'
|
|
|
|
|
import ArtistSentence from './ArtistSentence'
|
|
|
|
|
|
2017-03-27 08:29:18 +13:00
|
|
|
import * as helpers from '../helpers'
|
2017-01-27 13:24:36 +13:00
|
|
|
import * as uiActions from '../services/ui/actions'
|
|
|
|
|
|
|
|
|
|
class AlbumGrid extends React.Component{
|
2016-10-18 21:57:29 +13:00
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-27 13:24:36 +13:00
|
|
|
handleClick(e,link){
|
|
|
|
|
if( e.target.tagName.toLowerCase() !== 'a' ){
|
|
|
|
|
hashHistory.push(link)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-29 11:56:58 +13:00
|
|
|
handleContextMenu(e,item){
|
2017-01-27 13:24:36 +13:00
|
|
|
e.preventDefault()
|
2017-01-29 11:56:58 +13:00
|
|
|
var data = {
|
2017-01-29 16:34:17 +13:00
|
|
|
e: e,
|
|
|
|
|
context: 'album',
|
2017-01-29 11:56:58 +13:00
|
|
|
uris: [item.uri],
|
2017-02-28 16:13:27 +13:00
|
|
|
items: [item]
|
2017-01-29 11:56:58 +13:00
|
|
|
}
|
2017-01-29 16:34:17 +13:00
|
|
|
this.props.uiActions.showContextMenu(data)
|
2017-01-27 13:24:36 +13:00
|
|
|
}
|
|
|
|
|
|
2016-10-18 21:57:29 +13:00
|
|
|
render(){
|
2016-10-25 21:36:33 +13:00
|
|
|
if( this.props.albums ){
|
2016-10-26 08:51:28 +13:00
|
|
|
var className = "grid album-grid"
|
|
|
|
|
if( this.props.className ) className += ' '+this.props.className
|
2016-10-18 21:57:29 +13:00
|
|
|
return (
|
2016-10-26 08:51:28 +13:00
|
|
|
<div className={className}>
|
2016-10-18 21:57:29 +13:00
|
|
|
{
|
2016-10-25 21:36:33 +13:00
|
|
|
this.props.albums.map(
|
2016-10-18 21:57:29 +13:00
|
|
|
(album, index) => {
|
2017-01-27 13:24:36 +13:00
|
|
|
return (
|
|
|
|
|
<div className="grid-item"
|
|
|
|
|
key={index}
|
|
|
|
|
onClick={ (e) => this.handleClick(e,global.baseURL+'album/'+album.uri) }
|
2017-01-29 11:56:58 +13:00
|
|
|
onContextMenu={e => this.handleContextMenu(e,album)}>
|
2017-01-27 13:24:36 +13:00
|
|
|
<Thumbnail size="medium" images={album.images} />
|
2017-03-27 08:29:18 +13:00
|
|
|
<div className="name">
|
|
|
|
|
{album.name}
|
|
|
|
|
{this.props.show_source_icon ? <FontAwesome name={helpers.sourceIcon(album.uri)} className="source" fixedWidth /> : null}
|
|
|
|
|
</div>
|
2017-01-27 13:24:36 +13:00
|
|
|
<div className="secondary">
|
2017-03-27 08:29:18 +13:00
|
|
|
{album.artists ? <ArtistSentence artists={album.artists} /> : <span>-</span>}
|
2017-01-27 13:24:36 +13:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
2016-10-18 21:57:29 +13:00
|
|
|
}
|
|
|
|
|
)
|
|
|
|
|
}
|
2016-10-26 08:51:28 +13:00
|
|
|
</div>
|
2016-10-18 21:57:29 +13:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-27 13:24:36 +13:00
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AlbumGrid)
|
|
|
|
|
|