Splitting out helpers into separate files
This commit is contained in:
@ -2,18 +2,14 @@
|
||||
import React from 'react';
|
||||
import { connect } from 'react-redux';
|
||||
import { bindActionCreators } from 'redux';
|
||||
import ReactGA from 'react-ga';
|
||||
import Link from '../../components/Link';
|
||||
|
||||
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';
|
||||
import * as helpers from '../../helpers';
|
||||
import { uriSource } from '../../util/helpers';
|
||||
|
||||
class EditPlaylist extends React.Component {
|
||||
class EditPlaylist extends React.Component {
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@ -26,7 +22,7 @@ class EditPlaylist extends React.Component {
|
||||
};
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
componentDidMount() {
|
||||
this.props.uiActions.setWindowTitle('Edit playlist');
|
||||
|
||||
if (this.props.playlist) {
|
||||
@ -37,7 +33,7 @@ class EditPlaylist extends React.Component {
|
||||
collaborative: (this.props.playlist.collaborative == true),
|
||||
});
|
||||
} else {
|
||||
switch (helpers.uriSource(this.props.uri)) {
|
||||
switch (helpers.uriSource(this.props.uri)) {
|
||||
case 'spotify':
|
||||
this.props.spotifyActions.getPlaylist(this.props.uri);
|
||||
this.props.spotifyActions.following(this.props.uri);
|
||||
@ -52,7 +48,7 @@ class EditPlaylist extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
componentWillReceiveProps(nextProps) {
|
||||
componentWillReceiveProps(nextProps) {
|
||||
// Playlist just loaded
|
||||
if (!this.props.playlist && nextProps.playlist) {
|
||||
this.setState({
|
||||
@ -84,7 +80,7 @@ class EditPlaylist extends React.Component {
|
||||
this.state.image,
|
||||
);
|
||||
window.history.back();
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
setImage(e) {
|
||||
@ -104,7 +100,7 @@ class EditPlaylist extends React.Component {
|
||||
}
|
||||
|
||||
renderFields() {
|
||||
switch (helpers.uriSource(this.props.uri)) {
|
||||
switch (uriSource(this.props.uri)) {
|
||||
case 'spotify':
|
||||
return (
|
||||
<div>
|
||||
@ -114,7 +110,7 @@ class EditPlaylist extends React.Component {
|
||||
<input
|
||||
type="text"
|
||||
onChange={(e) => this.setState({ name: e.target.value })}
|
||||
value={this.state.name}
|
||||
value={this.state.name}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -124,7 +120,7 @@ class EditPlaylist extends React.Component {
|
||||
<input
|
||||
type="text"
|
||||
onChange={(e) => this.setState({ description: e.target.value })}
|
||||
value={this.state.description}
|
||||
value={this.state.description}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -134,7 +130,7 @@ class EditPlaylist extends React.Component {
|
||||
<input
|
||||
type="file"
|
||||
placeholder="Leave empty to keep existing image"
|
||||
onChange={(e) => this.setImage(e)}
|
||||
onChange={(e) => this.setImage(e)}
|
||||
/>
|
||||
<div className="description">
|
||||
JPEG only, 256kB max. Leave empty to keep cover image unchanged.
|
||||
@ -151,7 +147,7 @@ class EditPlaylist extends React.Component {
|
||||
type="checkbox"
|
||||
name="playlist_private"
|
||||
checked={this.state.public}
|
||||
onChange={(e) => this.setState({ public: !this.state.public })}
|
||||
onChange={(e) => this.setState({ public: !this.state.public })}
|
||||
/>
|
||||
<span className="label">Public</span>
|
||||
</label>
|
||||
@ -160,7 +156,7 @@ class EditPlaylist extends React.Component {
|
||||
type="checkbox"
|
||||
name="collaborative"
|
||||
checked={this.state.collaborative}
|
||||
onChange={(e) => this.setState({ collaborative: !this.state.collaborative })}
|
||||
onChange={(e) => this.setState({ collaborative: !this.state.collaborative })}
|
||||
/>
|
||||
<span className="label">Collaborative</span>
|
||||
</label>
|
||||
@ -179,7 +175,7 @@ class EditPlaylist extends React.Component {
|
||||
<input
|
||||
type="text"
|
||||
onChange={(e) => this.setState({ name: e.target.value })}
|
||||
value={this.state.name}
|
||||
value={this.state.name}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
@ -206,7 +202,7 @@ class EditPlaylist extends React.Component {
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
const mapStateToProps = (state, ownProps) => {
|
||||
// Decode the URI, and then re-encode selected characters
|
||||
// This is needed as Mopidy encodes *some* characters in playlist URIs (but not other characters)
|
||||
// We need to retain ":" because this a reserved URI separator
|
||||
|
||||
Reference in New Issue
Block a user