mirror of https://github.com/grafana/grafana
Improve DS Advance Picker to give user context about the built in DS and CTA (#68203)
* Add description to DS built-in list of items * Open the new DS view in a new tabpull/68256/head
parent
1d710408df
commit
cb293ecf1c
@ -0,0 +1,40 @@ |
||||
import React from 'react'; |
||||
|
||||
import { DataSourceInstanceSettings } from '@grafana/data'; |
||||
import { DataSourceRef } from '@grafana/schema'; |
||||
|
||||
import { useDatasources } from '../../hooks'; |
||||
|
||||
import { DataSourceCard } from './DataSourceCard'; |
||||
|
||||
const CUSTOM_DESCRIPTIONS_BY_UID: Record<string, string> = { |
||||
grafana: 'Discover visualizations using mock data', |
||||
'-- Mixed --': 'Use multiple data sources', |
||||
'-- Dashboard --': 'Reuse query results from other visualizations', |
||||
}; |
||||
|
||||
interface BuiltInDataSourceListProps { |
||||
className?: string; |
||||
current: DataSourceRef | string | null | undefined; |
||||
onChange: (ds: DataSourceInstanceSettings) => void; |
||||
} |
||||
|
||||
export function BuiltInDataSourceList({ className, current, onChange }: BuiltInDataSourceListProps) { |
||||
const grafanaDataSources = useDatasources({ mixed: true, dashboard: true, filter: (ds) => !!ds.meta.builtIn }); |
||||
|
||||
return ( |
||||
<div className={className}> |
||||
{grafanaDataSources.map((ds) => { |
||||
return ( |
||||
<DataSourceCard |
||||
key={ds.id} |
||||
ds={ds} |
||||
description={CUSTOM_DESCRIPTIONS_BY_UID[ds.uid]} |
||||
selected={current === ds.id} |
||||
onClick={() => onChange(ds)} |
||||
/> |
||||
); |
||||
})} |
||||
</div> |
||||
); |
||||
} |
Loading…
Reference in new issue