From 4df77a5581b076433f21db0687bb295f0699e65c Mon Sep 17 00:00:00 2001 From: abbyhu2000 Date: Mon, 25 Nov 2024 22:18:06 +0000 Subject: [PATCH] Revert "Keep previous query result if current query result in error (#8863)" This reverts commit bca4f5c637020b23c1b90c2a715f263f55807876. Signed-off-by: abbyhu2000 --- changelogs/fragments/8863.yml | 2 -- .../view_components/canvas/index.tsx | 23 +++++++++---------- 2 files changed, 11 insertions(+), 14 deletions(-) delete mode 100644 changelogs/fragments/8863.yml diff --git a/changelogs/fragments/8863.yml b/changelogs/fragments/8863.yml deleted file mode 100644 index 51dc8d37cc2f..000000000000 --- a/changelogs/fragments/8863.yml +++ /dev/null @@ -1,2 +0,0 @@ -fix: -- Keep previous query result if current query result in error ([#8863](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/8863)) \ No newline at end of file diff --git a/src/plugins/discover/public/application/view_components/canvas/index.tsx b/src/plugins/discover/public/application/view_components/canvas/index.tsx index 5fe1bac50891..71d47446c75c 100644 --- a/src/plugins/discover/public/application/view_components/canvas/index.tsx +++ b/src/plugins/discover/public/application/view_components/canvas/index.tsx @@ -84,13 +84,8 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history, optionalR if (next.bucketInterval && next.bucketInterval !== fetchState.bucketInterval) shouldUpdateState = true; if (next.chartData && next.chartData !== fetchState.chartData) shouldUpdateState = true; - // we still want to show rows from the previous query while current query is loading or the current query results in error - if ( - next.status !== ResultStatus.LOADING && - next.status !== ResultStatus.ERROR && - next.rows && - next.rows !== fetchState.rows - ) { + // we still want to show rows from the previous query while current query is loading + if (next.status !== ResultStatus.LOADING && next.rows && next.rows !== fetchState.rows) { shouldUpdateState = true; setRows(next.rows); } @@ -157,16 +152,20 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history, optionalR timeFieldName={timeField} /> )} + {fetchState.status === ResultStatus.ERROR && ( + + )} {fetchState.status === ResultStatus.UNINITIALIZED && ( refetch$.next()} /> )} {fetchState.status === ResultStatus.LOADING && !rows?.length && } - {fetchState.status === ResultStatus.ERROR && !rows?.length && ( - refetch$.next()} /> - )} {(fetchState.status === ResultStatus.READY || - (fetchState.status === ResultStatus.LOADING && !!rows?.length) || - (fetchState.status === ResultStatus.ERROR && !!rows?.length)) && + (fetchState.status === ResultStatus.LOADING && !!rows?.length)) && (isEnhancementsEnabled ? ( <>