mirror of
https://github.com/strapi/strapi.git
synced 2025-11-01 18:33:55 +00:00
💅 Show proper error messages for 'File Upload' plugin
This commit is contained in:
parent
c50a586418
commit
5539a3e27c
@ -1,6 +1,6 @@
|
||||
// import { LOCATION_CHANGE } from 'react-router-redux';
|
||||
import { Map } from 'immutable';
|
||||
import { isEmpty } from 'lodash';
|
||||
import { isEmpty, get, isObject } from 'lodash';
|
||||
import {
|
||||
all,
|
||||
call,
|
||||
@ -81,8 +81,11 @@ function* uploadFiles(action) {
|
||||
strapi.notification.success({ id: 'upload.notification.dropFiles.success', values: { number: newFiles.length } });
|
||||
}
|
||||
|
||||
} catch(err) {
|
||||
strapi.notification.error('notification.error');
|
||||
} catch(error) {
|
||||
let message = get(error, ['response', 'payload', 'message', '0', 'messages', '0']);
|
||||
if (isObject(message)) message = {...message, id: `upload.${message.id}`};
|
||||
|
||||
strapi.notification.error(message || 'notification.error');
|
||||
} finally {
|
||||
yield put(unsetLoading());
|
||||
}
|
||||
|
||||
@ -24,5 +24,7 @@
|
||||
"notification.config.success": "The settings has been updated",
|
||||
"notification.delete.success": "The file has been deleted",
|
||||
"notification.dropFile.success": "Your file has been uploaded",
|
||||
"notification.dropFiles.success": "{number} files have been uploaded"
|
||||
}
|
||||
"notification.dropFiles.success": "{number} files have been uploaded",
|
||||
"Upload.status.sizeLimit": "{file} is bigger than configured limit size",
|
||||
"Upload.status.disabled" : "File upload is disabled"
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user