Skip to content

Commit

Permalink
[Discover][ES|QL] Rename Documents tab to Results (elastic#197833)
Browse files Browse the repository at this point in the history
## Summary

This PR renames Documents label to Results for ES|QL mode.

<img width="1091" alt="Screenshot 2024-10-25 at 15 44 32"
src="https://github.com/user-attachments/assets/8678bb86-7e4b-4341-9bb3-50becced655b">
<img width="1676" alt="Screenshot 2024-10-25 at 15 52 55"
src="https://github.com/user-attachments/assets/c79d2ee0-62e1-4506-bcb5-29552287f140">




### 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
  • Loading branch information
jughosta authored Oct 28, 2024
1 parent a904803 commit 8a96f69
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,45 @@ 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 = (
<strong>
<FormattedNumber value={totalHitCount} />
</strong>
);

return (
<EuiText
grow={false}
size="s"
style={{ paddingRight: 2 }}
data-test-subj="savedSearchTotalDocuments"
>
<FormattedMessage
id="discover.docTable.totalDocuments"
defaultMessage="{totalDocuments} documents"
values={{
totalDocuments: (
<strong>
<FormattedNumber value={totalHitCount} />
</strong>
),
}}
/>
{isEsqlMode ? (
<FormattedMessage
id="discover.embeddable.totalResults"
defaultMessage="{totalDocuments} {totalHitCount, plural, one {result} other {results}}"
values={{
totalDocuments,
totalHitCount,
}}
/>
) : (
<FormattedMessage
id="discover.embeddable.totalDocuments"
defaultMessage="{totalDocuments} {totalHitCount, plural, one {document} other {documents}}"
values={{
totalDocuments,
totalHitCount,
}}
/>
)}
</EuiText>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand All @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,14 @@ export const DocumentViewModeToggle = ({
onClick={() => setDiscoverViewMode(VIEW_MODE.DOCUMENT_LEVEL)}
data-test-subj="dscViewModeDocumentButton"
>
<FormattedMessage id="discover.viewModes.document.label" defaultMessage="Documents" />
{isEsqlMode ? (
<FormattedMessage id="discover.viewModes.esql.label" defaultMessage="Results" />
) : (
<FormattedMessage
id="discover.viewModes.document.label"
defaultMessage="Documents"
/>
)}
<HitsCounter mode={HitsCounterMode.appended} stateContainer={stateContainer} />
</EuiTab>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ export function DiscoverGridEmbeddable(props: DiscoverGridEmbeddableProps) {
getRenderCustomToolbarWithElements({
leftSide:
typeof props.totalHitCount === 'number' ? (
<TotalDocuments totalHitCount={props.totalHitCount} />
<TotalDocuments totalHitCount={props.totalHitCount} isEsqlMode={props.isPlainRecord} />
) : undefined,
}),
[props.totalHitCount]
[props.totalHitCount, props.isPlainRecord]
);

const getCellRenderersAccessor = useProfileAccessor('getCellRenderers');
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "フィールドを列として表に追加するには、ゾーンをドロップします",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "放置区域以将字段作为列添加到表中",
Expand Down

0 comments on commit 8a96f69

Please sign in to comment.