Files
Iris/src/js/components/AlbumGrid.js

75 lines
1.7 KiB
JavaScript
Raw Normal View History

import React from 'react';
import { connect } from 'react-redux';
import { createStore, bindActionCreators } from 'redux';
import * as helpers from '../helpers';
import * as uiActions from '../services/ui/actions';
import * as lastfmActions from '../services/lastfm/actions';
import GridItem from './GridItem';
class AlbumGrid extends React.Component{
2017-10-10 13:05:28 +13:00
constructor(props){
super(props)
}
handleContextMenu(e,item){
e.preventDefault()
var data = {
2017-01-29 16:34:17 +13:00
e: e,
context: 'album',
uris: [item.uri],
items: [item],
tracklist_uri: item.uri
}
2017-01-29 16:34:17 +13:00
this.props.uiActions.showContextMenu(data)
}
render(){
2017-10-10 13:05:28 +13:00
if (this.props.albums){
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
return (
2016-10-26 08:51:28 +13:00
<div className={className}>
{
this.props.albums.map(album => {
return (
<GridItem
key={album.uri}
type="album"
item={album}
lastfmActions={this.props.lastfmActions}
show_source_icon={this.props.show_source_icon}
onContextMenu={e => this.handleContextMenu(e,album)}
/>
)}
)
}
2016-10-26 08:51:28 +13:00
</div>
);
}
return null;
}
}
const mapStateToProps = (state, ownProps) => {
2018-08-29 21:13:54 +12:00
return {
artists: state.core.artists
}
}
const mapDispatchToProps = (dispatch) => {
return {
uiActions: bindActionCreators(uiActions, dispatch),
lastfmActions: bindActionCreators(lastfmActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(AlbumGrid)