mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-24 02:38:58 +00:00
Move update() to Plugin.js to avoid duplication
This commit is contained in:
parent
7ffc0ee990
commit
6502d66d0b
3 changed files with 14 additions and 25 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import yo from 'yo-yo'
|
||||
|
||||
/**
|
||||
* Boilerplate that all Plugins share - and should not be used
|
||||
* directly. It also shows which methods final plugins should implement/override,
|
||||
|
|
@ -16,6 +18,15 @@ export default class Plugin {
|
|||
this.name = this.constructor.name
|
||||
}
|
||||
|
||||
update () {
|
||||
if (typeof this.el === 'undefined') {
|
||||
return
|
||||
}
|
||||
|
||||
const newEl = this.render(this.core.state)
|
||||
yo.update(this.el, newEl)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if supplied `target` is a `string` or an `object`.
|
||||
* If object (that means its a plugin), search `plugins` for
|
||||
|
|
@ -43,15 +54,11 @@ export default class Plugin {
|
|||
return
|
||||
}
|
||||
|
||||
update () {
|
||||
return
|
||||
}
|
||||
|
||||
install () {
|
||||
return
|
||||
}
|
||||
|
||||
run (results) {
|
||||
return results
|
||||
run () {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,15 +17,6 @@ export default class ProgressBar extends Plugin {
|
|||
this.opts = Object.assign({}, defaultOptions, opts)
|
||||
}
|
||||
|
||||
update () {
|
||||
if (typeof this.el === 'undefined') {
|
||||
return
|
||||
}
|
||||
|
||||
const newEl = this.render(this.core.state)
|
||||
yo.update(this.el, newEl)
|
||||
}
|
||||
|
||||
render (state) {
|
||||
const progress = state.totalProgress || 0
|
||||
|
||||
|
|
|
|||
|
|
@ -18,15 +18,6 @@ export default class ProgressDrawer extends Plugin {
|
|||
this.opts = Object.assign({}, defaultOptions, opts)
|
||||
}
|
||||
|
||||
update () {
|
||||
if (typeof this.el === 'undefined') {
|
||||
return
|
||||
}
|
||||
|
||||
const newEl = this.render(this.core.state)
|
||||
yo.update(this.el, newEl)
|
||||
}
|
||||
|
||||
drawerItem (file) {
|
||||
const isUploaded = file.progress === 100
|
||||
|
||||
|
|
@ -52,7 +43,7 @@ export default class ProgressDrawer extends Plugin {
|
|||
<h4 class="UppyProgressDrawer-itemName">
|
||||
${file.uploadURL
|
||||
? yo`<a href="${file.uploadURL}" target="_blank">${file.name}</a>`
|
||||
: yo`<span>${file.name} (${file.progress})</span>`
|
||||
: yo`<span>${file.name} (${file.progress}%)</span>`
|
||||
}
|
||||
</h4>
|
||||
${isUploaded ? checkIcon : ''}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue