DS Picker: Built-in datasources are not marked as selected (#70020)

This commit is contained in:
Ivan Ortega Alba 2023-06-14 10:52:49 +02:00 committed by GitHub
parent f41651ad68
commit 908b248e10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import { DataSourceRef } from '@grafana/schema';
import { useDatasources } from '../../hooks';
import { DataSourceCard } from './DataSourceCard';
import { isDataSourceMatch } from './utils';
const CUSTOM_DESCRIPTIONS_BY_UID: Record<string, string> = {
grafana: 'Discover visualizations using mock data',
@ -30,7 +31,7 @@ export function BuiltInDataSourceList({ className, current, onChange }: BuiltInD
key={ds.uid}
ds={ds}
description={CUSTOM_DESCRIPTIONS_BY_UID[ds.uid]}
selected={current === ds.id}
selected={isDataSourceMatch(ds, current)}
onClick={() => onChange(ds)}
/>
);

View File

@ -86,7 +86,7 @@ export function DataSourceList(props: DataSourceListProps) {
pushRecentlyUsedDataSource(ds);
onChange(ds);
}}
selected={!!isDataSourceMatch(ds, current)}
selected={isDataSourceMatch(ds, current)}
{...(enableKeyboardNavigation ? navigatableProps : {})}
/>
))}

View File

@ -3,7 +3,7 @@ import { DataSourceInstanceSettings, DataSourceJsonData, DataSourceRef } from '@
export function isDataSourceMatch(
ds: DataSourceInstanceSettings | undefined,
current: string | DataSourceInstanceSettings | DataSourceRef | null | undefined
): boolean | undefined {
): boolean {
if (!ds) {
return false;
}