Dashboards: Fix issue with changing panel JSON from edit view (#85717)
This commit is contained in:
@@ -78,22 +78,23 @@ export function InspectJSONTab({ panel, dashboard, data, onClose }: Props) {
|
|||||||
const onApplyPanelModel = useCallback(() => {
|
const onApplyPanelModel = useCallback(() => {
|
||||||
if (panel && dashboard && text) {
|
if (panel && dashboard && text) {
|
||||||
try {
|
try {
|
||||||
if (!dashboard!.meta.canEdit) {
|
if (!dashboard.meta.canEdit) {
|
||||||
appEvents.emit(AppEvents.alertError, ['Unable to apply']);
|
appEvents.emit(AppEvents.alertError, ['Unable to apply']);
|
||||||
} else {
|
} else {
|
||||||
const updates = JSON.parse(text);
|
const updates = JSON.parse(text);
|
||||||
dashboard!.shouldUpdateDashboardPanelFromJSON(updates, panel!);
|
dashboard.shouldUpdateDashboardPanelFromJSON(updates, panel);
|
||||||
|
|
||||||
//Report relevant updates
|
//Report relevant updates
|
||||||
reportPanelInspectInteraction(InspectTab.JSON, 'apply', {
|
reportPanelInspectInteraction(InspectTab.JSON, 'apply', {
|
||||||
panel_type_changed: panel!.type !== updates.type,
|
panel_type_changed: panel.type !== updates.type,
|
||||||
panel_id_changed: panel!.id !== updates.id,
|
panel_id_changed: panel.id !== updates.id,
|
||||||
panel_grid_pos_changed: !isEqual(panel!.gridPos, updates.gridPos),
|
panel_grid_pos_changed: !isEqual(panel.gridPos, updates.gridPos),
|
||||||
panel_targets_changed: !isEqual(panel!.targets, updates.targets),
|
panel_targets_changed: !isEqual(panel.targets, updates.targets),
|
||||||
});
|
});
|
||||||
|
|
||||||
panel!.restoreModel(updates);
|
panel.restoreModel(updates);
|
||||||
panel!.refresh();
|
panel.configRev++;
|
||||||
|
panel.refresh();
|
||||||
appEvents.emit(AppEvents.alertSuccess, ['Panel model updated']);
|
appEvents.emit(AppEvents.alertSuccess, ['Panel model updated']);
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|||||||
Reference in New Issue
Block a user