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

103 lines
3.3 KiB
JavaScript
Raw Normal View History

2017-03-08 09:13:24 +13:00
2019-09-05 15:36:11 +12:00
import React from 'react';
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import ReactGA from 'react-ga';
import Link from '../../components/Link';
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';
2019-09-05 15:36:11 +12:00
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
2019-09-05 15:36:11 +12:00
class AddToQueue extends React.Component {
constructor(props) {
super(props);
this.state = {
uris: '',
next: false,
};
}
2017-03-08 09:13:24 +13:00
2019-09-05 15:36:11 +12:00
componentDidMount() {
this.props.uiActions.setWindowTitle('Add to queue');
}
2017-03-08 09:13:24 +13:00
2019-09-05 15:36:11 +12:00
handleSubmit(e) {
e.preventDefault();
const uris = this.state.uris.split(',');
this.props.mopidyActions.enqueueURIs(uris, null, this.state.next);
window.history.back();
}
2018-07-13 16:48:41 +12:00
2019-09-05 15:36:11 +12:00
render() {
return (
<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
2019-09-05 15:36:11 +12: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>
</div>
2017-03-08 09:13:24 +13:00
2019-09-05 15:36:11 +12:00
<div className="field radio white">
<div className="name">
2018-05-29 21:05:03 +12:00
Position
2019-09-05 15:36:11 +12:00
</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>
</div>
2017-03-08 09:13:24 +13:00
2019-09-05 15:36:11 +12:00
<div className="actions centered-text">
<button type="submit" className="button button--primary button--large">Add</button>
</div>
</form>
</Modal>
);
}
2018-07-09 19:09:12 +12:00
}
2019-09-05 15:36:11 +12:00
const mapStateToProps = (state, ownProps) => ({
mopidy_connected: state.mopidy.connected,
playlist: (state.core.playlists[ownProps.match.params.uri] !== undefined ? state.core.playlists[ownProps.match.params.uri] : null),
playlists: state.core.playlists,
});
2018-07-09 19:09:12 +12:00
2019-09-05 15:36:11 +12:00
const mapDispatchToProps = (dispatch) => ({
coreActions: bindActionCreators(coreActions, dispatch),
uiActions: bindActionCreators(uiActions, dispatch),
mopidyActions: bindActionCreators(mopidyActions, dispatch),
spotifyActions: bindActionCreators(spotifyActions, dispatch),
});
2018-07-09 19:09:12 +12:00
2019-09-05 15:36:11 +12:00
export default connect(mapStateToProps, mapDispatchToProps)(AddToQueue);