mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Live: show popup if local changes exist (#36093)
* change tracker * not needed
This commit is contained in:
@@ -27,6 +27,8 @@ export const useDashboardSave = (dashboard: DashboardModel) => {
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (state.value) {
|
if (state.value) {
|
||||||
dashboard.version = state.value.version;
|
dashboard.version = state.value.version;
|
||||||
|
dashboard.clearUnsavedChanges();
|
||||||
|
|
||||||
// important that these happen before location redirect below
|
// important that these happen before location redirect below
|
||||||
appEvents.publish(new DashboardSavedEvent());
|
appEvents.publish(new DashboardSavedEvent());
|
||||||
appEvents.emit(AppEvents.alertSuccess, ['Dashboard saved']);
|
appEvents.emit(AppEvents.alertSuccess, ['Dashboard saved']);
|
||||||
|
|||||||
@@ -110,7 +110,9 @@ export class DashboardGrid extends PureComponent<Props, State> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
onResize: ItemCallback = (layout, oldItem, newItem) => {
|
onResize: ItemCallback = (layout, oldItem, newItem) => {
|
||||||
this.panelMap[newItem.i!].updateGridPos(newItem);
|
const panel = this.panelMap[newItem.i!];
|
||||||
|
panel.updateGridPos(newItem);
|
||||||
|
panel.configRev++; // trigger change handler
|
||||||
};
|
};
|
||||||
|
|
||||||
onResizeStop: ItemCallback = (layout, oldItem, newItem) => {
|
onResizeStop: ItemCallback = (layout, oldItem, newItem) => {
|
||||||
|
|||||||
@@ -497,6 +497,22 @@ export class DashboardModel {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clearUnsavedChanges() {
|
||||||
|
for (const panel of this.panels) {
|
||||||
|
panel.configRev = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hasUnsavedChanges() {
|
||||||
|
for (const panel of this.panels) {
|
||||||
|
if (panel.hasChanged) {
|
||||||
|
console.log('Panel has changed', panel);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
cleanUpRepeats() {
|
cleanUpRepeats() {
|
||||||
if (this.isSnapshotTruthy() || !this.hasVariables()) {
|
if (this.isSnapshotTruthy() || !this.hasVariables()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ class DashboardWatcher {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const showPopup = this.editing; // || changeTracker.hasChanges();
|
const showPopup = this.editing || dash.hasUnsavedChanges();
|
||||||
|
|
||||||
if (action === DashboardEventAction.Saved) {
|
if (action === DashboardEventAction.Saved) {
|
||||||
if (showPopup) {
|
if (showPopup) {
|
||||||
|
|||||||
Reference in New Issue
Block a user