fix: better error message for chart properties modal (#11381)

This commit is contained in:
ʈᵃᵢ 2020-10-26 13:33:19 -07:00 committed by GitHub
parent af337b9e5a
commit 910791b00b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -63,13 +63,17 @@ function PropertiesModal({ slice, onHide, onSave }: InternalProps) {
);
const [owners, setOwners] = useState<OptionsType<OwnerOption> | null>(null);
function showError({ error, statusText }: any) {
function showError({ error, statusText, message }: any) {
let errorText = error || statusText || t('An error has occurred');
if (message === 'Forbidden') {
errorText = t('You do not have permission to edit this chart');
}
errorDialog.current.show({
title: 'Error',
bsSize: 'medium',
bsStyle: 'danger',
actions: [Dialog.DefaultAction('Ok', () => {}, 'btn-danger')],
body: error || statusText || t('An error has occurred'),
body: errorText,
});
}