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

69 lines
1.7 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-02 21:23:35 +13:00
import List from '../../components/List'
import Header from '../../components/Header'
import * as mopidyActions from '../../services/mopidy/actions'
import * as spotifyActions from '../../services/spotify/actions'
class LibraryPlaylists extends React.Component{
constructor(props) {
super(props);
}
// on render
componentDidMount(){
if( this.props.mopidy_connected ) this.props.mopidyActions.getPlaylists();
if( this.props.spotify_authorized ) this.props.spotifyActions.getAllLibraryPlaylists();
}
render(){
if( !this.props.playlists ) return null
2016-11-02 21:23:35 +13:00
var columns = [
{ name: 'name', width: '50'},
{ name: 'uri', width: '25'}
]
return (
2016-10-26 16:55:47 +13:00
<div className="view library-playlists-view">
<Header icon="playlist" title="My playlists" />
<section className="list-wrapper">
<List columns={columns} rows={this.props.playlists} link_prefix="/playlist/" />
</section>
</div>
)
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return {
playlists: state.ui.playlists,
playlists_more: state.ui.playlists_more,
mopidy_connected: state.mopidy.connected,
spotify_authorized: state.spotify.authorized
}
}
const mapDispatchToProps = (dispatch) => {
return {
mopidyActions: bindActionCreators(mopidyActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(LibraryPlaylists)