Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] [Discover][ES|QL] Rename Documents tab to Results (#197833) #197979

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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