2016-10-18 21:57:29 +13:00
|
|
|
|
2019-02-10 19:51:33 +13:00
|
|
|
import React from 'react'
|
2017-01-27 13:24:36 +13:00
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { createStore, bindActionCreators } from 'redux'
|
2019-01-09 16:56:35 +13:00
|
|
|
|
2019-01-14 08:47:35 +13:00
|
|
|
import history from './history';
|
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'
|
2017-08-09 08:52:49 +12:00
|
|
|
import GridItem from './GridItem'
|
2017-01-27 13:24:36 +13:00
|
|
|
|
|
|
|
|
class AlbumGrid extends React.Component{
|
2016-10-18 21:57:29 +13:00
|
|
|
|
2017-10-10 13:05:28 +13:00
|
|
|
constructor(props){
|
2017-08-09 08:52:49 +12:00
|
|
|
super(props)
|
2017-01-27 13:24:36 +13:00
|
|
|
}
|
|
|
|
|
|
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],
|
2018-11-06 09:06:36 +13:00
|
|
|
items: [item],
|
|
|
|
|
tracklist_uri: item.uri
|
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(){
|
2017-10-10 13:05:28 +13:00
|
|
|
if (this.props.albums){
|
2018-12-08 21:16:05 +13:00
|
|
|
var className = "grid grid--albums";
|
|
|
|
|
if (this.props.className) className += ' '+this.props.className;
|
|
|
|
|
if (this.props.single_row) className += ' grid--single-row';
|
|
|
|
|
if (this.props.mini) className += ' grid--mini';
|
2017-09-03 16:10:32 +12:00
|
|
|
|
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
|
|
|
{
|
2018-08-29 21:13:54 +12:00
|
|
|
this.props.albums.map(item => {
|
2018-08-31 16:04:55 +12:00
|
|
|
var album = helpers.collate(item, {artists: this.props.artists});
|
2017-08-09 08:52:49 +12:00
|
|
|
return (
|
|
|
|
|
<GridItem
|
|
|
|
|
key={album.uri}
|
|
|
|
|
type="album"
|
|
|
|
|
item={album}
|
2018-01-02 15:58:55 +13:00
|
|
|
show_source_icon={this.props.show_source_icon}
|
2017-08-09 08:52:49 +12:00
|
|
|
onContextMenu={e => this.handleContextMenu(e,album)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
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) => {
|
2018-08-29 21:13:54 +12:00
|
|
|
return {
|
|
|
|
|
artists: state.core.artists
|
|
|
|
|
}
|
2017-01-27 13:24:36 +13:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AlbumGrid)
|
|
|
|
|
|