Skip to content

Commit

Permalink
Backport/backport 192 to 2.x (#199)
Browse files Browse the repository at this point in the history
Signed-off-by: Riya Saxena <[email protected]>
  • Loading branch information
riysaxen-amzn authored Apr 27, 2024
1 parent 0954519 commit 51b55ea
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
4 changes: 4 additions & 0 deletions public/components/MDSEnabledComponent/MDSEnabledComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
}


8 changes: 7 additions & 1 deletion public/pages/Channels/Channels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -158,6 +161,9 @@ export class Channels extends MDSEnabledComponent<ChannelsProps, ChannelsState>
);
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.')
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.')
);
Expand Down
8 changes: 7 additions & 1 deletion public/pages/Emails/components/tables/SESSendersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.')
);
Expand Down
8 changes: 7 additions & 1 deletion public/pages/Emails/components/tables/SendersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.')
);
Expand Down

0 comments on commit 51b55ea

Please sign in to comment.