Skip to content

Commit

Permalink
removes suppression fields when saving and suppression is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
dhurley14 committed Nov 26, 2024
1 parent 8b020ce commit 09be989
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import { useCallback } from 'react';
import type { DefineStepRule } from '../../../../detections/pages/detection_engine/rules/types';
import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features';
import { isEqlRule, isEqlSequenceQuery } from '../../../../../common/detection_engine/utils';
import {
ALERT_SUPPRESSION_FIELDS_FIELD_NAME,
ALERT_SUPPRESSION_DURATION_TYPE_FIELD_NAME,
ALERT_SUPPRESSION_DURATION_FIELD_NAME,
ALERT_SUPPRESSION_MISSING_FIELDS_FIELD_NAME,
} from '../../../rule_creation/components/alert_suppression_edit';

/**
* transforms DefineStepRule fields according to experimental feature flags
Expand All @@ -30,10 +36,10 @@ export const useExperimentalFeatureFieldsTransform = <T extends Partial<DefineSt
if (isSuppressionDisabled) {
return {
...fields,
groupByFields: [],
groupByRadioSelection: undefined,
groupByDuration: undefined,
suppressionMissingFields: undefined,
[ALERT_SUPPRESSION_FIELDS_FIELD_NAME]: [],
[ALERT_SUPPRESSION_DURATION_TYPE_FIELD_NAME]: undefined,
[ALERT_SUPPRESSION_DURATION_FIELD_NAME]: undefined,
[ALERT_SUPPRESSION_MISSING_FIELDS_FIELD_NAME]: undefined,
};
}
return fields;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,6 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
startTransaction({ name: SINGLE_RULE_ACTIONS.SAVE });
const localDefineStepData: DefineStepRule = defineFieldsTransform({
...defineStepData,
eqlOptions: eqlOptionsSelected,
});
const updatedRule = await updateRule({
...formatRule<RuleUpdateProps>(
Expand All @@ -401,7 +400,6 @@ const EditRulePageComponent: FC<{ rule: RuleResponse }> = ({ rule }) => {
actionsStepData,
defineStepData,
defineFieldsTransform,
eqlOptionsSelected,
addSuccess,
navigateToApp,
rule?.exceptions_list,
Expand Down

0 comments on commit 09be989

Please sign in to comment.