💅 Show proper error messages for 'File Upload' plugin

This commit is contained in:
REDDY PRASAD 2019-03-02 19:53:33 +05:30
parent c50a586418
commit 5539a3e27c
2 changed files with 10 additions and 5 deletions

View File

@ -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());
}

View File

@ -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"
}