Dashboard.js 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. const React = require('react')
  2. const UppyCore = require('../core/Core').Uppy
  3. const DashboardPlugin = require('../plugins/Dashboard')
  4. const h = React.createElement
  5. /**
  6. * React Component that renders a Dashboard for an Uppy instance. This component
  7. * renders the Dashboard inline, so you can put it anywhere you want.
  8. */
  9. class Dashboard extends React.Component {
  10. componentDidMount () {
  11. const uppy = this.props.uppy
  12. uppy.use(DashboardPlugin, {
  13. target: this.container,
  14. maxWidth: this.props.maxWidth,
  15. maxHeight: this.props.maxHeight,
  16. semiTransparent: this.props.semiTransparent,
  17. showProgressDetails: this.props.showProgressDetails,
  18. // TODO Accept a React node here and render it so we can pass a DOM
  19. // element to this option.
  20. // defaultTabIcon: this.props.defaultTabIcon,
  21. inline: true
  22. })
  23. this.plugin = uppy.getPlugin('DashboardUI')
  24. }
  25. render () {
  26. return h('div', {
  27. ref: (container) => {
  28. this.container = container
  29. }
  30. })
  31. }
  32. }
  33. Dashboard.propTypes = {
  34. uppy: React.PropTypes.instanceOf(UppyCore).isRequired,
  35. maxWidth: React.PropTypes.number,
  36. maxHeight: React.PropTypes.number,
  37. semiTransparent: React.PropTypes.bool,
  38. defaultTabIcon: React.PropTypes.node,
  39. showProgressDetails: React.PropTypes.bool
  40. }
  41. module.exports = Dashboard