2016-10-18 21:57:29 +13:00
|
|
|
|
2019-02-20 16:58:05 +13:00
|
|
|
import React from 'react';
|
|
|
|
|
import { connect } from 'react-redux';
|
2020-03-06 08:28:02 +13:00
|
|
|
import { bindActionCreators } from 'redux';
|
2019-01-09 16:56:35 +13:00
|
|
|
|
2019-02-20 16:58:05 +13:00
|
|
|
import * as uiActions from '../services/ui/actions';
|
2020-03-06 08:28:02 +13:00
|
|
|
import * as mopidyActions from '../services/mopidy/actions';
|
2019-02-20 16:58:05 +13:00
|
|
|
import * as lastfmActions from '../services/lastfm/actions';
|
|
|
|
|
|
|
|
|
|
import GridItem from './GridItem';
|
2017-01-27 13:24:36 +13:00
|
|
|
|
2020-03-03 16:39:37 +13:00
|
|
|
class AlbumGrid extends React.Component {
|
2020-03-06 11:01:33 +13:00
|
|
|
handleContextMenu = (e, item) => {
|
|
|
|
|
const { uiActions: { showContextMenu } } = this.props;
|
2019-09-05 15:36:11 +12:00
|
|
|
e.preventDefault();
|
2020-03-06 11:01:33 +13:00
|
|
|
showContextMenu({
|
2019-09-05 15:36:11 +12:00
|
|
|
e,
|
|
|
|
|
context: 'album',
|
|
|
|
|
uris: [item.uri],
|
|
|
|
|
items: [item],
|
|
|
|
|
tracklist_uri: item.uri,
|
2020-03-06 11:01:33 +13:00
|
|
|
});
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
2017-01-27 13:24:36 +13:00
|
|
|
|
2020-03-06 11:01:33 +13:00
|
|
|
render = () => {
|
|
|
|
|
const {
|
|
|
|
|
albums,
|
|
|
|
|
className,
|
|
|
|
|
mini,
|
|
|
|
|
lastfmActions,
|
|
|
|
|
mopidyActions,
|
|
|
|
|
show_source_icon,
|
|
|
|
|
} = this.props;
|
2017-01-27 13:24:36 +13:00
|
|
|
|
2020-03-06 11:01:33 +13:00
|
|
|
if (!albums) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className={`grid grid--albums ${className} ${mini ? ' grid--mini' : ''}`}>
|
|
|
|
|
{
|
|
|
|
|
albums.map((album) => (
|
|
|
|
|
<GridItem
|
|
|
|
|
key={album.uri}
|
|
|
|
|
type="album"
|
|
|
|
|
item={album}
|
|
|
|
|
lastfmActions={lastfmActions}
|
|
|
|
|
mopidyActions={mopidyActions}
|
|
|
|
|
show_source_icon={show_source_icon}
|
|
|
|
|
onContextMenu={(e) => this.handleContextMenu(e, album)}
|
|
|
|
|
/>
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
2019-09-05 15:36:11 +12:00
|
|
|
}
|
2016-10-18 21:57:29 +13:00
|
|
|
}
|
|
|
|
|
|
2020-03-06 11:01:33 +13:00
|
|
|
const mapStateToProps = (state) => ({
|
2019-09-05 15:36:11 +12:00
|
|
|
artists: state.core.artists,
|
|
|
|
|
});
|
2017-01-27 13:24:36 +13:00
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
const mapDispatchToProps = (dispatch) => ({
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
|
|
|
|
lastfmActions: bindActionCreators(lastfmActions, dispatch),
|
2020-03-06 08:28:02 +13:00
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch),
|
2019-09-05 15:36:11 +12:00
|
|
|
});
|
2017-01-27 13:24:36 +13:00
|
|
|
|
2019-09-05 15:36:11 +12:00
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(AlbumGrid);
|