Remove datalink template suggestions for accessing specific fields when there are multiple dataframes. (#32057)

* Don't suggest template strings using fields when there are mutliple dataframes

* Change to use label instead of state
This commit is contained in:
Oscar Kilhed
2021-03-19 09:28:15 +01:00
committed by GitHub
parent 8854001b67
commit f48a52e590
4 changed files with 63 additions and 20 deletions
@@ -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;
}