diff --git a/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx b/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx index 524c4768311..bf991307d11 100644 --- a/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx +++ b/catalog-rest-service/src/main/resources/ui/src/pages/explore/index.tsx @@ -92,6 +92,28 @@ const getCurrentTab = (tab: string) => { return currentTab; }; +const getCurrentIndex = (tab: string) => { + let currentIndex = SearchIndex.TABLE; + switch (tab) { + case 'topics': + currentIndex = SearchIndex.TOPIC; + + break; + case 'dashboards': + currentIndex = SearchIndex.DASHBOARD; + + break; + + case 'tables': + default: + currentIndex = SearchIndex.TABLE; + + break; + } + + return currentIndex; +}; + const ExplorePage: React.FC = (): React.ReactElement => { const location = useLocation(); const history = useHistory(); @@ -113,7 +135,7 @@ const ExplorePage: React.FC = (): React.ReactElement => { const [fieldListVisible, setFieldListVisible] = useState(false); const [sortField, setSortField] = useState('last_updated_timestamp'); const [sortOrder, setSortOrder] = useState('desc'); - const [searchIndex, setSearchIndex] = useState(SearchIndex.TABLE); + const [searchIndex, setSearchIndex] = useState(getCurrentIndex(tab)); const [currentTab, setCurrentTab] = useState(getCurrentTab(tab)); const [tableCount, setTableCount] = useState(0); const [topicCount, setTopicCount] = useState(0); @@ -491,7 +513,7 @@ const ExplorePage: React.FC = (): React.ReactElement => { setSearchText(searchQuery || ''); setCurrentPage(1); setCurrentTab(getCurrentTab(tab)); - setSearchIndex(tabsInfo[getCurrentTab(tab) - 1].index); + setSearchIndex(getCurrentIndex(tab)); setFieldList(tabsInfo[getCurrentTab(tab) - 1].sortingFields); setSortField(tabsInfo[getCurrentTab(tab) - 1].sortField); }, [searchQuery, tab]); @@ -507,7 +529,7 @@ const ExplorePage: React.FC = (): React.ReactElement => { }, [searchText, searchIndex]); useEffect(() => { - if (!isMounting.current && previsouIndex === searchIndex) { + if (!isMounting.current && previsouIndex === getCurrentIndex(tab)) { fetchTableData(false); } }, [currentPage, filters, sortField, sortOrder]);