content.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /**
  2. * @author oldj
  3. * @blog https://oldj.net
  4. */
  5. 'use strict'
  6. import React from 'react'
  7. import classnames from 'classnames'
  8. import Editor from './editor'
  9. import './content.less'
  10. export default class Content extends React.Component {
  11. constructor (props) {
  12. super(props)
  13. this.state = {
  14. is_loading: this.props.current.is_loading
  15. }
  16. }
  17. render () {
  18. let {current, lang} = this.props
  19. return (
  20. <div id="sh-content">
  21. <div className="inform">
  22. <span
  23. className={classnames({
  24. loading: 1,
  25. show: this.state.is_loading
  26. })}
  27. >loading...</span>
  28. <i
  29. className={classnames({
  30. show: current.where === 'remote',
  31. iconfont: 1,
  32. 'icon-earth': 1
  33. })}
  34. title={lang.remote_hosts}
  35. />
  36. <i
  37. className={classnames({
  38. show: this.props.readonly,
  39. iconfont: 1,
  40. 'icon-lock2': 1
  41. })}
  42. title={lang.readonly}
  43. />
  44. </div>
  45. <div className={classnames({
  46. errorMessage: 1,
  47. show: !!this.props.current.error
  48. })}>{this.props.current.error}</div>
  49. <Editor
  50. readonly={this.props.readonly}
  51. code={this.props.current.content || ''}
  52. //setValue={this.setValue.bind(this)}
  53. />
  54. </div>
  55. )
  56. }
  57. }