Files
Iris/src/js/components/Sidebar.js

139 lines
4.5 KiB
JavaScript
Raw Normal View History

import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { Link, withRouter } from 'react-router'
2016-11-03 08:57:16 +13:00
import Icon from './Icon'
import Dropzones from './Dropzones'
2017-06-16 15:40:39 +12:00
import Thumbnail from './Thumbnail'
import FontAwesome from 'react-fontawesome'
import * as uiActions from '../services/ui/actions'
import * as mopidyActions from '../services/mopidy/actions'
class Sidebar extends React.Component{
2017-10-10 13:05:28 +13:00
constructor(props){
2016-11-21 21:46:53 +13:00
super(props)
}
linkClassName(link){
if (this.props.location.pathname.startsWith('/'+link)){
return 'active'
} else {
return null
}
}
render(){
return (
<aside>
2016-11-22 11:10:30 +13:00
<div className="liner">
<nav>
<section>
<Link className={this.linkClassName('queue')} to={global.baseURL+"queue"}>
2017-06-18 05:47:36 +12:00
<Icon name="play" />
2016-11-22 11:10:30 +13:00
Now playing
</Link>
<Link className={this.linkClassName('search')} to={global.baseURL+"search"}>
2017-06-20 19:55:47 +12:00
<Icon name="search" />
Search
</Link>
2016-11-22 11:10:30 +13:00
</section>
{this.props.spotify_enabled ? <section>
2016-11-22 11:10:30 +13:00
<title>Discover</title>
<Link className={this.linkClassName('discover/recommendations')} to={global.baseURL+"discover/recommendations"}>
2017-06-18 05:47:36 +12:00
<Icon name="compass" />
2016-11-22 11:10:30 +13:00
Discover
</Link>
<Link className={this.linkClassName('discover/categories')} to={global.baseURL+"discover/categories"}>
2017-06-18 05:47:36 +12:00
<Icon name="grid" />
2016-11-22 11:10:30 +13:00
Genre / Mood
</Link>
<Link className={this.linkClassName('discover/featured')} to={global.baseURL+"discover/featured"}>
2017-06-18 05:47:36 +12:00
<Icon name="star" />
2016-11-22 11:10:30 +13:00
Featured playlists
</Link>
<Link className={this.linkClassName('discover/new-releases')} to={global.baseURL+"discover/new-releases"}>
2017-06-18 05:47:36 +12:00
<Icon name="leaf" />
2016-11-22 11:10:30 +13:00
New releases
</Link>
</section> : null}
2016-11-22 11:10:30 +13:00
<section>
<title>My Music</title>
<Link className={this.linkClassName('library/playlists')} to={global.baseURL+"library/playlists"}>
2017-06-18 05:47:36 +12:00
<Icon name="playlist" />
2016-11-22 11:10:30 +13:00
Playlists
</Link>
<Link className={this.linkClassName('library/artists')} to={global.baseURL+"library/artists"}>
2017-06-18 05:47:36 +12:00
<Icon name="mic" />
2016-11-22 11:10:30 +13:00
Artists
</Link>
<Link className={this.linkClassName('library/albums')} to={global.baseURL+"library/albums"}>
2017-06-18 05:47:36 +12:00
<Icon name="cd" />
2016-11-22 11:10:30 +13:00
Albums
</Link>
2017-08-15 21:53:57 +12:00
<Link className={this.linkClassName('library/tracks')} to={global.baseURL+"library/tracks"}>
2017-08-27 08:51:23 +12:00
<Icon name="music" />
2017-08-15 21:53:57 +12:00
Tracks
</Link>
2017-07-07 08:19:47 +12:00
<Link className={this.linkClassName('library/browse')} to={global.baseURL+"library/browse"}>
2017-06-18 05:47:36 +12:00
<Icon name="folder" />
2017-07-07 09:59:16 +12:00
Browse
2016-11-22 11:10:30 +13:00
</Link>
</section>
<section>
<Link className={this.linkClassName('settings')} to={global.baseURL+"settings"}>
2017-06-18 05:47:36 +12:00
<Icon name="cog" />
2016-11-22 11:10:30 +13:00
Settings
2018-02-20 08:25:46 +13:00
{this.props.test_mode ? <span className="status has-tooltip right-tooltip"><FontAwesome name="info-circle" className="orange-text" /><span className="tooltip">Test mode active</span></span>: null}
{!this.props.mopidy_connected || !this.props.pusher_connected ? <span className="status has-tooltip right-tooltip"><FontAwesome name="exclamation-triangle" className="red-text" /><span className="tooltip">{!this.props.mopidy_connected ? <span>Mopidy not connected<br /></span> : null}{!this.props.pusher_connected ? <span>Pusher not connected<br /></span> : null}</span></span> : null}
2016-11-22 11:10:30 +13:00
</Link>
</section>
</nav>
</div>
<Dropzones />
<div className="close" onClick={e => this.props.uiActions.toggleSidebar(false)}>
<FontAwesome name="chevron-right" />
</div>
</aside>
);
}
}
/**
* Export our component
*
* We also integrate our global store, using connect()
**/
const mapStateToProps = (state, ownProps) => {
return {
mopidy_connected: state.mopidy.connected,
pusher_connected: state.pusher.connected,
spotify_enabled: state.spotify.enabled,
spotify_authorized: state.spotify.authorization,
test_mode: (state.ui.test_mode ? state.ui.test_mode : false),
2016-11-10 16:17:10 +13:00
dragger: state.ui.dragger
}
}
const mapDispatchToProps = (dispatch) => {
return {
uiActions: bindActionCreators(uiActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch)
}
}
// We wrap our Sidebar with the Router, and then to the redux store
export default connect(mapStateToProps, mapDispatchToProps)(withRouter(Sidebar))