{"size": 1006, "ext": "js", "max_stars_repo_path": "rest_framework_docs/static/rest_framework_docs/js/components/request/headers.js", "max_stars_repo_name": "wildfish/django-rest-framework-docs", "max_stars_repo_stars_event_min_datetime": "2016-08-30T13:38:21.000Z", "max_stars_repo_stars_event_max_datetime": "2021-12-18T00:46:10.000Z", "max_issues_repo_path": "rest_framework_docs/static/rest_framework_docs/js/components/request/headers.js", "max_issues_repo_name": "wildfish/django-rest-framework-docs", "max_issues_repo_issues_event_min_datetime": "2015-12-18T23:46:37.000Z", "max_issues_repo_issues_event_max_datetime": "2016-08-27T07:34:07.000Z", "max_forks_repo_path": "rest_framework_docs/static/rest_framework_docs/js/components/request/headers.js", "max_forks_repo_name": "wildfish/django-rest-framework-docs", "max_forks_repo_forks_event_min_datetime": "2016-08-29T09:10:40.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-16T04:06:11.000Z"}
{"max_stars_count": 487, "max_issues_count": 63, "max_forks_count": 166, "avg_line_length": 22.8636363636, "max_line_length": 69, "alphanum_fraction": 0.634194831}
var React = require('react');

var Header = require('../helpers/header');
var FieldText = require('../fields/text');
var RequestUtils = require('../../utils/request');

var Headers = React.createClass({

  getInitialState: function() {
    return {
      authorization: this.props.headers.authorization
    };
  },

  handleChange: function (fieldName, event) {
    this.props.handleHeaderChange(event.target.value, fieldName);
  },

  componentWillReceiveProps: function(nextProps) {
    this.setState({
      authorization: nextProps.headers.authorization
    });
  },

  render: function () {
    if (!RequestUtils.shouldAddHeader(this.props.permissions)) {
      return null;
    }

    return (
      <div>
        <Header title='Headers' />
        <FieldText
          name='authorization'
          value={this.state.authorization}
          placeholder='Token 1234567890'
          onChange={this.handleChange.bind(this, 'authorization')} />
      </div>
    );
  }
});

module.exports = Headers;
