From 2edde8725e57b2d30c038655f8dac0a504bbf609 Mon Sep 17 00:00:00 2001 From: abbyhu2000 Date: Thu, 14 Nov 2024 00:13:35 +0000 Subject: [PATCH 1/4] keep previous result Signed-off-by: abbyhu2000 --- .../view_components/canvas/index.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) 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 71d47446c75c..131bff7cca13 100644 --- a/src/plugins/discover/public/application/view_components/canvas/index.tsx +++ b/src/plugins/discover/public/application/view_components/canvas/index.tsx @@ -85,7 +85,12 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history, optionalR 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 - if (next.status !== ResultStatus.LOADING && next.rows && next.rows !== fetchState.rows) { + if ( + next.status !== ResultStatus.LOADING && + next.status !== ResultStatus.ERROR && + next.rows && + next.rows !== fetchState.rows + ) { shouldUpdateState = true; setRows(next.rows); } @@ -152,20 +157,13 @@ 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.READY || - (fetchState.status === ResultStatus.LOADING && !!rows?.length)) && + (fetchState.status === ResultStatus.LOADING && !!rows?.length) || + fetchState.status === ResultStatus.ERROR) && (isEnhancementsEnabled ? ( <> From f591508b00c2dc2fb916181cad684f1cc4f707b0 Mon Sep 17 00:00:00 2001 From: "opensearch-changeset-bot[bot]" <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com> Date: Thu, 14 Nov 2024 00:16:32 +0000 Subject: [PATCH 2/4] Changeset file for PR #8863 created/updated --- changelogs/fragments/8863.yml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 changelogs/fragments/8863.yml diff --git a/changelogs/fragments/8863.yml b/changelogs/fragments/8863.yml new file mode 100644 index 000000000000..51dc8d37cc2f --- /dev/null +++ b/changelogs/fragments/8863.yml @@ -0,0 +1,2 @@ +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 From 6c9da3bc001c9629cd5b22008a70beefe39e1a09 Mon Sep 17 00:00:00 2001 From: abbyhu2000 Date: Thu, 14 Nov 2024 00:21:21 +0000 Subject: [PATCH 3/4] add some comment Signed-off-by: abbyhu2000 --- .../public/application/view_components/canvas/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 131bff7cca13..f2de8293a296 100644 --- a/src/plugins/discover/public/application/view_components/canvas/index.tsx +++ b/src/plugins/discover/public/application/view_components/canvas/index.tsx @@ -84,7 +84,7 @@ 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 + // 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 && From e70cf4eb19969a7fa80e6e312bb33fa0e2e76ed7 Mon Sep 17 00:00:00 2001 From: abbyhu2000 Date: Thu, 14 Nov 2024 01:31:46 +0000 Subject: [PATCH 4/4] invalid first query shows refresh data page Signed-off-by: abbyhu2000 --- .../public/application/view_components/canvas/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 f2de8293a296..5fe1bac50891 100644 --- a/src/plugins/discover/public/application/view_components/canvas/index.tsx +++ b/src/plugins/discover/public/application/view_components/canvas/index.tsx @@ -161,9 +161,12 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history, optionalR 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) && + (fetchState.status === ResultStatus.ERROR && !!rows?.length)) && (isEnhancementsEnabled ? ( <>