content.jsx 1.5 KB

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