Skip to content

Commit

Permalink
add list of failed channels on test message failure
Browse files Browse the repository at this point in the history
Signed-off-by: David Cui <davidcui@amazon.com>
  • Loading branch information
davidcui1225 committed Jul 30, 2021
1 parent 719f9a7 commit 65c3871
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ export function ReportDelivery(props: ReportDeliveryProps) {
if (selectedChannels.length === 0) {
handleTestMessageConfirmation(noDeliveryChannelsSelectedMessage);
}
let testMessageFailures = false;
let failedChannels: string[] = [];
// for each config ID in the current channels list
for (let i = 0; i < selectedChannels.length; ++i) {
try {
Expand All @@ -189,17 +191,20 @@ export function ReportDelivery(props: ReportDeliveryProps) {
.then((response) => {
if (!response.success) {
const error = new Error('Failed to send the test message.');
failedChannels.push(response.status_list[0].config_name);
error.stack = JSON.stringify(response.status_list, null, 2);
throw error;
}
else {
handleTestMessageConfirmation(testMessageConfirmationMessage);
}
});
} catch (error) {
// error message
handleTestMessageConfirmation(testMessageFailureMessage);
testMessageFailures = true;
}
}
if (testMessageFailures) {
handleTestMessageConfirmation(testMessageFailureMessage(failedChannels));
} else {
handleTestMessageConfirmation(testMessageConfirmationMessage);
}
}

const checkIfNotificationsPluginIsInstalled = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ export const testMessageConfirmationMessage = (
</EuiText>
);

export const testMessageFailureMessage = (
export const testMessageFailureMessage = (failedChannels: Array<string>) => (
<EuiText size='s'>
<EuiIcon type='alert'/> Failed to send test message. Please adjust channel settings.
<EuiIcon type='alert'/> Failed to send test message for some channels. Please adjust channel settings for {failedChannels.toString()}
</EuiText>
)

Expand Down

0 comments on commit 65c3871

Please sign in to comment.