mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
AppNotifications: Migrate usage of deprecated appEvents.emit method to redux actions (#45607)
This commit is contained in:
@@ -1,19 +1,19 @@
|
||||
import { useEffect } from 'react';
|
||||
import { useAsyncFn } from 'react-use';
|
||||
import { AppEvents } from '@grafana/data';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { useAppNotification } from 'app/core/copy/appNotification';
|
||||
import { deleteDashboard } from 'app/features/manage-dashboards/state/actions';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
|
||||
export const useDashboardDelete = (uid: string) => {
|
||||
const [state, onDeleteDashboard] = useAsyncFn(() => deleteDashboard(uid, false), []);
|
||||
const notifyApp = useAppNotification();
|
||||
|
||||
useEffect(() => {
|
||||
if (state.value) {
|
||||
locationService.replace('/');
|
||||
appEvents.emit(AppEvents.alertSuccess, ['Dashboard Deleted', state.value.title + ' has been deleted']);
|
||||
notifyApp.success('Dashboard Deleted', `${state.value.title} has been deleted`);
|
||||
}
|
||||
}, [state]);
|
||||
}, [state, notifyApp]);
|
||||
|
||||
return { state, onDeleteDashboard };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user