Skip to content

Commit

Permalink
[Security Solution][Hotfix] Avoid blocking prebuilt rule upgrade upon…
Browse files Browse the repository at this point in the history
… conflicts with disabled feature flag (elastic#198106)

## Summary

It turned out some of the update rule buttons are disabled. This is a side effect of the functionality not fully hidden under a feature flag. This PR hides prebuilt rule customisation functionality disabling update rule buttons under `prebuiltRulesCustomizationEnabled` feature flag.

## Before

![image](https://github.com/user-attachments/assets/b7ca5ff8-be37-47a7-ad7e-b85386909f38)

## After

<img width="1719" alt="image" src="https://github.com/user-attachments/assets/349223dc-dda5-46fb-832f-d7097a81580e">

<img width="1721" alt="image" src="https://github.com/user-attachments/assets/a28512f6-e605-460e-884d-571ab408a7d9">
  • Loading branch information
maximpn authored Oct 29, 2024
1 parent 82da511 commit 9622f62
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/

import { useCallback, useMemo, useState } from 'react';
import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features';
import type {
RulesUpgradeState,
FieldsUpgradeState,
Expand All @@ -32,6 +33,9 @@ interface UseRulesUpgradeStateResult {
export function usePrebuiltRulesUpgradeState(
ruleUpgradeInfos: RuleUpgradeInfoForReview[]
): UseRulesUpgradeStateResult {
const isPrebuiltRulesCustomizationEnabled = useIsExperimentalFeatureEnabled(
'prebuiltRulesCustomizationEnabled'
);
const [rulesResolvedConflicts, setRulesResolvedConflicts] = useState<RulesResolvedConflicts>({});

const setRuleFieldResolvedValue = useCallback(
Expand Down Expand Up @@ -61,16 +65,17 @@ export function usePrebuiltRulesUpgradeState(
ruleUpgradeInfo.diff.fields,
rulesResolvedConflicts[ruleUpgradeInfo.rule_id] ?? {}
),
hasUnresolvedConflicts:
getUnacceptedConflictsCount(
ruleUpgradeInfo.diff.fields,
rulesResolvedConflicts[ruleUpgradeInfo.rule_id] ?? {}
) > 0,
hasUnresolvedConflicts: isPrebuiltRulesCustomizationEnabled
? getUnacceptedConflictsCount(
ruleUpgradeInfo.diff.fields,
rulesResolvedConflicts[ruleUpgradeInfo.rule_id] ?? {}
) > 0
: false,
};
}

return state;
}, [ruleUpgradeInfos, rulesResolvedConflicts]);
}, [ruleUpgradeInfos, rulesResolvedConflicts, isPrebuiltRulesCustomizationEnabled]);

return {
rulesUpgradeState,
Expand Down

0 comments on commit 9622f62

Please sign in to comment.