From b570b74e01a35ea3ac3c5e270cf14428f5ca2af8 Mon Sep 17 00:00:00 2001 From: Tai Dupree Date: Wed, 21 Oct 2020 20:20:41 -0700 Subject: [PATCH] fix: better error messages for dashboard properties modal --- .../src/dashboard/components/PropertiesModal.jsx | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/superset-frontend/src/dashboard/components/PropertiesModal.jsx b/superset-frontend/src/dashboard/components/PropertiesModal.jsx index ede44fa9f3cce..2a042c8acba0d 100644 --- a/superset-frontend/src/dashboard/components/PropertiesModal.jsx +++ b/superset-frontend/src/dashboard/components/PropertiesModal.jsx @@ -165,13 +165,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, }); }