mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Dashboard: New panel in a dashboard is not deleted after "Discard"-ing changes in Panel Edit (#66476)
* add isNew notPersistedProperty to PanelModel * if panel is newly created and user "Discard"s it, the panel is removed entirely * add Todo's for when we remove the emptyDashboardPage FF * add isNew to new panel after file dropping on dashboard page * handle the "Apply" case * CSV file dropping is not relevant to a new panel bc it doesnt open edit page
This commit is contained in:
@@ -77,6 +77,7 @@ export const AddPanelWidgetUnconnected = ({ panel, dashboard }: Props) => {
|
||||
title: 'Panel Title',
|
||||
datasource: panel.datasource,
|
||||
gridPos: { x: gridPos.x, y: gridPos.y, w: gridPos.w, h: gridPos.h },
|
||||
isNew: true,
|
||||
};
|
||||
|
||||
dashboard.addPanel(newPanel);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { pick } from 'lodash';
|
||||
|
||||
import store from 'app/core/store';
|
||||
import { removePanel } from 'app/features/dashboard/utils/panel';
|
||||
import { cleanUpPanelState } from 'app/features/panel/state/actions';
|
||||
import { panelModelAndPluginReady } from 'app/features/panel/state/reducers';
|
||||
import { ThunkResult } from 'app/types';
|
||||
@@ -113,9 +114,9 @@ export function exitPanelEditor(): ThunkResult<void> {
|
||||
dashboard.exitPanelEditor();
|
||||
}
|
||||
|
||||
const sourcePanel = getSourcePanel();
|
||||
if (hasPanelChangedInPanelEdit(panel) && !shouldDiscardChanges) {
|
||||
const modifiedSaveModel = panel.getSaveModel();
|
||||
const sourcePanel = getSourcePanel();
|
||||
const panelTypeChanged = sourcePanel.type !== panel.type;
|
||||
|
||||
dispatch(updateDuplicateLibraryPanels(panel, dashboard));
|
||||
@@ -144,6 +145,15 @@ export function exitPanelEditor(): ThunkResult<void> {
|
||||
}, 20);
|
||||
}
|
||||
|
||||
// A new panel is only new until the first time we exit the panel editor
|
||||
if (sourcePanel.isNew) {
|
||||
if (!shouldDiscardChanges) {
|
||||
delete sourcePanel.isNew;
|
||||
} else {
|
||||
dashboard && removePanel(dashboard, sourcePanel, true);
|
||||
}
|
||||
}
|
||||
|
||||
dispatch(cleanUpPanelState(panel.key));
|
||||
dispatch(closeEditor());
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user