Skip to content

Commit

Permalink
should show loding
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaoyongjie committed May 30, 2022
1 parent 8e90264 commit c0b6de0
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export const ResultsPane = ({
const [data, setData] = useState<Record<string, any>[][]>([]);
const [colnames, setColnames] = useState<string[]>([]);
const [coltypes, setColtypes] = useState<GenericDataType[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [isLoading, setIsLoading] = useState<boolean>(true);
const [responseError, setResponseError] = useState<string>('');

useEffect(() => {
Expand Down Expand Up @@ -105,6 +105,12 @@ export const ResultsPane = ({
}
}, [queryFormData, isRequest]);

useEffect(() => {
if (errorMessage) {
setIsLoading(false);
}
}, [errorMessage]);

const originalFormattedTimeColumns = useOriginalFormattedTimeColumns(
queryFormData.datasource,
);
Expand All @@ -119,15 +125,15 @@ export const ResultsPane = ({
);
const filteredData = useFilteredTableData(filterText, data);

if (isLoading) {
return <Loading />;
}

if (errorMessage) {
const title = t('Run a query to display results');
return <EmptyStateMedium image="document.svg" title={title} />;
}

if (isLoading) {
return <Loading />;
}

if (responseError) {
return (
<>
Expand Down

0 comments on commit c0b6de0

Please sign in to comment.