mirror of
https://github.com/strapi/strapi.git
synced 2025-11-13 00:29:51 +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 { LOCATION_CHANGE } from 'react-router-redux';
|
||||||
import { Map } from 'immutable';
|
import { Map } from 'immutable';
|
||||||
import { isEmpty } from 'lodash';
|
import { isEmpty, get, isObject } from 'lodash';
|
||||||
import {
|
import {
|
||||||
all,
|
all,
|
||||||
call,
|
call,
|
||||||
@ -81,8 +81,11 @@ function* uploadFiles(action) {
|
|||||||
strapi.notification.success({ id: 'upload.notification.dropFiles.success', values: { number: newFiles.length } });
|
strapi.notification.success({ id: 'upload.notification.dropFiles.success', values: { number: newFiles.length } });
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch(err) {
|
} catch(error) {
|
||||||
strapi.notification.error('notification.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 {
|
} finally {
|
||||||
yield put(unsetLoading());
|
yield put(unsetLoading());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -24,5 +24,7 @@
|
|||||||
"notification.config.success": "The settings has been updated",
|
"notification.config.success": "The settings has been updated",
|
||||||
"notification.delete.success": "The file has been deleted",
|
"notification.delete.success": "The file has been deleted",
|
||||||
"notification.dropFile.success": "Your file has been uploaded",
|
"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