Files
Iris/src/js/views/library/LibraryPlaylists.js

72 lines
1.8 KiB
JavaScript
Raw Normal View History

import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
2016-10-17 14:27:48 +13:00
import { Link } from 'react-router'
2016-11-14 11:20:02 +13:00
import FontAwesome from 'react-fontawesome'
2016-11-12 16:36:36 +13:00
import PlaylistGrid from '../../components/PlaylistGrid'
import Header from '../../components/Header'
2016-11-14 11:20:02 +13:00
import * as uiActions from '../../services/ui/actions'
import * as mopidyActions from '../../services/mopidy/actions'
import * as spotifyActions from '../../services/spotify/actions'
class LibraryPlaylists extends React.Component{
constructor(props) {
super(props);
}
render(){
if( !this.props.playlists ) return null
2016-11-02 21:23:35 +13:00
var columns = [
2016-11-12 16:36:36 +13:00
{ name: 'name', width: '30'},
{ name: 'tracks.total', width: '15'},
2016-11-11 23:21:51 +13:00
{ name: 'can_edit', width: '15'},
2016-11-12 16:36:36 +13:00
{ name: 'uri', width: '40'}
2016-11-02 21:23:35 +13:00
]
2016-11-14 17:32:36 +13:00
var actions = (
<button onClick={ () => this.props.uiActions.openModal('create_playlist', {} ) }>
<FontAwesome name="plus" />&nbsp;
New
</button>
)
return (
2016-10-26 16:55:47 +13:00
<div className="view library-playlists-view">
2016-11-14 17:32:36 +13:00
<Header icon="playlist" title="My playlists" actions={actions} />
2016-11-14 11:20:02 +13:00
2016-11-12 16:36:36 +13:00
<section className="grid-wrapper">
<PlaylistGrid playlists={this.props.playlists} />
</section>
</div>
)
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return {
playlists: state.ui.playlists
}
}
2016-11-14 11:20:02 +13:00
const mapDispatchToProps = (dispatch) => {
return {
uiActions: bindActionCreators(uiActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(LibraryPlaylists)