Files
Iris/src/js/views/modals/AddToQueue.js

104 lines
3.0 KiB
JavaScript
Raw Normal View History

2017-03-08 09:13:24 +13:00
2018-07-09 19:09:12 +12:00
import React, { PropTypes } from 'react'
import { connect } from 'react-redux'
import { bindActionCreators } from 'redux'
import { Link } from 'react-router'
import ReactGA from 'react-ga'
2017-03-08 09:13:24 +13:00
2018-07-09 19:09:12 +12:00
import Modal from './Modal';
import Icon from '../../components/Icon';
import * as coreActions from '../../services/core/actions'
import * as uiActions from '../../services/ui/actions'
import * as mopidyActions from '../../services/mopidy/actions'
import * as spotifyActions from '../../services/spotify/actions'
2018-02-01 08:06:40 +13:00
import * as helpers from '../../helpers';
2017-03-08 09:13:24 +13:00
2018-07-09 19:09:12 +12:00
class AddToQueue extends React.Component{
2017-03-08 09:13:24 +13:00
constructor(props){
super(props)
this.state = {
uris: '',
next: false
2017-03-08 09:13:24 +13:00
}
}
2018-07-13 16:48:41 +12:00
componentDidMount(){
this.props.uiActions.setWindowTitle("Add to queue");
}
2017-03-08 09:13:24 +13:00
handleSubmit(e){
2018-07-09 19:09:12 +12:00
e.preventDefault();
var uris = this.state.uris.split(',');
this.props.mopidyActions.enqueueURIs(uris, null, this.state.next);
2018-07-09 19:09:12 +12:00
window.history.back();
2017-03-08 09:13:24 +13:00
}
render(){
return (
2018-07-13 16:48:41 +12:00
<Modal className="modal--add-to-queue">
<h1>Add to queue</h1>
<h2 className="mid_grey-text">Add a comma-separated list of URIs to the play queue. You must have the appropriate Mopidy backend enabled for each URI schema (eg spotify:, yt:).</h2>
2017-03-08 09:13:24 +13:00
<form onSubmit={e => this.handleSubmit(e)}>
<div className="field text">
<div className="name">URI(s)</div>
<div className="input">
<input
type="text"
onChange={e => this.setState({uris: e.target.value})}
value={this.state.uris} />
</div>
2017-03-08 09:13:24 +13:00
</div>
<div className="field radio white">
<div className="name">
2018-05-29 21:05:03 +12:00
Position
</div>
<div className="input">
<label>
<input
type="radio"
name="next"
checked={!this.state.next}
onChange={e => this.setState({next: false})} />
<span className="label">End</span>
</label>
<label>
<input
type="radio"
name="next"
checked={this.state.next}
onChange={e => this.setState({next: true})} />
<span className="label">After current track</span>
</label>
</div>
2017-03-08 09:13:24 +13:00
</div>
<div className="actions centered-text">
2018-02-01 08:06:40 +13:00
<button type="submit" className="primary large">Add</button>
2017-03-08 09:13:24 +13:00
</div>
</form>
2018-07-09 19:09:12 +12:00
</Modal>
2017-03-08 09:13:24 +13:00
)
}
2018-07-09 19:09:12 +12:00
}
const mapStateToProps = (state, ownProps) => {
return {
mopidy_connected: state.mopidy.connected,
playlist: (state.core.playlists[ownProps.params.uri] !== undefined ? state.core.playlists[ownProps.params.uri] : null),
playlists: state.core.playlists
}
}
const mapDispatchToProps = (dispatch) => {
return {
coreActions: bindActionCreators(coreActions, dispatch),
uiActions: bindActionCreators(uiActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch)
}
}
export default connect(mapStateToProps, mapDispatchToProps)(AddToQueue)