From c92899e142c3edf8318d0a7a13c15ff7cfb3a0f4 Mon Sep 17 00:00:00 2001 From: Ievgen Sorokopud Date: Mon, 16 Dec 2024 11:15:52 +0100 Subject: [PATCH] [Rules migration] Allow partial `RuleResponse` object to be passed to `RuleOverviewTab` (#204318) ## Summary These changes allow `Partial` to be used as a parameter for `RuleOverviewTab` component. We re-use this component for "SIEM Migrations" feature to display translated state of the rule which has just a few fields that represent the `RuleResponse` object. The set of fields used in `RuleMigration` object is a minimum set of fields enough for the rule creation. Right now, `RuleOverviewTab` component requires the complete `RuleResponse` object to be passed even though internally each section (`RuleAboutSection`, `RuleDefinitionSection`, `RuleScheduleSection` and `RuleSetupGuideSection`) of the rule's overview expects `Partial`. To be able to use this component we force type casting at the moment and would like to get rid of it. @elastic/security-detection-rule-management do you have objects regarding this change in `RuleOverviewTab` intefrace? ### Checklist Check the PR satisfies following conditions. Reviewers should verify this PR satisfies this list as well. - [x] [Flaky Test Runner](https://ci-stats.kibana.dev/trigger_flaky_test_runner/1) was used on any tests changed - Rule management cypress tests ([100 ESS & 100 Serverless](https://buildkite.com/elastic/kibana-flaky-test-suite-runner/builds/7601)) --- .../components/rule_details/rule_overview_tab.tsx | 2 +- .../rules/components/rule_details_flyout/index.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_overview_tab.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_overview_tab.tsx index 7fd3cc270286c..6ad182d722517 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_overview_tab.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_overview_tab.tsx @@ -88,7 +88,7 @@ const ExpandableSection = ({ title, isOpen, toggle, children }: ExpandableSectio }; interface RuleOverviewTabProps { - rule: RuleResponse; + rule: Partial; columnWidths?: EuiDescriptionListProps['columnWidths']; expandedOverviewSections: Record; toggleOverviewSection: Record void>; diff --git a/x-pack/plugins/security_solution/public/siem_migrations/rules/components/rule_details_flyout/index.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/rule_details_flyout/index.tsx index 60a44c251e924..584a5fb9320f3 100644 --- a/x-pack/plugins/security_solution/public/siem_migrations/rules/components/rule_details_flyout/index.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/rule_details_flyout/index.tsx @@ -126,7 +126,7 @@ export const MigrationRuleDetailsFlyout: React.FC { const elasticRule = ruleMigration?.elastic_rule; if (isMigrationCustomRule(elasticRule)) { - return convertMigrationCustomRuleToSecurityRulePayload(elasticRule, false) as RuleResponse; // TODO: we need to adjust RuleOverviewTab to allow partial RuleResponse as a parameter; + return convertMigrationCustomRuleToSecurityRulePayload(elasticRule, false); } return matchedPrebuiltRule; }, [ruleMigration, matchedPrebuiltRule]);