From 3fee6fd48408df9971929421a45a1ff16f037b31 Mon Sep 17 00:00:00 2001 From: Zacqary Adam Xeper Date: Fri, 2 Aug 2019 10:20:47 -0500 Subject: [PATCH] [Logs UI][a11y] Announce name of column on remove column button (#41695) * [Logs UI][a11y] Announce name of column on remove column button * Use title instead of aria-label * ariaColumnName => columnDescription * Move template string out of i18n * Revert label id change * Inject i18n to field title * Change title to Remove {columnDescription} column * Replace injectI18N with i18n.translate * Fix i18n --- .../log_columns_configuration_panel.tsx | 76 +++++++++++-------- .../translations/translations/ja-JP.json | 1 - .../translations/translations/zh-CN.json | 1 - 3 files changed, 43 insertions(+), 35 deletions(-) diff --git a/x-pack/legacy/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx b/x-pack/legacy/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx index bbc3cde41794c3..53d426eba04494 100644 --- a/x-pack/legacy/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx +++ b/x-pack/legacy/plugins/infra/public/components/source_configuration/log_columns_configuration_panel.tsx @@ -19,7 +19,8 @@ import { EuiDroppable, EuiIcon, } from '@elastic/eui'; -import { FormattedMessage, injectI18n } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; import React, { useCallback } from 'react'; import { DragHandleProps, DropResult } from '../../../../../common/eui_draggable'; @@ -167,29 +168,35 @@ const FieldLogColumnConfigurationPanel: React.FunctionComponent<{ remove, }, dragHandleProps, -}) => ( - - - -
- -
-
- - - - - {field} - - - - -
-
-); +}) => { + const fieldLogColumnTitle = i18n.translate( + 'xpack.infra.sourceConfiguration.fieldLogColumnTitle', + { + defaultMessage: 'Field', + } + ); + return ( + + + +
+ +
+
+ {fieldLogColumnTitle} + + {field} + + + + +
+
+ ); +}; const ExplainedLogColumnConfigurationPanel: React.FunctionComponent<{ fieldName: React.ReactNode; @@ -213,23 +220,26 @@ const ExplainedLogColumnConfigurationPanel: React.FunctionComponent<{ - + ); -const RemoveLogColumnButton = injectI18n<{ +const RemoveLogColumnButton: React.FunctionComponent<{ onClick?: () => void; -}>(({ intl, onClick }) => { - const removeColumnLabel = intl.formatMessage({ - id: 'xpack.infra.sourceConfiguration.removeLogColumnButtonLabel', - defaultMessage: 'Remove this column', - }); + columnDescription: string; +}> = ({ onClick, columnDescription }) => { + const removeColumnLabel = i18n.translate( + 'xpack.infra.sourceConfiguration.removeLogColumnButtonLabel', + { + defaultMessage: 'Remove {columnDescription} column', + values: { columnDescription }, + } + ); return ( ); -}); +}; const LogColumnConfigurationEmptyPrompt: React.FunctionComponent = () => (