uppy/packages/@uppy/robodog/src/addDashboardPlugin.js
Artur Paikin 68f36b1ac2
Refactor FileProgress component (#2303)
* refactor FileProgress component; pass hideCancelButton, hidePauseResumeButton and hideRetryButton

* move icons to where they are rendered, rename UppyIcon to uppy-u-icon

* cleanup: rename DashboardItem, remove xmlns

* update docs to specify the option also hides action button on each individual file
2020-06-06 04:10:01 +02:00

57 lines
1.2 KiB
JavaScript

const Dashboard = require('@uppy/dashboard')
const has = require('@uppy/utils/lib/hasProperty')
const dashboardOptionNames = [
'metaFields',
'width',
'height',
'thumbnailWidth',
'showLinkToFileUploadResult',
'showProgressDetails',
'hideRetryButton',
'hideCancelButton',
'hideUploadButton',
'hideProgressAfterFinish',
'note',
'disableStatusBar',
'disableInformer',
'disableThumbnailGenerator',
'showSelectedFiles',
'proudlyDisplayPoweredByUppy',
'theme'
]
const modalDashboardOptionNames = [
'trigger',
'closeModalOnClickOutside',
'closeAfterFinish',
'disablePageScrollWhenModalOpen',
'animateOpenClose',
'onRequestCloseModal',
'browserBackButtonClose'
]
function addDashboardPlugin (uppy, opts, overrideOpts) {
const dashboardOpts = {}
dashboardOptionNames.forEach((key) => {
if (has(opts, key)) {
dashboardOpts[key] = opts[key]
}
})
const inline = overrideOpts.inline == null ? dashboardOpts.inline : overrideOpts.inline
if (!inline) {
modalDashboardOptionNames.forEach((key) => {
if (has(opts, key)) {
dashboardOpts[key] = opts[key]
}
})
}
uppy.use(Dashboard, {
...dashboardOpts,
...overrideOpts
})
}
module.exports = addDashboardPlugin