Skip to content

Commit d7c16ba

Browse files
committed
Ensure toasts fired in an AssetUploaded event are delivered to front end
1 parent 4f835e2 commit d7c16ba

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

resources/js/components/assets/Uploader.vue

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,8 @@ export default {
268268
handleUploadSuccess(id, response) {
269269
this.$emit('upload-complete', response.data, this.uploads);
270270
this.uploads.splice(this.findUploadIndex(id), 1);
271+
272+
this.handleToasts(response._toasts ?? []);
271273
},
272274
273275
handleUploadError(id, status, response) {
@@ -284,12 +286,19 @@ export default {
284286
msg = Object.values(response.errors)[0][0]; // Get first validation message.
285287
}
286288
}
289+
290+
this.handleToasts(response._toasts ?? []);
291+
287292
upload.errorMessage = msg;
288293
upload.errorStatus = status;
289294
this.$emit('error', upload, this.uploads);
290295
this.processUploadQueue();
291296
},
292297
298+
handleToasts(toasts) {
299+
toasts.forEach(toast => Statamic.$toast[toast.type](toast.message, {duration: toast.duration}));
300+
},
301+
293302
retry(id, args) {
294303
let file = this.findUpload(id).instance.form.get('file');
295304
this.addFile(file, args);

0 commit comments

Comments
 (0)