App.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. metaFields={[
  57. { id: 'name', name: 'Name', placeholder: 'File name' }
  58. ]}
  59. />
  60. )}
  61. <h2>Modal Dashboard</h2>
  62. <div>
  63. <button onClick={this.handleModalClick}>
  64. {this.state.open ? 'Close dashboard' : 'Open dashboard'}
  65. </button>
  66. <DashboardModal
  67. uppy={this.uppy2}
  68. open={this.state.open}
  69. target={document.body}
  70. onRequestClose={() => this.setState({ open: false })}
  71. />
  72. </div>
  73. <h2>Drag Drop Area</h2>
  74. <DragDrop
  75. uppy={this.uppy}
  76. locale={{
  77. strings: {
  78. chooseFile: 'Boop a file',
  79. orDragDrop: 'or yoink it here'
  80. }
  81. }}
  82. />
  83. <h2>Progress Bar</h2>
  84. <ProgressBar
  85. uppy={this.uppy}
  86. />
  87. </div>
  88. )
  89. }
  90. }