mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Routing NG: Fix persistent modal after dashboard delete (#32033)
This commit is contained in:
parent
a97637a133
commit
48eb747da0
@ -4,6 +4,7 @@ import sumBy from 'lodash/sumBy';
|
||||
import { Modal, ConfirmModal, HorizontalGroup, Button } from '@grafana/ui';
|
||||
import { DashboardModel, PanelModel } from '../../state';
|
||||
import { useDashboardDelete } from './useDashboardDelete';
|
||||
import useAsyncFn from 'react-use/lib/useAsyncFn';
|
||||
|
||||
type DeleteDashboardModalProps = {
|
||||
hideModal(): void;
|
||||
@ -12,7 +13,13 @@ type DeleteDashboardModalProps = {
|
||||
|
||||
export const DeleteDashboardModal: React.FC<DeleteDashboardModalProps> = ({ hideModal, dashboard }) => {
|
||||
const isProvisioned = dashboard.meta.provisioned;
|
||||
const { onRestoreDashboard } = useDashboardDelete(dashboard.uid);
|
||||
const { onDeleteDashboard } = useDashboardDelete(dashboard.uid);
|
||||
|
||||
const [, onConfirm] = useAsyncFn(async () => {
|
||||
await onDeleteDashboard();
|
||||
hideModal();
|
||||
}, [hideModal]);
|
||||
|
||||
const modalBody = getModalBody(dashboard.panels, dashboard.title);
|
||||
|
||||
if (isProvisioned) {
|
||||
@ -23,7 +30,7 @@ export const DeleteDashboardModal: React.FC<DeleteDashboardModalProps> = ({ hide
|
||||
<ConfirmModal
|
||||
isOpen={true}
|
||||
body={modalBody}
|
||||
onConfirm={onRestoreDashboard}
|
||||
onConfirm={onConfirm}
|
||||
onDismiss={hideModal}
|
||||
title="Delete"
|
||||
icon="trash-alt"
|
||||
|
@ -6,7 +6,7 @@ import { deleteDashboard } from 'app/features/manage-dashboards/state/actions';
|
||||
import { locationService } from '@grafana/runtime';
|
||||
|
||||
export const useDashboardDelete = (uid: string) => {
|
||||
const [state, onRestoreDashboard] = useAsyncFn(() => deleteDashboard(uid, false), []);
|
||||
const [state, onDeleteDashboard] = useAsyncFn(() => deleteDashboard(uid, false), []);
|
||||
|
||||
useEffect(() => {
|
||||
if (state.value) {
|
||||
@ -15,5 +15,5 @@ export const useDashboardDelete = (uid: string) => {
|
||||
}
|
||||
}, [state]);
|
||||
|
||||
return { state, onRestoreDashboard };
|
||||
return { state, onDeleteDashboard };
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user