mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Canvas: Fix setting icon from field data #58499
This commit is contained in:
parent
41c491e2db
commit
47055561ec
@ -3870,12 +3870,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]
|
||||
],
|
||||
"public/app/features/dimensions/resource.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
|
||||
],
|
||||
"public/app/features/dimensions/scale.test.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
|
@ -10,7 +10,7 @@ export function getPublicOrAbsoluteUrl(v: string): string {
|
||||
if (!v) {
|
||||
return '';
|
||||
}
|
||||
return v.indexOf(':/') > 0 ? v : (window as any).__grafana_public_path__ + v;
|
||||
return v.indexOf(':/') > 0 ? v : window.__grafana_public_path__ + v;
|
||||
}
|
||||
|
||||
export function getResourceDimension(
|
||||
@ -19,7 +19,7 @@ export function getResourceDimension(
|
||||
): DimensionSupplier<string> {
|
||||
const mode = config.mode ?? ResourceDimensionMode.Fixed;
|
||||
if (mode === ResourceDimensionMode.Fixed) {
|
||||
const v = getPublicOrAbsoluteUrl(config.fixed!);
|
||||
const v = getPublicOrAbsoluteUrl(config.fixed);
|
||||
return {
|
||||
isAssumed: !Boolean(v),
|
||||
fixed: v,
|
||||
@ -40,7 +40,7 @@ export function getResourceDimension(
|
||||
}
|
||||
|
||||
if (mode === ResourceDimensionMode.Mapping) {
|
||||
const mapper = (v: any) => getPublicOrAbsoluteUrl(`${v}`);
|
||||
const mapper = (v: string) => getPublicOrAbsoluteUrl(`${v}`);
|
||||
return {
|
||||
field,
|
||||
get: (i) => mapper(field.values.get(i)),
|
||||
@ -48,9 +48,10 @@ export function getResourceDimension(
|
||||
};
|
||||
}
|
||||
|
||||
const getIcon = (value: any): string => {
|
||||
const disp = field.display!;
|
||||
return getPublicOrAbsoluteUrl(disp(value).icon ?? '');
|
||||
// mode === ResourceDimensionMode.Field case
|
||||
const getIcon = (value: string): string => {
|
||||
const display = field.display!;
|
||||
return getPublicOrAbsoluteUrl(display(value).icon ?? value ?? '');
|
||||
};
|
||||
|
||||
return {
|
||||
|
Loading…
Reference in New Issue
Block a user