App.js 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /* eslint-disable */
  2. const React = require('react')
  3. const Uppy = require('uppy/lib/core')
  4. const Tus10 = require('uppy/lib/plugins/Tus10')
  5. const GoogleDrive = require('uppy/lib/plugins/GoogleDrive')
  6. const DashboardPlugin = require('uppy/lib/plugins/Dashboard')
  7. const { Dashboard, DashboardModal, DragDrop, ProgressBar } = require('uppy/lib/uppy-react')
  8. module.exports = class App extends React.Component {
  9. constructor (props) {
  10. super(props)
  11. this.state = {
  12. showInlineDashboard: false,
  13. open: false
  14. }
  15. this.handleModalClick = this.handleModalClick.bind(this)
  16. }
  17. componentWillMount () {
  18. this.uppy = new Uppy({ autoProceed: false })
  19. .use(Tus10, { endpoint: 'https://master.tus.io/files' })
  20. .use(GoogleDrive, { target: DashboardPlugin, host: 'https://server.uppy.io' })
  21. .run()
  22. this.uppy2 = new Uppy({ autoProceed: false })
  23. .use(Tus10, { endpoint: 'https://master.tus.io/files' })
  24. .run()
  25. }
  26. componentWillUnmount () {
  27. this.uppy.close()
  28. this.uppy2.close()
  29. }
  30. handleModalClick () {
  31. this.setState({
  32. open: !this.state.open
  33. })
  34. }
  35. render () {
  36. const { showInlineDashboard } = this.state
  37. return (
  38. <div>
  39. <h1>React Examples</h1>
  40. <h2>Inline Dashboard</h2>
  41. <label>
  42. <input
  43. type="checkbox"
  44. checked={showInlineDashboard}
  45. onChange={(event) => {
  46. this.setState({
  47. showInlineDashboard: event.target.checked
  48. })
  49. }}
  50. />
  51. Show Dashboard
  52. </label>
  53. {showInlineDashboard && (
  54. <Dashboard uppy={this.uppy} />
  55. )}
  56. <h2>Modal Dashboard</h2>
  57. <div>
  58. <button onClick={this.handleModalClick}>
  59. {this.state.open ? 'Close dashboard' : 'Open dashboard'}
  60. </button>
  61. <DashboardModal
  62. uppy={this.uppy2}
  63. open={this.state.open}
  64. onRequestClose={() => this.setState({ open: false })}
  65. />
  66. </div>
  67. <h2>Drag Drop Area</h2>
  68. <DragDrop
  69. uppy={this.uppy}
  70. locale={{
  71. strings: {
  72. chooseFile: 'Boop a file',
  73. orDragDrop: 'or yoink it here'
  74. }
  75. }}
  76. />
  77. <h2>Progress Bar</h2>
  78. <ProgressBar uppy={this.uppy} />
  79. </div>
  80. )
  81. }
  82. }