From 1da877ed73de500fe78eea8cdc183643d16cf465 Mon Sep 17 00:00:00 2001 From: Daniel Vaz Gaspar Date: Wed, 10 Feb 2021 08:17:54 +0000 Subject: [PATCH] fix: UI toast typo (#13026) * fix: UI toast typo * translate * fix error msg --- .../components/ListViewCard/ImageLoader.tsx | 4 ++-- .../CRUD/data/database/DatabaseModal.tsx | 4 ++-- superset-frontend/src/views/CRUD/utils.tsx | 4 ++-- .../src/views/CRUD/welcome/Welcome.tsx | 20 ++++++++++++------- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/superset-frontend/src/components/ListViewCard/ImageLoader.tsx b/superset-frontend/src/components/ListViewCard/ImageLoader.tsx index 6ca7ff2091b94..f08a237d237be 100644 --- a/superset-frontend/src/components/ListViewCard/ImageLoader.tsx +++ b/superset-frontend/src/components/ListViewCard/ImageLoader.tsx @@ -64,8 +64,8 @@ export default function ImageLoader({ setImgSrc(imgURL); } }) - .catch(e => { - logging.error(e); + .catch(errMsg => { + logging.error(errMsg); setImgSrc(fallback); }); } diff --git a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx index 59cf8ee9fb935..081fb35809c64 100644 --- a/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx +++ b/superset-frontend/src/views/CRUD/data/database/DatabaseModal.tsx @@ -302,11 +302,11 @@ const DatabaseModal: FunctionComponent = ({ .then(() => { setDB(dbFetched); }) - .catch(e => + .catch(errMsg => addDangerToast( t( 'Sorry there was an error fetching database information: %s', - e.message, + errMsg.message, ), ), ); diff --git a/superset-frontend/src/views/CRUD/utils.tsx b/superset-frontend/src/views/CRUD/utils.tsx index 757f7b66f4856..638735dfc52f8 100644 --- a/superset-frontend/src/views/CRUD/utils.tsx +++ b/superset-frontend/src/views/CRUD/utils.tsx @@ -144,10 +144,10 @@ export const getRecentAcitivtyObjs = ( ]; return res; }) - .catch(e => + .catch(errMsg => addDangerToast( t('There was an error fetching your recent activity:'), - e, + errMsg, ), ); } diff --git a/superset-frontend/src/views/CRUD/welcome/Welcome.tsx b/superset-frontend/src/views/CRUD/welcome/Welcome.tsx index 83163db150d8c..836da13cb48b7 100644 --- a/superset-frontend/src/views/CRUD/welcome/Welcome.tsx +++ b/superset-frontend/src/views/CRUD/welcome/Welcome.tsx @@ -23,7 +23,11 @@ import { User } from 'src/types/bootstrapTypes'; import { reject } from 'lodash'; import withToasts from 'src/messageToasts/enhancers/withToasts'; import Loading from 'src/components/Loading'; -import { getRecentAcitivtyObjs, mq } from '../utils'; +import { + createErrorHandler, + getRecentAcitivtyObjs, + mq, +} from 'src/views/CRUD/utils'; import ActivityTable from './ActivityTable'; import ChartTable from './ChartTable'; @@ -111,12 +115,14 @@ function Welcome({ user, addDangerToast }: WelcomeProps) { setActivityData(data); setLoading(false); }) - .catch(e => { - setLoading(false); - addDangerToast( - `There was an issue fetching your recent acitivity: ${e}`, - ); - }); + .catch( + createErrorHandler((errMsg: unknown) => { + setLoading(false); + addDangerToast( + t('There was an issue fetching your recent activity: %s', errMsg), + ); + }), + ); }, []); return (