Remove datalink template suggestions for accessing specific fields when there are multiple dataframes. (#32057) (#32148)
* Don't suggest template strings using fields when there are mutliple dataframes
* Change to use label instead of state
(cherry picked from commit f48a52e590)
Co-authored-by: Oscar Kilhed <oscar.kilhed@grafana.com>
This commit is contained in:
co-authored by
Oscar Kilhed
parent
e3b5d53545
commit
5d58d0aabb
@@ -13,6 +13,9 @@ describe('getFieldDisplayValuesProxy', () => {
|
||||
{
|
||||
name: 'power',
|
||||
values: [100, 200, 300],
|
||||
labels: {
|
||||
name: 'POWAH!',
|
||||
},
|
||||
config: {
|
||||
displayName: 'The Power',
|
||||
},
|
||||
@@ -60,6 +63,7 @@ describe('getFieldDisplayValuesProxy', () => {
|
||||
});
|
||||
expect(p.power.numeric).toEqual(300);
|
||||
expect(p['power'].numeric).toEqual(300);
|
||||
expect(p['POWAH!'].numeric).toEqual(300);
|
||||
expect(p['The Power'].numeric).toEqual(300);
|
||||
expect(p[1].numeric).toEqual(300);
|
||||
});
|
||||
|
||||
@@ -28,9 +28,18 @@ export function getFieldDisplayValuesProxy(
|
||||
field = frame.fields[k];
|
||||
}
|
||||
if (!field) {
|
||||
// 3. Match the title
|
||||
// 3. Match the config displayName
|
||||
field = frame.fields.find((f) => key === f.config.displayName);
|
||||
}
|
||||
if (!field) {
|
||||
// 4. Match the name label
|
||||
field = frame.fields.find((f) => {
|
||||
if (f.labels) {
|
||||
return key === f.labels.name;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
if (!field) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user