Skip to content

Commit

Permalink
upgrade uppy to 2.3.x (#1761)
Browse files Browse the repository at this point in the history
* upgrade uppy to 2.3.x

* migrate Uppy usage to wepack
  • Loading branch information
johrstrom authored Jan 12, 2022
1 parent 189683f commit 70cd670
Show file tree
Hide file tree
Showing 6 changed files with 349 additions and 459 deletions.
1 change: 0 additions & 1 deletion apps/dashboard/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
//= require data-confirm-modal
//= require handlebars/dist/handlebars.min
//= require lodash/lodash.min
//= require uppy/dist/uppy.min
//= require_tree .

//FIXME: move to coffescript
Expand Down
7 changes: 7 additions & 0 deletions apps/dashboard/app/javascript/packs/files.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import ClipboardJS from 'clipboard'
import Swal from 'sweetalert2'
import { Uppy, BasePlugin } from '@uppy/core'
import Dashboard from '@uppy/dashboard'
import XHRUpload from '@uppy/xhr-upload'

window.ClipboardJS = ClipboardJS
window.Uppy = Uppy
window.BasePlugin = BasePlugin
window.Dashboard = Dashboard
window.XHRUpload = XHRUpload
window.Swal = Swal.mixin({
showClass: {
popup: 'swal2-noanimation',
Expand Down
8 changes: 4 additions & 4 deletions apps/dashboard/app/views/files/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@ function getFilesAndDirectoriesFromDirectory (directoryReader, oldEntries, logDr
}

(function(){
class EmptyDirCreator extends Uppy.Core.Plugin {
class EmptyDirCreator extends BasePlugin {
constructor (uppy, opts){
super(uppy, opts)
this.id = this.opts.id || 'EmptyDirUploaderCatcher';
Expand Down Expand Up @@ -536,13 +536,13 @@ function getFilesAndDirectoriesFromDirectory (directoryReader, oldEntries, logDr
}


window.uppy = Uppy.Core({
window.uppy = new Uppy({
restrictions: {
maxFileSize: <%= Configuration.file_upload_max %>,
}
});
uppy.use(EmptyDirCreator);
uppy.use(Uppy.Dashboard, {
uppy.use(Dashboard, {
trigger: '#upload-btn',
fileManagerSelectionType: 'both',
disableThumbnailGenerator: true,
Expand All @@ -553,7 +553,7 @@ function getFilesAndDirectoriesFromDirectory (directoryReader, oldEntries, logDr
onRequestCloseModal: () => closeAndResetUppyModal(uppy),
note: 'Empty directories will be included in the upload only when a directory upload is initiated via drag and drop. This is because the File and Directory Entries API is available only on a drop event, not during an input change event.'
});
uppy.use(Uppy.XHRUpload, {
uppy.use(XHRUpload, {
endpoint: '<%= files_upload_path %>',
withCredentials: true,
fieldName: 'file',
Expand Down
1 change: 1 addition & 0 deletions apps/dashboard/babel.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ module.exports = function(api) {
}

return {
sourceType: 'unambiguous',
presets: [
isTestEnv && [
'@babel/preset-env',
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"oboe": "^2.1.5",
"popper.js": "1.14.3",
"sweetalert2": "^10.15.7",
"uppy": "^1.27.0",
"uppy": "^2.3.3",
"webpack-merge": "^5.8.0"
}
}
Loading

0 comments on commit 70cd670

Please sign in to comment.