From f89e47613bf528de50571615fbe2a0e6b8c53d7a Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Wed, 18 Sep 2024 16:52:21 +0200 Subject: [PATCH] Address code review comments --- .../components/rule_details/helpers.ts | 7 +++++-- .../fields/description/description.tsx | 16 ++++++++-------- .../final_readonly/fields/name/name.tsx | 16 ++++++++-------- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/helpers.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/helpers.ts index 105d8895ed6b7..08e4c9535ae91 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/helpers.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/helpers.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { isPlainObject } from 'lodash'; import type { Filter } from '@kbn/es-query'; import type { DiffableAllFields, @@ -77,10 +78,12 @@ export function getQueryLanguageLabel(language: string) { } /** - * Assigns type `Filter[]` to an array if every item in has a `meta` property. + * Assigns type `Filter[]` to an array if every item in it has a `meta` property. */ export function isFilters(maybeFilters: unknown[]): maybeFilters is Filter[] { - return maybeFilters.every((f) => typeof f === 'object' && f !== null && 'meta' in f); + return maybeFilters.every( + (f) => typeof f === 'object' && f !== null && 'meta' in f && isPlainObject(f.meta) + ); } type DataSourceProps = diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/description/description.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/description/description.tsx index 14fa7be6eca3e..add624ba15a6d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/description/description.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/description/description.tsx @@ -10,14 +10,6 @@ import { EuiDescriptionList } from '@elastic/eui'; import * as ruleDetailsI18n from '../../../../translations'; import type { RuleDescription } from '../../../../../../../../../common/api/detection_engine'; -interface DescriptionProps { - description: RuleDescription; -} - -function Description({ description }: DescriptionProps) { - return <>{description}; -} - interface DescriptionReadOnlyProps { description: RuleDescription; } @@ -34,3 +26,11 @@ export function DescriptionReadOnly({ description }: DescriptionReadOnlyProps) { /> ); } + +interface DescriptionProps { + description: RuleDescription; +} + +function Description({ description }: DescriptionProps) { + return <>{description}; +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/name/name.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/name/name.tsx index e6c5039e579e6..a611f9821d54e 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/name/name.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/name/name.tsx @@ -10,14 +10,6 @@ import { EuiDescriptionList } from '@elastic/eui'; import * as ruleDetailsI18n from '../../../../translations'; import type { RuleName } from '../../../../../../../../../common/api/detection_engine'; -interface NameProps { - name: RuleName; -} - -function Name({ name }: NameProps) { - return <>{name}; -} - interface NameReadOnlyProps { name: RuleName; } @@ -34,3 +26,11 @@ export function NameReadOnly({ name }: NameReadOnlyProps) { /> ); } + +interface NameProps { + name: RuleName; +} + +function Name({ name }: NameProps) { + return <>{name}; +}