DSPicker: Respect datasource & mixed props (#70377)

This commit is contained in:
Giordano Ricci 2023-06-20 13:21:49 +01:00 committed by GitHub
parent 5622f2f43a
commit d5d3db9a6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 3 deletions

View File

@ -18,10 +18,12 @@ interface BuiltInDataSourceListProps {
className?: string;
current: DataSourceRef | string | null | undefined;
onChange: (ds: DataSourceInstanceSettings) => void;
dashboard?: boolean;
mixed?: boolean;
}
export function BuiltInDataSourceList({ className, current, onChange }: BuiltInDataSourceListProps) {
const grafanaDataSources = useDatasources({ mixed: true, dashboard: true, filter: (ds) => !!ds.meta.builtIn });
export function BuiltInDataSourceList({ className, current, onChange, dashboard, mixed }: BuiltInDataSourceListProps) {
const grafanaDataSources = useDatasources({ mixed, dashboard, filter: (ds) => !!ds.meta.builtIn });
return (
<div className={className}>

View File

@ -240,6 +240,8 @@ const PickerContent = React.forwardRef<HTMLDivElement, PickerContentProps>((prop
enableFileUpload: props.enableFileUpload,
fileUploadOptions: props.fileUploadOptions,
reportedInteractionFrom: 'ds_picker',
dashboard: props.dashboard,
mixed: props.mixed,
current,
onDismiss: hideModal,
onChange: (ds) => {

View File

@ -37,12 +37,16 @@ interface DataSourceModalProps {
onDismiss: () => void;
recentlyUsed?: string[];
enableFileUpload?: boolean;
dashboard?: boolean;
mixed?: boolean;
fileUploadOptions?: DropzoneOptions;
reportedInteractionFrom?: string;
}
export function DataSourceModal({
enableFileUpload,
dashboard,
mixed,
fileUploadOptions,
onChange,
current,
@ -113,6 +117,8 @@ export function DataSourceModal({
}
/>
<BuiltInDataSourceList
dashboard={dashboard}
mixed={mixed}
className={styles.appendBuiltInDataSourcesList}
onChange={onChangeDataSource}
current={current}
@ -122,7 +128,12 @@ export function DataSourceModal({
<div className={styles.rightColumn}>
<div className={styles.builtInDataSources}>
<CustomScrollbar className={styles.builtInDataSourcesList}>
<BuiltInDataSourceList onChange={onChangeDataSource} current={current} />
<BuiltInDataSourceList
onChange={onChangeDataSource}
current={current}
dashboard={dashboard}
mixed={mixed}
/>
</CustomScrollbar>
{enableFileUpload && (
<FileDropzone

View File

@ -13,6 +13,8 @@ export interface DataSourceDropdownProps {
onClickAddCSV?: () => void;
recentlyUsed?: string[];
hideTextValue?: boolean;
dashboard?: boolean;
mixed?: boolean;
width?: number;
}
@ -20,6 +22,8 @@ export interface PickerContentProps extends DataSourceDropdownProps {
keyboardEvents: Observable<React.KeyboardEvent>;
style: React.CSSProperties;
filterTerm?: string;
dashboard?: boolean;
mixed?: boolean;
onClose: () => void;
onDismiss: () => void;
}