DashboardScene: Panel edit search crash fix (#82449)

* DashboardScene: Panel edit search crash fix

* Fix issue with removing data links
This commit is contained in:
Torkel Ödegaard 2024-02-15 06:46:50 +01:00 committed by GitHub
parent 8832971aff
commit b7b83ded71
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 12 deletions

View File

@ -3,6 +3,7 @@ import React from 'react';
import { config } from '@grafana/runtime';
import { VizPanel } from '@grafana/scenes';
import { DataLinksInlineEditor, Input, RadioButtonGroup, Select, Switch, TextArea } from '@grafana/ui';
import { VizPanelLinks } from 'app/features/dashboard-scene/scene/PanelLinks';
import { dashboardSceneGraph } from 'app/features/dashboard-scene/utils/dashboardSceneGraph';
import { getPanelLinksVariableSuggestions } from 'app/features/panel/panellinks/link_srv';
@ -248,17 +249,7 @@ export function getPanelFrameCategory2(panel: VizPanel): OptionsPaneCategoryDesc
}).addItem(
new OptionsPaneItemDescriptor({
title: 'Panel links',
render: function renderLinks() {
const { rawLinks: links } = panelLinksObject.useState();
return (
<DataLinksInlineEditor
links={links}
onChange={(links) => panelLinksObject.setState({ rawLinks: links })}
getSuggestions={getPanelLinksVariableSuggestions}
data={[]}
/>
);
},
render: () => <ScenePanelLinksEditor panelLinks={panelLinksObject} />,
})
)
);
@ -325,3 +316,20 @@ export function getPanelFrameCategory2(panel: VizPanel): OptionsPaneCategoryDesc
// )
// );
}
interface ScenePanelLinksEditorProps {
panelLinks: VizPanelLinks;
}
function ScenePanelLinksEditor({ panelLinks }: ScenePanelLinksEditorProps) {
const { rawLinks: links } = panelLinks.useState();
return (
<DataLinksInlineEditor
links={links}
onChange={(links) => panelLinks.setState({ rawLinks: links })}
getSuggestions={getPanelLinksVariableSuggestions}
data={[]}
/>
);
}

View File

@ -229,7 +229,8 @@ export function getVisualizationOptions2(props: OptionPaneRenderProps2): Options
render: function renderEditor() {
const onChange = (v: unknown) => {
panel.onFieldConfigChange(
updateDefaultFieldConfigValue(currentFieldConfig, fieldOption.path, v, fieldOption.isCustom)
updateDefaultFieldConfigValue(currentFieldConfig, fieldOption.path, v, fieldOption.isCustom),
true
);
};