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

This commit is contained in:
kay delaney 2024-04-08 12:49:38 +01:00 committed by GitHub
parent a7f7f4787d
commit 1b376546e2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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) {