plugins.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. import React from 'react';
  2. import { connect } from 'react-redux';
  3. import classNames from 'classnames';
  4. import Tooltip from './tooltip';
  5. const Plugin = ({
  6. id, label, description, status
  7. }) => {
  8. const error = status !== 'ok';
  9. const className = classNames({ error });
  10. const tip = (
  11. <span>
  12. Description:
  13. {description}
  14. <br />
  15. Status:
  16. {' '}
  17. {status}
  18. </span>
  19. );
  20. // Inner span to hold styling so we don't effect the "before:content"
  21. return (
  22. <span className="plugins-plugin" key={id}>
  23. <Tooltip tip={tip}>
  24. <span className={className}>
  25. {error && <i className="plugins-plugin-icon fa fa-exclamation-circle" />}
  26. {label || id}
  27. </span>
  28. </Tooltip>
  29. </span>
  30. );
  31. };
  32. class Plugins extends React.Component {
  33. render() {
  34. const hasPlugins = this.props.plugins && this.props.plugins.size > 0;
  35. return (
  36. <div className="plugins">
  37. <span className="plugins-label">
  38. Plugins:
  39. </span>
  40. {hasPlugins && this.props.plugins.toIndexedSeq().map(plugin => Plugin(plugin.toJS()))}
  41. {!hasPlugins && <span className="plugins-empty">n/a</span>}
  42. </div>
  43. );
  44. }
  45. }
  46. function mapStateToProps(state) {
  47. return {
  48. plugins: state.get('plugins')
  49. };
  50. }
  51. export default connect(mapStateToProps)(Plugins);