[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
This commit is contained in:
Dmitrii Shevchenko 2024-12-05 14:25:35 +01:00 committed by GitHub
parent 54e103211a
commit 94c5614366
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 0 deletions

View file

@ -101,6 +101,7 @@ export const useBulkActionMutation = (
invalidateFetchRuleByIdQuery();
invalidateFetchRuleManagementFilters();
invalidateFetchCoverageOverviewQuery();
invalidateFetchPrebuiltRulesUpgradeReviewQuery();
break;
}

View file

@ -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<RuleResponse, Error, RuleUpdateProps>(
@ -37,6 +39,7 @@ export const useUpdateRuleMutation = (
invalidateFindRulesQuery();
invalidateFetchRuleManagementFilters();
invalidateFetchCoverageOverviewQuery();
invalidatePrebuiltRulesUpdateReview();
const [response] = args;