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> = [];
inPageSearchText = '';
explorePageTab = 'tables';
constructor() {
makeAutoObservable(this);

View File

@ -141,7 +141,15 @@ const Appbar: React.FC = (): JSX.Element => {
const target = e.target as HTMLInputElement;
if (e.key === 'Enter') {
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 (
<>
<PageContainer leftPanelContent={fetchLeftPanel && fetchLeftPanel()}>
<PageContainer leftPanelContent={fetchLeftPanel?.()}>
<div className="container-fluid" data-testid="fluid-container">
{isLoading ? (
<Loader />
@ -127,7 +127,10 @@ const SearchedData: React.FC<SearchedDataProp> = ({
) : null}
</>
) : (
<ErrorPlaceHolderES type="noData" />
<>
{children}
<ErrorPlaceHolderES type="noData" />
</>
)}
</>
)}

View File

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

View File

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