-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ac1b927
commit ff1858e
Showing
6 changed files
with
98 additions
and
9 deletions.
There are no files selected for viewing
24 changes: 24 additions & 0 deletions
24
...ic/detection_engine/rule_creation/components/anomaly_threshold/anomaly_threshold_edit.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<UseField path={path} component={AnomalyThresholdSlider} componentProps={componentProps} /> | ||
); | ||
} |
8 changes: 8 additions & 0 deletions
8
...rity_solution/public/detection_engine/rule_creation/components/anomaly_threshold/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
..._details/three_way_diff/final_edit/fields/anomaly_threshold/anomaly_threshold_adapter.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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 { AnomalyThresholdEdit } from '../../../../../../../rule_creation/components/anomaly_threshold'; | ||
|
||
export function AnomalyThresholdAdapter(): JSX.Element { | ||
return <AnomalyThresholdEdit path="anomalyThreshold" />; | ||
} |
46 changes: 46 additions & 0 deletions
46
...ule_details/three_way_diff/final_edit/fields/anomaly_threshold/anomaly_threshold_form.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 ( | ||
<RuleFieldEditFormWrapper | ||
component={AnomalyThresholdAdapter} | ||
ruleFieldFormSchema={anomalyThresholdSchema} | ||
deserializer={deserializer} | ||
serializer={serializer} | ||
/> | ||
); | ||
} | ||
|
||
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<AnomalyThresholdFormData>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters