[v9.5.x] Dashboards: Fix broken internal data links (#66581)

Dashboards: Fix broken internal data links (#66567)

* In dashboards splitOpenFn is not passed, instead "href" link is used. When we added tracking we changed the behaviour so onClickFn is always passed when generating the model. To bring back the previous behaviour we skip the onClickFn if the split function is not provided.

* Fix test and add a task to re-check the logic

(cherry picked from commit 4f5b80095e)

Co-authored-by: Piotr Jamróz <pm.jamroz@gmail.com>
This commit is contained in:
Grot (@grafanabot)
2023-04-14 15:14:58 +02:00
committed by GitHub
co-authored by Piotr Jamróz
parent 5bcc35298f
commit 84850f4553
2 changed files with 4 additions and 6 deletions
@@ -315,11 +315,7 @@ describe('explore links utils', () => {
links[0][0].onClick({});
}
expect(reportInteraction).toBeCalledWith('grafana_data_link_clicked', {
app: CoreApp.Explore,
internal: true,
origin: DataLinkConfigOrigin.Correlations,
});
expect(reportInteraction).not.toBeCalled();
expect(links[1]).toHaveLength(1);
expect(links[1][0].href).toBe(
+3 -1
View File
@@ -194,7 +194,9 @@ export const getFieldLinksForExplore = (options: {
scopedVars: allVars,
range,
field,
onClickFn: (options) => splitFnWithTracking(options),
// Don't track internal links without split view as they are used only in Dashboards
// TODO: It should be revisited in #66570
onClickFn: options.splitOpenFn ? (options) => splitFnWithTracking(options) : undefined,
replaceVariables: getTemplateSrv().replace.bind(getTemplateSrv()),
});
return { ...internalLink, variables: variables };