From 9453bec81999e95a82ab8d2cf7cee05b972c5f4c Mon Sep 17 00:00:00 2001 From: Levente Balogh Date: Fri, 27 Jan 2023 16:40:54 +0100 Subject: [PATCH] FileDropzone: Revert introducing a new prop (#62324) --- .../components/FileDropzone/FileDropzone.test.tsx | 6 ------ .../src/components/FileDropzone/FileDropzone.tsx | 13 ++----------- .../datasource/grafana/components/QueryEditor.tsx | 10 ++++------ 3 files changed, 6 insertions(+), 23 deletions(-) diff --git a/packages/grafana-ui/src/components/FileDropzone/FileDropzone.test.tsx b/packages/grafana-ui/src/components/FileDropzone/FileDropzone.test.tsx index 39dd8a23361..42ac0652b90 100644 --- a/packages/grafana-ui/src/components/FileDropzone/FileDropzone.test.tsx +++ b/packages/grafana-ui/src/components/FileDropzone/FileDropzone.test.tsx @@ -112,12 +112,6 @@ describe('The FileDropzone component', () => { expect(onDrop).toBeCalledWith([fileToUpload], [], expect.anything()); }); - it('should display the text generated by a custom primaryTextSupplier', async () => { - const customText = 'custom text from primaryTextSuplier'; - render( customText} />); - expect(await screen.findByText(customText)).toBeInTheDocument(); - }); - it('should show children inside the dropzone', () => { const component = ( diff --git a/packages/grafana-ui/src/components/FileDropzone/FileDropzone.tsx b/packages/grafana-ui/src/components/FileDropzone/FileDropzone.tsx index 08acef7fc28..76f3ed99f74 100644 --- a/packages/grafana-ui/src/components/FileDropzone/FileDropzone.tsx +++ b/packages/grafana-ui/src/components/FileDropzone/FileDropzone.tsx @@ -46,7 +46,6 @@ export interface FileDropzoneProps { */ fileListRenderer?: (file: DropzoneFile, removeFile: (file: DropzoneFile) => void) => ReactNode; onFileRemove?: (file: DropzoneFile) => void; - primaryTextSupplier?: (files: DropzoneFile[], options?: BackwardsCompatibleDropzoneOptions) => string; } export interface DropzoneFile { @@ -58,15 +57,7 @@ export interface DropzoneFile { retryUpload?: () => void; } -export function FileDropzone({ - options, - primaryTextSupplier = getPrimaryText, - children, - readAs, - onLoad, - fileListRenderer, - onFileRemove, -}: FileDropzoneProps) { +export function FileDropzone({ options, children, readAs, onLoad, fileListRenderer, onFileRemove }: FileDropzoneProps) { const [files, setFiles] = useState([]); const [fileErrors, setErrorMessages] = useState([]); @@ -221,7 +212,7 @@ export function FileDropzone({
- {children ?? } + {children ?? }
{fileErrors.length > 0 && renderErrorMessages(fileErrors)} {options?.accept && ( diff --git a/public/app/plugins/datasource/grafana/components/QueryEditor.tsx b/public/app/plugins/datasource/grafana/components/QueryEditor.tsx index 23c16c1a213..edc9f18abb2 100644 --- a/public/app/plugins/datasource/grafana/components/QueryEditor.tsx +++ b/public/app/plugins/datasource/grafana/components/QueryEditor.tsx @@ -24,6 +24,7 @@ import { InlineFieldRow, InlineLabel, FileDropzone, + FileDropzoneDefaultChildren, DropzoneFile, Themeable2, withTheme2, @@ -68,10 +69,6 @@ export class UnthemedQueryEditor extends PureComponent { }, ]; - dropzoneTextSupplier = () => { - return this.props?.query?.file ? 'Replace file' : 'Upload file'; - }; - constructor(props: Props) { super(props); @@ -403,8 +400,9 @@ export class UnthemedQueryEditor extends PureComponent { fileListRenderer={this.fileListRenderer} options={{ onDropAccepted: this.onDropAccepted, maxSize: 200000, multiple: false }} onLoad={this.onFileDrop} - primaryTextSupplier={this.dropzoneTextSupplier} - > + > + + {file && (
{file?.name}