Skip to content

Commit

Permalink
revert aria-label
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpn committed Nov 13, 2024
1 parent aa3a6c0 commit b0eda60
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
* 2.0.
*/

import React from 'react';
import React, { memo } from 'react';
import { EuiPopover, EuiText, EuiButtonIcon, EuiLink } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import * as i18n from './translations';

import { useBoolState } from '../../../../common/hooks/use_bool_state';
import { useBoolean } from '@kbn/react-hooks';
import { useKibana } from '../../../../common/lib/kibana';
import * as i18n from './translations';

/**
* Icon and popover that gives hint to users how to get started with ES|QL rules
*/
const EsqlInfoIconComponent = () => {
export const EsqlInfoIcon = memo(function EsqlInfoIcon(): JSX.Element {
const { docLinks } = useKibana().services;

const [isPopoverOpen, , closePopover, togglePopover] = useBoolState();
const [isPopoverOpen, { off: closePopover, on: togglePopover }] = useBoolean(false);

const button = (
<EuiButtonIcon iconType="iInCircle" onClick={togglePopover} aria-label={i18n.ARIA_LABEL} />
Expand All @@ -29,13 +27,13 @@ const EsqlInfoIconComponent = () => {
<EuiPopover button={button} isOpen={isPopoverOpen} closePopover={closePopover}>
<EuiText size="s">
<FormattedMessage
id="xpack.securitySolution.detectionEngine.createRule.stepDefineRule.esqlInfoTooltipContent"
id="xpack.securitySolution.ruleManagement.esqlQuery.esqlInfoTooltipContent"
defaultMessage="Check out our {createEsqlRuleTypeLink} to get started using ES|QL rules."
values={{
createEsqlRuleTypeLink: (
<EuiLink href={docLinks.links.securitySolution.createEsqlRuleType} target="_blank">
<FormattedMessage
id="xpack.securitySolution.detectionEngine.createRule.stepDefineRule.esqlInfoTooltipLink"
id="xpack.securitySolution.ruleManagement.esqlQuery.esqlInfoTooltipLink"
defaultMessage="documentation"
/>
</EuiLink>
Expand All @@ -45,8 +43,4 @@ const EsqlInfoIconComponent = () => {
</EuiText>
</EuiPopover>
);
};

export const EsqlInfoIcon = React.memo(EsqlInfoIconComponent);

EsqlInfoIcon.displayName = 'EsqlInfoIcon';
});
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

import { i18n } from '@kbn/i18n';

export const ESQL_QUERY = i18n.translate(
'xpack.securitySolution.detectionEngine.createRule.stepDefineRule.esqlQueryLabel',
export const ESQL_QUERY = i18n.translate('xpack.securitySolution.ruleManagement.esqlQuery.label', {
defaultMessage: 'ES|QL query',
});

export const ARIA_LABEL = i18n.translate(
'xpack.securitySolution.ruleManagement.esqlQuery.ariaLabel',
{
defaultMessage: 'ES|QL query',
defaultMessage: `Open help popover`,
}
);
Original file line number Diff line number Diff line change
Expand Up @@ -153,27 +153,27 @@ function constructValidationError(error: Error): ValidationError {
}

const ESQL_VALIDATION_UNKNOWN_ERROR = i18n.translate(
'xpack.securitySolution.detectionEngine.esqlValidation.unknownError',
'xpack.securitySolution.ruleManagement.esqlValidation.unknownError',
{
defaultMessage: 'Unknown error while validating ES|QL',
}
);

const esqlValidationErrorMessage = (message: string) =>
i18n.translate('xpack.securitySolution.detectionEngine.esqlValidation.errorMessage', {
i18n.translate('xpack.securitySolution.ruleManagement.esqlValidation.errorMessage', {
values: { message },
defaultMessage: 'Error validating ES|QL: "{message}"',
});

const ESQL_VALIDATION_MISSING_METADATA_OPERATOR_IN_QUERY_ERROR = i18n.translate(
'xpack.securitySolution.detectionEngine.esqlValidation.missingMetadataOperatorInQueryError',
'xpack.securitySolution.ruleManagement.esqlValidation.missingMetadataOperatorInQueryError',
{
defaultMessage: `Queries that don’t use the STATS...BY function (non-aggregating queries) must include the "metadata _id, _version, _index" operator after the source command. For example: FROM logs* metadata _id, _version, _index.`,
}
);

const ESQL_VALIDATION_MISSING_ID_FIELD_IN_QUERY_ERROR = i18n.translate(
'xpack.securitySolution.detectionEngine.esqlValidation.missingIdFieldInQueryError',
'xpack.securitySolution.ruleManagement.esqlValidation.missingIdFieldInQueryError',
{
defaultMessage: `Queries that don’t use the STATS...BY function (non-aggregating queries) must include the "metadata _id, _version, _index" operator after the source command. For example: FROM logs* metadata _id, _version, _index. In addition, the metadata properties (_id, _version, and _index) must be returned in the query response.`,
}
Expand Down

0 comments on commit b0eda60

Please sign in to comment.