From 1b259ee3d6f8b02ef64b85a19bc4223343a1f3b9 Mon Sep 17 00:00:00 2001 From: Xavier Mouligneau Date: Tue, 31 Oct 2023 13:57:08 -0400 Subject: [PATCH] fix logic for serverless --- .../sections/rule_form/rule_form.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx index 8dcd5da0bbbb3..c88e3beba0cad 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form.tsx @@ -251,21 +251,18 @@ export const RuleForm = ({ validConsumers, }) ) - .filter((item) => - rule.consumer === ALERTS_FEATURE_ID + .filter((item) => { + return rule.consumer === ALERTS_FEATURE_ID ? !item.ruleTypeModel.requiresAppContext - : item.ruleType!.producer === rule.consumer - ); + : item.ruleType!.producer === rule.consumer; + }); const availableRuleTypesResult = getAvailableRuleTypes(ruleTypes); setAvailableRuleTypes(availableRuleTypesResult); const solutionsResult = availableRuleTypesResult.reduce( (result: Map, ruleTypeItem) => { - if ( - !result.has(ruleTypeItem.ruleType.producer) && - ruleTypeItem.ruleType.producer !== AlertConsumers.OBSERVABILITY - ) { + if (!result.has(ruleTypeItem.ruleType.producer)) { result.set( ruleTypeItem.ruleType.producer, (kibanaFeatures @@ -279,7 +276,10 @@ export const RuleForm = ({ new Map() ); const solutionsEntries = [...solutionsResult.entries()]; - if (solutionsEntries.length > 0) { + const isOnlyO11y = + availableRuleTypesResult.length === 1 && + availableRuleTypesResult.every((rt) => rt.ruleType.producer === AlertConsumers.OBSERVABILITY); + if (!isOnlyO11y) { setSolutions(new Map(solutionsEntries.sort(([, a], [, b]) => a.localeCompare(b)))); } // eslint-disable-next-line react-hooks/exhaustive-deps