-
Notifications
You must be signed in to change notification settings - Fork 2k
/
App.js
115 lines (101 loc) · 3.07 KB
/
App.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import React, { Component } from 'react'
import Uppy from '@uppy/core'
import Tus from '@uppy/tus'
import GoogleDrive from '@uppy/google-drive'
import { Dashboard, DashboardModal } from '@uppy/react'
// import { Dashboard, DashboardModal, DragDrop, ProgressBar } from '@uppy/react'
import '@uppy/core/dist/style.css'
import '@uppy/dashboard/dist/style.css'
// import '@uppy/drag-drop/dist/style.css'
// import '@uppy/progress-bar/dist/style.css'
const isOnTravis = process.env.REACT_APP_ON_TRAVIS
const endpoint = isOnTravis ? 'http://companion.test:1080' : 'http://localhost:1080'
class App extends Component {
constructor (props) {
super(props)
this.uppy = new Uppy({ id: 'uppy1', autoProceed: true, debug: true })
.use(Tus, { endpoint: `${endpoint}/files/` })
.use(GoogleDrive, { companionUrl: 'https://companion.uppy.io' })
this.uppy2 = new Uppy({ id: 'uppy2', autoProceed: false, debug: true })
.use(Tus, { endpoint: `${endpoint}/files/` })
this.state = {
showInlineDashboard: true,
open: false
}
this.handleModalClick = this.handleModalClick.bind(this)
}
componentWillUnmount () {
this.uppy.close()
this.uppy2.close()
}
handleModalClick () {
this.setState({
open: !this.state.open
})
}
render () {
const { showInlineDashboard } = this.state
return (
<div>
<h1>React Examples</h1>
<h2>Inline Dashboard</h2>
<div id="inline-dashboard">
<label>
<input
id="inline-dashboard-toggle"
type="checkbox"
checked={showInlineDashboard}
onChange={(event) => {
this.setState({
showInlineDashboard: event.target.checked
})
}}
/>
Show Dashboard
</label>
{showInlineDashboard && (
<Dashboard
uppy={this.uppy}
plugins={['GoogleDrive']}
metaFields={[
{ id: 'name', name: 'Name', placeholder: 'File name' }
]}
/>
)}
</div>
<h2>Modal Dashboard</h2>
<div id="modal-dashboard">
<button onClick={this.handleModalClick} id="modal-dashboard-toggle">
{this.state.open ? 'Close dashboard' : 'Open dashboard'}
</button>
<DashboardModal
uppy={this.uppy2}
open={this.state.open}
target="#modal-dashboard"
onRequestClose={() => this.setState({ open: false })}
/>
</div>
{/* <h2>Drag Drop Area</h2>
<div id="drag-drop">
<DragDrop
uppy={this.uppy}
locale={{
strings: {
chooseFile: 'Boop a file',
orDragDrop: 'or yoink it here'
}
}}
/>
</div>
<h2>Progress Bar</h2>
<div id="progress-bar">
<ProgressBar
uppy={this.uppy}
hideAfterFinish={false}
/>
</div> */}
</div>
)
}
}
export default App