mirror of
https://github.com/grafana/grafana.git
synced 2024-11-21 16:38:03 -06:00
DashboardScenes: Fix panel links to update on variable or timerange change (#94865)
* Fix panel links to update on variable or timerange change * refactor --------- Co-authored-by: alexandra vargas <alexa1866@gmail.com>
This commit is contained in:
parent
1860737117
commit
beac7de4df
@ -1,5 +1,12 @@
|
||||
import { DataLink, LinkModel } from '@grafana/data';
|
||||
import { SceneComponentProps, SceneObjectBase, SceneObjectState, VizPanel } from '@grafana/scenes';
|
||||
import {
|
||||
SceneComponentProps,
|
||||
sceneGraph,
|
||||
SceneObjectBase,
|
||||
SceneObjectState,
|
||||
VariableDependencyConfig,
|
||||
VizPanel,
|
||||
} from '@grafana/scenes';
|
||||
import { Dropdown, Icon, Menu, PanelChrome, ToolbarButton } from '@grafana/ui';
|
||||
|
||||
import { getPanelLinks } from './PanelMenuBehavior';
|
||||
@ -11,11 +18,20 @@ interface VizPanelLinksState extends SceneObjectState {
|
||||
}
|
||||
|
||||
export class VizPanelLinks extends SceneObjectBase<VizPanelLinksState> {
|
||||
protected _variableDependency = new VariableDependencyConfig(this, {
|
||||
onAnyVariableChanged: () => {
|
||||
if (this.state.rawLinks && this.state.rawLinks.length > 0) {
|
||||
this.forceRender();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
static Component = VizPanelLinksRenderer;
|
||||
}
|
||||
|
||||
function VizPanelLinksRenderer({ model }: SceneComponentProps<VizPanelLinks>) {
|
||||
const { menu, rawLinks } = model.useState();
|
||||
sceneGraph.getTimeRange(model).useState();
|
||||
|
||||
if (!(model.parent instanceof VizPanel)) {
|
||||
throw new Error('VizPanelLinks must be a child of VizPanel');
|
||||
|
Loading…
Reference in New Issue
Block a user