Skip to content

Commit

Permalink
fix: [Obs Synthetics > Monitor test run][KEYBOARD]: Date (check) drop…
Browse files Browse the repository at this point in the history
…down needs a semantic label for the current check

Closes: elastic/observability-dev#3689
  • Loading branch information
alexwizp committed Jul 2, 2024
1 parent d183092 commit 36be3a3
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import React, { ReactElement, useState } from 'react';
import React, { useState } from 'react';
import {
EuiButtonEmpty,
EuiDescriptionList,
Expand Down Expand Up @@ -43,8 +43,7 @@ export const StepPageNavigation = ({ testRunPage }: { testRunPage?: boolean }) =
const formatter = useDateFormat();
const { basePath } = useSyntheticsSettingsContext();
const selectedLocation = useSelectedLocation();

let startedAt: string | ReactElement = formatter(data?.details?.timestamp);
const startedAt = formatter(data?.details?.timestamp);

const { stepIndex, monitorId } = useParams<{ stepIndex: string; monitorId: string }>();

Expand Down Expand Up @@ -77,9 +76,7 @@ export const StepPageNavigation = ({ testRunPage }: { testRunPage?: boolean }) =
}
}

if (!startedAt) {
startedAt = <EuiSkeletonText lines={1} />;
}
const startedAtWrapped = startedAt || <EuiSkeletonText lines={1} />;

return (
<EuiPopover
Expand All @@ -94,7 +91,7 @@ export const StepPageNavigation = ({ testRunPage }: { testRunPage?: boolean }) =
iconSide="right"
flush="left"
>
{startedAt}
{startedAtWrapped}
</EuiButtonEmpty>
}
>
Expand All @@ -111,8 +108,12 @@ export const StepPageNavigation = ({ testRunPage }: { testRunPage?: boolean }) =
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="s" className="eui-textNoWrap">
{startedAt}
<EuiText
size="s"
className="eui-textNoWrap"
aria-label={CURRENT_CHECK_ARIA_LABEL(startedAt)}
>
{startedAtWrapped}
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down Expand Up @@ -145,3 +146,11 @@ export const NEXT_CHECK_BUTTON_TEXT = i18n.translate(
defaultMessage: 'Next check',
}
);

export const CURRENT_CHECK_ARIA_LABEL = (timestamp: string) =>
i18n.translate('xpack.synthetics.synthetics.stepDetail.currentCheckAriaLabel', {
defaultMessage: 'Current check: {timestamp}',
values: {
timestamp,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ export const NEXT_CHECK_BUTTON_TEXT = i18n.translate(
}
);

export const CURRENT_CHECK_ARIA_LABEL = (timestamp: string) =>
i18n.translate('xpack.uptime.synthetics.stepDetail.currentCheckAriaLabel', {
defaultMessage: 'Current check: {timestamp}',
values: {
timestamp,
},
});

interface Props {
previousCheckGroup?: string;
dateFormat: string;
Expand All @@ -40,6 +48,8 @@ export const StepPageNavigation = ({
checkTimestamp,
nextCheckGroup,
}: Props) => {
const formattedTimestamp = moment(checkTimestamp).format(dateFormat);

return (
<EuiFlexGroup alignItems="center" justifyContent="flexEnd" responsive={false}>
<EuiFlexItem grow={false}>
Expand All @@ -54,7 +64,9 @@ export const StepPageNavigation = ({
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size="s">{moment(checkTimestamp).format(dateFormat)}</EuiText>
<EuiText size="s" aria-label={CURRENT_CHECK_ARIA_LABEL(formattedTimestamp)}>
{formattedTimestamp}
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiButtonEmpty
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
import { FormattedMessage } from '@kbn/i18n-react';
import { useHistory } from 'react-router-dom';
import moment from 'moment';
import { i18n } from '@kbn/i18n';
import { SyntheticsJourneyApiResponse } from '../../../../common/runtime_types/ping';
import { getShortTimeStamp } from '../../components/overview/monitor_list/columns/monitor_status_column';

Expand All @@ -27,6 +28,7 @@ interface Props {
export const ChecksNavigation = ({ timestamp, details }: Props) => {
const history = useHistory();
const isMobile = useIsWithinMaxBreakpoint('s');
const shortTimestamp = getShortTimeStamp(moment(timestamp));

return (
<EuiFlexGroup alignItems="center" responsive={false} gutterSize="none">
Expand All @@ -47,8 +49,17 @@ export const ChecksNavigation = ({ timestamp, details }: Props) => {
</EuiButtonEmpty>
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiText size={isMobile ? 'xs' : 'm'} className="eui-textNoWrap">
{getShortTimeStamp(moment(timestamp))}
<EuiText
size={isMobile ? 'xs' : 'm'}
className="eui-textNoWrap"
aria-label={i18n.translate('xpack.uptime.synthetics.stepList.currentCheckAriaLabel', {
defaultMessage: 'Current check: {shortTimestamp}',
values: {
shortTimestamp,
},
})}
>
{shortTimestamp}
</EuiText>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down

0 comments on commit 36be3a3

Please sign in to comment.