mirror of
https://github.com/transloadit/uppy.git
synced 2026-07-18 00:55:35 +00:00
robodog: actually support specifying Dashboard options (#1504)
robodog: actually support specifying Dashboard options
This commit is contained in:
commit
9a6d487d4e
5 changed files with 61 additions and 6 deletions
|
|
@ -54,6 +54,7 @@ const formUppyWithDashboard = robodog.form('#dashboard-form', {
|
|||
allowedFileTypes: ['.png']
|
||||
},
|
||||
waitForEncoding: true,
|
||||
note: 'Only PNG files please!',
|
||||
params: {
|
||||
auth: { key: TRANSLOADIT_KEY },
|
||||
template_id: TEMPLATE_ID
|
||||
|
|
@ -66,6 +67,7 @@ window.formUppyWithDashboard = formUppyWithDashboard
|
|||
const dashboard = robodog.dashboard('#dashboard', {
|
||||
debug: true,
|
||||
waitForEncoding: true,
|
||||
note: 'Images will be resized with Transloadit',
|
||||
params: {
|
||||
auth: { key: TRANSLOADIT_KEY },
|
||||
template_id: TEMPLATE_ID
|
||||
|
|
|
|||
53
packages/@uppy/robodog/src/addDashboardPlugin.js
Normal file
53
packages/@uppy/robodog/src/addDashboardPlugin.js
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
const Dashboard = require('@uppy/dashboard')
|
||||
|
||||
const dashboardOptionNames = [
|
||||
'metaFields',
|
||||
'width',
|
||||
'height',
|
||||
'thumbnailWidth',
|
||||
'showLinkToFileUploadResult',
|
||||
'showProgressDetails',
|
||||
'hideRetryButton',
|
||||
'hidePauseResumeCancelButtons',
|
||||
'hideProgressAfterFinish',
|
||||
'note',
|
||||
'disableStatusBar',
|
||||
'disableInformer',
|
||||
'disableThumbnailGenerator',
|
||||
'showSelectedFiles'
|
||||
]
|
||||
|
||||
const modalDashboardOptionNames = [
|
||||
'trigger',
|
||||
'closeModalOnClickOutside',
|
||||
'closeAfterFinish',
|
||||
'disablePageScrollWhenModalOpen',
|
||||
'animateOpenClose',
|
||||
'onRequestCloseModal',
|
||||
'browserBackButtonClose'
|
||||
]
|
||||
|
||||
function addDashboardPlugin (uppy, opts, overrideOpts) {
|
||||
const dashboardOpts = {}
|
||||
dashboardOptionNames.forEach((key) => {
|
||||
if (opts.hasOwnProperty(key)) {
|
||||
dashboardOpts[key] = opts[key]
|
||||
}
|
||||
})
|
||||
|
||||
const inline = overrideOpts.inline == null ? dashboardOpts.inline : overrideOpts.inline
|
||||
if (inline === false) {
|
||||
modalDashboardOptionNames.forEach((key) => {
|
||||
if (opts.hasOwnProperty(key)) {
|
||||
dashboardOpts[key] = opts[key]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
uppy.use(Dashboard, {
|
||||
...dashboardOpts,
|
||||
...overrideOpts
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = addDashboardPlugin
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
const Dashboard = require('@uppy/dashboard')
|
||||
const createUppy = require('./createUppy')
|
||||
const addDashboardPlugin = require('./addDashboardPlugin')
|
||||
const addTransloaditPlugin = require('./addTransloaditPlugin')
|
||||
const addProviders = require('./addProviders')
|
||||
|
||||
|
|
@ -9,7 +9,7 @@ function dashboard (target, opts = {}) {
|
|||
const pluginId = 'Dashboard'
|
||||
const uppy = createUppy(opts)
|
||||
addTransloaditPlugin(uppy, opts)
|
||||
uppy.use(Dashboard, {
|
||||
addDashboardPlugin(uppy, opts, {
|
||||
id: pluginId,
|
||||
inline,
|
||||
target,
|
||||
|
|
|
|||
|
|
@ -1,10 +1,10 @@
|
|||
const Uppy = require('@uppy/core')
|
||||
const Form = require('@uppy/form')
|
||||
const StatusBar = require('@uppy/status-bar')
|
||||
const Dashboard = require('@uppy/dashboard')
|
||||
const findDOMElement = require('@uppy/utils/lib/findDOMElement')
|
||||
const AttachFileInputs = require('./AttachFileInputs')
|
||||
const TransloaditFormResult = require('./TransloaditFormResult')
|
||||
const addDashboardPlugin = require('./addDashboardPlugin')
|
||||
const addTransloaditPlugin = require('./addTransloaditPlugin')
|
||||
const addProviders = require('./addProviders')
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ function form (target, opts) {
|
|||
dashboardOpts.inline = true
|
||||
dashboardOpts.hideUploadButton = true
|
||||
}
|
||||
uppy.use(Dashboard, dashboardOpts)
|
||||
addDashboardPlugin(uppy, opts, dashboardOpts)
|
||||
|
||||
if (Array.isArray(opts.providers)) {
|
||||
addProviders(uppy, opts.providers, {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
const Dashboard = require('@uppy/dashboard')
|
||||
const createUppy = require('./createUppy')
|
||||
const addDashboardPlugin = require('./addDashboardPlugin')
|
||||
const addTransloaditPlugin = require('./addTransloaditPlugin')
|
||||
const addProviders = require('./addProviders')
|
||||
|
||||
|
|
@ -13,7 +13,7 @@ function pick (opts = {}) {
|
|||
allowMultipleUploads: false
|
||||
})
|
||||
addTransloaditPlugin(uppy, opts)
|
||||
uppy.use(Dashboard, {
|
||||
addDashboardPlugin(uppy, opts, {
|
||||
id: pluginId,
|
||||
target,
|
||||
closeAfterFinish: true
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue