fix: better error messages for dashboard properties modal (#11382)

This commit is contained in:
ʈᵃᵢ 2020-10-26 16:36:37 -07:00 committed by GitHub
parent 59885c4dea
commit 2227b13b52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -202,13 +202,25 @@ class PropertiesModal extends React.PureComponent {
}
async handleErrorResponse(response) {
const { error, statusText } = await getClientErrorObject(response);
const { error, statusText, message } = await getClientErrorObject(response);
let errorText = error || statusText || t('An error has occurred');
if (typeof message === 'object' && message.json_metadata) {
errorText = message.json_metadata;
} else if (typeof message === 'string') {
errorText = message;
if (message === 'Forbidden') {
errorText = t('You do not have permission to edit this dashboard');
}
}
this.dialog.show({
title: 'Error',
bsSize: 'medium',
bsStyle: 'danger',
actions: [Dialog.DefaultAction('Ok', () => {}, 'btn-danger')],
body: error || statusText || t('An error has occurred'),
body: errorText,
});
}