mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
# Backport This will backport the following commits from `main` to `8.13`: - [[EDR Workflows] Fix automated process action field name behavior (#178727)](https://github.com/elastic/kibana/pull/178727) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Tomasz Ciecierski","email":"tomasz.ciecierski@elastic.co"},"sourceCommit":{"committedDate":"2024-04-02T18:03:13Z","message":"[EDR Workflows] Fix automated process action field name behavior (#178727)","sha":"5469e88705a193c6ee178315e8b7c2679ec055ae","branchLabelMapping":{"^v8.14.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","Team:Defend Workflows","v8.14.0","v8.13.2"],"title":"[EDR Workflows] Fix automated process action field name behavior","number":178727,"url":"https://github.com/elastic/kibana/pull/178727","mergeCommit":{"message":"[EDR Workflows] Fix automated process action field name behavior (#178727)","sha":"5469e88705a193c6ee178315e8b7c2679ec055ae"}},"sourceBranch":"main","suggestedTargetBranches":["8.13"],"targetPullRequestStates":[{"branch":"main","label":"v8.14.0","branchLabelMappingKey":"^v8.14.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/178727","number":178727,"mergeCommit":{"message":"[EDR Workflows] Fix automated process action field name behavior (#178727)","sha":"5469e88705a193c6ee178315e8b7c2679ec055ae"}},{"branch":"8.13","label":"v8.13.2","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Tomasz Ciecierski <tomasz.ciecierski@elastic.co>
This commit is contained in:
parent
4cd95fb575
commit
536a7dd3cd
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