Skip to content

Commit

Permalink
[ML] Adding missing aria labels to eui button icons (elastic#199447)
Browse files Browse the repository at this point in the history
Fix to stop browser console errors in ML overview page.
Also adds some missing translations.


![image](https://github.com/user-attachments/assets/38f3b5b1-8d44-4589-b82f-336150f2395f)
  • Loading branch information
jgowdyelastic authored Nov 8, 2024
1 parent aad3a44 commit cbebdae
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
} from '@elastic/eui';
import type { PropsWithChildren } from 'react';
import React, { type FC } from 'react';
import { i18n } from '@kbn/i18n';
import { PanelHeaderItems } from './panel_header_items';
import { useCurrentThemeVars } from '../../contexts/kibana';

Expand All @@ -24,6 +25,7 @@ export interface CollapsiblePanelProps {
onToggle: (isOpen: boolean) => void;
header: React.ReactElement;
headerItems?: React.ReactElement[];
ariaLabel: string;
}

export const CollapsiblePanel: FC<PropsWithChildren<CollapsiblePanelProps>> = ({
Expand All @@ -32,6 +34,7 @@ export const CollapsiblePanel: FC<PropsWithChildren<CollapsiblePanelProps>> = ({
children,
header,
headerItems,
ariaLabel,
}) => {
const { euiTheme } = useCurrentThemeVars();

Expand All @@ -51,6 +54,17 @@ export const CollapsiblePanel: FC<PropsWithChildren<CollapsiblePanelProps>> = ({
<EuiFlexGroup gutterSize={'s'}>
<EuiFlexItem grow={false}>
<EuiButtonIcon
aria-label={
isOpen
? i18n.translate('xpack.ml.collapsiblePanel.toggleClose', {
defaultMessage: 'Close {ariaLabel}',
values: { ariaLabel },
})
: i18n.translate('xpack.ml.collapsiblePanel.toggleOpen', {
defaultMessage: 'Open {ariaLabel}',
values: { ariaLabel },
})
}
color={'text'}
iconType={isOpen ? 'arrowDown' : 'arrowRight'}
onClick={() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,12 @@ export const ExpandableSectionResults: FC<ExpandableSectionResultsProps> = ({
anchorPosition="upCenter"
button={
<EuiButtonIcon
aria-label="Show actions"
aria-label={i18n.translate(
'xpack.ml.dataframe.analytics.exploration.dataGridActions.showActionsAriaLabel',
{
defaultMessage: 'Show actions',
}
)}
iconType="gear"
color="text"
onClick={() => setIsPopoverVisible(!isPopoverVisible)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ export const AlertsPanel: FC = () => {
</>
);
})}
ariaLabel={i18n.translate('xpack.ml.explorer.alertsPanel.ariaLabel', {
defaultMessage: 'alerts panel',
})}
>
<AnomalyDetectionAlertsOverviewChart />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ export const FunctionHelpPopover = memo(() => {
const onHelpClick = () => setIsHelpOpen((prevIsHelpOpen) => !prevIsHelpOpen);
const closeHelp = () => setIsHelpOpen(false);

const helpButton = <EuiButtonIcon onClick={onHelpClick} iconType="help" />;
const helpButton = (
<EuiButtonIcon
onClick={onHelpClick}
iconType="help"
aria-label={i18n.translate(
'xpack.ml.newJob.wizard.pickFieldsStep.advancedDetectorModal.functionHelpAriaLabel',
{
defaultMessage: 'Show help',
}
)}
/>
);

const columns = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,12 @@ export const DetectorTitle: FC<PropsWithChildren<DetectorTitleProps>> = ({
onClick={() => deleteDetector(index)}
iconType="cross"
size="s"
aria-label="Next"
aria-label={i18n.translate(
'xpack.ml.newJob.wizard.pickFieldsStep.nextButtonAriaLabel',
{
defaultMessage: 'Next',
}
)}
/>
)}
</EuiFlexItem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ export const AnalyticsPanel: FC<Props> = ({ setLazyJobCount }) => {
})}
</EuiLink>,
]}
ariaLabel={i18n.translate('xpack.ml.overview.analyticsListPanel.ariaLabel', {
defaultMessage: 'data frame analytics panel',
})}
>
{noDFAJobs ? <AnalyticsEmptyPrompt /> : null}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ export const AnomalyDetectionPanel: FC<Props> = ({ anomalyTimelineService, setLa
})}
</EuiLink>,
]}
ariaLabel={i18n.translate('xpack.ml.overview.adJobsPanel.ariaLabel', {
defaultMessage: 'anomaly detection panel',
})}
>
{noAdJobs ? <AnomalyDetectionEmptyState /> : null}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ export const OverviewPage: FC = () => {
})}
</EuiLink>,
]}
ariaLabel={i18n.translate('xpack.ml.overview.nodesPanel.ariaLabel', {
defaultMessage: 'overview panel',
})}
>
<NodesList compactView />
</CollapsiblePanel>
Expand Down

0 comments on commit cbebdae

Please sign in to comment.