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

Add missing aria-label for discover page #6898

Merged
merged 5 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 4 additions & 0 deletions src/plugins/data/public/ui/filter_bar/filter_bar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* under the License.
*/

import { i18n } from '@osd/i18n';
import {
EuiButtonEmpty,
EuiFlexGroup,
Expand Down Expand Up @@ -112,6 +113,9 @@ function FilterBarUI(props: Props) {
size="xs"
onClick={() => setIsAddFilterPopoverOpen(true)}
data-test-subj="addFilter"
aria-label={i18n.translate('data.filter.filterBar.addFilterButtonLabel', {
defaultMessage: 'Add filter',
})}
className="globalFilterBar__addButton"
>
+{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import {
EuiButtonEmpty,
EuiForm,
Expand Down Expand Up @@ -48,6 +49,9 @@ export function LegacyQueryLanguageSwitcher(props: Props) {
onClick={() => setIsPopoverOpen(!isPopoverOpen)}
className="euiFormControlLayout__append dqlQueryBar__languageSwitcherButton"
data-test-subj={'switchQueryLanguageButton'}
aria-label={i18n.translate('data.query.queryBar.switchQueryLanguageButtonLabel', {
defaultMessage: 'Query language switch button',
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
})}
>
{props.language === 'lucene' ? luceneLabel : dqlLabel}
</EuiButtonEmpty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@
* under the License.
*/

import { i18n } from '@osd/i18n';
import dateMath from '@elastic/datemath';
import classNames from 'classnames';
import React, { useState } from 'react';
import { i18n } from '@osd/i18n';

import {
EuiButton,
Expand Down Expand Up @@ -314,6 +314,9 @@ export default function QueryBarTopRow(props: QueryBarTopRowProps) {
isLoading={props.isLoading}
onClick={onClickSubmitButton}
data-test-subj="querySubmitButton"
aria-label={i18n.translate('data.query.queryBar.querySubmitButtonLabel', {
defaultMessage: 'Submit query button',
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
})}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import React, { useState } from 'react';
import { EuiPanel } from '@elastic/eui';
import { IndexPattern, getServices } from '../../../opensearch_dashboards_services';
Expand Down Expand Up @@ -124,6 +125,9 @@ export const DataGridTable = ({
data-title={title}
data-description={description}
data-test-subj="discoverTable"
aria-label={i18n.translate('discover.dataGrid.discoverTableLabel', {
defaultMessage: 'Discover table',
})}
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
className="eui-xScrollWithShadows"
>
<EuiPanel hasBorder={false} hasShadow={false} {...tablePanelProps}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,12 +72,21 @@ const TableCellUI = ({
);

return isTimeField ? (
<td data-test-subj="docTableField" className="osdDocTableCell eui-textNoWrap">
<td
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
data-test-subj="docTableField"
aria-label={i18n.translate('discover.defaultTable.docTableFieldLabel', {
defaultMessage: 'Discover table field',
})}
className="osdDocTableCell eui-textNoWrap"
>
{content}
</td>
) : (
<td
data-test-subj="docTableField"
aria-label={i18n.translate('discover.defaultTable.docTableFieldLabel', {
defaultMessage: 'Discover table field',
})}
className="osdDocTableCell eui-textBreakAll eui-textBreakWord"
>
<div className="osdDocTable__limitedHeight">{content}</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

import './_table_header.scss';

import React, { ReactNode } from 'react';
import { i18n } from '@osd/i18n';
import React, { ReactNode } from 'react';
import { EuiButtonIcon, EuiToolTip } from '@elastic/eui';
import { SortOrder } from '../../../saved_searches/types';

Expand Down Expand Up @@ -169,7 +169,12 @@ export function TableHeaderColumn({

return (
<th data-test-subj="docTableHeaderField" className="docTableHeaderField">
<span data-test-subj={`docTableHeader-${name}`}>
<span
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
data-test-subj={`docTableHeader-${name}`}
aria-label={i18n.translate('discover.defaultTable.docTableHeaderLabel', {
defaultMessage: `Discover table column: ${name}`,
})}
>
{displayName}
{buttons
.filter((button) => button.active)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
* GitHub history for details.
*/

import { i18n } from '@osd/i18n';
import React, { useState, useCallback } from 'react';
import { EuiButtonIcon, EuiFlexGroup, EuiFlexItem, EuiIcon } from '@elastic/eui';
import dompurify from 'dompurify';
Expand Down Expand Up @@ -53,7 +54,9 @@ const TableRowUI = ({
color="text"
onClick={handleExpanding}
iconType={isExpanded ? 'arrowDown' : 'arrowRight'}
aria-label="Next"
aria-label={i18n.translate('discover.defaultTable.docTableExpandToggleColumnLabel', {
defaultMessage: `Toggle for expanding row details`,
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
})}
data-test-subj="docTableExpandToggleColumn"
/>
</td>
Expand Down Expand Up @@ -142,6 +145,9 @@ const TableRowUI = ({
<EuiFlexItem>
<h4
data-test-subj="docTableRowDetailsTitle"
aria-label={i18n.translate('discover.defaultTable.docTableRowDetailsTitleLabel', {
defaultMessage: 'Discover table row details',
})}
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
className="euiTitle euiTitle--xsmall"
i18n-id="discover.docTable.tableRow.detailHeading"
i18n-default-message="Expanded document"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import React from 'react';
import { EuiFlexGroup, EuiFlexItem, EuiListGroupItemProps, EuiLink } from '@elastic/eui';
import { getDocViewsLinksRegistry } from '../../../opensearch_dashboards_services';
Expand All @@ -18,6 +19,9 @@ export function DocViewerLinks(renderProps: DocViewLinkRenderProps) {
'data-test-subj': `docTableRowAction`,
...props,
href: generateCb ? generateCb(renderProps).url : href,
'aria-label': i18n.translate('discover.docViewerLinks.docTableRowActionLabel', {
defaultMessage: 'Discover table row action',
}),
};

return listItem;
Expand All @@ -32,6 +36,7 @@ export function DocViewerLinks(renderProps: DocViewLinkRenderProps) {
target="_blank"
style={{ fontWeight: 'normal' }}
data-test-subj={`${item['data-test-subj']}-${index}`}
aria-label={item['aria-label']}
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
>
{item.label}
</EuiLink>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ const FieldList = ({
onClick={() => setExpanded(!expanded)}
size="xs"
className="dscSideBar_fieldGroup"
aria-label={i18n.translate('discover.fieldChooser.fieldGroupLabel', {
defaultMessage: title,
})}
>
{title}
</EuiButtonEmpty>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
* under the License.
*/

import { i18n } from '@osd/i18n';
import classNames from 'classnames';
import React, { ReactNode } from 'react';
import { FieldMapping, DocViewFilterFn } from '../../doc_views/doc_views_types';
Expand Down Expand Up @@ -78,7 +79,13 @@ export function DocViewTableRow({
});

return (
<tr key={field} data-test-subj={`tableDocViewRow-${field}`}>
<tr
key={field}
data-test-subj={`tableDocViewRow-${field}`}
aria-label={i18n.translate('discover.tble.tableDocViewRowLabel', {
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
defaultMessage: `Discover table field: ${field}`,
})}
>
{typeof onFilter === 'function' && (
<td className="osdDocViewer__buttons">
<DocViewTableRowBtnFilterAdd
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ export const getTopNavLinks = (
});
},
testId: 'discoverNewButton',
ariaLabel: i18n.translate('discover.topNav.discoverNewButtonLabel', {
defaultMessage: `New discover button`,
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
}),
};

const saveSearch: TopNavMenuData = {
Expand All @@ -69,6 +72,9 @@ export const getTopNavLinks = (
defaultMessage: 'Save Search',
}),
testId: 'discoverSaveButton',
ariaLabel: i18n.translate('discover.topNav.discoverSaveButtonLabel', {
defaultMessage: `Save discover button`,
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
}),
run: async () => {
const onSave = async ({
newTitle,
Expand Down Expand Up @@ -165,6 +171,9 @@ export const getTopNavLinks = (
defaultMessage: 'Open Saved Search',
}),
testId: 'discoverOpenButton',
ariaLabel: i18n.translate('discover.topNav.discoverOpenButtonLabel', {
defaultMessage: `Open discover button`,
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
}),
run: () => {
const flyoutSession = services.overlays.openFlyout(
toMountPoint(
Expand Down Expand Up @@ -192,6 +201,9 @@ export const getTopNavLinks = (
defaultMessage: 'Share Search',
}),
testId: 'shareTopNavButton',
ariaLabel: i18n.translate('discover.topNav.discoverShareButtonLabel', {
defaultMessage: `Share discover button`,
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
}),
run: async (anchorElement) => {
const state: DiscoverState = store!.getState().discover; // store is defined before the view is loaded
const sharingData = await getSharingData({
Expand Down Expand Up @@ -224,6 +236,9 @@ export const getTopNavLinks = (
defaultMessage: 'Open Inspector for search',
}),
testId: 'openInspectorButton',
ariaLabel: i18n.translate('discover.topNav.discoverInspectorButtonLabel', {
defaultMessage: `Inspect discover button`,
abbyhu2000 marked this conversation as resolved.
Show resolved Hide resolved
}),
run() {
inspector.open(inspectorAdapters, {
title: savedSearch?.title,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { i18n } from '@osd/i18n';
import React, { useEffect, useState, useRef, useCallback } from 'react';
import { EuiButtonIcon, EuiContextMenu, EuiPanel, EuiPopover, EuiSwitch } from '@elastic/eui';
import { TopNav } from './top_nav';
Expand Down Expand Up @@ -104,6 +105,9 @@ export default function DiscoverCanvas({ setHeaderActionMenu, history }: ViewPro
button={
<EuiButtonIcon
data-test-subj="discoverOptionsButton"
aria-label={i18n.translate('discover.canvas.discoverOptionsButtonLabel', {
defaultMessage: 'Options for discover',
})}
size="s"
iconType="gear"
onClick={() => setOptionsOpen(!isOptionsOpen)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import { EuiButtonProps } from '@elastic/eui';
import { EuiIconType } from '@elastic/eui/src/components/icon/icon';
import { string } from 'mathjs';

export type TopNavMenuAction = (anchorElement: HTMLElement) => void;

Expand All @@ -42,6 +43,7 @@ export interface TopNavMenuData {
className?: string;
disableButton?: boolean | (() => boolean);
tooltip?: string | (() => string | undefined);
ariaLabel?: string;
emphasize?: boolean;
iconType?: EuiIconType;
iconSide?: EuiButtonProps['iconSide'];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function TopNavMenuItem(props: TopNavMenuData) {
iconSide: props.iconSide,
'data-test-subj': props.testId,
className: props.className,
'aria-label': props.ariaLabel,
};

let component;
Expand Down
Loading