Skip to content

Commit

Permalink
disable flatten result index option for existing detectors (#965)
Browse files Browse the repository at this point in the history
Signed-off-by: Jackie Han <[email protected]>
  • Loading branch information
jackiehanyang authored Jan 28, 2025
1 parent e60e4e9 commit c51aca0
Showing 1 changed file with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ interface CustomResultIndexProps {
function CustomResultIndex(props: CustomResultIndexProps) {
const [enabled, setEnabled] = useState<boolean>(!!props.resultIndex);
const [customResultIndexConditionsEnabled, setCustomResultIndexConditionsEnabled] = useState<boolean>(true);
const [isDisabled, setIsDisabled] = useState(false);
const customResultIndexMinAge = get(props.formikProps, 'values.resultIndexMinAge');
const customResultIndexMinSize = get(props.formikProps, 'values.resultIndexMinSize');
const customResultIndexTTL = get(props.formikProps, 'values.resultIndexTtl');
Expand All @@ -66,6 +67,14 @@ function CustomResultIndex(props: CustomResultIndexProps) {
}
},[customResultIndexConditionsEnabled])

useEffect(() => {
if (props.isEdit && !get(props.formikProps, 'values.flattenCustomResultIndex')) {
setIsDisabled(true);
} else {
setIsDisabled(false);
}
}, [props.isEdit]);

const hintTextStyle = {
color: '#69707d',
fontSize: '12px',
Expand Down Expand Up @@ -162,6 +171,7 @@ function CustomResultIndex(props: CustomResultIndexProps) {
id={'flattenCustomResultIndex'}
label="Enable flattened custom result index"
checked={field.value ? field.value : get(props.formikProps, 'values.flattenCustomResultIndex')}
disabled={isDisabled}
{...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>
Expand Down

0 comments on commit c51aca0

Please sign in to comment.