Skip to content

Commit 8fd7f32

Browse files
committed
remove condition field
1 parent 0d67072 commit 8fd7f32

27 files changed

+273
-3100
lines changed

x-pack/platform/packages/shared/response-ops/alerting-v2-rule-form/form/field_groups/alert_conditions_field_group.test.tsx

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ jest.mock('../fields/recovery_base_query_only_field', () => ({
2121
),
2222
}));
2323

24-
jest.mock('../fields/recovery_base_and_condition_field', () => ({
25-
RecoveryBaseAndConditionField: () => (
26-
<div data-test-subj="mockRecoveryBaseAndConditionField">Recovery Condition Field</div>
27-
),
28-
}));
29-
3024
jest.mock('../fields/alert_delay_field', () => ({
3125
AlertDelayField: () => <div data-test-subj="mockAlertDelayField">Alert Delay Field</div>,
3226
}));
@@ -109,10 +103,9 @@ describe('AlertConditionsFieldGroup', () => {
109103
);
110104

111105
expect(screen.queryByTestId('mockRecoveryBaseQueryOnlyField')).not.toBeInTheDocument();
112-
expect(screen.queryByTestId('mockRecoveryBaseAndConditionField')).not.toBeInTheDocument();
113106
});
114107

115-
it('renders RecoveryBaseQueryOnlyField when type is query and no evaluation condition exists', () => {
108+
it('renders RecoveryBaseQueryOnlyField when type is query', () => {
116109
const Wrapper = createFormWrapper({
117110
kind: 'alert',
118111
recoveryPolicy: { type: 'query' },
@@ -126,29 +119,6 @@ describe('AlertConditionsFieldGroup', () => {
126119
);
127120

128121
expect(screen.getByTestId('mockRecoveryBaseQueryOnlyField')).toBeInTheDocument();
129-
expect(screen.queryByTestId('mockRecoveryBaseAndConditionField')).not.toBeInTheDocument();
130-
});
131-
132-
it('renders RecoveryBaseAndConditionField when type is query and evaluation condition exists', () => {
133-
const Wrapper = createFormWrapper({
134-
kind: 'alert',
135-
recoveryPolicy: { type: 'query' },
136-
evaluation: {
137-
query: {
138-
base: 'FROM logs | STATS count() BY host',
139-
condition: 'WHERE count > 100',
140-
},
141-
},
142-
});
143-
144-
render(
145-
<Wrapper>
146-
<AlertConditionsFieldGroup />
147-
</Wrapper>
148-
);
149-
150-
expect(screen.getByTestId('mockRecoveryBaseAndConditionField')).toBeInTheDocument();
151-
expect(screen.queryByTestId('mockRecoveryBaseQueryOnlyField')).not.toBeInTheDocument();
152122
});
153123

154124
it('always renders recovery type field regardless of type', () => {
@@ -165,26 +135,4 @@ describe('AlertConditionsFieldGroup', () => {
165135

166136
expect(screen.getByTestId('mockRecoveryTypeField')).toBeInTheDocument();
167137
});
168-
169-
it('falls back to RecoveryBaseQueryOnlyField when evaluation condition is only whitespace', () => {
170-
const Wrapper = createFormWrapper({
171-
kind: 'alert',
172-
recoveryPolicy: { type: 'query' },
173-
evaluation: {
174-
query: {
175-
base: 'FROM logs | STATS count() BY host',
176-
condition: ' ',
177-
},
178-
},
179-
});
180-
181-
render(
182-
<Wrapper>
183-
<AlertConditionsFieldGroup />
184-
</Wrapper>
185-
);
186-
187-
expect(screen.getByTestId('mockRecoveryBaseQueryOnlyField')).toBeInTheDocument();
188-
expect(screen.queryByTestId('mockRecoveryBaseAndConditionField')).not.toBeInTheDocument();
189-
});
190138
});

x-pack/platform/packages/shared/response-ops/alerting-v2-rule-form/form/field_groups/alert_conditions_field_group.tsx

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import type { FormValues } from '../types';
1313
import { FieldGroup } from './field_group';
1414
import { RecoveryTypeField } from '../fields/recovery_type_field';
1515
import { RecoveryBaseQueryOnlyField } from '../fields/recovery_base_query_only_field';
16-
import { RecoveryBaseAndConditionField } from '../fields/recovery_base_and_condition_field';
1716
import { useRuleFormServices } from '../contexts';
1817
import { useRecoveryValidation } from '../hooks/use_recovery_validation';
1918
import { AlertDelayField } from '../fields/alert_delay_field';
@@ -26,9 +25,6 @@ import { RecoveryDelayField } from '../fields/recovery_delay_field';
2625
* - Alert delay (pending state transition: immediate / breaches / duration)
2726
* - A dropdown to select recovery type (no_breach vs. custom query)
2827
* - When `query` type is selected:
29-
* - If an evaluation condition (WHERE clause) exists:
30-
* uses RecoveryBaseAndConditionField (split mode with WHERE clause editor)
31-
* - If no evaluation condition exists:
3228
* uses RecoveryBaseQueryOnlyField (full ES|QL editor with "not same as eval" validation)
3329
* - Recovery delay (recovering state transition: immediate / breaches / duration)
3430
*/
@@ -58,11 +54,7 @@ export const AlertConditionsFieldGroup = () => {
5854
{recoveryType === 'query' && (
5955
<>
6056
<EuiSpacer size="m" />
61-
{recoveryValidation.hasEvaluationCondition ? (
62-
<RecoveryBaseAndConditionField validation={recoveryValidation} />
63-
) : (
64-
<RecoveryBaseQueryOnlyField validation={recoveryValidation} />
65-
)}
57+
<RecoveryBaseQueryOnlyField validation={recoveryValidation} />
6658
</>
6759
)}
6860
<EuiSpacer size="m" />

x-pack/platform/packages/shared/response-ops/alerting-v2-rule-form/form/field_groups/condition_field_group.tsx

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import { EuiSpacer, EuiFormRow, EuiCodeBlock } from '@elastic/eui';
1111
import { useFormContext, useWatch } from 'react-hook-form';
1212
import type { FormValues } from '../types';
1313
import { FieldGroup } from './field_group';
14-
import { WhereClauseEditor } from '../fields/where_clause_editor';
1514
import { EvaluationQueryField } from '../fields/evaluation_query_field';
1615
import { GroupFieldSelect } from '../fields/group_field_select';
1716
import { TimeFieldSelect } from '../fields/time_field_select';
@@ -30,10 +29,9 @@ interface ConditionFieldGroupProps {
3029
*
3130
* This component displays:
3231
* - An editable ES|QL query editor (when includeQuery is true) OR a read-only view of the base query
33-
* - An editable WHERE clause condition field
3432
*
35-
* The base query defines what data is being evaluated, while the
36-
* condition field defines the threshold or filter that triggers alerts.
33+
* The base query defines what data is being evaluated and the trigger
34+
* condition must be embedded within it (e.g. as a trailing WHERE clause).
3735
*/
3836
export const ConditionFieldGroup = ({ includeBase = false }: ConditionFieldGroupProps) => {
3937
const { control } = useFormContext<FormValues>();
@@ -72,26 +70,6 @@ export const ConditionFieldGroup = ({ includeBase = false }: ConditionFieldGroup
7270
)
7371
)}
7472

75-
<WhereClauseEditor
76-
name="evaluation.query.condition"
77-
label={i18n.translate('xpack.alertingV2.ruleForm.conditionLabel', {
78-
defaultMessage: 'Trigger condition',
79-
})}
80-
labelTooltip={i18n.translate('xpack.alertingV2.ruleForm.conditionTooltip', {
81-
defaultMessage:
82-
'A trigger condition filters when alerts are created. If no condition is specified, an alert will be created for every result returned by the base query.',
83-
})}
84-
helpText={
85-
!baseQuery
86-
? i18n.translate('xpack.alertingV2.ruleForm.conditionDisabledHelp', {
87-
defaultMessage: 'Define a base query first to enable the condition editor.',
88-
})
89-
: undefined
90-
}
91-
baseQuery={baseQuery || ''}
92-
disabled={!baseQuery}
93-
fullWidth={true}
94-
/>
9573
<GroupFieldSelect />
9674
<TimeFieldSelect />
9775
</FieldGroup>

0 commit comments

Comments
 (0)