Skip to content

Commit

Permalink
[Security Solution] Add validation error description on prebuilt rule…
Browse files Browse the repository at this point in the history
… editing elastic#191832
  • Loading branch information
e40pud committed Sep 12, 2024
1 parent ce5464d commit 1aa5901
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,20 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
const onSubmit = useCallback(async () => {
setNonBlockingRuleErrors([]);

const actionsStepFormValid = await actionsStepForm.validate();
if (rule.immutable) {
// Since users cannot edit Define, About and Schedule tabs of the rule, we skip validation of those to avoid
// user confusion of seeing that those tabs have error and not being able to see or do anything about that.
// We will need to remove this condition once rule customization work is done.
if (actionsStepFormValid) {
await saveChanges();
}
return;
}

const defineStepFormValid = await defineStepForm.validate();
const aboutStepFormValid = await aboutStepForm.validate();
const scheduleStepFormValid = await scheduleStepForm.validate();
const actionsStepFormValid = await actionsStepForm.validate();

if (
defineStepFormValid &&
aboutStepFormValid &&
Expand All @@ -465,6 +474,7 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
showSaveWithErrorsModal();
}
}, [
rule.immutable,
defineStepForm,
aboutStepForm,
scheduleStepForm,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ describe('EQL rules', { tags: ['@ess', '@serverless'] }, () => {
const rule = getEqlRule();

it('validates missing data source', () => {
login();
visit(CREATE_RULE_URL);
selectEqlRuleType();
getIndexPatternClearButton().click();
Expand All @@ -258,7 +257,6 @@ describe('EQL rules', { tags: ['@ess', '@serverless'] }, () => {
});

it('validates missing data fields', () => {
login();
visit(CREATE_RULE_URL);
selectEqlRuleType();

Expand All @@ -282,7 +280,6 @@ describe('EQL rules', { tags: ['@ess', '@serverless'] }, () => {
});

it('validates syntax errors', () => {
login();
visit(CREATE_RULE_URL);
selectEqlRuleType();

Expand Down

0 comments on commit 1aa5901

Please sign in to comment.