From 1c1647a4a3c78cd78f95e0214d818e3ce0b61b19 Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Tue, 3 Sep 2024 11:12:42 -0700 Subject: [PATCH 1/2] Revert "Add Enable Flattened custom result index checkbox (#830) (#833)" This reverts commit f53450c733ca32341cec5f5295086b64ce6a04ae. --- public/models/interfaces.ts | 1 - .../CustomResultIndex/CustomResultIndex.tsx | 63 ++++------------- .../containers/DefineDetector.tsx | 1 - .../DefineDetector.test.tsx.snap | 30 -------- .../pages/DefineDetector/models/interfaces.ts | 1 - .../utils/__tests__/helpers.test.tsx | 2 - .../pages/DefineDetector/utils/constants.tsx | 3 +- public/pages/DefineDetector/utils/helpers.ts | 2 - .../DetectorConfig.test.tsx.snap | 68 ------------------- .../DetectorDefinitionFields.tsx | 9 +-- .../DetectorDefinitionFields.test.tsx | 2 - .../DetectorDefinitionFields.test.tsx.snap | 68 ------------------- .../ReviewAndCreate.test.tsx.snap | 68 ------------------- public/pages/ReviewAndCreate/utils/helpers.ts | 4 -- public/redux/reducers/__tests__/utils.ts | 1 - 15 files changed, 17 insertions(+), 306 deletions(-) diff --git a/public/models/interfaces.ts b/public/models/interfaces.ts index 74a0a1e6..f5a62568 100644 --- a/public/models/interfaces.ts +++ b/public/models/interfaces.ts @@ -194,7 +194,6 @@ export type Detector = { resultIndexMinAge?: number; resultIndexMinSize?: number; resultIndexTtl?: number; - flattenCustomResultIndex?: boolean; filterQuery: { [key: string]: any }; featureAttributes: FeatureAttributes[]; windowDelay: { period: Schedule }; diff --git a/public/pages/DefineDetector/components/CustomResultIndex/CustomResultIndex.tsx b/public/pages/DefineDetector/components/CustomResultIndex/CustomResultIndex.tsx index dadff697..f8b8fe50 100644 --- a/public/pages/DefineDetector/components/CustomResultIndex/CustomResultIndex.tsx +++ b/public/pages/DefineDetector/components/CustomResultIndex/CustomResultIndex.tsx @@ -66,16 +66,6 @@ function CustomResultIndex(props: CustomResultIndexProps) { } },[customResultIndexConditionsEnabled]) - const hintTextStyle = { - color: '#69707d', - fontSize: '12px', - lineHeight: '16px', - fontWeight: 'normal', - fontFamily: 'Helvetica, sans-serif', - textAlign: 'left', - width: '400px', -}; - return ( ) : null} + + {enabled ? ( + + { + setCustomResultIndexConditionsEnabled(!customResultIndexConditionsEnabled); + }} + /> + + ) : null} )} - - - { enabled ? ( - - {({ field, form }: FieldProps) => ( - - - -

Flattening the custom result index will make it easier to query them on the dashboard. It also allows you to perform term aggregations on categorical fields.

-
-
- )} -
) : null} -
- - {enabled ? ( - - { - setCustomResultIndexConditionsEnabled(!customResultIndexConditionsEnabled); - }} - /> - - ) : null} - -
- - { (enabled && customResultIndexConditionsEnabled) ? ( {({ field, form }: FieldProps) => ( diff --git a/public/pages/DefineDetector/containers/DefineDetector.tsx b/public/pages/DefineDetector/containers/DefineDetector.tsx index 06a0bb09..40e1012a 100644 --- a/public/pages/DefineDetector/containers/DefineDetector.tsx +++ b/public/pages/DefineDetector/containers/DefineDetector.tsx @@ -229,7 +229,6 @@ export const DefineDetector = (props: DefineDetectorProps) => { formikProps.setFieldTouched('resultIndexMinAge'); formikProps.setFieldTouched('resultIndexMinSize'); formikProps.setFieldTouched('resultIndexTtl'); - formikProps.setFieldTouched('flattenCustomResultIndex'); formikProps.validateForm().then((errors) => { if (isEmpty(errors)) { if (props.isEdit) { diff --git a/public/pages/DefineDetector/containers/__tests__/__snapshots__/DefineDetector.test.tsx.snap b/public/pages/DefineDetector/containers/__tests__/__snapshots__/DefineDetector.test.tsx.snap index 672db621..a4080a9d 100644 --- a/public/pages/DefineDetector/containers/__tests__/__snapshots__/DefineDetector.test.tsx.snap +++ b/public/pages/DefineDetector/containers/__tests__/__snapshots__/DefineDetector.test.tsx.snap @@ -974,16 +974,6 @@ exports[` Full creating detector definition renders the compon -
-
-
-
@@ -1963,16 +1953,6 @@ exports[` empty creating detector definition renders the compo -
-
-
-
@@ -2985,16 +2965,6 @@ exports[` empty editing detector definition renders the compon -
-
-
-
diff --git a/public/pages/DefineDetector/models/interfaces.ts b/public/pages/DefineDetector/models/interfaces.ts index c10ac7cf..c13f5bcd 100644 --- a/public/pages/DefineDetector/models/interfaces.ts +++ b/public/pages/DefineDetector/models/interfaces.ts @@ -25,5 +25,4 @@ export interface DetectorDefinitionFormikValues { resultIndexMinAge?: number | string; resultIndexMinSize?: number | string; resultIndexTtl?:number | string; - flattenCustomResultIndex?: boolean; } diff --git a/public/pages/DefineDetector/utils/__tests__/helpers.test.tsx b/public/pages/DefineDetector/utils/__tests__/helpers.test.tsx index e6385f7d..c461f2cc 100644 --- a/public/pages/DefineDetector/utils/__tests__/helpers.test.tsx +++ b/public/pages/DefineDetector/utils/__tests__/helpers.test.tsx @@ -44,7 +44,6 @@ describe('detectorDefinitionToFormik', () => { resultIndexMinAge: randomDetector.resultIndexMinAge, resultIndexMinSize: randomDetector.resultIndexMinSize, resultIndexTtl: randomDetector.resultIndexTtl, - flattenCustomResultIndex: randomDetector.flattenCustomResultIndex, }); }); test('should return if detector does not have metadata', () => { @@ -65,7 +64,6 @@ describe('detectorDefinitionToFormik', () => { resultIndexMinAge: randomDetector.resultIndexMinAge, resultIndexMinSize: randomDetector.resultIndexMinSize, resultIndexTtl: randomDetector.resultIndexTtl, - flattenCustomResultIndex: randomDetector.flattenCustomResultIndex, }); }); test("upgrade old detector's filters to include filter type", () => { diff --git a/public/pages/DefineDetector/utils/constants.tsx b/public/pages/DefineDetector/utils/constants.tsx index d6ef4dff..fafda119 100644 --- a/public/pages/DefineDetector/utils/constants.tsx +++ b/public/pages/DefineDetector/utils/constants.tsx @@ -46,6 +46,5 @@ export const INITIAL_DETECTOR_DEFINITION_VALUES: DetectorDefinitionFormikValues resultIndex: undefined, resultIndexMinAge: 7, resultIndexMinSize: 51200, - resultIndexTtl: 60, - flattenCustomResultIndex: false, + resultIndexTtl: 60 }; diff --git a/public/pages/DefineDetector/utils/helpers.ts b/public/pages/DefineDetector/utils/helpers.ts index 7ece3554..ed3443b1 100644 --- a/public/pages/DefineDetector/utils/helpers.ts +++ b/public/pages/DefineDetector/utils/helpers.ts @@ -48,7 +48,6 @@ export function detectorDefinitionToFormik( resultIndexMinAge: get(ad, 'resultIndexMinAge', undefined), resultIndexMinSize:get(ad, 'resultIndexMinSize', undefined), resultIndexTtl: get(ad, 'resultIndexTtl', undefined), - flattenCustomResultIndex: get(ad, 'flattenCustomResultIndex', false), }; } @@ -126,7 +125,6 @@ export function formikToDetectorDefinition( resultIndexMinAge: values.resultIndexMinAge, resultIndexMinSize: values.resultIndexMinSize, resultIndexTtl: values.resultIndexTtl, - flattenCustomResultIndex: values.flattenCustomResultIndex, } as Detector; return detectorBody; diff --git a/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap b/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap index 23c72f8d..42f38e5d 100644 --- a/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap +++ b/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap @@ -1890,40 +1890,6 @@ exports[` spec renders the component 1`] = ` -
-
-
- -
-
-
-

- Yes -

-
-
-
-
@@ -3321,40 +3287,6 @@ exports[` spec renders the component with 2 custom and 1 simpl
-
-
-
- -
-
-
-

- Yes -

-
-
-
-
diff --git a/public/pages/ReviewAndCreate/components/DetectorDefinitionFields/DetectorDefinitionFields.tsx b/public/pages/ReviewAndCreate/components/DetectorDefinitionFields/DetectorDefinitionFields.tsx index de5391a5..d1969c3c 100644 --- a/public/pages/ReviewAndCreate/components/DetectorDefinitionFields/DetectorDefinitionFields.tsx +++ b/public/pages/ReviewAndCreate/components/DetectorDefinitionFields/DetectorDefinitionFields.tsx @@ -137,8 +137,7 @@ export const DetectorDefinitionFields = ( const minSize = (minSizeValue === undefined) ? '-' : minSizeValue + " MB"; const ttlValue = get(props, 'detector.resultIndexTtl', undefined); const ttl = (ttlValue === undefined) ? '-' : ttlValue + " Days"; - const flattenCustomResultIndex = get(props, 'detector.flattenCustomResultIndex', undefined); - const flatten = (flattenCustomResultIndex === undefined) ? '-' : flattenCustomResultIndex ? 'Yes' : 'No'; + return ( - - - spec', () => { @@ -86,7 +85,6 @@ describe(' spec', () => { getByText('test-timefield'); getByText('1 Minutes'); getByText('opensearch-ad-plugin-result-test'); - getByText('Yes') getByText('7 Days'); getByText('51200 MB'); getByText('60 Days'); diff --git a/public/pages/ReviewAndCreate/components/__tests__/__snapshots__/DetectorDefinitionFields.test.tsx.snap b/public/pages/ReviewAndCreate/components/__tests__/__snapshots__/DetectorDefinitionFields.test.tsx.snap index cc35b8ff..17380e4d 100644 --- a/public/pages/ReviewAndCreate/components/__tests__/__snapshots__/DetectorDefinitionFields.test.tsx.snap +++ b/public/pages/ReviewAndCreate/components/__tests__/__snapshots__/DetectorDefinitionFields.test.tsx.snap @@ -342,40 +342,6 @@ exports[` spec renders the component in create mode (no ID
-
-
-
- -
-
-
-

- Yes -

-
-
-
-
@@ -896,40 +862,6 @@ exports[` spec renders the component in edit mode (with ID
-
-
-
- -
-
-
-

- Yes -

-
-
-
-
diff --git a/public/pages/ReviewAndCreate/containers/__tests__/__snapshots__/ReviewAndCreate.test.tsx.snap b/public/pages/ReviewAndCreate/containers/__tests__/__snapshots__/ReviewAndCreate.test.tsx.snap index 13019616..e08dd2f7 100644 --- a/public/pages/ReviewAndCreate/containers/__tests__/__snapshots__/ReviewAndCreate.test.tsx.snap +++ b/public/pages/ReviewAndCreate/containers/__tests__/__snapshots__/ReviewAndCreate.test.tsx.snap @@ -398,40 +398,6 @@ exports[` spec renders the component, validation loading 1`]
-
-
-
- -
-
-
-

- - -

-
-
-
-
@@ -1685,40 +1651,6 @@ exports[`issue in detector validation issues in feature query 1`] = `
-
-
-
- -
-
-
-

- - -

-
-
-
-
diff --git a/public/pages/ReviewAndCreate/utils/helpers.ts b/public/pages/ReviewAndCreate/utils/helpers.ts index f123f6fd..fd640477 100644 --- a/public/pages/ReviewAndCreate/utils/helpers.ts +++ b/public/pages/ReviewAndCreate/utils/helpers.ts @@ -72,10 +72,6 @@ export function formikToDetector(values: CreateDetectorFormikValues): Detector { resultIndex && resultIndex.trim().length > 0 ? values.resultIndexTtl : undefined, - flattenCustomResultIndex: - resultIndex && resultIndex.trim().length > 0 - ? values.flattenCustomResultIndex - : undefined, imputationOption: formikToImputationOption(values.imputationOption), rules: formikToRules(values.suppressionRules), } as Detector; diff --git a/public/redux/reducers/__tests__/utils.ts b/public/redux/reducers/__tests__/utils.ts index 76a734e4..b4974892 100644 --- a/public/redux/reducers/__tests__/utils.ts +++ b/public/redux/reducers/__tests__/utils.ts @@ -131,7 +131,6 @@ export const getRandomDetector = ( resultIndexMinAge: 7, resultIndexMinSize: 51200, resultIndexTtl: 60, - flattenCustomResultIndex: true, imputationOption: randomImputationOption(features), rules: randomRules(features) }; From 902dca4a281c922868358d55791e9c7b869c7a95 Mon Sep 17 00:00:00 2001 From: Jackie Han Date: Tue, 3 Sep 2024 12:25:52 -0700 Subject: [PATCH 2/2] update snapshot Signed-off-by: Jackie Han --- .../DetectorConfig.test.tsx.snap | 34 ------------------- 1 file changed, 34 deletions(-) diff --git a/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap b/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap index 42f38e5d..20c8a9b7 100644 --- a/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap +++ b/public/pages/DetectorConfig/containers/__tests__/__snapshots__/DetectorConfig.test.tsx.snap @@ -432,40 +432,6 @@ exports[` spec renders rules 1`] = `
-
-
-
- -
-
-
-

- - -

-
-
-
-