Skip to content

Commit

Permalink
[7.x] useSavedDashboard: call toast methods in their context (#86803) (
Browse files Browse the repository at this point in the history
  • Loading branch information
afharo authored Dec 23, 2020
1 parent e062390 commit 43bc592
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export const useSavedDashboard = (savedDashboardId: string | undefined, history:
// abstraction of service dependencies easier.
const { indexPatterns } = data;
const { recentlyAccessed: recentlyAccessedPaths, docTitle } = chrome;
const { addDanger: showDangerToast, addWarning: showWarningToast } = core.notifications.toasts;
const { toasts } = core.notifications;

useEffect(() => {
(async function loadSavedDashboard() {
Expand All @@ -46,7 +46,7 @@ export const useSavedDashboard = (savedDashboardId: string | undefined, history:
pathname: DashboardConstants.CREATE_NEW_DASHBOARD_URL,
});

showWarningToast(getDashboard60Warning());
toasts.addWarning(getDashboard60Warning());
return;
}

Expand All @@ -63,7 +63,7 @@ export const useSavedDashboard = (savedDashboardId: string | undefined, history:
setSavedDashboard(dashboard);
} catch (error) {
// E.g. a corrupt or deleted dashboard
showDangerToast(error.message);
toasts.addDanger(error.message);
history.push(DashboardConstants.LANDING_PAGE_PATH);
}
})();
Expand All @@ -75,8 +75,7 @@ export const useSavedDashboard = (savedDashboardId: string | undefined, history:
recentlyAccessedPaths,
savedDashboardId,
savedDashboards,
showDangerToast,
showWarningToast,
toasts,
]);

return savedDashboard;
Expand Down

0 comments on commit 43bc592

Please sign in to comment.