From 4d41106157bfdaf50bd201877688e259eb0884da Mon Sep 17 00:00:00 2001 From: Adam Struck Date: Mon, 26 Feb 2024 20:57:03 -0800 Subject: [PATCH] fix: schema filtering in table search modal (#1348) * fix: schema filtering for table search * revert unnecessary changes --- .../components/Search/SearchOverview.tsx | 1 + .../components/Search/SearchSchemaSelect.tsx | 31 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/querybook/webapp/components/Search/SearchOverview.tsx b/querybook/webapp/components/Search/SearchOverview.tsx index 082f59553..ac41e7891 100644 --- a/querybook/webapp/components/Search/SearchOverview.tsx +++ b/querybook/webapp/components/Search/SearchOverview.tsx @@ -775,6 +775,7 @@ export const SearchOverview: React.FC = ({ {queryMetastoreHasDataElements && ( diff --git a/querybook/webapp/components/Search/SearchSchemaSelect.tsx b/querybook/webapp/components/Search/SearchSchemaSelect.tsx index 7d5458156..a90ebee94 100644 --- a/querybook/webapp/components/Search/SearchSchemaSelect.tsx +++ b/querybook/webapp/components/Search/SearchSchemaSelect.tsx @@ -1,7 +1,5 @@ import React, { useMemo, useCallback } from 'react'; import AsyncSelect from 'react-select/async'; -import { useSelector } from 'react-redux'; -import { IStoreState } from 'redux/store/types'; import { makeReactSelectStyle, asyncReactSelectStyles, @@ -10,6 +8,7 @@ import { import { SearchSchemaResource } from 'resource/search'; interface ISearchSchemaSelectProps { + metastoreId: number; schema?: string[]; updateSearchFilter: (key: string, value: string[]) => void; } @@ -22,11 +21,8 @@ const tableReactSelectStyle = makeReactSelectStyle( export const SearchSchemaSelect: React.FC = ({ updateSearchFilter, schema, + metastoreId, }) => { - const currentMetastoreId = useSelector( - (state: IStoreState) => state.environment.currentEnvironmentId - ); - const handleUpdateSearchFilter = useCallback((option: IOptions) => { updateSearchFilter( 'schema', @@ -34,17 +30,20 @@ export const SearchSchemaSelect: React.FC = ({ ); }, []); - const loadOptions = useCallback(async (value) => { - const searchRequest = await SearchSchemaResource.getMore({ - metastore_id: currentMetastoreId, - name: value, - }); + const loadOptions = useCallback( + async (value) => { + const searchRequest = await SearchSchemaResource.getMore({ + metastore_id: metastoreId, + name: value, + }); - return searchRequest.data.results.map((schema) => ({ - label: schema.name, - value: schema.name, - })); - }, []); + return searchRequest.data.results.map((schema) => ({ + label: schema.name, + value: schema.name, + })); + }, + [metastoreId, schema] + ); const selectedSchemaItems = useMemo( () =>