DataLinks: Removes getDataSourceSettingsByUid from applyFieldOverrides (#29447)

* DataLinks: Removes getDataSourceSettingsByUid from applyFieldOverrides and data linking code

* Fixed test

* Fixed a few tests

* Fixed unit tests

* Removed old getDataSourceSettingsByUid from interface, still there for runtime backward compatability
This commit is contained in:
Torkel Ödegaard
2020-12-01 19:10:23 +01:00
committed by GitHub
parent 9913ac73fb
commit 34f2a72ff2
26 changed files with 143 additions and 176 deletions

View File

@@ -41,10 +41,10 @@ describe('createSpanLinkFactory', () => {
} as DataSourceInstanceSettings,
];
},
getDataSourceSettingsByUid(uid: string): DataSourceInstanceSettings | undefined {
getInstanceSettings(uid: string): DataSourceInstanceSettings | undefined {
if (uid === 'lokiUid') {
return {
name: 'Loki1',
name: 'loki1',
} as any;
}
return undefined;
@@ -82,7 +82,7 @@ describe('createSpanLinkFactory', () => {
} as any);
expect(linkDef.href).toBe(
`/explore?left={"range":{"from":"20201014T000000","to":"20201014T010006"},"datasource":"Loki1","queries":[{"expr":"{cluster=\\"cluster1\\", hostname=\\"hostname1\\"}","refId":""}]}`
`/explore?left={"range":{"from":"20201014T000000","to":"20201014T010006"},"datasource":"loki1","queries":[{"expr":"{cluster=\\"cluster1\\", hostname=\\"hostname1\\"}","refId":""}]}`
);
});
});

View File

@@ -34,17 +34,24 @@ export function createSpanLinkFactory(splitOpenFn: (options: { datasourceUid: st
url: '',
internal: {
datasourceUid: lokiDs.uid,
datasourceName: lokiDs.name,
query: {
expr: getLokiQueryFromSpan(span),
refId: '',
},
},
};
const link = mapInternalLinkToExplore(dataLink, {}, getTimeRangeFromSpan(span), {} as Field, {
const link = mapInternalLinkToExplore({
link: dataLink,
internalLink: dataLink.internal!,
scopedVars: {},
range: getTimeRangeFromSpan(span),
field: {} as Field,
onClickFn: splitOpenFn,
replaceVariables: getTemplateSrv().replace.bind(getTemplateSrv()),
getDataSourceSettingsByUid: getDataSourceSrv().getDataSourceSettingsByUid.bind(getDataSourceSrv()),
});
return {
href: link.href,
onClick: link.onClick,