<commit_before>"use strict";

/* eslint camelcase:0 */

var React = require('react')
  , Immutable = require('immutable')
  , Note = require('../records/note')

module.exports = React.createClass({
  displayName: 'NoteEdit',

  propTypes: {
    data: React.PropTypes.instanceOf(Immutable.Map),
    project: React.PropTypes.instanceOf(Immutable.Map),
  },

  getInitialState() {
    return { note: new Note(this.props.data) }
  },

  renderBreadcrumb() {
    var Breadcrumb = require('./shared/breadcrumb.jsx')
      , note = this.props.data
      , project = this.props.project || note.get('project')
      , crumbs

    crumbs = Immutable.fromJS([
      { href: project.get('url'), label: project.get('name') },
      { href: project.get('url') + 'notes/', label: 'Notes' },
    ]);

    crumbs = crumbs.concat(Immutable.fromJS(
      !this.props.data ?
        [ { label: 'Add' } ] :
        [
          { href: note.get('url'), label: note.get('title') },
          { label: 'Edit' }
        ]
    ))


    return <Breadcrumb crumbs={crumbs} />
  },

  isNew() {
    return !this.props.data
  },

  getProjectURL() {
    return this.isNew() ?
      this.props.project.get('url') :
      this.props.data.get('url').replace(/\/notes\/.*/, '/')
  },

  handleNoteChange(note) {
    this.setState({ note });
  },

  handleSave() {
    var saveItem = require('../utils/save_item')
      , id = this.isNew() ? null : this.props.data.get('id')

    saveItem('note', id, this.getProjectURL(), this.state.note)
  },

  render() {
    var NoteForm = require('./shared/note_form.jsx')

    return (
      <div>
        { this.renderBreadcrumb() }

        <NoteForm
            note={this.state.note}
            projectURL={this.getProjectURL()}
            onChange={this.handleNoteChange} />

        <section>
          <div className="well">
            <button
                className="btn btn-primary btn-large"
                onClick={this.handleSave}>
              Save
            </button>
          </div>
        </section>

      </div>
    )
  }
});
<commit_msg>Linting<commit_after>"use strict";

/* eslint camelcase:0 */

var React = require('react')
  , Immutable = require('immutable')
  , Note = require('../records/note')

module.exports = React.createClass({
  displayName: 'NoteEdit',

  propTypes: {
    data: React.PropTypes.instanceOf(Immutable.Map),
    project: React.PropTypes.instanceOf(Immutable.Map),
  },

  getInitialState() {
    return { note: new Note(this.props.data) }
  },

  renderBreadcrumb() {
    var Breadcrumb = require('./shared/breadcrumb.jsx')
      , note = this.props.data
      , project = this.props.project || note.get('project')
      , crumbs

    crumbs = Immutable.fromJS([
      { href: project.get('url'), label: project.get('name') },
      { href: project.get('url') + 'notes/', label: 'Notes' },
    ]);

    crumbs = crumbs.concat(Immutable.fromJS(
      !this.props.data ?
        [ { label: 'Add' } ] :
        [
          { href: note.get('url'), label: note.get('title') },
          { label: 'Edit' }
        ]
    ))


    return <Breadcrumb crumbs={crumbs} />
  },

  isNew() {
    return !this.props.data
  },

  getProjectURL() {
    return this.isNew() ?
      this.props.project.get('url') :
      this.props.data.get('url').replace(/\/notes\/.*/, '/')
  },

  handleNoteChange(note) {
    this.setState({ note });
  },

  handleSave() {
    var saveItem = require('../utils/save_item')
      , id = this.isNew() ? null : this.props.data.get('id')

    saveItem('note', id, this.getProjectURL(), this.state.note)
  },

  render() {
    var NoteForm = require('./shared/note_form.jsx')
      , { note } = this.state

    return (
      <div>
        { this.renderBreadcrumb() }

        <NoteForm
            note={note}
            projectURL={this.getProjectURL()}
            onChange={this.handleNoteChange} />

        <section>
          <div className="well">
            <button
                className="btn btn-primary btn-large"
                onClick={this.handleSave}>
              Save
            </button>
          </div>
        </section>

      </div>
    )
  }
});

{'fraction_non_alphanumeric': 0.17383986535224813, 'fraction_numerical': 0.00048088482808367395, 'mean_word_length': 2.1419939577039275, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7561657', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1344, 'n_words': 216}