Skip to content

Commit 66abe0f

Browse files
committed
disable flatten result index option for existing detectors
Signed-off-by: Jackie Han <hnyng@amazon.com>
1 parent 58bbec8 commit 66abe0f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

public/pages/DefineDetector/components/CustomResultIndex/CustomResultIndex.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ interface CustomResultIndexProps {
4848
function CustomResultIndex(props: CustomResultIndexProps) {
4949
const [enabled, setEnabled] = useState<boolean>(!!props.resultIndex);
5050
const [customResultIndexConditionsEnabled, setCustomResultIndexConditionsEnabled] = useState<boolean>(true);
51+
const [isDisabled, setIsDisabled] = useState(false);
5152
const customResultIndexMinAge = get(props.formikProps, 'values.resultIndexMinAge');
5253
const customResultIndexMinSize = get(props.formikProps, 'values.resultIndexMinSize');
5354
const customResultIndexTTL = get(props.formikProps, 'values.resultIndexTtl');
@@ -66,6 +67,14 @@ function CustomResultIndex(props: CustomResultIndexProps) {
6667
}
6768
},[customResultIndexConditionsEnabled])
6869

70+
useEffect(() => {
71+
if (props.isEdit && !get(props.formikProps, 'values.flattenCustomResultIndex')) {
72+
setIsDisabled(true);
73+
} else {
74+
setIsDisabled(false);
75+
}
76+
}, [props.isEdit]);
77+
6978
const hintTextStyle = {
7079
color: '#69707d',
7180
fontSize: '12px',
@@ -162,6 +171,7 @@ function CustomResultIndex(props: CustomResultIndexProps) {
162171
id={'flattenCustomResultIndex'}
163172
label="Enable flattened custom result index"
164173
checked={field.value ? field.value : get(props.formikProps, 'values.flattenCustomResultIndex')}
174+
disabled={isDisabled}
165175
{...field}
166176
/>
167177
<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>

0 commit comments

Comments
 (0)