Dashboard: Fix the unintentional time range and variables updates on saving (#101475)
pass the changedModel
This commit is contained in:
@@ -54,6 +54,7 @@ export function SaveDashboardAsForm({ dashboard, changeInfo }: Props) {
|
||||
const result = await onSaveDashboard(dashboard, {
|
||||
overwrite,
|
||||
folderUid: data.folder.uid,
|
||||
rawDashboardJSON: changedSaveModel,
|
||||
|
||||
// save as config
|
||||
saveAsCopy: true,
|
||||
|
||||
@@ -25,7 +25,7 @@ export interface Props {
|
||||
}
|
||||
|
||||
export function SaveDashboardForm({ dashboard, drawer, changeInfo }: Props) {
|
||||
const { hasChanges } = changeInfo;
|
||||
const { hasChanges, changedSaveModel } = changeInfo;
|
||||
|
||||
const { state, onSaveDashboard } = useSaveDashboard(false);
|
||||
const [options, setOptions] = useState<SaveDashboardOptions>({
|
||||
@@ -38,7 +38,7 @@ export function SaveDashboardForm({ dashboard, drawer, changeInfo }: Props) {
|
||||
});
|
||||
|
||||
const onSave = async (overwrite: boolean) => {
|
||||
const result = await onSaveDashboard(dashboard, { ...options, overwrite });
|
||||
const result = await onSaveDashboard(dashboard, { ...options, rawDashboardJSON: changedSaveModel, overwrite });
|
||||
if (result.status === 'success') {
|
||||
dashboard.closeModal();
|
||||
drawer.state.onSaveSuccess?.();
|
||||
|
||||
@@ -3,6 +3,7 @@ import { useAsyncFn } from 'react-use';
|
||||
import { locationUtil } from '@grafana/data';
|
||||
import { locationService, reportInteraction } from '@grafana/runtime';
|
||||
import { Dashboard } from '@grafana/schema';
|
||||
import { DashboardV2Spec } from '@grafana/schema/dist/esm/schema/dashboard/v2alpha0';
|
||||
import appEvents from 'app/core/app_events';
|
||||
import { useAppNotification } from 'app/core/copy/appNotification';
|
||||
import { updateDashboardName } from 'app/core/reducers/navBarTree';
|
||||
@@ -25,7 +26,7 @@ export function useSaveDashboard(isCopy = false) {
|
||||
options: SaveDashboardOptions &
|
||||
SaveDashboardAsOptions & {
|
||||
// When provided, will take precedence over the scene's save model
|
||||
rawDashboardJSON?: Dashboard;
|
||||
rawDashboardJSON?: Dashboard | DashboardV2Spec;
|
||||
}
|
||||
) => {
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user