Skip to content

Commit

Permalink
fix: schema filtering in table search modal (#1348)
Browse files Browse the repository at this point in the history
* fix: schema filtering for table search

* revert unnecessary changes
  • Loading branch information
adamstruck authored Feb 27, 2024
1 parent 8190652 commit 4d41106
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
1 change: 1 addition & 0 deletions querybook/webapp/components/Search/SearchOverview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,7 @@ export const SearchOverview: React.FC<ISearchOverviewProps> = ({
<SearchSchemaSelect
updateSearchFilter={updateSearchFilter}
schema={searchFilters?.schema}
metastoreId={metastoreId}
/>
</div>
{queryMetastoreHasDataElements && (
Expand Down
31 changes: 15 additions & 16 deletions querybook/webapp/components/Search/SearchSchemaSelect.tsx
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -10,6 +8,7 @@ import {
import { SearchSchemaResource } from 'resource/search';

interface ISearchSchemaSelectProps {
metastoreId: number;
schema?: string[];
updateSearchFilter: (key: string, value: string[]) => void;
}
Expand All @@ -22,29 +21,29 @@ const tableReactSelectStyle = makeReactSelectStyle(
export const SearchSchemaSelect: React.FC<ISearchSchemaSelectProps> = ({
updateSearchFilter,
schema,
metastoreId,
}) => {
const currentMetastoreId = useSelector(
(state: IStoreState) => state.environment.currentEnvironmentId
);

const handleUpdateSearchFilter = useCallback((option: IOptions<string>) => {
updateSearchFilter(
'schema',
option.map((o) => o.value)
);
}, []);

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(
() =>
Expand Down

0 comments on commit 4d41106

Please sign in to comment.