import { DataSourceInstanceSettings, DataSourceJsonData, DataSourceRef } from '@grafana/data'; export function isDataSourceMatch( ds: DataSourceInstanceSettings | undefined, current: string | DataSourceInstanceSettings | DataSourceRef | null | undefined ): boolean | undefined { if (!ds) { return false; } if (!current) { return false; } if (typeof current === 'string') { return ds.uid === current; } return ds.uid === current.uid; } export function dataSourceName( dataSource: DataSourceInstanceSettings | string | DataSourceRef | null | undefined ) { if (!dataSource) { return 'Unknown'; } if (typeof dataSource === 'string') { return `${dataSource} - not found`; } if ('name' in dataSource) { return dataSource.name; } if (dataSource.uid) { return `${dataSource.uid} - not found`; } return 'Unknown'; }