Skip to content

Commit 75f584c

Browse files
fix: clear discover summary if t2ppl failed (#9552)
* fix: clear discover summary if t2ppl failed + removed the placeholder of last ask question Signed-off-by: Yulong Ruan <ruanyl@amazon.com> * Changeset file for PR #9552 created/updated --------- Signed-off-by: Yulong Ruan <ruanyl@amazon.com> Co-authored-by: opensearch-changeset-bot[bot] <154024398+opensearch-changeset-bot[bot]@users.noreply.github.com>
1 parent 3c5a261 commit 75f584c

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

changelogs/fragments/9552.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fix:
2+
- Clear discover summary if t2ppl failed ([#9552](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9552))
3+
- Query-assist removed the placeholder of last ask question ([#9552](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/9552))

src/plugins/query_enhancements/public/query_assist/components/query_assist_bar.tsx

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ export const QueryAssistBar: React.FC<QueryAssistInputProps> = (props) => {
8282
} else {
8383
services.notifications.toasts.addError(error, { title: 'Failed to generate results' });
8484
}
85+
updateQueryState({
86+
question: previousQuestionRef.current,
87+
generatedQuery: '', // query generate failed, set it to empty
88+
});
8589
} else if (response) {
8690
services.data.query.queryString.setQuery({
8791
query: response.query,

src/plugins/query_enhancements/public/query_assist/components/query_assist_input.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -87,16 +87,15 @@ export const QueryAssistInput: React.FC<QueryAssistInputProps> = (props) => {
8787
onChange={(e) => setValue(e.target.value)}
8888
onKeyDown={() => setIsSuggestionsVisible(true)}
8989
placeholder={
90-
props.previousQuestion ||
91-
(props.selectedIndex
90+
props.selectedIndex
9291
? i18n.translate('queryEnhancements.queryAssist.input.placeholderWithIndex', {
9392
defaultMessage:
9493
'Ask a natural language question about {selectedIndex} to generate a query',
9594
values: { selectedIndex: props.selectedIndex },
9695
})
9796
: i18n.translate('queryEnhancements.queryAssist.input.placeholderWithoutIndex', {
9897
defaultMessage: 'Select an index to ask a question',
99-
}))
98+
})
10099
}
101100
prepend={<EuiIcon type={assistantMark} />}
102101
append={<WarningBadge error={props.error} />}

src/plugins/query_enhancements/public/query_assist/components/query_assist_summary.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import React, { useEffect, useState, useCallback, useRef } from 'react';
1818
import { i18n } from '@osd/i18n';
1919
import { IDataFrame } from 'src/plugins/data/common';
2020
import { v4 as uuidv4 } from 'uuid';
21-
import { isEmpty, isEqual } from 'lodash';
21+
import { isEmpty } from 'lodash';
2222
import { filter, distinctUntilChanged } from 'rxjs/operators';
2323
import { HttpSetup } from 'opensearch-dashboards/public';
2424
import { QueryAssistState, useQueryAssist } from '../hooks';
@@ -151,7 +151,7 @@ export const QueryAssistSummary: React.FC<QueryAssistSummaryProps> = (props) =>
151151
filter((value) => !isEmpty(value) && !isEmpty(value?.fields))
152152
)
153153
.subscribe((df) => {
154-
if (df && currentQueryStateRef.current.question) {
154+
if (df) {
155155
setResults(convertResult(df));
156156
}
157157
});
@@ -275,7 +275,7 @@ export const QueryAssistSummary: React.FC<QueryAssistSummaryProps> = (props) =>
275275
return (
276276
<EuiText size="s" data-test-subj="queryAssist_summary_can_not_generate">
277277
{i18n.translate('queryEnhancements.queryAssist.summary.canNotGenerate', {
278-
defaultMessage: 'Summary unavailable, please check if there were results.',
278+
defaultMessage: 'Summary unavailable, please check if there were results or errors.',
279279
})}
280280
</EuiText>
281281
);

0 commit comments

Comments
 (0)