Skip to content

Commit 0769bf4

Browse files
committed
Some changes to appease the Uppy gods
1 parent ba72e6d commit 0769bf4

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

Gemfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ gem 'rails', '~> 7.1.3'
99
gem 'pg', '>= 0.18', '< 2.0'
1010
# Use Puma as the app server
1111
gem 'puma', '~> 6.0'
12-
# Use SCSS for stylesheets
13-
gem 'sass-rails', '>= 6'
12+
# We still use Sprockets/Sass for serviceworker-rails/activeadmin FIXME
13+
gem 'sass-rails'
1414
# Transpile JavaScript/CSS
1515
gem 'cssbundling-rails', '~> 1.1'
1616
gem 'jsbundling-rails', '~> 1.1'

Gemfile.lock

+1-1
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ DEPENDENCIES
635635
rswag-api (~> 2.4)
636636
rswag-specs (~> 2.4)
637637
rswag-ui (~> 2.4)
638-
sass-rails (>= 6)
638+
sass-rails
639639
serviceworker-rails (~> 0.6.0)!
640640
simple_form (~> 5.0)
641641
spicy-proton (~> 2.1)

app/javascript/controllers/likeness_uploader_controller.ts

+7-9
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Controller } from "@hotwired/stimulus"
22

3-
import Uppy from '@uppy/core'
3+
import Uppy, { Meta } from '@uppy/core'
44
import XHRUpload from '@uppy/xhr-upload'
55
import Dashboard from '@uppy/dashboard'
66
import ImageEditor from '@uppy/image-editor'
@@ -31,14 +31,12 @@ export default class extends Controller {
3131
override connect(): void {
3232
this.uploader
3333
.use(Dashboard, {
34-
autoOpenFileEditor: true,
34+
autoOpen: 'imageEditor'
3535
})
3636
.use(Webcam, {
37-
target: Dashboard,
3837
modes: ['picture']
3938
})
4039
.use(ImageEditor, {
41-
target: Dashboard,
4240
quality: 0.8,
4341
cropperOptions: {
4442
aspectRatio: 1,
@@ -58,7 +56,6 @@ export default class extends Controller {
5856
})
5957
.use(XHRUpload, {
6058
endpoint: this.endpointValue,
61-
// @ts-expect-error until https://github.com/transloadit/uppy/pull/5279
6259
method: 'PATCH',
6360
fieldName: this.fieldNameValue,
6461
headers: {
@@ -73,20 +70,21 @@ export default class extends Controller {
7370
this.uploader.cancelAll()
7471
})
7572
this.uploader.on('complete', result => {
76-
if (result.successful.length > 0) {
73+
if (result.successful && result.successful.length > 0) {
7774
let img = document.createElement('img')
78-
img.setAttribute('src', result.successful[0].uploadURL)
75+
img.setAttribute('src', result.successful[0].uploadURL ?? '')
7976
this.previewTarget.innerHTML = ''
8077
this.previewTarget.appendChild(img)
8178
this.deleteTarget.disabled = false;
82-
(this.uploader.getPlugin('Dashboard') as Dashboard).closeModal()
79+
// FIXME: Should have a stricter type than 'any'
80+
(this.uploader.getPlugin('Dashboard') as any).closeModal()
8381
this.uploader.cancelAll()
8482
}
8583
})
8684
}
8785

8886
public start(): void {
89-
(this.uploader.getPlugin('Dashboard') as Dashboard).openModal()
87+
(this.uploader.getPlugin('Dashboard') as any).openModal()
9088
}
9189

9290
}

0 commit comments

Comments
 (0)