From 94c561436644d3a97e01a2d762a368c6965d0ac1 Mon Sep 17 00:00:00 2001 From: Dmitrii Shevchenko Date: Thu, 5 Dec 2024 14:25:35 +0100 Subject: [PATCH] [Security Solution] Add rule upgrade review cache invalidation (#202969) **Resolves: https://github.com/elastic/kibana/issues/202779** ## Summary Implemented proper cache invalidation after rule CRUD operations to prevent displaying stale data in rule upgrade flyouts. See the linked issue for more details. ### How to Test 1. Ensure rule customization is enabled 2. Navigate to the Rule Updates page 3. Locate any rule with updates 4. Make changes to the rule: - Edit the rule via the Rule Editing page - Use bulk actions - Delete the rule 5. Return to the Rule Updates page - All introduced changes should be reflected: - Modifications should be visible - If the rule was deleted, it should no longer appear on the page --- .../rule_management/api/hooks/use_bulk_action_mutation.ts | 1 + .../rule_management/api/hooks/use_update_rule_mutation.ts | 3 +++ 2 files changed, 4 insertions(+) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts index 7d8f42adad31b..376b26684d4a5 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_bulk_action_mutation.ts @@ -101,6 +101,7 @@ export const useBulkActionMutation = ( invalidateFetchRuleByIdQuery(); invalidateFetchRuleManagementFilters(); invalidateFetchCoverageOverviewQuery(); + invalidateFetchPrebuiltRulesUpgradeReviewQuery(); break; } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_update_rule_mutation.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_update_rule_mutation.ts index 5eedf122a6ac6..812b97b669378 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_update_rule_mutation.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/use_update_rule_mutation.ts @@ -17,6 +17,7 @@ import { useInvalidateFindRulesQuery } from './use_find_rules_query'; import { useUpdateRuleByIdCache } from './use_fetch_rule_by_id_query'; import { useInvalidateFetchRuleManagementFiltersQuery } from './use_fetch_rule_management_filters_query'; import { useInvalidateFetchCoverageOverviewQuery } from './use_fetch_coverage_overview_query'; +import { useInvalidateFetchPrebuiltRulesUpgradeReviewQuery } from './prebuilt_rules/use_fetch_prebuilt_rules_upgrade_review_query'; export const UPDATE_RULE_MUTATION_KEY = ['PUT', DETECTION_ENGINE_RULES_URL]; @@ -26,6 +27,7 @@ export const useUpdateRuleMutation = ( const invalidateFindRulesQuery = useInvalidateFindRulesQuery(); const invalidateFetchRuleManagementFilters = useInvalidateFetchRuleManagementFiltersQuery(); const invalidateFetchCoverageOverviewQuery = useInvalidateFetchCoverageOverviewQuery(); + const invalidatePrebuiltRulesUpdateReview = useInvalidateFetchPrebuiltRulesUpgradeReviewQuery(); const updateRuleCache = useUpdateRuleByIdCache(); return useMutation( @@ -37,6 +39,7 @@ export const useUpdateRuleMutation = ( invalidateFindRulesQuery(); invalidateFetchRuleManagementFilters(); invalidateFetchCoverageOverviewQuery(); + invalidatePrebuiltRulesUpdateReview(); const [response] = args;