2016-10-17 10:39:11 +13:00
|
|
|
|
|
|
|
|
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-10-17 10:39:11 +13:00
|
|
|
|
2016-11-12 16:36:36 +13:00
|
|
|
import PlaylistGrid from '../../components/PlaylistGrid'
|
2016-11-21 16:26:47 +13:00
|
|
|
import List from '../../components/List'
|
|
|
|
|
import DropdownField from '../../components/DropdownField'
|
2016-10-23 23:48:06 +13:00
|
|
|
import Header from '../../components/Header'
|
2016-10-21 23:27:50 +13:00
|
|
|
|
2016-11-14 11:20:02 +13:00
|
|
|
import * as uiActions from '../../services/ui/actions'
|
2016-10-21 09:56:07 +13:00
|
|
|
import * as mopidyActions from '../../services/mopidy/actions'
|
|
|
|
|
import * as spotifyActions from '../../services/spotify/actions'
|
2016-10-17 10:39:11 +13:00
|
|
|
|
2016-10-21 09:56:07 +13:00
|
|
|
class LibraryPlaylists extends React.Component{
|
2016-10-17 10:39:11 +13:00
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
super(props);
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-21 16:26:47 +13:00
|
|
|
renderView(){
|
2016-11-10 10:26:15 +13:00
|
|
|
if( !this.props.playlists ) return null
|
2016-11-21 16:26:47 +13:00
|
|
|
|
|
|
|
|
if( this.props.view == 'list' ){
|
|
|
|
|
var columns = [
|
|
|
|
|
{
|
|
|
|
|
width: 30,
|
|
|
|
|
label: 'Name',
|
|
|
|
|
name: 'name'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
width: 30,
|
|
|
|
|
label: 'Owner',
|
|
|
|
|
name: 'owner.id'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
width: 10,
|
|
|
|
|
label: 'Can edit',
|
|
|
|
|
name: 'can_edit'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
width: 10,
|
|
|
|
|
label: 'Tracks',
|
|
|
|
|
name: 'tracks.total'
|
|
|
|
|
}
|
|
|
|
|
]
|
|
|
|
|
return (
|
|
|
|
|
<section className="list-wrapper">
|
|
|
|
|
<List rows={this.props.playlists} columns={columns} link_prefix="/playlist/" show_source_icon={true} />
|
|
|
|
|
</section>
|
|
|
|
|
)
|
|
|
|
|
}else{
|
|
|
|
|
return (
|
|
|
|
|
<section className="grid-wrapper">
|
|
|
|
|
<PlaylistGrid playlists={this.props.playlists} />
|
|
|
|
|
</section>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
render(){
|
|
|
|
|
|
|
|
|
|
var view_options = [
|
|
|
|
|
{
|
|
|
|
|
value: 'thumbnails',
|
|
|
|
|
label: 'Thumbnails'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
value: 'list',
|
|
|
|
|
label: 'List'
|
|
|
|
|
}
|
2016-11-02 21:23:35 +13:00
|
|
|
]
|
|
|
|
|
|
2016-11-14 17:32:36 +13:00
|
|
|
var actions = (
|
2016-11-21 16:26:47 +13:00
|
|
|
<div>
|
|
|
|
|
<DropdownField icon="eye" name="View" value={ this.props.view } options={ view_options } handleChange={ value => this.props.uiActions.setView({ library_playlists_view: value }) } />
|
|
|
|
|
<button onClick={ () => this.props.uiActions.openModal('create_playlist', {} ) }>
|
|
|
|
|
<FontAwesome name="plus" />
|
|
|
|
|
New
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
2016-11-14 17:32:36 +13:00
|
|
|
)
|
|
|
|
|
|
2016-10-21 23:27:50 +13:00
|
|
|
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-21 16:26:47 +13:00
|
|
|
{ this.renderView() }
|
2016-10-21 23:27:50 +13:00
|
|
|
</div>
|
|
|
|
|
)
|
2016-10-17 10:39:11 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Export our component
|
|
|
|
|
*
|
|
|
|
|
* We also integrate our global store, using connect()
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
2016-11-10 10:26:15 +13:00
|
|
|
return {
|
2016-11-21 16:26:47 +13:00
|
|
|
view: state.ui.library_playlists_view,
|
2016-11-10 13:44:14 +13:00
|
|
|
playlists: state.ui.playlists
|
2016-10-17 10:39:11 +13:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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)
|