diff --git a/superset-frontend/src/components/TableSelector/index.tsx b/superset-frontend/src/components/TableSelector/index.tsx index acf9f67f7c..691590b95e 100644 --- a/superset-frontend/src/components/TableSelector/index.tsx +++ b/superset-frontend/src/components/TableSelector/index.tsx @@ -196,7 +196,7 @@ const TableSelector: FunctionComponent = ({ ? data.options.map(table => ({ value: table.value, label: , - text: table.label, + text: table.value, })) : [], [data], diff --git a/superset-frontend/src/hooks/apiResources/tables.test.ts b/superset-frontend/src/hooks/apiResources/tables.test.ts index 11afef6b12..6ff19cb401 100644 --- a/superset-frontend/src/hooks/apiResources/tables.test.ts +++ b/superset-frontend/src/hooks/apiResources/tables.test.ts @@ -103,7 +103,7 @@ describe('useTables hook', () => { }); expect(SupersetClient.get).toHaveBeenCalledTimes(1); expect(SupersetClient.get).toHaveBeenCalledWith({ - endpoint: `/superset/tables/${expectDbId}/${expectedSchema}/undefined/${forceRefresh}/`, + endpoint: `/superset/tables/${expectDbId}/${expectedSchema}/${forceRefresh}/`, }); expect(result.current.data).toEqual(expectedData); await act(async () => { @@ -111,38 +111,11 @@ describe('useTables hook', () => { }); expect(SupersetClient.get).toHaveBeenCalledTimes(2); expect(SupersetClient.get).toHaveBeenCalledWith({ - endpoint: `/superset/tables/${expectDbId}/${expectedSchema}/undefined/true/`, + endpoint: `/superset/tables/${expectDbId}/${expectedSchema}/true/`, }); expect(result.current.data).toEqual(expectedData); }); - it('returns api response for search keyword', async () => { - const expectDbId = 'db1'; - const expectedSchema = 'schemaA'; - const expectedKeyword = 'my work'; - const forceRefresh = false; - renderHook( - () => - useTables({ - dbId: expectDbId, - schema: expectedSchema, - keyword: expectedKeyword, - }), - { - wrapper: QueryProvider, - }, - ); - await act(async () => { - jest.runAllTimers(); - }); - expect(SupersetClient.get).toHaveBeenCalledTimes(1); - expect(SupersetClient.get).toHaveBeenCalledWith({ - endpoint: `/superset/tables/${expectDbId}/${expectedSchema}/${encodeURIComponent( - expectedKeyword, - )}/${forceRefresh}/`, - }); - }); - it('returns hasMore when total is larger than result size', async () => { (SupersetClient.get as jest.Mock).mockResolvedValueOnce( fakeHasMoreApiResult, diff --git a/superset-frontend/src/hooks/apiResources/tables.ts b/superset-frontend/src/hooks/apiResources/tables.ts index 80dd5001ac..994a7380f4 100644 --- a/superset-frontend/src/hooks/apiResources/tables.ts +++ b/superset-frontend/src/hooks/apiResources/tables.ts @@ -24,7 +24,6 @@ export type FetchTablesQueryParams = { dbId?: string | number; schema?: string; forceRefresh?: boolean; - keyword?: string; }; export interface Table { label: string; @@ -52,14 +51,12 @@ export function fetchTables({ dbId, schema, forceRefresh, - keyword, }: FetchTablesQueryParams) { const encodedSchema = schema ? encodeURIComponent(schema) : ''; - const encodedKeyword = keyword ? encodeURIComponent(keyword) : 'undefined'; // TODO: Would be nice to add pagination in a follow-up. Needs endpoint changes. const endpoint = `/superset/tables/${ dbId ?? 'undefined' - }/${encodedSchema}/${encodedKeyword}/${forceRefresh}/`; + }/${encodedSchema}/${forceRefresh}/`; return SupersetClient.get({ endpoint }) as Promise; } @@ -67,11 +64,11 @@ type Params = FetchTablesQueryParams & Pick; export function useTables(options: Params) { - const { dbId, schema, keyword, onSuccess, onError } = options || {}; + const { dbId, schema, onSuccess, onError } = options || {}; const forceRefreshRef = useRef(false); - const params = { dbId, schema, keyword }; + const params = { dbId, schema }; const result = useQuery( - ['tables', { dbId, schema, keyword }], + ['tables', { dbId, schema }], () => fetchTables({ ...params, forceRefresh: forceRefreshRef.current }), { select: ({ json }) => ({ diff --git a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx index 9d79d5cc8f..1b40e42299 100644 --- a/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx +++ b/superset-frontend/src/views/CRUD/data/dataset/AddDataset/LeftPanel/index.tsx @@ -172,7 +172,7 @@ export default function LeftPanel({ useEffect(() => { if (loadTables) { const endpoint = encodeURI( - `/superset/tables/${dbId}/${encodedSchema}/undefined/${refresh}/`, + `/superset/tables/${dbId}/${encodedSchema}/${refresh}/`, ); getTablesList(endpoint); } @@ -188,10 +188,8 @@ export default function LeftPanel({ const search = useMemo( () => debounce((value: string) => { - const encodeTableName = - value === '' ? undefined : encodeURIComponent(value); const endpoint = encodeURI( - `/superset/tables/${dbId}/${encodedSchema}/${encodeTableName}/`, + `/superset/tables/${dbId}/${encodedSchema}/`, ); getTablesList(endpoint); }, FAST_DEBOUNCE),