Skip to content

Commit

Permalink
Update UI copy
Browse files Browse the repository at this point in the history
  • Loading branch information
nikitaindik committed May 15, 2024
1 parent dfae1a3 commit af57ac5
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,6 @@ import type { RequiredFieldInput } from '../../../../../common/api/detection_eng
const ADD_REQUIRED_FIELD_BUTTON_TEST_ID = 'addRequiredFieldButton';
const REQUIRED_FIELDS_GENERAL_WARNING_TEST_ID = 'requiredFieldsGeneralWarning';

jest.mock('../../../../common/lib/kibana', () => ({
useKibana: jest.fn().mockReturnValue({
services: {
docLinks: {
links: {
securitySolution: {
createDetectionRules: 'http://link-to-docs',
},
},
},
},
}),
}));

describe('RequiredFields form part', () => {
it('displays the required fields label', () => {
render(<TestForm />);
Expand Down Expand Up @@ -228,7 +214,7 @@ describe('RequiredFields form part', () => {

expect(
screen.getByText(
'Field "field-that-does-not-exist" is not found within specified index patterns'
`Field "field-that-does-not-exist" is not found within the rule's specified index patterns`
)
).toBeVisible();

Expand All @@ -255,7 +241,7 @@ describe('RequiredFields form part', () => {

expect(
screen.getByText(
'Field "field1" with type "type-that-does-not-exist" is not found within specified index patterns'
`Field "field1" with type "type-that-does-not-exist" is not found within the rule's specified index patterns`
)
).toBeVisible();

Expand Down Expand Up @@ -284,7 +270,7 @@ describe('RequiredFields form part', () => {

expect(
screen.getByText(
'Field "field-that-does-not-exist" is not found within specified index patterns'
`Field "field-that-does-not-exist" is not found within the rule's specified index patterns`
)
).toBeVisible();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@

import React, { useMemo } from 'react';
import { EuiButtonEmpty, EuiCallOut, EuiFormRow, EuiSpacer, EuiText } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import type { DataViewFieldBase } from '@kbn/es-query';
import type { RequiredFieldInput } from '../../../../../common/api/detection_engine';
import { UseArray, useFormData } from '../../../../shared_imports';
import type { FormHook, ArrayItem } from '../../../../shared_imports';
import { RequiredFieldsHelpInfo } from './required_fields_help_info';
import { RequiredFieldRow } from './required_fields_row';
import * as defineRuleI18n from '../../../rule_creation_ui/components/step_define_rule/translations';
import * as i18n from './translations';

interface RequiredFieldsComponentProps {
Expand Down Expand Up @@ -157,7 +159,15 @@ const RequiredFieldsList = ({
iconType="help"
data-test-subj="requiredFieldsGeneralWarning"
>
<p>{i18n.REQUIRED_FIELDS_GENERAL_WARNING_DESCRIPTION}</p>
<p>
<FormattedMessage
id="xpack.securitySolution.detectionEngine.ruleDescription.requiredFields.generalWarningDescription"
defaultMessage="This doesn't break rule execution, but it might indicate that required fields were set incorrectly. Please check that indices specified in the rule's {source} exist and have expected fields and types in mappings."
values={{
source: <strong>{defineRuleI18n.SOURCE}</strong>,
}}
/>
</p>
</EuiCallOut>
)}
<EuiSpacer size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

import React from 'react';
import { useToggle } from 'react-use';
import { EuiLink, EuiPopover, EuiText, EuiButtonIcon } from '@elastic/eui';
import { EuiPopover, EuiText, EuiButtonIcon } from '@elastic/eui';
import { FormattedMessage } from '@kbn/i18n-react';
import { useKibana } from '../../../../common/lib/kibana';
import * as defineRuleI18n from '../../../rule_creation_ui/components/step_define_rule/translations';
import * as i18n from './translations';

/**
* Theme doesn't expose width variables. Using provided size variables will require
Expand All @@ -22,13 +23,12 @@ const POPOVER_WIDTH = 320;

export function RequiredFieldsHelpInfo(): JSX.Element {
const [isPopoverOpen, togglePopover] = useToggle(false);
const { docLinks } = useKibana().services;

const button = (
<EuiButtonIcon
iconType="questionInCircle"
onClick={togglePopover}
aria-label="Open help popover"
aria-label={i18n.OPEN_HELP_POPOVER_ARIA_LABEL}
/>
);

Expand All @@ -37,16 +37,9 @@ export function RequiredFieldsHelpInfo(): JSX.Element {
<EuiText style={{ width: POPOVER_WIDTH }} size="s">
<FormattedMessage
id="xpack.securitySolution.detectionEngine.ruleDescription.requiredFields.fieldRequiredFieldsHelpText"
defaultMessage="Choose the fields that are needed for this rule to execute. You can read more about required fields in our {docLink}."
defaultMessage="Choose the fields and data types needed for this rule to function. You can select the fields available in the rule's {source} index patterns or data view."
values={{
docLink: (
<EuiLink href={docLinks.links.securitySolution.createDetectionRules} target="_blank">
<FormattedMessage
id="xpack.securitySolution.detectionEngine.ruleDescription.requiredFields.docLink"
defaultMessage="documentation"
/>
</EuiLink>
),
source: <strong>{defineRuleI18n.SOURCE}</strong>,
}}
/>
</EuiText>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,17 @@ export const FIELD_TYPE = i18n.translate(
}
);

export const REQUIRED_FIELDS_GENERAL_WARNING_TITLE = i18n.translate(
'xpack.securitySolution.detectionEngine.ruleDescription.requiredFields.generalWarningTitle',
export const OPEN_HELP_POPOVER_ARIA_LABEL = i18n.translate(
'xpack.securitySolution.detectionEngine.ruleDescription.requiredFields.openHelpPopoverAriaLabel',
{
defaultMessage: 'Some fields are not found within specified index patterns.',
defaultMessage: 'Open help popover',
}
);

export const REQUIRED_FIELDS_GENERAL_WARNING_DESCRIPTION = i18n.translate(
'xpack.securitySolution.detectionEngine.ruleDescription.requiredFields.generalWarningDescription',
export const REQUIRED_FIELDS_GENERAL_WARNING_TITLE = i18n.translate(
'xpack.securitySolution.detectionEngine.ruleDescription.requiredFields.generalWarningTitle',
{
defaultMessage: `This doesn't break rule execution, but it might indicate that required fields were set incorrectly. Please check that indices specified in index patterns exist and have expected fields and types in mappings.`,
defaultMessage: `Some fields aren't found within the rule's specified index patterns.`,
}
);

Expand Down Expand Up @@ -68,7 +68,7 @@ export const FIELD_NAME_NOT_FOUND_WARNING = (name: string) =>
'xpack.securitySolution.detectionEngine.ruleDescription.requiredFields.fieldNameNotFoundWarning',
{
values: { name },
defaultMessage: `Field "{name}" is not found within specified index patterns`,
defaultMessage: `Field "{name}" is not found within the rule's specified index patterns`,
}
);

Expand All @@ -77,7 +77,7 @@ export const FIELD_TYPE_NOT_FOUND_WARNING = (name: string, type: string) =>
'xpack.securitySolution.detectionEngine.ruleDescription.requiredFields.fieldTypeNotFoundWarning',
{
values: { name, type },
defaultMessage: `Field "{name}" with type "{type}" is not found within specified index patterns`,
defaultMessage: `Field "{name}" with type "{type}" is not found within the rule's specified index patterns`,
}
);

Expand Down
2 changes: 1 addition & 1 deletion x-pack/plugins/translations/translations/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -45103,4 +45103,4 @@
"xpack.serverlessObservability.nav.projectSettings": "Paramètres de projet",
"xpack.serverlessObservability.nav.synthetics": "Synthetics"
}
}
}
2 changes: 1 addition & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -45073,4 +45073,4 @@
"xpack.serverlessObservability.nav.projectSettings": "プロジェクト設定",
"xpack.serverlessObservability.nav.synthetics": "Synthetics"
}
}
}
2 changes: 1 addition & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -45121,4 +45121,4 @@
"xpack.serverlessObservability.nav.projectSettings": "项目设置",
"xpack.serverlessObservability.nav.synthetics": "Synthetics"
}
}
}

0 comments on commit af57ac5

Please sign in to comment.