[v11.0.x] Dashboards: Fix issue with changing panel JSON from edit view (#85728)

Dashboards: Fix issue with changing panel JSON from edit view (#85717)

(cherry picked from commit 1b376546e2)

Co-authored-by: kay delaney <45561153+kaydelaney@users.noreply.github.com>
This commit is contained in:
grafana-delivery-bot[bot]
2024-04-08 15:06:57 +03:00
committed by GitHub
co-authored by kay delaney
parent 48d499da74
commit 6d23466d5f
@@ -78,22 +78,23 @@ export function InspectJSONTab({ panel, dashboard, data, onClose }: Props) {
const onApplyPanelModel = useCallback(() => {
if (panel && dashboard && text) {
try {
if (!dashboard!.meta.canEdit) {
if (!dashboard.meta.canEdit) {
appEvents.emit(AppEvents.alertError, ['Unable to apply']);
} else {
const updates = JSON.parse(text);
dashboard!.shouldUpdateDashboardPanelFromJSON(updates, panel!);
dashboard.shouldUpdateDashboardPanelFromJSON(updates, panel);
//Report relevant updates
reportPanelInspectInteraction(InspectTab.JSON, 'apply', {
panel_type_changed: panel!.type !== updates.type,
panel_id_changed: panel!.id !== updates.id,
panel_grid_pos_changed: !isEqual(panel!.gridPos, updates.gridPos),
panel_targets_changed: !isEqual(panel!.targets, updates.targets),
panel_type_changed: panel.type !== updates.type,
panel_id_changed: panel.id !== updates.id,
panel_grid_pos_changed: !isEqual(panel.gridPos, updates.gridPos),
panel_targets_changed: !isEqual(panel.targets, updates.targets),
});
panel!.restoreModel(updates);
panel!.refresh();
panel.restoreModel(updates);
panel.configRev++;
panel.refresh();
appEvents.emit(AppEvents.alertSuccess, ['Panel model updated']);
}
} catch (err) {