mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[EDR Workflows] Fix automated process action field name behavior (#178727)
This commit is contained in:
parent
2d363d2833
commit
5469e88705
2 changed files with 22 additions and 12 deletions
|
@ -33,6 +33,13 @@ const ECSSchemaOptions = ECSSchema.map((ecs) => ({
|
|||
const SINGLE_SELECTION = Object.freeze({ asPlainText: true });
|
||||
|
||||
const FIELD_LABEL: string = 'Custom field name';
|
||||
const REQUIRED_ERROR = i18n.translate(
|
||||
'xpack.securitySolution.responseActions.endpoint.validations.fieldNameIsRequiredErrorMessage',
|
||||
{
|
||||
defaultMessage: '{field} selection is required when the process.pid toggle is disabled.',
|
||||
values: { field: FIELD_LABEL },
|
||||
}
|
||||
);
|
||||
const FieldNameFieldComponent = ({
|
||||
path,
|
||||
disabled,
|
||||
|
@ -50,6 +57,11 @@ const FieldNameFieldComponent = ({
|
|||
if (currentFieldNameField && !isRequired) {
|
||||
currentFieldNameField?.clearErrors();
|
||||
}
|
||||
|
||||
// if the field is required and the value is empty, set an error, but don't do that before first validation (thus isValidated check)
|
||||
if (currentFieldNameField?.isValidated && !currentFieldNameField?.value && isRequired) {
|
||||
currentFieldNameField?.setErrors([{ message: REQUIRED_ERROR }]);
|
||||
}
|
||||
}, [currentFieldNameField, isRequired]);
|
||||
|
||||
const renderEntityIdNote = useMemo(() => {
|
||||
|
@ -82,14 +94,7 @@ const FieldNameFieldComponent = ({
|
|||
return {
|
||||
code: 'ERR_FIELD_MISSING',
|
||||
path,
|
||||
message: i18n.translate(
|
||||
'xpack.securitySolution.responseActions.endpoint.validations.fieldNameIsRequiredErrorMessage',
|
||||
{
|
||||
defaultMessage:
|
||||
'{field} selection is required when the process.pid toggle is disabled.',
|
||||
values: { field: FIELD_LABEL },
|
||||
}
|
||||
),
|
||||
message: REQUIRED_ERROR,
|
||||
};
|
||||
}
|
||||
},
|
||||
|
@ -131,10 +136,10 @@ const FieldNameFieldComponent = ({
|
|||
selectedOptions={value && valueInList ? [{ value, label: value }] : undefined}
|
||||
onChange={(newValue) => {
|
||||
if (newValue.length === 0) {
|
||||
// Don't allow clearing the type. One must always be selected
|
||||
return;
|
||||
setValue('');
|
||||
} else {
|
||||
setValue(newValue[0].label);
|
||||
}
|
||||
setValue(newValue[0].label);
|
||||
}}
|
||||
data-test-subj="config-custom-field-name"
|
||||
/>
|
||||
|
|
|
@ -122,8 +122,13 @@ describe(
|
|||
'Custom field name selection is required when the process.pid toggle is disabled.'
|
||||
);
|
||||
});
|
||||
|
||||
// field name can be cleared out
|
||||
cy.getByTestSubj(`response-actions-list-item-1`).within(() => {
|
||||
cy.getByTestSubj('config-custom-field-name').should('have.text', '');
|
||||
cy.getByTestSubj('config-custom-field-name').type('process.entity_id{downArrow}{enter}');
|
||||
cy.getByTestSubj('config-custom-field-name').should('contain', 'process.entity_id');
|
||||
cy.getByTestSubj('comboBoxClearButton').click();
|
||||
cy.getByTestSubj('config-custom-field-name').should('not.contain', 'process.entity_id');
|
||||
cy.getByTestSubj('config-custom-field-name').type('process.entity_id{downArrow}{enter}');
|
||||
});
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue