From d5d3db9a6e150eaf22314d5f61d4b288fd10d2f7 Mon Sep 17 00:00:00 2001 From: Giordano Ricci Date: Tue, 20 Jun 2023 13:21:49 +0100 Subject: [PATCH] DSPicker: Respect datasource & mixed props (#70377) --- .../components/picker/BuiltInDataSourceList.tsx | 6 ++++-- .../components/picker/DataSourceDropdown.tsx | 2 ++ .../components/picker/DataSourceModal.tsx | 13 ++++++++++++- .../features/datasources/components/picker/types.ts | 4 ++++ 4 files changed, 22 insertions(+), 3 deletions(-) diff --git a/public/app/features/datasources/components/picker/BuiltInDataSourceList.tsx b/public/app/features/datasources/components/picker/BuiltInDataSourceList.tsx index 10f1ea14bcf..de1d4e0b38c 100644 --- a/public/app/features/datasources/components/picker/BuiltInDataSourceList.tsx +++ b/public/app/features/datasources/components/picker/BuiltInDataSourceList.tsx @@ -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 (
diff --git a/public/app/features/datasources/components/picker/DataSourceDropdown.tsx b/public/app/features/datasources/components/picker/DataSourceDropdown.tsx index 3ea10beef02..5293f370824 100644 --- a/public/app/features/datasources/components/picker/DataSourceDropdown.tsx +++ b/public/app/features/datasources/components/picker/DataSourceDropdown.tsx @@ -240,6 +240,8 @@ const PickerContent = React.forwardRef((prop enableFileUpload: props.enableFileUpload, fileUploadOptions: props.fileUploadOptions, reportedInteractionFrom: 'ds_picker', + dashboard: props.dashboard, + mixed: props.mixed, current, onDismiss: hideModal, onChange: (ds) => { diff --git a/public/app/features/datasources/components/picker/DataSourceModal.tsx b/public/app/features/datasources/components/picker/DataSourceModal.tsx index 09a1dd538f0..d48a3144a3d 100644 --- a/public/app/features/datasources/components/picker/DataSourceModal.tsx +++ b/public/app/features/datasources/components/picker/DataSourceModal.tsx @@ -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({ } />
- + {enableFileUpload && ( void; recentlyUsed?: string[]; hideTextValue?: boolean; + dashboard?: boolean; + mixed?: boolean; width?: number; } @@ -20,6 +22,8 @@ export interface PickerContentProps extends DataSourceDropdownProps { keyboardEvents: Observable; style: React.CSSProperties; filterTerm?: string; + dashboard?: boolean; + mixed?: boolean; onClose: () => void; onDismiss: () => void; }