Fixed #488 Explore page Entity tab issue (#489)

* Fixed #488 Explore page Entity tab issue

* minor fix
This commit is contained in:
Sachin Chaurasiya 2021-09-14 19:16:49 +05:30 committed by GitHub
parent 96729e49e3
commit cb5e2196be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 26 additions and 8 deletions

View File

@ -32,6 +32,7 @@ class AppState {
userTeams: Array<UserTeam> = []; userTeams: Array<UserTeam> = [];
inPageSearchText = ''; inPageSearchText = '';
explorePageTab = 'tables';
constructor() { constructor() {
makeAutoObservable(this); makeAutoObservable(this);

View File

@ -141,7 +141,15 @@ const Appbar: React.FC = (): JSX.Element => {
const target = e.target as HTMLInputElement; const target = e.target as HTMLInputElement;
if (e.key === 'Enter') { if (e.key === 'Enter') {
setIsOpen(false); setIsOpen(false);
history.push(getExplorePathWithSearch(target.value)); history.push(
getExplorePathWithSearch(
target.value,
// this is for if user is searching from another page
location.pathname.startsWith(ROUTES.EXPLORE)
? appState.explorePageTab
: 'tables'
)
);
} }
}} }}
/> />

View File

@ -92,7 +92,7 @@ const SearchedData: React.FC<SearchedDataProp> = ({
return ( return (
<> <>
<PageContainer leftPanelContent={fetchLeftPanel && fetchLeftPanel()}> <PageContainer leftPanelContent={fetchLeftPanel?.()}>
<div className="container-fluid" data-testid="fluid-container"> <div className="container-fluid" data-testid="fluid-container">
{isLoading ? ( {isLoading ? (
<Loader /> <Loader />
@ -127,7 +127,10 @@ const SearchedData: React.FC<SearchedDataProp> = ({
) : null} ) : null}
</> </>
) : ( ) : (
<ErrorPlaceHolderES type="noData" /> <>
{children}
<ErrorPlaceHolderES type="noData" />
</>
)} )}
</> </>
)} )}

View File

@ -312,7 +312,7 @@ const DatabaseDetails: FunctionComponent = () => {
</Link> </Link>
</td> </td>
<td className="tableBody-cell"> <td className="tableBody-cell">
{table.description ? ( {table.description.trim() ? (
<RichTextEditorPreviewer <RichTextEditorPreviewer
markdown={table.description} markdown={table.description}
/> />

View File

@ -26,6 +26,7 @@ import {
} from 'Models'; } from 'Models';
import React, { useCallback, useEffect, useRef, useState } from 'react'; import React, { useCallback, useEffect, useRef, useState } from 'react';
import { useHistory, useLocation, useParams } from 'react-router-dom'; import { useHistory, useLocation, useParams } from 'react-router-dom';
import AppState from '../../AppState';
import { searchData } from '../../axiosAPIs/miscAPI'; import { searchData } from '../../axiosAPIs/miscAPI';
import { Button } from '../../components/buttons/Button/Button'; import { Button } from '../../components/buttons/Button/Button';
import ErrorPlaceHolderES from '../../components/common/error-with-placeholder/ErrorPlaceHolderES'; import ErrorPlaceHolderES from '../../components/common/error-with-placeholder/ErrorPlaceHolderES';
@ -471,6 +472,7 @@ const ExplorePage: React.FC = (): React.ReactElement => {
}; };
const onTabChange = (selectedTab: number) => { const onTabChange = (selectedTab: number) => {
if (tabsInfo[selectedTab - 1].path !== tab) { if (tabsInfo[selectedTab - 1].path !== tab) {
AppState.explorePageTab = tabsInfo[selectedTab - 1].path;
resetFilters(); resetFilters();
history.push({ history.push({
pathname: getExplorePathWithSearch( pathname: getExplorePathWithSearch(
@ -511,14 +513,18 @@ const ExplorePage: React.FC = (): React.ReactElement => {
}; };
useEffect(() => { useEffect(() => {
setFilters(filterObject);
setSearchText(searchQuery || ''); setSearchText(searchQuery || '');
setCurrentPage(1); setCurrentPage(1);
setCurrentTab(getCurrentTab(tab)); }, [searchQuery]);
setSearchIndex(getCurrentIndex(tab));
useEffect(() => {
setFilters(filterObject);
setFieldList(tabsInfo[getCurrentTab(tab) - 1].sortingFields); setFieldList(tabsInfo[getCurrentTab(tab) - 1].sortingFields);
setSortField(tabsInfo[getCurrentTab(tab) - 1].sortField); setSortField(tabsInfo[getCurrentTab(tab) - 1].sortField);
}, [searchQuery, tab]); setCurrentTab(getCurrentTab(tab));
setSearchIndex(getCurrentIndex(tab));
setCurrentPage(1);
}, [tab]);
useEffect(() => { useEffect(() => {
if (getFilterString(filters)) { if (getFilterString(filters)) {