Show image-upload errors on /admin/advanced/tools (#16448)

* Show image-upload errors on /admin/advanced/tools

* Simplify error handling

This also makes the error message consistent with the rest of the admin
validation errors, so it's probably better even if it doesn't look as
flashy.

* Remove obsolete clearTimeout call

We aren't setting this timer anymore
This commit is contained in:
Jamie Gaskins 2022-02-08 10:41:54 -05:00 committed by GitHub
parent 1f6ea6fb3f
commit 5d00a4d967
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,5 @@
import { Controller } from '@hotwired/stimulus';
import { displayErrorAlert } from '../messageUtilities';
export default class ImageUploadController extends Controller {
static targets = ['fileField', 'imageResult'];
@ -29,7 +30,8 @@ export default class ImageUploadController extends Controller {
}
const { links } = json;
return this.onUploadSuccess(links);
});
})
.catch(this.onUploadFailure);
}
onUploadSuccess(result) {
@ -45,4 +47,8 @@ export default class ImageUploadController extends Controller {
`;
this.imageResultTarget.innerHTML = output;
}
onUploadFailure(error) {
displayErrorAlert(error.message);
}
}