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

[WIP] [ML] (Accessibility) Read summary info for File contents and Summary stats #31117 #34686

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from 2 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 @@ -6,6 +6,7 @@


import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import React from 'react';

import {
Expand All @@ -16,11 +17,12 @@ import {

export function AnalysisSummary({ results }) {
const items = createDisplayItems(results);
const itemsWithI18n = pimpOutDisplayItemsWithAriaAndI18n(items);

return (
<React.Fragment>
<EuiTitle size="s">
<h3>
<h3 tabIndex="0">
<FormattedMessage
id="xpack.ml.fileDatavisualizer.analysisSummary.summaryTitle"
defaultMessage="Summary"
Expand All @@ -32,22 +34,26 @@ export function AnalysisSummary({ results }) {

<EuiDescriptionList
type="column"
listItems={items}
listItems={itemsWithI18n}
className="analysis-summary-list"
titleProps={{ tabIndex: '0' }}
/>
</React.Fragment>
);
}

function pimpOutDisplayItemsWithAriaAndI18n(items) {
PhilippBaranovskiy marked this conversation as resolved.
Show resolved Hide resolved
return items.map(item => Object.assign(item, {
PhilippBaranovskiy marked this conversation as resolved.
Show resolved Hide resolved
title: <span aria-label={`${item.title}: ${item.description}`}>{item.title}</span>
}));
}

function createDisplayItems(results) {
const items = [
{
title: (
<FormattedMessage
id="xpack.ml.fileDatavisualizer.analysisSummary.analyzedLinesNumberTitle"
defaultMessage="Number of lines analyzed"
/>
),
title: i18n.translate('xpack.ml.fileDatavisualizer.analysisSummary.analyzedLinesNumberTitle', {
defaultMessage: 'Number of lines analyzed'
}),
description: results.num_lines_analyzed,
},
// {
Expand All @@ -58,33 +64,24 @@ function createDisplayItems(results) {

if (results.format !== undefined) {
items.push({
title: (
<FormattedMessage
id="xpack.ml.fileDatavisualizer.analysisSummary.formatTitle"
defaultMessage="Format"
/>
),
title: i18n.translate('xpack.ml.fileDatavisualizer.analysisSummary.formatTitle', {
defaultMessage: 'Format'
}),
description: results.format,
});

if (results.format === 'delimited') {
items.push({
title: (
<FormattedMessage
id="xpack.ml.fileDatavisualizer.analysisSummary.delimiterTitle"
defaultMessage="Delimiter"
/>
),
title: i18n.translate('xpack.ml.fileDatavisualizer.analysisSummary.delimiterTitle', {
defaultMessage: 'Delimiter'
}),
description: results.delimiter,
});

items.push({
title: (
<FormattedMessage
id="xpack.ml.fileDatavisualizer.analysisSummary.hasHeaderRowTitle"
defaultMessage="Has header row"
/>
),
title: i18n.translate('xpack.ml.fileDatavisualizer.analysisSummary.hasHeaderRowTitle', {
defaultMessage: 'Has header row'
}),
description: `${results.has_header_row}`,
});

Expand All @@ -93,39 +90,30 @@ function createDisplayItems(results) {

if (results.grok_pattern !== undefined) {
items.push({
title: (
<FormattedMessage
id="xpack.ml.fileDatavisualizer.analysisSummary.grokPatternTitle"
defaultMessage="Grok pattern"
/>
),
title: i18n.translate('xpack.ml.fileDatavisualizer.analysisSummary.grokPatternTitle', {
defaultMessage: 'Grok pattern'
}),
description: results.grok_pattern,
});
}

if (results.timestamp_field !== undefined) {
items.push({
title: (
<FormattedMessage
id="xpack.ml.fileDatavisualizer.analysisSummary.timeFieldTitle"
defaultMessage="Time field"
/>
),
title: i18n.translate('xpack.ml.fileDatavisualizer.analysisSummary.timeFieldTitle', {
defaultMessage: 'Time field'
}),
description: results.timestamp_field,
});
}

if (results.java_timestamp_formats !== undefined) {
items.push({
title: (
<FormattedMessage
id="xpack.ml.fileDatavisualizer.analysisSummary.timeFormatTitle"
defaultMessage="Time {timestampFormats, plural, zero {format} one {format} other {formats}}"
values={{
timestampFormats: results.java_timestamp_formats.length,
}}
/>
),
title: i18n.translate('xpack.ml.fileDatavisualizer.analysisSummary.timeFormatTitle', {
defaultMessage: 'Time {timestampFormats, plural, zero {format} one {format} other {formats}}',
values: {
timestampFormats: results.java_timestamp_formats.length,
}
}),
description: results.java_timestamp_formats.join(', '),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/


import { FormattedMessage } from '@kbn/i18n/react';
import { i18n } from '@kbn/i18n';
import React from 'react';

import {
Expand All @@ -22,27 +22,36 @@ export function FileContents({ data, format, numberOfLines }) {
}

const formattedData = limitByNumberOfLines(data, numberOfLines);
const fileContentsHeader = i18n.translate('xpack.ml.fileDatavisualizer.fileContents.fileContentsTitle', {
defaultMessage: `File contents`
PhilippBaranovskiy marked this conversation as resolved.
Show resolved Hide resolved
});
const fileContentsDescription = i18n.translate('xpack.ml.fileDatavisualizer.fileContents.firstLinesDescription', {
defaultMessage: `First {numberOfLines, plural, zero {# line} one {# line} other {# lines}}`,
PhilippBaranovskiy marked this conversation as resolved.
Show resolved Hide resolved
values: {
numberOfLines
}
});
const ariaLabelI18n = i18n.translate('xpack.ml.fileDatavisualizer.fileContents.ariaLabelBeforeSentUserToCodeEditor', {
defaultMessage: `{translatedHeader}. {translatedAmountOfFirstLines} is shown in a code editor below. Hit Tab key to go to code editor.`,
PhilippBaranovskiy marked this conversation as resolved.
Show resolved Hide resolved
values: {
translatedHeader: fileContentsHeader,
translatedAmountOfFirstLines: fileContentsDescription,

}
});

return (
<React.Fragment>
<EuiTitle size="s">
<h3>
<FormattedMessage
id="xpack.ml.fileDatavisualizer.fileContents.fileContentsTitle"
defaultMessage="File contents"
/>
<h3
tabIndex="0"
aria-label={ariaLabelI18n}
>
{fileContentsHeader}
</h3>
</EuiTitle>

<div>
<FormattedMessage
id="xpack.ml.fileDatavisualizer.fileContents.firstLinesDescription"
defaultMessage="First {numberOfLines, plural, zero {# line} one {# line} other {# lines}}"
values={{
numberOfLines: numberOfLines,
}}
/>
</div>
<div>{fileContentsDescription}</div>

<EuiSpacer size="s" />

Expand Down