{"size": 1251, "ext": "js", "max_stars_repo_path": "packages/frontend/src/components/common/MiniEditor/index.js", "max_stars_repo_name": "salekseev/LambStatus", "max_stars_repo_stars_event_min_datetime": "2016-10-24T13:24:20.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-23T07:23:21.000Z", "max_issues_repo_path": "packages/frontend/src/components/common/MiniEditor/index.js", "max_issues_repo_name": "salekseev/LambStatus", "max_issues_repo_issues_event_min_datetime": "2016-11-09T10:41:42.000Z", "max_issues_repo_issues_event_max_datetime": "2020-03-25T13:27:06.000Z", "max_forks_repo_path": "packages/frontend/src/components/common/MiniEditor/index.js", "max_forks_repo_name": "gibbsie/LambStatus", "max_forks_repo_forks_event_min_datetime": "2016-11-14T11:05:41.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-22T11:39:20.000Z"}
{"max_stars_count": 1415, "max_issues_count": 136, "max_forks_count": 176, "avg_line_length": 27.1956521739, "max_line_length": 92, "alphanum_fraction": 0.657873701}
import React, { PropTypes } from 'react'
import Button from 'components/common/Button'
import ErrorMessage from 'components/common/ErrorMessage'
import TextField from 'components/common/TextField'
import classes from './MiniEditor.scss'

export default class MiniEditor extends React.Component {
  static propTypes = {
    onSave: PropTypes.func.isRequired,
    onCancel: PropTypes.func.isRequired,
    initialText: PropTypes.string,
    errorMessage: PropTypes.string,
    isUpdating: PropTypes.bool
  }

  constructor (props) {
    super(props)
    this.state = {
      message: props.initialText,
      isUpdating: false
    }
  }

  handleChangeMessage = (value) => {
    this.setState({message: value})
  }

  save = () => {
    this.props.onSave(this.state.message)
  }

  render () {
    return (
      <div>
        <ErrorMessage message={this.props.errorMessage} />
        <TextField text={this.state.message} rows={1} onChange={this.handleChangeMessage} />
        <div className={classes['message-bottons']}>
          <Button onClick={this.props.onCancel} name='Cancel' />
          <Button onClick={this.save} name='Save'
            class='mdl-button--accent' disabled={this.props.isUpdating} />
        </div>
      </div>
    )
  }
}
