diff --git a/superset-frontend/src/components/ReportModal/index.tsx b/superset-frontend/src/components/ReportModal/index.tsx index 148b03376ebc..ec2ee4ab321c 100644 --- a/superset-frontend/src/components/ReportModal/index.tsx +++ b/superset-frontend/src/components/ReportModal/index.tsx @@ -225,7 +225,7 @@ const ReportModal: FunctionComponent = ({ onClick={onSave} disabled={!currentReport?.name} > - Add + {isEditMode ? t('Save') : t('Add')} ); diff --git a/superset-frontend/src/reports/actions/reports.js b/superset-frontend/src/reports/actions/reports.js index 04073837aad5..c7eb0c934561 100644 --- a/superset-frontend/src/reports/actions/reports.js +++ b/superset-frontend/src/reports/actions/reports.js @@ -19,6 +19,7 @@ /* eslint camelcase: 0 */ import { t, SupersetClient } from '@superset-ui/core'; import rison from 'rison'; +import { getClientErrorObject } from 'src/utils/getClientErrorObject'; import { addDangerToast, addSuccessToast } from '../../messageToasts/actions'; export const SET_REPORT = 'SET_REPORT'; @@ -106,11 +107,17 @@ export const addReport = report => dispatch => { dispatch({ type: ADD_REPORT, json }); dispatch(addSuccessToast(t('The report has been created'))); }) - .catch(() => + .catch(async e => { + const parsedError = await getClientErrorObject(e); + const errorMessage = parsedError.message; + const errorArr = Object.keys(errorMessage); + const error = errorMessage[errorArr[0]][0]; dispatch( - addDangerToast(t('An error occurred while creating this report.')), - ), - ); + addDangerToast( + t('An error occurred while editing this report: %s', error), + ), + ); + }); }; export const EDIT_REPORT = 'EDIT_REPORT';