Skip to content

Commit

Permalink
add fieldsToValidateOnChange to EqlQueryEdit
Browse files Browse the repository at this point in the history
  • Loading branch information
maximpn committed Nov 18, 2024
1 parent 5a0fb3f commit 76fed4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import type { FieldValueQueryBar } from '../query_bar';

interface EqlQueryEditProps {
path: string;
fieldsToValidateOnChange?: string | string[];
eqlFieldsComboBoxOptions?: EqlFieldsComboBoxOptions;
eqlOptions?: EqlOptions;
showEqlSizeOption?: boolean;
Expand All @@ -38,6 +39,7 @@ interface EqlQueryEditProps {

export function EqlQueryEdit({
path,
fieldsToValidateOnChange,
eqlFieldsComboBoxOptions,
eqlOptions,
showEqlSizeOption = false,
Expand Down Expand Up @@ -81,6 +83,9 @@ export function EqlQueryEdit({
const fieldConfig: FieldConfig<FieldValueQueryBar> = useMemo(
() => ({
label: i18n.EQL_QUERY_BAR_LABEL,
fieldsToValidateOnChange: fieldsToValidateOnChange
? [path, fieldsToValidateOnChange].flat()
: undefined,
validations: [
...(required
? [
Expand All @@ -107,7 +112,7 @@ export function EqlQueryEdit({
},
],
}),
[required, dataView.id, dataView.title, eqlOptions]
[required, dataView.id, dataView.title, eqlOptions, path, fieldsToValidateOnChange]
);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ import { useAlertSuppression } from '../../../rule_management/logic/use_alert_su
import { AiAssistant } from '../ai_assistant';
import { RelatedIntegrations } from '../../../rule_creation/components/related_integrations';
import { useMLRuleConfig } from '../../../../common/components/ml/hooks/use_ml_rule_config';
import { AlertSuppressionEdit } from '../../../rule_creation/components/alert_suppression_edit';
import {
ALERT_SUPPRESSION_FIELDS_FIELD_NAME,
AlertSuppressionEdit,
} from '../../../rule_creation/components/alert_suppression_edit';
import { ThresholdAlertSuppressionEdit } from '../../../rule_creation/components/threshold_alert_suppression_edit';
import { usePersistentAlertSuppressionState } from './use_persistent_alert_suppression_state';

Expand Down Expand Up @@ -797,6 +800,7 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
<EqlQueryEdit
key="eqlQueryBar"
path="queryBar"
fieldsToValidateOnChange={ALERT_SUPPRESSION_FIELDS_FIELD_NAME}
required
showFilterBar
eqlFieldsComboBoxOptions={optionsData}
Expand Down

0 comments on commit 76fed4e

Please sign in to comment.