From e48be5713bd8dd7198e0f97943a1ec68a7aa5776 Mon Sep 17 00:00:00 2001 From: Zacqary Xeper Date: Fri, 1 Dec 2023 12:06:55 -0600 Subject: [PATCH] Default to stack rules if available --- .../rule_form/rule_form_consumer_selection.tsx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form_consumer_selection.tsx b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form_consumer_selection.tsx index f19cf58f03892..7d62c108d7241 100644 --- a/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form_consumer_selection.tsx +++ b/x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_form_consumer_selection.tsx @@ -8,7 +8,7 @@ import React, { useMemo, useCallback, useEffect } from 'react'; import { EuiComboBox, EuiFormRow, EuiComboBoxOptionOption } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { AlertConsumers } from '@kbn/rule-data-utils'; +import { AlertConsumers, STACK_ALERTS_FEATURE_ID } from '@kbn/rule-data-utils'; import { IErrorObject, RuleCreationValidConsumer } from '../../../types'; const SELECT_LABEL: string = i18n.translate( @@ -123,8 +123,14 @@ export const RuleFormConsumerSelection = (props: RuleFormConsumerSelectionProps) }, [consumers]); useEffect(() => { - // At initialization, select the first value - if (!validatedSelectedConsumer) onChange(consumers[0] as RuleCreationValidConsumer); + // At initialization, select Stack Alerts, or the first value + if (!validatedSelectedConsumer) { + if (consumers.includes(STACK_ALERTS_FEATURE_ID)) { + onChange(STACK_ALERTS_FEATURE_ID); + return; + } + onChange(consumers[0] as RuleCreationValidConsumer); + } // eslint-disable-next-line react-hooks/exhaustive-deps }, []);