Skip to content

Commit

Permalink
Revert "Add Enable Flattened custom result index checkbox (opensearch…
Browse files Browse the repository at this point in the history
  • Loading branch information
jackiehanyang committed Sep 3, 2024
1 parent 3def729 commit f428c8e
Show file tree
Hide file tree
Showing 15 changed files with 16 additions and 305 deletions.
1 change: 0 additions & 1 deletion public/models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ export type Detector = {
resultIndexMinAge?: number;
resultIndexMinSize?: number;
resultIndexTtl?: number;
flattenCustomResultIndex?: boolean;
filterQuery: { [key: string]: any };
featureAttributes: FeatureAttributes[];
windowDelay: { period: Schedule };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ContentPanel
title={
Expand Down Expand Up @@ -146,48 +136,25 @@ function CustomResultIndex(props: CustomResultIndexProps) {
</EuiCompressedFormRow>
</EuiFlexItem>
) : null}

{enabled ? (
<EuiFlexItem>
<EuiCheckbox
id={'resultIndexConditionCheckbox'}
label="Enable custom result index lifecycle management"
checked={customResultIndexConditionsEnabled}
onChange={() => {
setCustomResultIndexConditionsEnabled(!customResultIndexConditionsEnabled);
}}
/>
</EuiFlexItem>
) : null}
</EuiFlexGroup>
)}
</Field>

<EuiFlexGroup direction="column">
<EuiFlexItem>
{ enabled ? (
<Field
name="flattenCustomResultIndex">
{({ field, form }: FieldProps) => (
<EuiFlexGroup>
<EuiFlexItem>
<EuiCompressedCheckbox
id={'flattenCustomResultIndex'}
label="Enable flattened custom result index"
checked={field.value ? field.value : get(props.formikProps, 'values.flattenCustomResultIndex')}
{...field}
/>
<p style={hintTextStyle}>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.</p>
</EuiFlexItem>
</EuiFlexGroup>
)}
</Field>) : null}
</EuiFlexItem>
<EuiFlexItem>
{enabled ? (
<EuiFlexItem>
<EuiCompressedCheckbox
id={'resultIndexConditionCheckbox'}
label="Enable custom result index lifecycle management"
checked={customResultIndexConditionsEnabled}
onChange={() => {
setCustomResultIndexConditionsEnabled(!customResultIndexConditionsEnabled);
}}
/>
</EuiFlexItem>
) : null}
</EuiFlexItem>
</EuiFlexGroup>

