From 3de1e30807997ada0e2e265814fe1e8f76305cc3 Mon Sep 17 00:00:00 2001 From: Julia Rechkunova Date: Mon, 28 Oct 2024 12:45:39 +0100 Subject: [PATCH] [Discover][ES|QL] Rename Documents tab to Results (#197833) ## Summary This PR renames Documents label to Results for ES|QL mode. Screenshot 2024-10-25 at 15 44 32 Screenshot 2024-10-25 at 15 52 55 ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios (cherry picked from commit 8a96f69250ffe674c3d2fff340db39f7f8b99652) --- .../total_documents/total_documents.tsx | 44 ++++++++++++++----- .../view_mode_toggle.test.tsx | 2 + .../view_mode_toggle/view_mode_toggle.tsx | 9 +++- .../components/saved_search_grid.tsx | 4 +- .../translations/translations/fr-FR.json | 1 - .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 1 - 7 files changed, 44 insertions(+), 18 deletions(-) diff --git a/src/plugins/discover/public/application/main/components/total_documents/total_documents.tsx b/src/plugins/discover/public/application/main/components/total_documents/total_documents.tsx index f9a3f04cc1c56..5644efc8a9bbd 100644 --- a/src/plugins/discover/public/application/main/components/total_documents/total_documents.tsx +++ b/src/plugins/discover/public/application/main/components/total_documents/total_documents.tsx @@ -11,7 +11,19 @@ import React from 'react'; import { FormattedMessage, FormattedNumber } from '@kbn/i18n-react'; import { EuiText } from '@elastic/eui'; -export const TotalDocuments = ({ totalHitCount }: { totalHitCount: number }) => { +export const TotalDocuments = ({ + totalHitCount, + isEsqlMode, +}: { + totalHitCount: number; + isEsqlMode?: boolean; +}) => { + const totalDocuments = ( + + + + ); + return ( style={{ paddingRight: 2 }} data-test-subj="savedSearchTotalDocuments" > - - - - ), - }} - /> + {isEsqlMode ? ( + + ) : ( + + )} ); }; diff --git a/src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.test.tsx b/src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.test.tsx index f045e78de5ddf..7d88f9ad1fef4 100644 --- a/src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.test.tsx +++ b/src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.test.tsx @@ -94,6 +94,7 @@ describe('Document view mode toggle component', () => { expect(findTestSubject(component, 'dscViewModeDocumentButton').exists()).toBe(true); expect(findTestSubject(component, 'dscViewModePatternAnalysisButton').exists()).toBe(true); expect(findTestSubject(component, 'dscViewModeFieldStatsButton').exists()).toBe(true); + expect(findTestSubject(component, 'dscViewModeDocumentButton').text()).toBe('Documents (10)'); }); it('should not render if SHOW_FIELD_STATISTICS is false', async () => { @@ -114,6 +115,7 @@ describe('Document view mode toggle component', () => { expect(findTestSubject(component, 'dscViewModeDocumentButton').exists()).toBe(true); expect(findTestSubject(component, 'dscViewModePatternAnalysisButton').exists()).toBe(false); expect(findTestSubject(component, 'dscViewModeFieldStatsButton').exists()).toBe(true); + expect(findTestSubject(component, 'dscViewModeDocumentButton').text()).toBe('Results (10)'); }); it('should set the view mode to VIEW_MODE.DOCUMENT_LEVEL when dscViewModeDocumentButton is clicked', async () => { diff --git a/src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.tsx b/src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.tsx index 10a92dc8fefa9..22c4aaa11b43a 100644 --- a/src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.tsx +++ b/src/plugins/discover/public/components/view_mode_toggle/view_mode_toggle.tsx @@ -130,7 +130,14 @@ export const DocumentViewModeToggle = ({ onClick={() => setDiscoverViewMode(VIEW_MODE.DOCUMENT_LEVEL)} data-test-subj="dscViewModeDocumentButton" > - + {isEsqlMode ? ( + + ) : ( + + )} diff --git a/src/plugins/discover/public/embeddable/components/saved_search_grid.tsx b/src/plugins/discover/public/embeddable/components/saved_search_grid.tsx index e45ad009db898..f6c77dc6cddf5 100644 --- a/src/plugins/discover/public/embeddable/components/saved_search_grid.tsx +++ b/src/plugins/discover/public/embeddable/components/saved_search_grid.tsx @@ -85,10 +85,10 @@ export function DiscoverGridEmbeddable(props: DiscoverGridEmbeddableProps) { getRenderCustomToolbarWithElements({ leftSide: typeof props.totalHitCount === 'number' ? ( - + ) : undefined, }), - [props.totalHitCount] + [props.totalHitCount, props.isPlainRecord] ); const getCellRenderersAccessor = useProfileAccessor('getCellRenderers'); diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index f4a38ce6ee929..7d16a6f2f1c06 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -2423,7 +2423,6 @@ "discover.docTable.tableRow.toggleRowDetailsButtonAriaLabel": "Afficher/Masquer les détails de la ligne", "discover.docTable.tableRow.viewSingleDocumentLinkText": "Afficher un seul document", "discover.docTable.tableRow.viewSurroundingDocumentsLinkText": "Afficher les documents alentour", - "discover.docTable.totalDocuments": "{totalDocuments} documents", "discover.documentsAriaLabel": "Documents", "discover.docViews.table.scoreSortWarningTooltip": "Filtrez sur _score pour pouvoir récupérer les valeurs correspondantes.", "discover.dropZoneTableLabel": "Abandonner la zone pour ajouter un champ en tant que colonne dans la table", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 27b79ebde86f6..d9e6817794c29 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -2422,7 +2422,6 @@ "discover.docTable.tableRow.toggleRowDetailsButtonAriaLabel": "行の詳細を切り替える", "discover.docTable.tableRow.viewSingleDocumentLinkText": "単一のドキュメントを表示", "discover.docTable.tableRow.viewSurroundingDocumentsLinkText": "周りのドキュメントを表示", - "discover.docTable.totalDocuments": "{totalDocuments}ドキュメント", "discover.documentsAriaLabel": "ドキュメント", "discover.docViews.table.scoreSortWarningTooltip": "_scoreの値を取得するには、並べ替える必要があります。", "discover.dropZoneTableLabel": "フィールドを列として表に追加するには、ゾーンをドロップします", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index ee8601400fef0..a8e060d1e39af 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -2424,7 +2424,6 @@ "discover.docTable.tableRow.toggleRowDetailsButtonAriaLabel": "切换行详细信息", "discover.docTable.tableRow.viewSingleDocumentLinkText": "查看单个文档", "discover.docTable.tableRow.viewSurroundingDocumentsLinkText": "查看周围文档", - "discover.docTable.totalDocuments": "{totalDocuments} 个文档", "discover.documentsAriaLabel": "文档", "discover.docViews.table.scoreSortWarningTooltip": "要检索 _score 的值,必须按其筛选。", "discover.dropZoneTableLabel": "放置区域以将字段作为列添加到表中",