diff --git a/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx b/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx index 75d0b9a7..79522bc1 100644 --- a/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx +++ b/public/components/MDSEnabledComponent/MDSEnabledComponent.tsx @@ -31,4 +31,8 @@ export function isDataSourceChanged(prevProps, currentProps) { return false; } +export function isDataSourceError(error) { + return (error.body && error.body.message && error.body.message.includes("Data Source Error")); +} + diff --git a/public/pages/Channels/Channels.tsx b/public/pages/Channels/Channels.tsx index df6afc58..f472761a 100644 --- a/public/pages/Channels/Channels.tsx +++ b/public/pages/Channels/Channels.tsx @@ -39,7 +39,10 @@ import { ChannelActions } from './components/ChannelActions'; import { ChannelControls } from './components/ChannelControls'; import { ChannelFiltersType } from './types'; import { DataSourceMenuProperties } from '../../services/DataSourceMenuContext'; -import MDSEnabledComponent, { isDataSourceChanged } from '../../components/MDSEnabledComponent/MDSEnabledComponent'; +import MDSEnabledComponent, { + isDataSourceChanged, + isDataSourceError, +} from '../../components/MDSEnabledComponent/MDSEnabledComponent'; interface ChannelsProps extends RouteComponentProps, DataSourceMenuProperties { notificationService: NotificationService; @@ -158,6 +161,9 @@ export class Channels extends MDSEnabledComponent ); this.setState({ items: channels.items, total: channels.total }); } catch (error) { + if (isDataSourceError(error)) { + this.setState({ items: [], total: 0 }); + } this.context.notifications.toasts.addDanger( getErrorMessage(error, 'There was a problem loading channels.') ); diff --git a/public/pages/Emails/components/tables/RecipientGroupsTable.tsx b/public/pages/Emails/components/tables/RecipientGroupsTable.tsx index b23b7c7c..50205e04 100644 --- a/public/pages/Emails/components/tables/RecipientGroupsTable.tsx +++ b/public/pages/Emails/components/tables/RecipientGroupsTable.tsx @@ -34,7 +34,10 @@ import { getErrorMessage } from '../../../../utils/helpers'; import { DetailsListModal } from '../../../Channels/components/modals/DetailsListModal'; import { DEFAULT_PAGE_SIZE_OPTIONS } from '../../../Notifications/utils/constants'; import { DeleteRecipientGroupModal } from '../modals/DeleteRecipientGroupModal'; -import { isDataSourceChanged } from '../../../../components/MDSEnabledComponent/MDSEnabledComponent'; +import { + isDataSourceError, + isDataSourceChanged, +} from '../../../../components/MDSEnabledComponent/MDSEnabledComponent'; interface RecipientGroupsTableProps { coreContext: CoreStart; @@ -166,6 +169,9 @@ export class RecipientGroupsTable extends Component< total: recipientGroups.total, }); } catch (error) { + if (isDataSourceError(error)) { + this.setState({ items: [], total: 0 }); + } this.props.coreContext.notifications.toasts.addDanger( getErrorMessage(error, 'There was a problem loading recipient groups.') ); diff --git a/public/pages/Emails/components/tables/SESSendersTable.tsx b/public/pages/Emails/components/tables/SESSendersTable.tsx index 7500d2e4..bf749009 100644 --- a/public/pages/Emails/components/tables/SESSendersTable.tsx +++ b/public/pages/Emails/components/tables/SESSendersTable.tsx @@ -32,7 +32,10 @@ import { ROUTES } from '../../../../utils/constants'; import { getErrorMessage } from '../../../../utils/helpers'; import { DEFAULT_PAGE_SIZE_OPTIONS } from '../../../Notifications/utils/constants'; import { DeleteSenderModal } from '../modals/DeleteSenderModal'; -import { isDataSourceChanged } from '../../../../components/MDSEnabledComponent/MDSEnabledComponent'; +import { + isDataSourceError, + isDataSourceChanged, +} from '../../../../components/MDSEnabledComponent/MDSEnabledComponent'; interface SESSendersTableProps { coreContext: CoreStart; @@ -130,6 +133,9 @@ export class SESSendersTable extends Component< ); this.setState({ items: senders.items, total: senders.total }); } catch (error) { + if (isDataSourceError(error)) { + this.setState({ items: [], total: 0 }); + } this.props.coreContext.notifications.toasts.addDanger( getErrorMessage(error, 'There was a problem loading SES senders.') ); diff --git a/public/pages/Emails/components/tables/SendersTable.tsx b/public/pages/Emails/components/tables/SendersTable.tsx index 32f38c57..ebbf5d9d 100644 --- a/public/pages/Emails/components/tables/SendersTable.tsx +++ b/public/pages/Emails/components/tables/SendersTable.tsx @@ -32,7 +32,10 @@ import { SendersTableControls, SendersTableControlsFilterType, } from './SendersTableControls'; -import { isDataSourceChanged } from '../../../../components/MDSEnabledComponent/MDSEnabledComponent'; +import { + isDataSourceError, + isDataSourceChanged, +} from '../../../../components/MDSEnabledComponent/MDSEnabledComponent'; interface SendersTableProps { coreContext: CoreStart; @@ -151,6 +154,9 @@ export class SendersTable extends Component< ); this.setState({ items: senders.items, total: senders.total }); } catch (error) { + if (isDataSourceError(error)) { + this.setState({ items: [], total: 0 }); + } this.props.coreContext.notifications.toasts.addDanger( getErrorMessage(error, 'There was a problem loading SMTP senders.') );