DashboardSave: Correctly overwrite dashboard when saving (#22650)

This commit is contained in:
Dominik Prokop
2020-03-09 18:16:10 +01:00
committed by GitHub
parent 5d8fc6a1a9
commit 0304493bd2
4 changed files with 41 additions and 10 deletions

View File

@@ -8,12 +8,20 @@ import { SaveDashboardModalProps } from './types';
import { SaveDashboardAsButton } from './SaveDashboardButton';
interface SaveDashboardErrorProxyProps {
/** original dashboard */
dashboard: DashboardModel;
/** dashboard save model with applied modifications, i.e. title */
dashboardSaveModel: any;
error: any;
onDismiss: () => void;
}
export const SaveDashboardErrorProxy: React.FC<SaveDashboardErrorProxyProps> = ({ dashboard, error, onDismiss }) => {
export const SaveDashboardErrorProxy: React.FC<SaveDashboardErrorProxyProps> = ({
dashboard,
dashboardSaveModel,
error,
onDismiss,
}) => {
const { onDashboardSave } = useDashboardSave(dashboard);
useEffect(() => {
@@ -35,7 +43,7 @@ export const SaveDashboardErrorProxy: React.FC<SaveDashboardErrorProxyProps> = (
}
confirmText="Save & Overwrite"
onConfirm={async () => {
await onDashboardSave(dashboard.getSaveModelClone(), { overwrite: true }, dashboard);
await onDashboardSave(dashboardSaveModel, { overwrite: true }, dashboard);
onDismiss();
}}
onDismiss={onDismiss}
@@ -53,7 +61,7 @@ export const SaveDashboardErrorProxy: React.FC<SaveDashboardErrorProxyProps> = (
}
confirmText="Save & Overwrite"
onConfirm={async () => {
await onDashboardSave(dashboard.getSaveModelClone(), { overwrite: true }, dashboard);
await onDashboardSave(dashboardSaveModel, { overwrite: true }, dashboard);
onDismiss();
}}
onDismiss={onDismiss}