2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
import React, { PropTypes } from 'react'
|
|
|
|
|
import { connect } from 'react-redux'
|
|
|
|
|
import { bindActionCreators } from 'redux'
|
|
|
|
|
|
|
|
|
|
import * as helpers from '../../helpers'
|
|
|
|
|
import Icon from '../Icon'
|
|
|
|
|
import AddToPlaylistModal from './AddToPlaylistModal'
|
2017-03-08 09:13:24 +13:00
|
|
|
import AddToQueueModal from './AddToQueueModal'
|
2016-11-14 17:32:36 +13:00
|
|
|
import CreatePlaylistModal from './CreatePlaylistModal'
|
|
|
|
|
import EditPlaylistModal from './EditPlaylistModal'
|
2016-12-12 09:07:47 +13:00
|
|
|
import SendAuthorizationModal from './SendAuthorizationModal'
|
2017-01-30 16:59:37 +13:00
|
|
|
import EditRadioModal from './EditRadioModal'
|
2017-01-24 09:04:26 +13:00
|
|
|
import ImageZoomModal from './ImageZoomModal'
|
2017-02-23 22:06:43 +13:00
|
|
|
import KioskModeModal from './KioskModeModal'
|
2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
import * as uiActions from '../../services/ui/actions'
|
|
|
|
|
import * as mopidyActions from '../../services/mopidy/actions'
|
|
|
|
|
import * as spotifyActions from '../../services/spotify/actions'
|
2016-12-12 09:07:47 +13:00
|
|
|
import * as pusherActions from '../../services/pusher/actions'
|
2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
class Modal extends React.Component{
|
|
|
|
|
|
|
|
|
|
constructor(props){
|
|
|
|
|
super(props)
|
|
|
|
|
}
|
|
|
|
|
|
2017-02-28 16:13:27 +13:00
|
|
|
componentWillReceiveProps( nextProps ){
|
|
|
|
|
if (nextProps.modal){
|
|
|
|
|
$('body').addClass('modal-open')
|
|
|
|
|
} else {
|
|
|
|
|
$('body').removeClass('modal-open')
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-14 17:32:36 +13:00
|
|
|
render(){
|
|
|
|
|
if( !this.props.modal ) return null;
|
|
|
|
|
|
|
|
|
|
return (
|
2017-01-24 09:04:26 +13:00
|
|
|
<div className={this.props.modal.name+" modal"}>
|
2016-11-14 17:32:36 +13:00
|
|
|
<div className="close-modal" onClick={ () => this.props.uiActions.closeModal() }>
|
|
|
|
|
<Icon name="close" className="white" />
|
|
|
|
|
</div>
|
|
|
|
|
<div className="content">
|
|
|
|
|
|
2016-11-19 13:06:08 +13:00
|
|
|
{ this.props.modal.name == 'add_to_playlist' ? <AddToPlaylistModal uiActions={this.props.uiActions} playlists={this.props.playlists} tracks_uris={this.props.modal.data.tracks_uris} /> : null }
|
2017-03-08 09:13:24 +13:00
|
|
|
{ this.props.modal.name == 'add_to_queue' ? <AddToQueueModal uiActions={this.props.uiActions} mopidyActions={this.props.mopidyActions} /> : null }
|
2016-11-14 18:15:22 +13:00
|
|
|
{ this.props.modal.name == 'create_playlist' ? <CreatePlaylistModal uiActions={this.props.uiActions} /> : null }
|
2016-11-14 17:32:36 +13:00
|
|
|
{ this.props.modal.name == 'edit_playlist' ? <EditPlaylistModal uiActions={this.props.uiActions} data={this.props.modal.data} /> : null }
|
2016-12-12 09:07:47 +13:00
|
|
|
{ this.props.modal.name == 'send_authorization' ? <SendAuthorizationModal uiActions={this.props.uiActions} pusherActions={this.props.pusherActions} data={this.props.modal.data} /> : null }
|
2017-02-01 10:10:31 +13:00
|
|
|
{ this.props.modal.name == 'edit_radio' ? <EditRadioModal uiActions={this.props.uiActions} pusherActions={this.props.pusherActions} spotifyActions={this.props.spotifyActions} data={this.props.modal.data} radio={this.props.radio} artists={this.props.artists} tracks={this.props.tracks} /> : null }
|
2017-01-24 09:04:26 +13:00
|
|
|
{ this.props.modal.name == 'image_zoom' ? <ImageZoomModal uiActions={this.props.uiActions} data={this.props.modal.data} /> : null }
|
2017-02-23 22:06:43 +13:00
|
|
|
{ this.props.modal.name == 'kiosk_mode' ? <KioskModeModal uiActions={this.props.uiActions} data={this.props.modal.data} /> : null }
|
2016-11-14 17:32:36 +13:00
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapStateToProps = (state, ownProps) => {
|
|
|
|
|
return {
|
|
|
|
|
modal: state.ui.modal,
|
2017-01-30 16:59:37 +13:00
|
|
|
radio: state.ui.radio,
|
2017-02-01 10:10:31 +13:00
|
|
|
tracks: state.ui.tracks,
|
|
|
|
|
artists: state.ui.artists,
|
2016-11-14 17:32:36 +13:00
|
|
|
playlists: state.ui.playlists,
|
|
|
|
|
context_menu: state.ui.context_menu,
|
|
|
|
|
mopidy_connected: state.mopidy.connected,
|
|
|
|
|
spotify_authorized: state.spotify.authorized
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const mapDispatchToProps = (dispatch) => {
|
|
|
|
|
return {
|
|
|
|
|
uiActions: bindActionCreators(uiActions, dispatch),
|
2016-12-12 09:07:47 +13:00
|
|
|
pusherActions: bindActionCreators(pusherActions, dispatch),
|
2016-11-14 17:32:36 +13:00
|
|
|
spotifyActions: bindActionCreators(spotifyActions, dispatch),
|
|
|
|
|
mopidyActions: bindActionCreators(mopidyActions, dispatch)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default connect(mapStateToProps, mapDispatchToProps)(Modal)
|