|
@@ -14,8 +14,8 @@ const { defaultTabIcon } = require('./icons')
|
|
|
module.exports = class DashboardUI extends Plugin {
|
|
|
constructor (core, opts) {
|
|
|
super(core, opts)
|
|
|
- this.id = 'DashboardUI'
|
|
|
- this.title = 'Dashboard UI'
|
|
|
+ this.id = 'Dashboard'
|
|
|
+ this.title = 'Dashboard'
|
|
|
this.type = 'orchestrator'
|
|
|
|
|
|
const defaultLocale = {
|
|
@@ -66,8 +66,8 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
this.translator = new Translator({locale: this.locale})
|
|
|
this.containerWidth = this.translator.translate.bind(this.translator)
|
|
|
|
|
|
- this.hideModal = this.hideModal.bind(this)
|
|
|
- this.showModal = this.showModal.bind(this)
|
|
|
+ this.hide = this.hide.bind(this)
|
|
|
+ this.show = this.show.bind(this)
|
|
|
|
|
|
this.addTarget = this.addTarget.bind(this)
|
|
|
this.actions = this.actions.bind(this)
|
|
@@ -143,7 +143,11 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
})})
|
|
|
}
|
|
|
|
|
|
- hideModal () {
|
|
|
+ isOpen () {
|
|
|
+ return !this.core.getState().modal.isHidden || false
|
|
|
+ }
|
|
|
+
|
|
|
+ hide () {
|
|
|
const modal = this.core.getState().modal
|
|
|
|
|
|
this.core.setState({
|
|
@@ -157,7 +161,7 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
window.scrollTo(0, this.savedDocumentScrollPosition)
|
|
|
}
|
|
|
|
|
|
- showModal () {
|
|
|
+ show () {
|
|
|
const modal = this.core.getState().modal
|
|
|
|
|
|
this.core.setState({
|
|
@@ -185,19 +189,23 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
|
|
|
handleEscapeKeyPress (event) {
|
|
|
if (event.keyCode === 27) {
|
|
|
- this.hideModal()
|
|
|
+ this.hide()
|
|
|
}
|
|
|
}
|
|
|
|
|
|
handleClickOutside () {
|
|
|
- if (this.opts.closeModalOnClickOutside) this.hideModal()
|
|
|
+ if (this.opts.closeModalOnClickOutside) this.hide()
|
|
|
}
|
|
|
|
|
|
initEvents () {
|
|
|
|
|
|
const showModalTrigger = findDOMElement(this.opts.trigger)
|
|
|
if (!this.opts.inline && showModalTrigger) {
|
|
|
- showModalTrigger.addEventListener('click', this.showModal)
|
|
|
+ if (Array.isArray(showModalTrigger)) {
|
|
|
+ showModalTrigger.forEach(trigger => trigger.addEventListener('click', this.show))
|
|
|
+ } else {
|
|
|
+ showModalTrigger.addEventListener('click', this.show)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (!this.opts.inline && !showModalTrigger) {
|
|
@@ -215,7 +223,11 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
removeEvents () {
|
|
|
const showModalTrigger = findDOMElement(this.opts.trigger)
|
|
|
if (!this.opts.inline && showModalTrigger) {
|
|
|
- showModalTrigger.removeEventListener('click', this.showModal)
|
|
|
+ if (Array.isArray(showModalTrigger)) {
|
|
|
+ showModalTrigger.forEach(trigger => trigger.removeEventListener('click', this.show))
|
|
|
+ } else {
|
|
|
+ showModalTrigger.removeEventListener('click', this.show)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
this.removeDragDropListener()
|
|
@@ -259,7 +271,7 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
}
|
|
|
|
|
|
handleDrop (files) {
|
|
|
- this.core.log('All right, someone dropped something...')
|
|
|
+ this.core.log('[Dashboard] Files were droppeded')
|
|
|
|
|
|
files.forEach((file) => {
|
|
|
this.core.addFile({
|
|
@@ -300,7 +312,6 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
inProgressFilesArray.push(files[file])
|
|
|
})
|
|
|
|
|
|
-
|
|
|
let totalSize = 0
|
|
|
let totalUploadedSize = 0
|
|
|
inProgressFilesArray.forEach((file) => {
|
|
@@ -326,7 +337,7 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
}
|
|
|
|
|
|
const pauseUpload = (fileID) => {
|
|
|
- this.core.emit.emit('core:upload-pause', fileID)
|
|
|
+ this.core.emit('core:upload-pause', fileID)
|
|
|
}
|
|
|
|
|
|
const cancelUpload = (fileID) => {
|
|
@@ -343,9 +354,9 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
this.core.emit('dashboard:file-card')
|
|
|
}
|
|
|
|
|
|
- const info = (text, type, duration) => {
|
|
|
- this.core.info(text, type, duration)
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
const resumableUploads = this.core.state.capabilities.resumableUploads || false
|
|
|
|
|
@@ -362,7 +373,7 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
autoProceed: this.core.opts.autoProceed,
|
|
|
hideUploadButton: this.opts.hideUploadButton,
|
|
|
id: this.id,
|
|
|
- hideModal: this.hideModal,
|
|
|
+ hide: this.hide,
|
|
|
handleClickOutside: this.handleClickOutside,
|
|
|
showProgressDetails: this.opts.showProgressDetails,
|
|
|
inline: this.opts.inline,
|
|
@@ -375,7 +386,7 @@ module.exports = class DashboardUI extends Plugin {
|
|
|
resumeAll: this.resumeAll,
|
|
|
addFile: this.core.addFile,
|
|
|
removeFile: this.core.removeFile,
|
|
|
- info: info,
|
|
|
+ info: this.core.info,
|
|
|
note: this.opts.note,
|
|
|
metaFields: state.metaFields,
|
|
|
resumableUploads: resumableUploads,
|