Skip to content

Commit

Permalink
DashboardScenes: Fix panel links to update on variable or timerange c…
Browse files Browse the repository at this point in the history
…hange (grafana#94865)

* Fix panel links to update on variable or timerange change

* refactor

---------

Co-authored-by: alexandra vargas <[email protected]>
  • Loading branch information
mdvictor and axelavargas authored Oct 17, 2024
1 parent 1860737 commit beac7de
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion public/app/features/dashboard-scene/scene/PanelLinks.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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');
Expand Down

0 comments on commit beac7de

Please sign in to comment.