diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/anomaly_threshold/anomaly_threshold_edit.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/anomaly_threshold/anomaly_threshold_edit.tsx new file mode 100644 index 0000000000000..1cafa5dc570bc --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/anomaly_threshold/anomaly_threshold_edit.tsx @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { UseField } from '../../../../shared_imports'; +import { AnomalyThresholdSlider } from '../../../rule_creation_ui/components/anomaly_threshold_slider'; + +const componentProps = { + describedByIds: ['anomalyThreshold'], +}; + +interface AnomalyThresholdEditProps { + path: string; +} + +export function AnomalyThresholdEdit({ path }: AnomalyThresholdEditProps): JSX.Element { + return ( + + ); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/anomaly_threshold/index.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/anomaly_threshold/index.ts new file mode 100644 index 0000000000000..406e555795656 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation/components/anomaly_threshold/index.ts @@ -0,0 +1,8 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +export { AnomalyThresholdEdit } from './anomaly_threshold_edit'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_define_rule/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_define_rule/index.tsx index a9d71a1f79bd8..e20ec9792c6c2 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_define_rule/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/step_define_rule/index.tsx @@ -44,7 +44,6 @@ import { StepRuleDescription } from '../description_step'; import type { QueryBarDefineRuleProps } from '../query_bar'; import { QueryBarDefineRule } from '../query_bar'; import { SelectRuleType } from '../select_rule_type'; -import { AnomalyThresholdSlider } from '../anomaly_threshold_slider'; import { PickTimeline } from '../../../rule_creation/components/pick_timeline'; import { StepContentWrapper } from '../../../rule_creation/components/step_content_wrapper'; import { ThresholdInput } from '../threshold_input'; @@ -94,6 +93,7 @@ import { AlertSuppressionEdit } from '../../../rule_creation/components/alert_su import { ThresholdAlertSuppressionEdit } from '../../../rule_creation/components/threshold_alert_suppression_edit'; import { usePersistentAlertSuppressionState } from './use_persistent_alert_suppression_state'; import { MachineLearningJobIdEdit } from '../../../rule_creation/components/machine_learning_job_id_edit'; +import { AnomalyThresholdEdit } from '../../../rule_creation/components/anomaly_threshold'; const CommonUseField = getUseField({ component: Field }); @@ -859,13 +859,7 @@ const StepDefineRuleComponent: FC = ({ <> - + ; +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_edit/fields/anomaly_threshold/anomaly_threshold_form.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_edit/fields/anomaly_threshold/anomaly_threshold_form.tsx new file mode 100644 index 0000000000000..8cce8da19aa68 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_edit/fields/anomaly_threshold/anomaly_threshold_form.tsx @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { FormData, FormSchema } from '../../../../../../../../shared_imports'; +import { schema } from '../../../../../../../rule_creation_ui/components/step_define_rule/schema'; +import { RuleFieldEditFormWrapper } from '../rule_field_edit_form_wrapper'; +import { AnomalyThresholdAdapter } from './anomaly_threshold_adapter'; +import type { AnomalyThreshold } from '../../../../../../../../../common/api/detection_engine'; + +interface AnomalyThresholdFormData { + anomalyThreshold: AnomalyThreshold; +} + +export function AnomalyThresholdForm(): JSX.Element { + return ( + + ); +} + +function deserializer(defaultValue: FormData): AnomalyThresholdFormData { + return { + anomalyThreshold: defaultValue.anomaly_threshold, + }; +} + +function serializer(formData: FormData): { + anomaly_threshold: AnomalyThresholdFormData; +} { + return { + anomaly_threshold: formData.anomalyThreshold, + }; +} + +const anomalyThresholdSchema = { + anomalyThreshold: schema.anomalyThreshold, +} as FormSchema; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_edit/machine_learning_rule_field_edit.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_edit/machine_learning_rule_field_edit.tsx index da40ce843f726..9563c64da7da1 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_edit/machine_learning_rule_field_edit.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_edit/machine_learning_rule_field_edit.tsx @@ -7,8 +7,10 @@ import React from 'react'; import type { UpgradeableMachineLearningFields } from '../../../../model/prebuilt_rule_upgrade/fields'; +import { AnomalyThresholdForm } from './fields/anomaly_threshold/anomaly_threshold_form'; import { AlertSuppressionEditForm } from './fields/alert_suppression'; import { MachineLearningJobIdForm } from './fields/machine_learning_job_id/machine_learning_job_id_form'; +import { assertUnreachable } from '../../../../../../../common/utility_types'; interface MachineLearningRuleFieldEditProps { fieldName: UpgradeableMachineLearningFields; @@ -18,9 +20,11 @@ export function MachineLearningRuleFieldEdit({ fieldName }: MachineLearningRuleF switch (fieldName) { case 'alert_suppression': return ; + case 'anomaly_threshold': + return ; case 'machine_learning_job_id': return ; default: - return null; // Will be replaced with `assertUnreachable(fieldName)` once all fields are implemented + return assertUnreachable(fieldName); } }