diff --git a/x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx b/x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx index bc5da8218d118..e8c8b520f8e38 100644 --- a/x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx +++ b/x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.test.tsx @@ -188,10 +188,10 @@ describe('Rule Definition', () => { expect(ruleDescription.find('div.euiText').text()).toEqual('Security detection rule'); }); - it('show rule conditions "', async () => { + it('show rule conditions only if the rule allows multiple conditions', async () => { const ruleConditions = wrapper.find('[data-test-subj="ruleSummaryRuleConditions"]'); expect(ruleConditions).toBeTruthy(); - expect(ruleConditions.find('div.euiText').text()).toEqual(`0 conditions`); + expect(ruleConditions.find('div.euiText').text()).toEqual('1 condition'); }); it('show rule interval with human readable value', async () => { @@ -225,7 +225,24 @@ function mockRule(overwrite = {}): Rule { ruleTypeId: 'test_rule_type', schedule: { interval: '1s' }, actions: [], - params: { name: 'test rule type name', description: 'siem description' }, + params: { + name: 'test rule type name', + description: 'siem description', + criteria: [ + { + comparator: '>', + metrics: [ + { + name: 'A', + aggType: 'count', + }, + ], + threshold: [100], + timeSize: 1, + timeUnit: 'm', + }, + ], + }, createdBy: null, updatedBy: null, apiKeyOwner: null, diff --git a/x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.tsx b/x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.tsx index ed21bb88992a8..371fe483a4695 100644 --- a/x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.tsx +++ b/x-pack/platform/plugins/shared/triggers_actions_ui/public/application/sections/rule_details/components/rule_definition.tsx @@ -49,6 +49,8 @@ export const RuleDefinition: React.FunctionComponent = ({ const [editFlyoutVisible, setEditFlyoutVisible] = useState(false); const [ruleType, setRuleType] = useState(); + + const hasConditions = !!(rule?.params.criteria as any[])?.length; const { ruleTypesState: { data: ruleTypeIndex, isLoading: ruleTypesIsLoading }, } = useLoadRuleTypesQuery({ @@ -159,28 +161,32 @@ export const RuleDefinition: React.FunctionComponent = ({ /> ), }, - { - title: i18n.translate('xpack.triggersActionsUI.ruleDetails.conditionsTitle', { - defaultMessage: 'Conditions', - }), - description: ( - - - {hasEditButton ? ( - - {getRuleConditionsWording()} - - ) : ( - {getRuleConditionsWording()} - )} - - - ), - }, + ...(hasConditions + ? [ + { + title: i18n.translate('xpack.triggersActionsUI.ruleDetails.conditionsTitle', { + defaultMessage: 'Conditions', + }), + description: ( + + + {hasEditButton ? ( + + {getRuleConditionsWording()} + + ) : ( + {getRuleConditionsWording()} + )} + + + ), + }, + ] + : []), { title: i18n.translate('xpack.triggersActionsUI.ruleDetails.actions', { defaultMessage: 'Actions',