content: import React from 'react';
  import {connect} from 'react-redux';
  
  import {editFeedRequest} from '../../actions';
  import Button from '../shared/button';
  import Dialog from '../shared/dialog';
  import FormError from '../shared/form-error';
  import TextField from '../shared/text-field';
  
  class FeedEdit extends React.Component {
      constructor(props) {
          super(props);
          this.state = {
              name: this.props.feed.get('name'),
              url: this.props.feed.get('url')
          };
          this.handleNameChange = this.handleNameChange.bind(this);
          this.handleUrlChange = this.handleUrlChange.bind(this);
          this.handleSubmit = this.handleSubmit.bind(this);
      }
      render() {
          let data = this.props.data,
              isDone = data.get('isDone'),
              error = data.get('error'),
              actions = [
                  <Button
                      key="save"
                      disabled={!isDone}
                      label={isDone ? 'Save' : 'Loading...'}
                      onClick={this.handleSubmit}
                      primary={true} />,
                  <Button
                      key="cancel"
                      disable={!isDone}
                      label="Cancel"
                      onClick={this.props.onRequestClose} />
              ];
  
          return <Dialog actions={actions} open={this.props.open} title="Edit Feed">
              <TextField
                  label="Name"
                  onChange={this.handleNameChange}
                  value={this.state.name} />
              <TextField
                  label="URL"
                  onChange={this.handleUrlChange}
                  value={this.state.url} />
              <FormError message={error} />
          </Dialog>;
      }
      handleNameChange(name) {
          this.setState({name});
      }
      handleUrlChange(url) {
          this.setState({url});
      }
      handleSubmit() {
          this.props.submit(
              this.props.feed.get('id'),
              this.state.name,
              this.state.url,
              this.props.feed.get('cid'),
          ).then(data => {
              if (data.response && data.response.success) {
                  this.props.onRequestClose();
              }
          });
      }
  }
  
  FeedEdit.propTypes = {
      data: React.PropTypes.object.isRequired,
      feed: React.PropTypes.object.isRequired,
      onRequestClose: React.PropTypes.func.isRequired,
      open: React.PropTypes.bool.isRequired,
      submit: React.PropTypes.func.isRequired
  };
  
  export default connect(
      state => ({data: state.editFeedRequest}),
      dispatch => ({submit: (...params) => dispatch(editFeedRequest.send(...params))})
  )(FeedEdit);
  