From 6ebdfc52ff44b6b293c44e72bb9de9157ac3eeb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Kopycin=CC=81ski?= Date: Mon, 9 Mar 2020 12:55:41 +0100 Subject: [PATCH] WIP --- .../rules/components/rule_actions_field/index.tsx | 13 ++++--------- .../rules/components/step_rule_actions/index.tsx | 14 ++++++++++++-- .../components/throttle_select_field/index.tsx | 7 +++---- .../signals/signal_rule_alert_type.ts | 5 +---- .../sections/action_connector_form/action_form.tsx | 2 +- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_actions_field/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_actions_field/index.tsx index 0219c32264c23..43d1a61227a4a 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_actions_field/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/rule_actions_field/index.tsx @@ -17,15 +17,11 @@ import { AlertAction } from '../../../../../../../../../plugins/triggers_actions type ThrottleSelectField = typeof SelectField; -const ACTION_TYPES = [ +const SUPPORTED_ACTION_TYPES = [ { id: '.email', name: 'Email', enabled: true }, - { id: '.index', name: 'Index', enabled: false }, { id: '.pagerduty', name: 'PagerDuty', enabled: true }, - { id: '.server-log', name: 'Server log', enabled: false }, - { id: '.servicenow', name: 'servicenow', enabled: false }, { id: '.slack', name: 'Slack', enabled: true }, - { id: '.webhook', name: 'Webhook', enabled: false }, - { id: '.example-action', name: 'Example Action', enabled: false }, + { id: '.webhook', name: 'Webhook', enabled: true }, ]; const DEFAULT_ACTION_GROUP_ID = 'default'; @@ -49,7 +45,7 @@ const getMessageVariables = memoizeOne(() => { }); export const RuleActionsField: ThrottleSelectField = ({ field }) => { - const { http, toastNotifications, triggers_actions_ui } = useKibana().services; + const { http, triggers_actions_ui } = useKibana().services; const actionTypeRegistry = triggers_actions_ui.actionTypeRegistry; const messageVariables = getMessageVariables(); @@ -79,7 +75,6 @@ export const RuleActionsField: ThrottleSelectField = ({ field }) => { return ( { setActionParamsProperty={setActionParamsProperty} http={http} actionTypeRegistry={actionTypeRegistry} - actionTypes={ACTION_TYPES} + actionTypes={SUPPORTED_ACTION_TYPES} defaultActionMessage={DEFAULT_ACTION_MESSAGE} /> ); diff --git a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_rule_actions/index.tsx b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_rule_actions/index.tsx index ddf3f20ca9e7a..182e926243555 100644 --- a/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_rule_actions/index.tsx +++ b/x-pack/legacy/plugins/siem/public/pages/detection_engine/rules/components/step_rule_actions/index.tsx @@ -81,7 +81,17 @@ const StepRuleActionsComponent: FC = ({ } }, [form]); - // console.error('ss', myStepData, form.getFormData()); + // useEffect(() => { + // if (!form) return; + + // const subscription = form.subscribe(updatedData => { + // setMyStepData({ ...updatedData.data.raw, ...stepActionsDefaultValue }); + // }); + + // return subscription.unsubscribe; + // }, [form]); + + console.error('ss', myStepData, form.getFormData()); return isReadOnlyView && myStepData != null ? ( @@ -104,7 +114,7 @@ const StepRuleActionsComponent: FC = ({ }, }} /> - {form.getFormData().throttle !== stepActionsDefaultValue.throttle && ( + {myStepData.throttle !== stepActionsDefaultValue.throttle && ( <> void; http: HttpSetup; actionTypeRegistry: TypeRegistry; - toastNotifications: Pick< + toastNotifications?: Pick< ToastsApi, 'get$' | 'add' | 'remove' | 'addSuccess' | 'addWarning' | 'addDanger' | 'addError' >;