Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe('useAddSuggestedDashboards', () => {
// Check that notifications.toasts.addSuccess was called
expect(mockUseKibanaReturnValue.services.notifications.toasts.addSuccess).toHaveBeenCalledWith({
title: 'Added to linked dashboard',
text: `From now on this dashboard will be linked to all alerts related to ${TEST_RULE_NAME}`,
text: `From now on, this dashboard will be linked to all alerts triggered by this rule`,
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,21 @@ export const useAddSuggestedDashboards = ({
[notifications.toasts]
);

const onSuccess = useCallback(
async (data: Rule) => {
if (!addingDashboardId)
throw new Error('Adding dashboard id not defined, this should never occur');
await onSuccessAddSuggestedDashboard();
setAddingDashboardId(undefined);
notifications.toasts.addSuccess({
title: i18n.translate(
'xpack.observability.alertDetails.addSuggestedDashboardSuccess.title',
{
defaultMessage: 'Added to linked dashboard',
}
),
text: i18n.translate('xpack.observability.alertDetails.addSuggestedDashboardSuccess.text', {
defaultMessage:
'From now on this dashboard will be linked to all alerts related to {ruleName}',
values: {
ruleName: data.name,
},
}),
});
},
[addingDashboardId, notifications.toasts, onSuccessAddSuggestedDashboard]
);
const onSuccess = useCallback(async () => {
if (!addingDashboardId)
throw new Error('Adding dashboard id not defined, this should never occur');
await onSuccessAddSuggestedDashboard();
setAddingDashboardId(undefined);
notifications.toasts.addSuccess({
title: i18n.translate('xpack.observability.alertDetails.addSuggestedDashboardSuccess.title', {
defaultMessage: 'Added to linked dashboard',
}),
text: i18n.translate('xpack.observability.alertDetails.addSuggestedDashboardSuccess.text', {
defaultMessage:
'From now on, this dashboard will be linked to all alerts triggered by this rule',
}),
});
}, [addingDashboardId, notifications.toasts, onSuccessAddSuggestedDashboard]);

const { mutateAsync: updateRule } = useUpdateRule({ http, onError, onSuccess });

Expand Down