App.js 2.3 KB

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