{"size": 1195, "ext": "js", "max_stars_repo_path": "src/components/ErrorLog.js", "max_stars_repo_name": "rcdexta/js-warrior", "max_stars_repo_stars_event_min_datetime": "2017-08-06T13:31:51.000Z", "max_stars_repo_stars_event_max_datetime": "2019-05-20T16:28:07.000Z", "max_issues_repo_path": "src/components/ErrorLog.js", "max_issues_repo_name": "rcdexta/js-warrior", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/components/ErrorLog.js", "max_forks_repo_name": "rcdexta/js-warrior", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 3, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 22.1296296296, "max_line_length": 73, "alphanum_fraction": 0.5790794979}
import React, { Component } from 'react'
import { connect } from 'react-redux'
import AceEditor from 'react-ace'
import 'brace/mode/ruby'
import 'brace/theme/solarized_dark'

class ErrorLog extends Component {

  componentDidMount() {
    this.aceEditor.editor.renderer.$cursorLayer.element.style.opacity = 0
  }

  content = () => {
    const { errors, logs } = this.props.appState
    if (errors.length > 0) {
      return `[Error] ${errors.join('\n')}`
    }
    if (logs.length > 0) {
      return logs.join('\n')
    }
  }

  render = () => {
    return (
      <AceEditor
        ref={input => {
          this.aceEditor = input
        }}
        mode="ruby"
        theme="solarized_dark"
        name="js-warrior-log"
        showPrintMargin={false}
        value={this.content()}
        fontSize={14}
        width="100%"
        highlightActiveLine={false}
        readOnly
        cursorStart={100}
        showGutter={false}
        editorProps={{ $blockScrolling: true }}
        setOptions={{
          cursorStyle: 'wide'
        }}
      />
    )
  }
}

const mapStateToProps = state => ({
  appState: state.appState
})

export default connect(mapStateToProps, null)(ErrorLog)
