From d29f82118dbaca5966e8a459c4e44cb1c5bd5a5e Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 29 Oct 2024 20:16:50 +1100 Subject: [PATCH] [8.x] [Security Solution][Hotfix] Avoid blocking prebuilt rule upgrade upon conflicts with disabled feature flag (#198106) (#198112) # Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution][Hotfix] Avoid blocking prebuilt rule upgrade upon conflicts with disabled feature flag (#198106)](https://github.com/elastic/kibana/pull/198106) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: Maxim Palenov --- .../use_prebuilt_rules_upgrade_state.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/use_prebuilt_rules_upgrade_state.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/use_prebuilt_rules_upgrade_state.ts index d44f9738b1fd6..29c5b2b201fe6 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/use_prebuilt_rules_upgrade_state.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/use_prebuilt_rules_upgrade_state.ts @@ -6,6 +6,7 @@ */ import { useCallback, useMemo, useState } from 'react'; +import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; import type { RulesUpgradeState, FieldsUpgradeState, @@ -32,6 +33,9 @@ interface UseRulesUpgradeStateResult { export function usePrebuiltRulesUpgradeState( ruleUpgradeInfos: RuleUpgradeInfoForReview[] ): UseRulesUpgradeStateResult { + const isPrebuiltRulesCustomizationEnabled = useIsExperimentalFeatureEnabled( + 'prebuiltRulesCustomizationEnabled' + ); const [rulesResolvedConflicts, setRulesResolvedConflicts] = useState({}); const setRuleFieldResolvedValue = useCallback( @@ -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,