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:
parent
1f6ea6fb3f
commit
5d00a4d967
1 changed files with 7 additions and 1 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue