Skip to content

Commit

Permalink
Disable all suppression fields as a group
Browse files Browse the repository at this point in the history
We did not previously extend our full disabling logic to all suppression
fields. Now, when we determine that alert suppression is
invalid/disabled, we disable all those relevant fields together.

This commit accomplishes the above, and also factors out some shared
boolean logic into the more general `areSuppressionFieldsDisabled`
boolean, which is shared by most of these fields.
  • Loading branch information
rylnd committed Jul 16, 2024
1 parent d5aa551 commit 983945b
Showing 1 changed file with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -477,11 +477,17 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
isEqlSequenceQuery(queryBar?.query?.query as string) &&
groupByFields.length === 0;

const isSuppressionGroupByDisabled =
/**
* If we don't have ML field information, users can't meaningfully interact with these fields */
const areSuppressionFieldsDisabledByMlFields =
isMlRule(ruleType) && (noMlJobsStarted || mlFieldsLoading || !mlSuppressionFields.length);

const areSuppressionFieldsDisabled =
!isAlertSuppressionLicenseValid ||
areSuppressionFieldsDisabledBySequence ||
isEsqlSuppressionLoading ||
(isMlRule(ruleType) && (noMlJobsStarted || mlFieldsLoading || !mlSuppressionFields.length));
areSuppressionFieldsDisabledByMlFields;

const isSuppressionGroupByDisabled = areSuppressionFieldsDisabled || isEsqlSuppressionLoading;

const suppressionGroupByDisabledText = useMemo(() => {
if (areSuppressionFieldsDisabledBySequence) {
Expand Down Expand Up @@ -513,54 +519,48 @@ const StepDefineRuleComponent: FC<StepDefineRuleProps> = ({
* - if suppression license is not valid(i.e. less than platinum)
* - or for not threshold rule - when groupBy fields not selected
* - Eql sequence is used
* - ML Field information is not available
*/
const isGroupByChildrenDisabled =
areSuppressionFieldsDisabledBySequence || !isAlertSuppressionLicenseValid || isThresholdRule
? false
: !groupByFields?.length;
areSuppressionFieldsDisabled || (isThresholdRule ? false : !groupByFields?.length);

/**
* Per rule execution radio option is disabled
* - if suppression license is not valid(i.e. less than platinum)
* - always disabled for threshold rule
* - Eql sequence is used and suppression fields are in the default state
* - ML Field information is not available
*/
const isPerRuleExecutionDisabled =
areSuppressionFieldsDisabledBySequence || !isAlertSuppressionLicenseValid || isThresholdRule;
const isPerRuleExecutionDisabled = areSuppressionFieldsDisabled || isThresholdRule;

/**
* Per time period execution radio option is disabled
* - if suppression license is not valid(i.e. less than platinum)
* - disabled for threshold rule when enabled suppression is not checked
* - Eql sequence is used and suppression fields are in the default state
* - ML Field information is not available
*/
const isPerTimePeriodDisabled =
areSuppressionFieldsDisabledBySequence ||
!isAlertSuppressionLicenseValid ||
(isThresholdRule && !enableThresholdSuppression);
areSuppressionFieldsDisabled || (isThresholdRule && !enableThresholdSuppression);

/**
* Suppression duration is disabled when
* - if suppression license is not valid(i.e. less than platinum)
* - when suppression by rule execution is selected in radio button
* - when threshold suppression is not enabled and no group by fields selected
* - Eql sequence is used and suppression fields are in the default state
* - ML Field information is not available
* */
const isDurationDisabled =
areSuppressionFieldsDisabledBySequence ||
!isAlertSuppressionLicenseValid ||
(!enableThresholdSuppression && groupByFields?.length === 0);
areSuppressionFieldsDisabled || (!enableThresholdSuppression && groupByFields?.length === 0);

/**
* Suppression missing fields is disabled when
* - if suppression license is not valid(i.e. less than platinum)
* - when no group by fields selected
* - Eql sequence is used and suppression fields are in the default state
* */
const isMissingFieldsDisabled =
areSuppressionFieldsDisabledBySequence ||
!isAlertSuppressionLicenseValid ||
!groupByFields.length;
const isMissingFieldsDisabled = areSuppressionFieldsDisabled || !groupByFields.length;

const GroupByChildren = useCallback(
({ groupByRadioSelection, groupByDurationUnit, groupByDurationValue }) => (
Expand Down

0 comments on commit 983945b

Please sign in to comment.