{ (enabled && customResultIndexConditionsEnabled) ? (<Field
name="resultIndexMinAge"
{ (enabled && customResultIndexConditionsEnabled) ? (<Field
name="resultIndexMinAge"
validate={(enabled && customResultIndexConditionsEnabled) ? validateEmptyOrPositiveInteger : null}
>
{({ field, form }: FieldProps) => (
Expand Down
1 change: 0 additions & 1 deletion public/pages/DefineDetector/containers/DefineDetector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,16 +974,6 @@ exports[`<DefineDetector /> Full creating detector definition renders the compon
</div>
</div>
</div>
<div
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--directionColumn euiFlexGroup--responsive"
>
<div
class="euiFlexItem"
/>
<div
class="euiFlexItem"
/>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -1963,16 +1953,6 @@ exports[`<DefineDetector /> empty creating detector definition renders the compo
</div>
</div>
</div>
<div
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--directionColumn euiFlexGroup--responsive"
>
<div
class="euiFlexItem"
/>
<div
class="euiFlexItem"
/>
</div>
</div>
</div>
</div>
Expand Down Expand Up @@ -2985,16 +2965,6 @@ exports[`<DefineDetector /> empty editing detector definition renders the compon
</div>
</div>
</div>
<div
class="euiFlexGroup euiFlexGroup--gutterLarge euiFlexGroup--directionColumn euiFlexGroup--responsive"
>
<div
class="euiFlexItem"
/>
<div
class="euiFlexItem"
/>
</div>
</div>
</div>
</div>
Expand Down
1 change: 0 additions & 1 deletion public/pages/DefineDetector/models/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,4 @@ export interface DetectorDefinitionFormikValues {
resultIndexMinAge?: number | string;
resultIndexMinSize?: number | string;
resultIndexTtl?:number | string;
flattenCustomResultIndex?: boolean;
}
2 changes: 0 additions & 2 deletions public/pages/DefineDetector/utils/__tests__/helpers.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand All @@ -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", () => {
Expand Down
1 change: 0 additions & 1 deletion public/pages/DefineDetector/utils/constants.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export const INITIAL_DETECTOR_DEFINITION_VALUES: DetectorDefinitionFormikValues
resultIndexMinAge: 7,
resultIndexMinSize: 51200,
resultIndexTtl: 60,
flattenCustomResultIndex: false,
imputationMethod: undefined,
customImputationValue: undefined
};
2 changes: 0 additions & 2 deletions public/pages/DefineDetector/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};
}

Expand Down Expand Up @@ -126,7 +125,6 @@ export function formikToDetectorDefinition(
resultIndexMinAge: values.resultIndexMinAge,
resultIndexMinSize: values.resultIndexMinSize,
resultIndexTtl: values.resultIndexTtl,
flattenCustomResultIndex: values.flattenCustomResultIndex,
} as Detector;

return detectorBody;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -430,40 +430,6 @@ exports[`<DetectorConfig /> spec renders the component 1`] = `
</div>
</div>
</div>
<div
class="euiFlexItem"
>
<div
class="euiFormRow euiFormRow--compressed"
id="random_html_id-row"
style="width: 250px;"
>
<div
class="euiFormRow__labelWrapper"
>
<label
class="euiFormLabel euiFormRow__label"
for="random_html_id"
>
Flatten custom result index
</label>
</div>
<div
class="euiFormRow__fieldWrapper"
>
<div
class="euiText euiText--medium"
id="random_html_id"
>
<p
class="enabled"
>
Yes
</p>
</div>
</div>
</div>
</div>
<div
class="euiFlexItem"
>
Expand Down Expand Up @@ -1808,40 +1774,6 @@ exports[`<DetectorConfig /> spec renders the component with 2 custom and 1 simpl
</div>
</div>
</div>
<div
class="euiFlexItem"
>
<div
class="euiFormRow euiFormRow--compressed"
id="random_html_id-row"
style="width: 250px;"
>
<div
class="euiFormRow__labelWrapper"
>
<label
class="euiFormLabel euiFormRow__label"
for="random_html_id"
>
Flatten custom result index
</label>
</div>
<div
class="euiFormRow__fieldWrapper"
>
<div
class="euiText euiText--medium"
id="random_html_id"
>
<p
class="enabled"
>
Yes
</p>
</div>
</div>
</div>
</div>
<div
class="euiFlexItem"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<ContentPanel
Expand Down Expand Up @@ -226,12 +225,6 @@ export const DetectorDefinitionFields = (
description={get(props, 'detector.resultIndex', '-')}
/>
</EuiFlexItem>
<EuiFlexItem>
<ConfigCell
title="Flatten custom result index"
description={flatten}
/>
</EuiFlexItem>
<EuiFlexItem>
<ConfigCell
title="Custom result index min age"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ const testDetector = {
resultIndexMinAge: 7,
resultIndexMinSize: 51200,
resultIndexTtl: 60,
flattenCustomResultIndex: true,
} as Detector;

describe('<AdditionalSettings /> spec', () => {
Expand Down Expand Up @@ -86,7 +85,6 @@ describe('<AdditionalSettings /> spec', () => {
getByText('test-timefield');
getByText('1 Minutes');
getByText('opensearch-ad-plugin-result-test');
getByText('Yes')
getByText('7 Days');
getByText('51200 MB');
getByText('60 Days');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,40 +342,6 @@ exports[`<AdditionalSettings /> spec renders the component in create mode (no ID
</div>
</div>
</div>
<div
class="euiFlexItem"
>
<div
class="euiFormRow euiFormRow--compressed"
id="random_html_id-row"
style="width: 250px;"
>
<div
class="euiFormRow__labelWrapper"
>
<label
class="euiFormLabel euiFormRow__label"
for="random_html_id"
>
Flatten custom result index
</label>
</div>
<div
class="euiFormRow__fieldWrapper"
>
<div
class="euiText euiText--medium"
id="random_html_id"
>
<p
class="enabled"
>
Yes
</p>
</div>
</div>
</div>
</div>
<div
class="euiFlexItem"
>
Expand Down Expand Up @@ -896,40 +862,6 @@ exports[`<AdditionalSettings /> spec renders the component in edit mode (with ID
</div>
</div>
</div>
<div
class="euiFlexItem"
>
<div
class="euiFormRow euiFormRow--compressed"
id="random_html_id-row"
style="width: 250px;"
>
<div
class="euiFormRow__labelWrapper"
>
<label
class="euiFormLabel euiFormRow__label"
for="random_html_id"
>
Flatten custom result index
</label>
</div>
<div
class="euiFormRow__fieldWrapper"
>
<div
class="euiText euiText--medium"
id="random_html_id"
>
<p
class="enabled"
>
Yes
</p>
</div>
</div>
</div>
</div>
<div
class="euiFlexItem"
>
Expand Down
Loading

0 comments on commit f428c8e

Please sign in to comment.