|
@@ -1,7 +1,7 @@
|
|
|
const React = require('react')
|
|
|
const PropTypes = require('prop-types')
|
|
|
const UppyCore = require('../core/Core')
|
|
|
-const UppyWrapper = require('./Wrapper')
|
|
|
+const DashboardPlugin = require('../plugins/Dashboard')
|
|
|
|
|
|
const h = React.createElement
|
|
|
|
|
@@ -10,14 +10,42 @@ const h = React.createElement
|
|
|
* renders the Dashboard inline, so you can put it anywhere you want.
|
|
|
*/
|
|
|
|
|
|
-const Dashboard = (props) =>
|
|
|
- h(UppyWrapper, props)
|
|
|
+class Dashboard extends React.Component {
|
|
|
+ componentDidMount () {
|
|
|
+ const uppy = this.props.uppy
|
|
|
+ const options = Object.assign(
|
|
|
+ {},
|
|
|
+ this.props,
|
|
|
+ { target: this.container }
|
|
|
+ )
|
|
|
+ delete options.uppy
|
|
|
+ uppy.use(DashboardPlugin, options)
|
|
|
+
|
|
|
+ this.plugin = uppy.getPlugin('DashboardUI')
|
|
|
+ }
|
|
|
+
|
|
|
+ componentWillUnmount () {
|
|
|
+ const uppy = this.props.uppy
|
|
|
+
|
|
|
+ uppy.removePlugin(this.plugin)
|
|
|
+ }
|
|
|
+
|
|
|
+ render () {
|
|
|
+ return h('div', {
|
|
|
+ ref: (container) => {
|
|
|
+ this.container = container
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
Dashboard.propTypes = {
|
|
|
- uppy: PropTypes.instanceOf(UppyCore).isRequired
|
|
|
+ uppy: PropTypes.instanceOf(UppyCore).isRequired,
|
|
|
+ inline: PropTypes.bool,
|
|
|
+ plugins: PropTypes.arrayOf(PropTypes.string)
|
|
|
}
|
|
|
Dashboard.defaultProps = {
|
|
|
- plugin: 'DashboardUI'
|
|
|
+ inline: true
|
|
|
}
|
|
|
|
|
|
module.exports = Dashboard
|