From f7af1638e71460df793a3c5af5ab808888f3dc55 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Tue, 27 Aug 2024 13:58:04 +0200 Subject: [PATCH 01/18] WIP --- .../rule_details/rule_definition_section.tsx | 83 ++++++--- .../comparison_side.stories.tsx | 2 +- .../data_source/data_source.stories.tsx | 64 +++++++ .../data_source/data_source.tsx | 56 ++++++ .../eql_query/eql_query.stories.tsx | 77 +++++++++ .../field_components/eql_query/eql_query.tsx | 46 +++++ .../esql_query/esql_query.stories.tsx | 46 +++++ .../esql_query/esql_query.tsx | 29 ++++ .../field_components/kql_query/index.tsx | 34 ++++ .../kql_query/inline_query.tsx | 55 ++++++ .../kql_query/kql_query.stories.tsx | 163 ++++++++++++++++++ .../kql_query/saved_query.tsx | 73 ++++++++ .../field_components/kql_query/utils.ts | 19 ++ .../machine_learning_job_id.stories.tsx | 97 +++++++++++ .../machine_learning_job_id.tsx | 31 ++++ .../field_components/translations.ts | 29 ++++ .../final_readonly/final_readonly.tsx | 52 ++++++ .../final_readonly/storybook/mocks.ts | 62 +++++++ .../storybook/storybook_providers.tsx | 24 +++ .../final_readonly/storybook/utils.ts | 45 +++++ .../upgrade_prebuilt_rules_table_context.tsx | 11 +- 21 files changed, 1072 insertions(+), 26 deletions(-) create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_query.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_query.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/utils.ts create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/translations.ts create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/utils.ts diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx index 35f429f776fab..917109c5ab130 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React from 'react'; +import React, { useEffect, useState } from 'react'; import { isEmpty } from 'lodash/fp'; import { EuiDescriptionList, @@ -39,8 +39,6 @@ import { AlertSuppressionLabel } from '../../../rule_creation_ui/components/desc import { useGetSavedQuery } from '../../../../detections/pages/detection_engine/rules/use_get_saved_query'; import * as threatMatchI18n from '../../../../common/components/threat_match/translations'; import * as timelinesI18n from '../../../../timelines/components/timeline/translations'; -import { useRuleIndexPattern } from '../../../rule_creation_ui/pages/form'; -import { DataSourceType } from '../../../../detections/pages/detection_engine/rules/types'; import type { Duration } from '../../../../detections/pages/detection_engine/rules/types'; import { convertHistoryStartToSize } from '../../../../detections/pages/detection_engine/rules/helpers'; import { MlJobsDescription } from '../../../rule_creation/components/ml_jobs_description/ml_jobs_description'; @@ -62,12 +60,53 @@ interface SavedQueryNameProps { savedQueryName: string; } -const SavedQueryName = ({ savedQueryName }: SavedQueryNameProps) => ( +export const SavedQueryName = ({ savedQueryName }: SavedQueryNameProps) => ( {savedQueryName} ); +interface UseFetchDataViewParams { + index?: string[]; + dataViewId?: string; +} + +interface UseFetchDataViewReturn { + dataView: DataView | null; + error: Error | null; + isLoading: boolean; +} + +/* + Fetches a DataView by its ID if `dataViewId` is provided, or creates a new DataView out of index patterns if `index` is provided. +*/ +function useFetchDataView({ dataViewId, index }: UseFetchDataViewParams): UseFetchDataViewReturn { + const { data } = useKibana().services; + + const [dataView, setDataView] = useState(null); + const [error, setError] = useState(null); + + useEffect(() => { + if (dataViewId) { + data.dataViews + .get(dataViewId) + .then((dv) => { + setDataView(dv); + }) + .catch(setError); + } else if (index) { + data.dataViews + .create({ title: index.join(','), id: index.join(','), allowNoIndex: true }) + .then((dv) => { + setDataView(dv); + }) + .catch(setError); + } + }, [data, dataViewId, index]); + + return { dataView, error, isLoading: !dataView && !error }; +} + interface FiltersProps { filters: Filter[]; dataViewId?: string; @@ -75,14 +114,15 @@ interface FiltersProps { 'data-test-subj'?: string; } -const Filters = ({ filters, dataViewId, index, 'data-test-subj': dataTestSubj }: FiltersProps) => { - const flattenedFilters = mapAndFlattenFilters(filters); +export const Filters = ({ + filters, + dataViewId, + index, + 'data-test-subj': dataTestSubj, +}: FiltersProps) => { + const { dataView } = useFetchDataView({ dataViewId, index }); - const { indexPattern } = useRuleIndexPattern({ - dataSourceType: dataViewId ? DataSourceType.DataView : DataSourceType.IndexPatterns, - index: index ?? [], - dataViewId, - }); + const flattenedFilters = mapAndFlattenFilters(filters); const styles = filtersStyles; @@ -94,7 +134,7 @@ const Filters = ({ filters, dataViewId, index, 'data-test-subj': dataTestSubj }: responsive={false} gutterSize="xs" > - + {dataView && } ); }; @@ -104,7 +144,7 @@ interface QueryProps { 'data-test-subj'?: string; } -const Query = ({ query, 'data-test-subj': dataTestSubj = 'query' }: QueryProps) => { +export const Query = ({ query, 'data-test-subj': dataTestSubj = 'query' }: QueryProps) => { const styles = queryStyles; return (
@@ -117,7 +157,7 @@ interface IndexProps { index: string[]; } -const Index = ({ index }: IndexProps) => ( +export const Index = ({ index }: IndexProps) => ( ); @@ -125,7 +165,7 @@ interface DataViewIdProps { dataViewId: string; } -const DataViewId = ({ dataViewId }: DataViewIdProps) => ( +export const DataViewId = ({ dataViewId }: DataViewIdProps) => ( {dataViewId} @@ -135,7 +175,7 @@ interface DataViewIndexPatternProps { dataViewId: string; } -const DataViewIndexPattern = ({ dataViewId }: DataViewIndexPatternProps) => { +export const DataViewIndexPattern = ({ dataViewId }: DataViewIndexPatternProps) => { const { data } = useKibana().services; const [indexPattern, setIndexPattern] = React.useState(''); const [hasError, setHasError] = React.useState(false); @@ -191,18 +231,19 @@ const AnomalyThreshold = ({ anomalyThreshold }: AnomalyThresholdProps) => ( ); interface MachineLearningJobListProps { - jobIds: string[]; + jobIds: string | string[]; isInteractive: boolean; } -const MachineLearningJobList = ({ jobIds, isInteractive }: MachineLearningJobListProps) => { +export const MachineLearningJobList = ({ jobIds, isInteractive }: MachineLearningJobListProps) => { const { jobs } = useSecurityJobs(); + const jobIdsArray = Array.isArray(jobIds) ? jobIds : [jobIds]; if (isInteractive) { - return ; + return ; } - const relevantJobs = jobs.filter((job) => jobIds.includes(job.id)); + const relevantJobs = jobs.filter((job) => jobIdsArray.includes(job.id)); return ( <> @@ -542,7 +583,7 @@ const prepareDefinitionSectionListItems = ( ), description: ( ), diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/comparison_side/comparison_side.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/comparison_side/comparison_side.stories.tsx index 37ddb71dce9f7..535c469f3aa11 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/comparison_side/comparison_side.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/comparison_side/comparison_side.stories.tsx @@ -33,7 +33,7 @@ export default { }, resolvedValue: { control: 'text', - description: 'Resolved value', + description: 'User-set resolved value', }, }, }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx new file mode 100644 index 0000000000000..be1aae4752232 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx @@ -0,0 +1,64 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; + +import { StorybookProviders } from '../../storybook/storybook_providers'; +import { dataViewDataSource, indexPatternsDataSource } from '../../storybook/mocks'; + +export default { + component: FinalReadonly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/data_source', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; + kibanaServicesMock?: Record; +} + +const Template: Story = (args) => { + return ( + + + + ); +}; + +export const DataSourceWithIndexPatterns = Template.bind({}); + +DataSourceWithIndexPatterns.args = { + finalDiffableRule: { + data_source: indexPatternsDataSource, + }, +}; + +export const DataSourceWithDataView = Template.bind({}); + +DataSourceWithDataView.args = { + finalDiffableRule: { + data_source: dataViewDataSource, + }, + kibanaServicesMock: { + data: { + dataViews: { + get: async () => ({ getIndexPattern: () => 'logs-*' }), + }, + }, + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.tsx new file mode 100644 index 0000000000000..29518981011fa --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.tsx @@ -0,0 +1,56 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import { DataSourceType } from '../../../../../../../../../common/api/detection_engine'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import { Index, DataViewId, DataViewIndexPattern } from '../../../../rule_definition_section'; +import * as ruleDetailsI18n from '../../../../translations'; +import { assertUnreachable } from '../../../../../../../../../common/utility_types'; + +interface DataSourceReadOnlyProps { + dataSource: DiffableAllFields['data_source']; +} + +export function DataSourceReadOnly({ dataSource }: DataSourceReadOnlyProps) { + if (!dataSource) { + return null; + } + + if (dataSource.type === DataSourceType.index_patterns) { + return ( + , + }, + ]} + /> + ); + } + + if (dataSource.type === DataSourceType.data_view) { + return ( + , + }, + { + title: ruleDetailsI18n.DATA_VIEW_INDEX_PATTERN_FIELD_LABEL, + description: , + }, + ]} + /> + ); + } + + return assertUnreachable(dataSource); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx new file mode 100644 index 0000000000000..767945398210c --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx @@ -0,0 +1,77 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { DataView } from '@kbn/data-views-plugin/common'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; + +import { StorybookProviders } from '../../storybook/storybook_providers'; +import { EqlQueryReadOnly } from './eql_query'; +import { dataSourceWithIndexPatterns, filtersMock } from '../../storybook/mocks'; + +export default { + component: EqlQueryReadOnly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/eql_query', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; + kibanaServicesMock?: Record; +} + +const Template: Story = (args) => { + return ( + + + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + eql_query: { + query: '*', + language: 'eql', + filters: filtersMock, + }, + data_source: dataSourceWithIndexPatterns, + }, + kibanaServicesMock: { + data: { + dataViews: { + create: async (spec: Record) => { + const dataView = new DataView({ + spec: { + ...spec, + fields: { + 'Responses.message': { + name: 'Responses.message', + type: 'string', + }, + }, + }, + } as unknown as ConstructorParameters[0]); + + return dataView; + }, + }, + }, + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.tsx new file mode 100644 index 0000000000000..01f7752f8e918 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.tsx @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import type { EuiDescriptionListProps } from '@elastic/eui'; +import type { Filter } from '@kbn/es-query'; +import { DataSourceType } from '../../../../../../../../../common/api/detection_engine'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; +import { Query, Filters } from '../../../../rule_definition_section'; + +interface EqlQueryReadOnlyProps { + eqlQuery: DiffableAllFields['eql_query']; + dataSource: DiffableAllFields['data_source']; +} + +export function EqlQueryReadOnly({ eqlQuery, dataSource }: EqlQueryReadOnlyProps) { + const listItems: EuiDescriptionListProps['listItems'] = [ + { + title: descriptionStepI18n.EQL_QUERY_LABEL, + description: , + }, + ]; + + if (eqlQuery.filters.length > 0 && dataSource) { + const index = + dataSource.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; + + const dataViewId = + dataSource.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; + + listItems.push({ + title: descriptionStepI18n.FILTERS_LABEL, + description: ( + + ), + }); + } + + return ; +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx new file mode 100644 index 0000000000000..85afa13b0d674 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; + +export default { + component: FinalReadonly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/esql_query', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + return ( + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + esql_query: { + query: 'source.ip: *', + language: 'esql', + }, + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.tsx new file mode 100644 index 0000000000000..ec110bd034b67 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.tsx @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; +import { Query } from '../../../../rule_definition_section'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; + +interface EsqlQueryReadonlyProps { + esqlQuery: DiffableAllFields['esql_query']; +} + +export function EsqlQueryReadOnly({ esqlQuery }: EsqlQueryReadonlyProps) { + return ( + , + }, + ]} + /> + ); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx new file mode 100644 index 0000000000000..528e6f7a2765e --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { KqlQueryType } from '../../../../../../../../../common/api/detection_engine'; +import type { + DiffableAllFields, + RuleKqlQuery, +} from '../../../../../../../../../common/api/detection_engine'; +import { InlineQuery } from './inline_query'; +import { SavedQuery } from './saved_query'; +import { assertUnreachable } from '../../../../../../../../../common/utility_types'; + +interface KqlQueryReadOnlyProps { + kqlQuery: RuleKqlQuery; + dataSource: DiffableAllFields['data_source']; + ruleType: DiffableAllFields['type']; +} + +export function KqlQueryReadOnly({ kqlQuery, dataSource, ruleType }: KqlQueryReadOnlyProps) { + if (kqlQuery.type === KqlQueryType.inline_query) { + return ; + } + + if (kqlQuery.type === KqlQueryType.saved_query) { + return ; + } + + return assertUnreachable(kqlQuery); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_query.tsx new file mode 100644 index 0000000000000..c1dcd83c21aed --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_query.tsx @@ -0,0 +1,55 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import type { EuiDescriptionListProps } from '@elastic/eui'; +import type { Filter } from '@kbn/es-query'; +import { DataSourceType } from '../../../../../../../../../common/api/detection_engine'; +import type { + DiffableAllFields, + InlineKqlQuery, +} from '../../../../../../../../../common/api/detection_engine'; +import { Query, Filters } from '../../../../rule_definition_section'; +import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; +import * as i18n from '../translations'; +import { getQueryLanguageLabel } from './utils'; + +interface InlineQueryProps { + kqlQuery: InlineKqlQuery; + dataSource: DiffableAllFields['data_source']; +} + +export function InlineQuery({ kqlQuery, dataSource }: InlineQueryProps) { + const listItems: EuiDescriptionListProps['listItems'] = [ + { + title: descriptionStepI18n.QUERY_LABEL, + description: , + }, + { + title: i18n.LANGUAGE_LABEL, + description: getQueryLanguageLabel(kqlQuery.language), + }, + ]; + + if (kqlQuery.filters.length > 0 && dataSource) { + const index = + dataSource.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; + + const dataViewId = + dataSource.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; + + listItems.push({ + title: descriptionStepI18n.FILTERS_LABEL, + description: ( + + ), + }); + } + + return ; +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx new file mode 100644 index 0000000000000..58164e51a36fb --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx @@ -0,0 +1,163 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { DataView } from '@kbn/data-views-plugin/common'; +import { FinalReadonly } from '../../final_readonly'; +import { KqlQueryType } from '../../../../../../../../../common/api/detection_engine'; +import type { + DiffableAllFields, + RuleKqlQuery, +} from '../../../../../../../../../common/api/detection_engine'; + +import { StorybookProviders } from '../../storybook/storybook_providers'; +import { + dataSourceWithDataView, + dataSourceWithIndexPatterns, + filtersMock, + inlineKqlQuery, +} from '../../storybook/mocks'; + +type DataViewDeps = ConstructorParameters[0]; + +export default { + component: FinalReadonly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/kql_query', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial | { kql_query: RuleKqlQuery }; + kibanaServicesMock?: Record; +} + +const Template: Story = (args) => { + return ( + + + + ); +}; + +export const InlineKqlQueryWithIndexPatterns = Template.bind({}); + +InlineKqlQueryWithIndexPatterns.args = { + finalDiffableRule: { + kql_query: inlineKqlQuery, + data_source: dataSourceWithIndexPatterns, + }, + kibanaServicesMock: { + data: { + dataViews: { + create: async (spec: Record) => { + const dataView = new DataView({ + spec: { + ...spec, + fields: { + 'Responses.message': { + name: 'Responses.message', + type: 'string', + }, + }, + }, + } as unknown as DataViewDeps); + + return dataView; + }, + }, + }, + }, +}; + +export const InlineKqlQueryWithDataView = Template.bind({}); + +InlineKqlQueryWithDataView.args = { + finalDiffableRule: { + kql_query: inlineKqlQuery, + data_source: dataSourceWithDataView, + }, + kibanaServicesMock: { + data: { + dataViews: { + get: async (id: string) => { + const dataView = new DataView({ + spec: { + id, + fields: { + 'Responses.message': { + name: 'Responses.message', + type: 'string', + }, + }, + }, + } as unknown as DataViewDeps); + + return dataView; + }, + }, + }, + }, +}; + +export const SavedKqlQueryWithDataView = Template.bind({}); + +SavedKqlQueryWithDataView.args = { + kibanaServicesMock: { + data: { + dataViews: { + get: async (id: string) => { + const dataView = new DataView({ + spec: { + id, + fields: { + 'Responses.message': { + name: 'Responses.message', + type: 'string', + }, + }, + }, + } as unknown as DataViewDeps); + + return dataView; + }, + }, + }, + http: { + get: async () => { + const mockedSavedQuery = { + id: 'fake-saved-query-id', + attributes: { + title: 'Fake Saved Query', + description: '', + query: { query: '*', language: 'kuery' }, + filters: filtersMock, + }, + namespaces: ['default'], + }; + + return mockedSavedQuery; + }, + }, + }, + finalDiffableRule: { + kql_query: { + type: KqlQueryType.saved_query, + saved_query_id: 'fake-saved-query-id', + }, + data_source: dataSourceWithDataView, + type: 'saved_query', + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_query.tsx new file mode 100644 index 0000000000000..2011a66e3261f --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_query.tsx @@ -0,0 +1,73 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import type { EuiDescriptionListProps } from '@elastic/eui'; +import { DataSourceType } from '../../../../../../../../../common/api/detection_engine'; +import type { + SavedKqlQuery, + DiffableRule, + DiffableAllFields, +} from '../../../../../../../../../common/api/detection_engine'; +import { Query, SavedQueryName, Filters } from '../../../../rule_definition_section'; +import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; +import { useGetSavedQuery } from '../../../../../../../../detections/pages/detection_engine/rules/use_get_saved_query'; +import * as i18n from '../translations'; +import { getQueryLanguageLabel } from './utils'; + +interface SavedQueryProps { + kqlQuery: SavedKqlQuery; + dataSource: DiffableAllFields['data_source']; + ruleType: DiffableRule['type']; +} + +export function SavedQuery({ kqlQuery, dataSource, ruleType }: SavedQueryProps) { + const { savedQuery } = useGetSavedQuery({ + savedQueryId: kqlQuery.saved_query_id, + ruleType, + }); + + if (!savedQuery) { + return null; + } + + const listItems: EuiDescriptionListProps['listItems'] = [ + { + title: descriptionStepI18n.SAVED_QUERY_NAME_LABEL, + description: , + }, + { + title: i18n.LANGUAGE_LABEL, + description: getQueryLanguageLabel(savedQuery.attributes.query.language), + }, + ]; + + if (typeof savedQuery.attributes.query.query === 'string') { + listItems.push({ + title: descriptionStepI18n.SAVED_QUERY_LABEL, + description: , + }); + } + + if (savedQuery.attributes.filters && dataSource) { + const index = + dataSource.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; + + const dataViewId = + dataSource.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; + + listItems.push({ + title: descriptionStepI18n.SAVED_QUERY_FILTERS_LABEL, + description: ( + + ), + }); + } + + return ; +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/utils.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/utils.ts new file mode 100644 index 0000000000000..fd733b20b074b --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/utils.ts @@ -0,0 +1,19 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import * as i18n from '../translations'; + +export function getQueryLanguageLabel(language: string) { + switch (language) { + case 'kuery': + return i18n.KUERY_LABEL; + case 'lucene': + return i18n.LUCENE_LABEL; + default: + return language; + } +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx new file mode 100644 index 0000000000000..6dd07cd2c340c --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx @@ -0,0 +1,97 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { useQueryClient } from '@tanstack/react-query'; +import type { Story } from '@storybook/react'; +import { MachineLearningJobIdReadOnly } from './machine_learning_job_id'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import { FinalReadonly } from '../../final_readonly'; +import { StorybookProviders } from '../../storybook/storybook_providers'; +import { GET_MODULES_QUERY_KEY } from '../../../../../../../../common/components/ml_popover/hooks/use_fetch_modules_query'; +import { GET_RECOGNIZER_QUERY_KEY } from '../../../../../../../../common/components/ml_popover/hooks/use_fetch_recognizer_query'; +import { GET_JOBS_SUMMARY_QUERY_KEY } from '../../../../../../../../common/components/ml/hooks/use_fetch_jobs_summary_query'; + +export default { + component: MachineLearningJobIdReadOnly, + title: + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/machine_learning_job_id', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +const mockedModulesData = [ + { + id: 'security_auth', + jobs: [ + { + id: 'auth_high_count_logon_events', + config: { + groups: [], + custom_settings: { + security_app_display_name: 'Spike in Logon Events', + }, + }, + }, + ], + }, +]; + +const mockedCompatibleModules = [ + { + id: 'security_auth', + }, +]; + +function MockMlData({ children }: { children: React.ReactNode }) { + const queryClient = useQueryClient(); + + queryClient.setQueryData([GET_JOBS_SUMMARY_QUERY_KEY, {}], []); + + queryClient.setQueryData([GET_MODULES_QUERY_KEY, {}], mockedModulesData); + + queryClient.setQueryData( + [GET_RECOGNIZER_QUERY_KEY, { indexPatternName: undefined }], + mockedCompatibleModules + ); + + return <>{children}; +} + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + // console.log('dbg template', useSecurityJobs); + + return ( + + + + + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + // machine_learning_job_id: 'fake-ml-job-id', + machine_learning_job_id: 'auth_high_count_logon_events', + }, +}; + +// Template. diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.tsx new file mode 100644 index 0000000000000..b177da1467910 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.tsx @@ -0,0 +1,31 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import { MachineLearningJobList } from '../../../../rule_definition_section'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import * as ruleDetailsI18n from '../../../../translations'; + +interface MachineLearningJobIdProps { + machineLearningJobId: DiffableAllFields['machine_learning_job_id']; +} + +export function MachineLearningJobIdReadOnly({ machineLearningJobId }: MachineLearningJobIdProps) { + return ( + + ), + }, + ]} + /> + ); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/translations.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/translations.ts new file mode 100644 index 0000000000000..f8a02217727cb --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/translations.ts @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { i18n } from '@kbn/i18n'; + +export const LANGUAGE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.rules.upgradeRules.finalReadonly.languageLabel', + { + defaultMessage: 'Language', + } +); + +export const KUERY_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.rules.upgradeRules.finalReadonly.kueryLabel', + { + defaultMessage: 'KQL', + } +); + +export const LUCENE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.rules.upgradeRules.finalReadonly.luceneLabel', + { + defaultMessage: 'Lucene', + } +); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx new file mode 100644 index 0000000000000..6afb656196ff2 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx @@ -0,0 +1,52 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { DiffableAllFields } from '../../../../../../../common/api/detection_engine'; +import { KqlQueryReadOnly } from './field_components/kql_query'; +import { DataSourceReadOnly } from './field_components/data_source/data_source'; +import { EqlQueryReadOnly } from './field_components/eql_query/eql_query'; +import { assertUnreachable } from '../../../../../../../common/utility_types'; +import { EsqlQueryReadOnly } from './field_components/esql_query/esql_query'; +import { MachineLearningJobIdReadOnly } from './field_components/machine_learning_job_id/machine_learning_job_id'; + +interface FinalReadonlyProps { + fieldName: keyof DiffableAllFields; + finalDiffableRule: DiffableAllFields; +} + +export function FinalReadonly({ fieldName, finalDiffableRule }: FinalReadonlyProps) { + switch (fieldName) { + case 'data_source': + return ; + case 'eql_query': + return ( + + ); + case 'esql_query': + return ; + case 'kql_query': + return ( + + ); + case 'machine_learning_job_id': + return ( + + ); + default: + return assertUnreachable(fieldName); + } +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts new file mode 100644 index 0000000000000..b9f0e64539271 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts @@ -0,0 +1,62 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { DataSourceType, KqlQueryType } from '../../../../../../../../common/api/detection_engine'; +import type { DiffableAllFields } from '../../../../../../../../common/api/detection_engine'; + +export const filtersMock = [ + { + meta: { + disabled: false, + negate: false, + alias: null, + index: '', + key: 'Responses.message', + field: 'Responses.message', + params: ['test-1', 'test-2'], + value: ['test-1', 'test-2'], + type: 'phrases', + }, + query: { + bool: { + minimum_should_match: 1, + should: [ + { match_phrase: { 'Responses.message': 'test-1' } }, + { match_phrase: { 'Responses.message': 'test-2' } }, + ], + }, + }, + $state: { store: 'appState' }, + }, +]; + +export const indexPatternsDataSource: DiffableAllFields['data_source'] = { + type: DataSourceType.index_patterns, + index_patterns: ['logs-*'], +}; + +export const dataViewDataSource: DiffableAllFields['data_source'] = { + type: DataSourceType.data_view, + data_view_id: 'logs-*', +}; + +export const inlineKqlQuery: DiffableAllFields['kql_query'] = { + type: KqlQueryType.inline_query, + query: '*', + language: 'kuery', + filters: filtersMock, +}; + +export const dataSourceWithIndexPatterns: DiffableAllFields['data_source'] = { + type: DataSourceType.index_patterns, + index_patterns: ['logs-*'], +}; + +export const dataSourceWithDataView: DiffableAllFields['data_source'] = { + type: DataSourceType.data_view, + data_view_id: 'logs-*', +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx new file mode 100644 index 0000000000000..6f8cb7ec3c4a7 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx @@ -0,0 +1,24 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public'; +import { ReactQueryClientProvider } from '../../../../../../../common/containers/query_client/query_client_provider'; +// import { UpgradePrebuiltRulesTableContextProvider } from '../../../../../../rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context'; +import { createKibanaServicesMock } from './utils'; + +// const queryClient = new QueryClient + +export function StorybookProviders({ children, kibanaServicesMock }) { + const KibanaReactContext = createKibanaReactContext(createKibanaServicesMock(kibanaServicesMock)); + + return ( + + {children} + + ); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/utils.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/utils.ts new file mode 100644 index 0000000000000..582602a0c9c55 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/utils.ts @@ -0,0 +1,45 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { merge } from 'lodash'; +import type { CoreStart } from '@kbn/core/public'; +import { Subject } from 'rxjs'; + +export const createKibanaServicesMock = (overrides?: Partial) => { + const baseMock = { + data: { + dataViews: { + create: async () => {}, + get: async () => {}, + }, + }, + http: { + get: async () => {}, + basePath: { + get: () => '', + }, + }, + notifications: { + toasts: { + addError: () => {}, + addSuccess: () => {}, + addWarning: () => {}, + remove: () => {}, + }, + }, + settings: { + client: { + get: () => {}, + get$: () => new Subject(), + set: () => {}, + }, + }, + uiSettings: {}, + } as unknown as CoreStart; + + return merge(baseMock, overrides); +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context.tsx index 9d1a3071b44e1..fdbd00f22d7d5 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context.tsx @@ -107,11 +107,12 @@ const UpgradePrebuiltRulesTableContext = createContext; } -export const UpgradePrebuiltRulesTableContextProvider = ({ - children, -}: UpgradePrebuiltRulesTableContextProviderProps) => { +export const UpgradePrebuiltRulesTableContextProvider = ( + props: UpgradePrebuiltRulesTableContextProviderProps +) => { const [loadingRules, setLoadingRules] = useState([]); const [selectedRules, setSelectedRules] = useState([]); const [filterOptions, setFilterOptions] = useState({ @@ -246,6 +247,7 @@ export const UpgradePrebuiltRulesTableContextProvider = ({ selectedRules, loadingRules, lastUpdated: dataUpdatedAt, + ...props.stateOverride, }, actions, }; @@ -263,6 +265,7 @@ export const UpgradePrebuiltRulesTableContextProvider = ({ loadingRules, dataUpdatedAt, actions, + props.stateOverride, ]); const extraTabs = useMemo(() => { @@ -312,7 +315,7 @@ export const UpgradePrebuiltRulesTableContextProvider = ({ onConfirm={handleUpgradeConfirm} /> )} - {children} + {props.children} {previewedRule && ( Date: Tue, 27 Aug 2024 20:05:25 +0200 Subject: [PATCH 02/18] Add more field components --- .../rule_details/rule_about_section.tsx | 8 +- .../rule_details/rule_definition_section.tsx | 6 +- .../field_components/kql_query/index.tsx | 10 ++- ...{inline_query.tsx => inline_kql_query.tsx} | 4 +- .../{saved_query.tsx => saved_kql_query.tsx} | 4 +- .../machine_learning_job_id.stories.tsx | 3 - .../related_integrations.stories.tsx | 70 ++++++++++++++++++ .../related_integrations.tsx | 29 ++++++++ .../required_fields.stories.tsx | 46 ++++++++++++ .../required_fields/required_fields.tsx | 29 ++++++++ .../risk_score_mapping.stories.tsx | 45 +++++++++++ .../risk_score_mapping/risk_score_mapping.tsx | 30 ++++++++ .../severity_mapping.stories.tsx | 58 +++++++++++++++ .../severity_mapping/severity_mapping.tsx | 27 +++++++ .../threat/threat.stories.tsx | 67 +++++++++++++++++ .../field_components/threat/threat.tsx | 35 +++++++++ .../threat_index/threat_index.stories.tsx | 44 +++++++++++ .../threat_index/threat_index.tsx | 34 +++++++++ .../threat_indicator_path.stories.tsx | 45 +++++++++++ .../threat_indicator_path.tsx | 40 ++++++++++ .../threat_mapping/threat_mapping.stories.tsx | 54 ++++++++++++++ .../threat_mapping/threat_mapping.tsx | 29 ++++++++ .../threat_query/threat_query.stories.tsx | 74 +++++++++++++++++++ .../threat_query/threat_query.tsx | 28 +++++++ .../final_readonly/final_readonly.tsx | 40 +++++++++- .../storybook/storybook_providers.tsx | 7 +- 26 files changed, 845 insertions(+), 21 deletions(-) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/{inline_query.tsx => inline_kql_query.tsx} (93%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/{saved_query.tsx => saved_kql_query.tsx} (94%) create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_about_section.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_about_section.tsx index 7f52bae481160..281d8653960ae 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_about_section.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_about_section.tsx @@ -86,7 +86,7 @@ interface SeverityMappingItemProps { severityMappingItem: SeverityMappingItemType; } -const SeverityMappingItem = ({ severityMappingItem }: SeverityMappingItemProps) => ( +export const SeverityMappingItem = ({ severityMappingItem }: SeverityMappingItemProps) => ( ( +export const RiskScoreMappingItem = ({ riskScoreMappingItem }: RiskScoreMappingItemProps) => ( ( +export const Threat = ({ threat }: ThreatProps) => ( ); @@ -226,7 +226,7 @@ interface ThreatIndicatorPathProps { threatIndicatorPath: string; } -const ThreatIndicatorPath = ({ threatIndicatorPath }: ThreatIndicatorPathProps) => ( +export const ThreatIndicatorPath = ({ threatIndicatorPath }: ThreatIndicatorPathProps) => ( {threatIndicatorPath} ); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx index 917109c5ab130..a6e5854db14ad 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx @@ -292,7 +292,7 @@ interface RequiredFieldsProps { requiredFields: RequiredFieldArray; } -const RequiredFields = ({ requiredFields }: RequiredFieldsProps) => { +export const RequiredFields = ({ requiredFields }: RequiredFieldsProps) => { const styles = useRequiredFieldsStyles(); return ( @@ -334,7 +334,7 @@ interface ThreatIndexProps { threatIndex: string[]; } -const ThreatIndex = ({ threatIndex }: ThreatIndexProps) => ( +export const ThreatIndex = ({ threatIndex }: ThreatIndexProps) => ( ); @@ -342,7 +342,7 @@ interface ThreatMappingProps { threatMapping: ThreatMappingType; } -const ThreatMapping = ({ threatMapping }: ThreatMappingProps) => { +export const ThreatMapping = ({ threatMapping }: ThreatMappingProps) => { const description = threatMapping.reduce( (accumThreatMaps, threatMap, threatMapIndex, { length: threatMappingLength }) => { const matches = threatMap.entries.reduce( diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx index 528e6f7a2765e..a2dd75e188a0c 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx @@ -11,8 +11,8 @@ import type { DiffableAllFields, RuleKqlQuery, } from '../../../../../../../../../common/api/detection_engine'; -import { InlineQuery } from './inline_query'; -import { SavedQuery } from './saved_query'; +import { InlineKqlQueryReadOnly } from './inline_kql_query'; +import { SavedKqlQueryReadOnly } from './saved_kql_query'; import { assertUnreachable } from '../../../../../../../../../common/utility_types'; interface KqlQueryReadOnlyProps { @@ -23,11 +23,13 @@ interface KqlQueryReadOnlyProps { export function KqlQueryReadOnly({ kqlQuery, dataSource, ruleType }: KqlQueryReadOnlyProps) { if (kqlQuery.type === KqlQueryType.inline_query) { - return ; + return ; } if (kqlQuery.type === KqlQueryType.saved_query) { - return ; + return ( + + ); } return assertUnreachable(kqlQuery); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_kql_query.tsx similarity index 93% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_query.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_kql_query.tsx index c1dcd83c21aed..3413ccb522f5f 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_kql_query.tsx @@ -21,10 +21,10 @@ import { getQueryLanguageLabel } from './utils'; interface InlineQueryProps { kqlQuery: InlineKqlQuery; - dataSource: DiffableAllFields['data_source']; + dataSource?: DiffableAllFields['data_source']; } -export function InlineQuery({ kqlQuery, dataSource }: InlineQueryProps) { +export function InlineKqlQueryReadOnly({ kqlQuery, dataSource }: InlineQueryProps) { const listItems: EuiDescriptionListProps['listItems'] = [ { title: descriptionStepI18n.QUERY_LABEL, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_kql_query.tsx similarity index 94% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_query.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_kql_query.tsx index 2011a66e3261f..ef7206af6da23 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_kql_query.tsx @@ -22,11 +22,11 @@ import { getQueryLanguageLabel } from './utils'; interface SavedQueryProps { kqlQuery: SavedKqlQuery; - dataSource: DiffableAllFields['data_source']; + dataSource?: DiffableAllFields['data_source']; ruleType: DiffableRule['type']; } -export function SavedQuery({ kqlQuery, dataSource, ruleType }: SavedQueryProps) { +export function SavedKqlQueryReadOnly({ kqlQuery, dataSource, ruleType }: SavedQueryProps) { const { savedQuery } = useGetSavedQuery({ savedQueryId: kqlQuery.saved_query_id, ruleType, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx index 6dd07cd2c340c..6680928c8e996 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx @@ -89,9 +89,6 @@ export const Default = Template.bind({}); Default.args = { finalDiffableRule: { - // machine_learning_job_id: 'fake-ml-job-id', machine_learning_job_id: 'auth_high_count_logon_events', }, }; - -// Template. diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx new file mode 100644 index 0000000000000..bffa7e29bb949 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx @@ -0,0 +1,70 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { useQueryClient } from '@tanstack/react-query'; +import type { Story } from '@storybook/react'; +import { RelatedIntegrationsReadOnly } from './related_integrations'; +import { StorybookProviders } from '../../storybook/storybook_providers'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; + +export default { + component: RelatedIntegrationsReadOnly, + title: + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/related_integrations', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +const mockedIntegrationsData = [ + { + package_name: 'endpoint', + package_title: 'Elastic Defend', + latest_package_version: '8.15.1', + installed_package_version: '8.16.0-prerelease.1', + is_installed: true, + is_enabled: false, + }, +]; + +function MockRelatedIntegrationsData({ children }: { children: React.ReactNode }) { + const queryClient = useQueryClient(); + + queryClient.setQueryData(['integrations'], mockedIntegrationsData); + + return <>{children}; +} + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + return ( + + + + + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + related_integrations: [{ package: 'endpoint', version: '^8.2.0' }], + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.tsx new file mode 100644 index 0000000000000..6e6c0708a0bb4 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.tsx @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import * as ruleDetailsI18n from '../../../../translations'; +import { RelatedIntegrationsDescription } from '../../../../../../../../detections/components/rules/related_integrations/integrations_description'; +import type { RelatedIntegrationArray } from '../../../../../../../../../common/api/detection_engine'; + +interface RelatedIntegrationsReadOnly { + relatedIntegrations: RelatedIntegrationArray; +} + +export function RelatedIntegrationsReadOnly({ relatedIntegrations }: RelatedIntegrationsReadOnly) { + return ( + , + }, + ]} + /> + ); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx new file mode 100644 index 0000000000000..cc7b4e48bb185 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx @@ -0,0 +1,46 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import React from 'react'; +import type { Story } from '@storybook/react'; +import { RequiredFieldsReadOnly } from './required_fields'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; + +export default { + component: RequiredFieldsReadOnly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/required_fields', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + return ( + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + required_fields: [ + { name: 'event.kind', type: 'keyword', ecs: true }, + { name: 'event.module', type: 'keyword', ecs: true }, + ], + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.tsx new file mode 100644 index 0000000000000..4d60acc8d5f15 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.tsx @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import * as ruleDetailsI18n from '../../../../translations'; +import type { RequiredFieldArray } from '../../../../../../../../../common/api/detection_engine'; +import { RequiredFields } from '../../../../rule_definition_section'; + +interface RequiredFieldsReadOnlyProps { + requiredFields: RequiredFieldArray; +} + +export function RequiredFieldsReadOnly({ requiredFields }: RequiredFieldsReadOnlyProps) { + return ( + , + }, + ]} + /> + ); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx new file mode 100644 index 0000000000000..7af926e816929 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx @@ -0,0 +1,45 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import { RiskScoreMappingReadOnly } from './risk_score_mapping'; + +export default { + component: RiskScoreMappingReadOnly, + title: + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/risk_score_mapping', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + return ( + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + risk_score_mapping: [{ field: 'event.risk_score', operator: 'equals', value: '' }], + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.tsx new file mode 100644 index 0000000000000..bb28d48197167 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.tsx @@ -0,0 +1,30 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { requiredOptional } from '@kbn/zod-helpers'; +import { EuiDescriptionList } from '@elastic/eui'; +import type { RiskScoreMapping } from '../../../../../../../../../common/api/detection_engine'; +import * as ruleDetailsI18n from '../../../../translations'; +import { RiskScoreMappingItem } from '../../../../rule_about_section'; + +interface RiskScoreMappingReadProps { + riskScoreMapping: RiskScoreMapping; +} + +export const RiskScoreMappingReadOnly = ({ riskScoreMapping }: RiskScoreMappingReadProps) => { + const listItems = riskScoreMapping + .filter((riskScoreMappingItem) => riskScoreMappingItem.field !== '') + .map((riskScoreMappingItem, index) => ({ + title: index === 0 ? ruleDetailsI18n.RISK_SCORE_MAPPING_FIELD_LABEL : '', + description: ( + + ), + })); + + return ; +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx new file mode 100644 index 0000000000000..85d1d3081fe95 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx @@ -0,0 +1,58 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import { SeverityMappingReadOnly } from './severity_mapping'; + +export default { + component: SeverityMappingReadOnly, + title: + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/severity_mapping', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + return ( + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + severity_mapping: [ + { + field: 'event.severity', + operator: 'equals', + severity: 'low', + value: 'not severe', + }, + { + field: 'event.severity', + operator: 'equals', + severity: 'high', + value: 'pretty severe', + }, + ], + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.tsx new file mode 100644 index 0000000000000..6499375802b24 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.tsx @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import type { SeverityMapping } from '../../../../../../../../../common/api/detection_engine'; +import * as ruleDetailsI18n from '../../../../translations'; +import { SeverityMappingItem } from '../../../../rule_about_section'; + +interface SeverityMappingReadOnlyProps { + severityMapping: SeverityMapping; +} + +export const SeverityMappingReadOnly = ({ severityMapping }: SeverityMappingReadOnlyProps) => { + const listItems = severityMapping + .filter((severityMappingItem) => severityMappingItem.field !== '') + .map((severityMappingItem, index) => ({ + title: index === 0 ? ruleDetailsI18n.SEVERITY_MAPPING_FIELD_LABEL : '', + description: , + })); + + return ; +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx new file mode 100644 index 0000000000000..c2032d523e204 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx @@ -0,0 +1,67 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import { ThreatReadOnly } from './threat'; + +export default { + component: ThreatReadOnly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + return ( + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + threat: [ + { + framework: 'MITRE ATT&CK', + tactic: { + id: 'TA0006', + name: 'Credential Access', + reference: 'https://attack.mitre.org/tactics/TA0006/', + }, + technique: [ + { + id: 'T1003', + name: 'OS Credential Dumping', + reference: 'https://attack.mitre.org/techniques/T1003/', + subtechnique: [ + { + id: 'T1003.001', + name: 'LSASS Memory', + reference: 'https://attack.mitre.org/techniques/T1003/001/', + }, + ], + }, + ], + }, + ], + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx new file mode 100644 index 0000000000000..05a0367dda68b --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx @@ -0,0 +1,35 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import type { Threats } from '@kbn/securitysolution-io-ts-alerting-types'; +import * as ruleDetailsI18n from '../../../../translations'; +import { Threat } from '../../../../rule_about_section'; + +interface ThreatReadOnlyProps { + threat: Threats; +} + +export const ThreatReadOnly = ({ threat }: ThreatReadOnlyProps) => { + return ( + , + }, + ]} + /> + ); +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx new file mode 100644 index 0000000000000..597380cc2ad27 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx @@ -0,0 +1,44 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import { ThreatIndexReadOnly } from './threat_index'; + +export default { + component: ThreatIndexReadOnly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_index', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + return ( + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + threat_index: ['logs-ti_*', 'logs-defend_*'], + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx new file mode 100644 index 0000000000000..e2987b349cdd7 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx @@ -0,0 +1,34 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import * as ruleDetailsI18n from '../../../../translations'; +import { ThreatIndex } from '../../../../rule_definition_section'; + +interface ThreatIndexReadOnlyProps { + threatIndex: string[]; +} + +export const ThreatIndexReadOnly = ({ threatIndex }: ThreatIndexReadOnlyProps) => { + return ( + , + }, + ]} + /> + ); +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx new file mode 100644 index 0000000000000..605e3a031d5d5 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx @@ -0,0 +1,45 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import { ThreatIndicatorPathReadOnly } from './threat_indicator_path'; + +export default { + component: ThreatIndicatorPathReadOnly, + title: + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_indicator_path', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + return ( + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + threat_indicator_path: 'threat.indicator', + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx new file mode 100644 index 0000000000000..04ce64cda5741 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx @@ -0,0 +1,40 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import * as ruleDetailsI18n from '../../../../translations'; +import { ThreatIndicatorPath } from '../../../../rule_about_section'; + +interface ThreatIndicatorPathReadOnlyProps { + threatIndicatorPath?: string; +} + +export const ThreatIndicatorPathReadOnly = ({ + threatIndicatorPath, +}: ThreatIndicatorPathReadOnlyProps) => { + if (!threatIndicatorPath) { + return null; + } + + return ( + , + }, + ]} + /> + ); +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx new file mode 100644 index 0000000000000..d480811a7e354 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx @@ -0,0 +1,54 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import { ThreatMappingReadOnly } from './threat_mapping'; + +export default { + component: ThreatMappingReadOnly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_mapping', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; +} + +const Template: Story = (args) => { + return ( + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + threat_mapping: [ + { + entries: [ + { + field: 'Endpoint.capabilities', + type: 'mapping', + value: 'Target.dll.pe.description', + }, + ], + }, + ], + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.tsx new file mode 100644 index 0000000000000..34eb2da09dce3 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.tsx @@ -0,0 +1,29 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import { EuiDescriptionList } from '@elastic/eui'; +import type { ThreatMapping } from '../../../../../../../../../common/api/detection_engine'; +import { ThreatMapping as ThreatMappingComponent } from '../../../../rule_definition_section'; +import * as ruleDetailsI18n from '../../../../translations'; + +interface ThreatMappingReadOnlyProps { + threatMapping: ThreatMapping; +} + +export const ThreatMappingReadOnly = ({ threatMapping }: ThreatMappingReadOnlyProps) => { + return ( + , + }, + ]} + /> + ); +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx new file mode 100644 index 0000000000000..b71a88a747e89 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx @@ -0,0 +1,74 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { Story } from '@storybook/react'; +import { DataView } from '@kbn/data-views-plugin/common'; +import { FinalReadonly } from '../../final_readonly'; +import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; +import { ThreatQueryReadOnly } from './threat_query'; +import { dataSourceWithDataView, inlineKqlQuery } from '../../storybook/mocks'; +import { StorybookProviders } from '../../storybook/storybook_providers'; + +type DataViewDeps = ConstructorParameters[0]; + +export default { + component: ThreatQueryReadOnly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_query', + argTypes: { + finalDiffableRule: { + control: 'object', + description: 'Final value of the diffable rule', + }, + }, +}; + +interface TemplateProps { + finalDiffableRule: Partial; + kibanaServicesMock?: Record; +} + +const Template: Story = (args) => { + return ( + + + + ); +}; + +export const Default = Template.bind({}); + +Default.args = { + finalDiffableRule: { + threat_query: inlineKqlQuery, + data_source: dataSourceWithDataView, + }, + kibanaServicesMock: { + data: { + dataViews: { + get: async (id: string) => { + const dataView = new DataView({ + spec: { + id, + fields: { + 'Responses.message': { + name: 'Responses.message', + type: 'string', + }, + }, + }, + } as unknown as DataViewDeps); + + return dataView; + }, + }, + }, + }, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx new file mode 100644 index 0000000000000..f76465617d558 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx @@ -0,0 +1,28 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React from 'react'; +import type { + DiffableAllFields, + InlineKqlQuery, +} from '../../../../../../../../../common/api/detection_engine'; +import { InlineKqlQueryReadOnly } from '../kql_query/inline_kql_query'; + +interface ThreatQueryReadOnlyProps { + threatQuery: InlineKqlQuery; + dataSource: DiffableAllFields['data_source']; +} + +export const ThreatQueryReadOnly = ({ threatQuery, dataSource }: ThreatQueryReadOnlyProps) => { + return ; +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx index 6afb656196ff2..80293cf6357ca 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx @@ -6,13 +6,22 @@ */ import React from 'react'; +import { assertUnreachable } from '../../../../../../../common/utility_types'; import type { DiffableAllFields } from '../../../../../../../common/api/detection_engine'; import { KqlQueryReadOnly } from './field_components/kql_query'; import { DataSourceReadOnly } from './field_components/data_source/data_source'; import { EqlQueryReadOnly } from './field_components/eql_query/eql_query'; -import { assertUnreachable } from '../../../../../../../common/utility_types'; import { EsqlQueryReadOnly } from './field_components/esql_query/esql_query'; import { MachineLearningJobIdReadOnly } from './field_components/machine_learning_job_id/machine_learning_job_id'; +import { RelatedIntegrationsReadOnly } from './field_components/related_integrations/related_integrations'; +import { RequiredFieldsReadOnly } from './field_components/required_fields/required_fields'; +import { SeverityMappingReadOnly } from './field_components/severity_mapping/severity_mapping'; +import { RiskScoreMappingReadOnly } from './field_components/risk_score_mapping/risk_score_mapping'; +import { ThreatMappingReadOnly } from './field_components/threat_mapping/threat_mapping'; +import { ThreatReadOnly } from './field_components/threat/threat'; +import { ThreatIndexReadOnly } from './field_components/threat_index/threat_index'; +import { ThreatIndicatorPathReadOnly } from './field_components/threat_indicator_path/threat_indicator_path'; +import { ThreatQueryReadOnly } from './field_components/threat_query/threat_query'; interface FinalReadonlyProps { fieldName: keyof DiffableAllFields; @@ -46,6 +55,35 @@ export function FinalReadonly({ fieldName, finalDiffableRule }: FinalReadonlyPro machineLearningJobId={finalDiffableRule.machine_learning_job_id} /> ); + case 'related_integrations': + return ( + + ); + case 'required_fields': + return ; + case 'risk_score_mapping': + return ; + case 'severity_mapping': + return ; + case 'threat': + return ; + case 'threat_index': + return ; + case 'threat_indicator_path': + return ( + + ); + case 'threat_mapping': + return ; + case 'threat_query': + return ( + + ); default: return assertUnreachable(fieldName); } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx index 6f8cb7ec3c4a7..e8aa4d78a6abc 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx @@ -11,9 +11,12 @@ import { ReactQueryClientProvider } from '../../../../../../../common/containers // import { UpgradePrebuiltRulesTableContextProvider } from '../../../../../../rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context'; import { createKibanaServicesMock } from './utils'; -// const queryClient = new QueryClient +interface StorybookProvidersProps { + children: React.ReactNode; + kibanaServicesMock?: ReturnType; +} -export function StorybookProviders({ children, kibanaServicesMock }) { +export function StorybookProviders({ children, kibanaServicesMock }: StorybookProvidersProps) { const KibanaReactContext = createKibanaReactContext(createKibanaServicesMock(kibanaServicesMock)); return ( From dcc9454b0f829de4269bdefcb4dd8a5055307ce6 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Fri, 30 Aug 2024 16:48:06 +0200 Subject: [PATCH 03/18] Update Storybook mocks --- .../rule_details/rule_definition_section.tsx | 55 ++-------- .../data_source/data_source.stories.tsx | 6 +- .../eql_query/eql_query.stories.tsx | 54 +++++----- .../esql_query/esql_query.stories.tsx | 2 +- .../kql_query/kql_query.stories.tsx | 100 ++++++------------ .../machine_learning_job_id.stories.tsx | 6 +- .../related_integrations.stories.tsx | 6 +- .../threat_query/threat_query.stories.tsx | 52 ++++----- ...=> final_readonly_storybook_providers.tsx} | 27 ++++- .../final_readonly/storybook/mocks.ts | 83 ++++++++++++--- .../storybook/storybook_providers.tsx | 27 ----- 11 files changed, 196 insertions(+), 222 deletions(-) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/{utils.ts => final_readonly_storybook_providers.tsx} (54%) delete mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx index a6e5854db14ad..1743fd5292da4 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import React, { useEffect, useState } from 'react'; +import React from 'react'; import { isEmpty } from 'lodash/fp'; import { EuiDescriptionList, @@ -39,6 +39,8 @@ import { AlertSuppressionLabel } from '../../../rule_creation_ui/components/desc import { useGetSavedQuery } from '../../../../detections/pages/detection_engine/rules/use_get_saved_query'; import * as threatMatchI18n from '../../../../common/components/threat_match/translations'; import * as timelinesI18n from '../../../../timelines/components/timeline/translations'; +import { useRuleIndexPattern } from '../../../rule_creation_ui/pages/form'; +import { DataSourceType } from '../../../../detections/pages/detection_engine/rules/types'; import type { Duration } from '../../../../detections/pages/detection_engine/rules/types'; import { convertHistoryStartToSize } from '../../../../detections/pages/detection_engine/rules/helpers'; import { MlJobsDescription } from '../../../rule_creation/components/ml_jobs_description/ml_jobs_description'; @@ -66,47 +68,6 @@ export const SavedQueryName = ({ savedQueryName }: SavedQueryNameProps) => ( ); -interface UseFetchDataViewParams { - index?: string[]; - dataViewId?: string; -} - -interface UseFetchDataViewReturn { - dataView: DataView | null; - error: Error | null; - isLoading: boolean; -} - -/* - Fetches a DataView by its ID if `dataViewId` is provided, or creates a new DataView out of index patterns if `index` is provided. -*/ -function useFetchDataView({ dataViewId, index }: UseFetchDataViewParams): UseFetchDataViewReturn { - const { data } = useKibana().services; - - const [dataView, setDataView] = useState(null); - const [error, setError] = useState(null); - - useEffect(() => { - if (dataViewId) { - data.dataViews - .get(dataViewId) - .then((dv) => { - setDataView(dv); - }) - .catch(setError); - } else if (index) { - data.dataViews - .create({ title: index.join(','), id: index.join(','), allowNoIndex: true }) - .then((dv) => { - setDataView(dv); - }) - .catch(setError); - } - }, [data, dataViewId, index]); - - return { dataView, error, isLoading: !dataView && !error }; -} - interface FiltersProps { filters: Filter[]; dataViewId?: string; @@ -120,10 +81,14 @@ export const Filters = ({ index, 'data-test-subj': dataTestSubj, }: FiltersProps) => { - const { dataView } = useFetchDataView({ dataViewId, index }); - const flattenedFilters = mapAndFlattenFilters(filters); + const { indexPattern } = useRuleIndexPattern({ + dataSourceType: dataViewId ? DataSourceType.DataView : DataSourceType.IndexPatterns, + index: index ?? [], + dataViewId, + }); + const styles = filtersStyles; return ( @@ -134,7 +99,7 @@ export const Filters = ({ responsive={false} gutterSize="xs" > - {dataView && } + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx index be1aae4752232..a44e813655b1b 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx @@ -10,7 +10,7 @@ import type { Story } from '@storybook/react'; import { FinalReadonly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; -import { StorybookProviders } from '../../storybook/storybook_providers'; +import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; import { dataViewDataSource, indexPatternsDataSource } from '../../storybook/mocks'; export default { @@ -31,12 +31,12 @@ interface TemplateProps { const Template: Story = (args) => { return ( - + - + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx index 767945398210c..15e725dc02382 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx @@ -7,13 +7,17 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { DataView } from '@kbn/data-views-plugin/common'; import { FinalReadonly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; -import { StorybookProviders } from '../../storybook/storybook_providers'; +import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; import { EqlQueryReadOnly } from './eql_query'; -import { dataSourceWithIndexPatterns, filtersMock } from '../../storybook/mocks'; +import { + dataSourceWithDataView, + dataSourceWithIndexPatterns, + eqlQuery, + mockDataView, +} from '../../storybook/mocks'; export default { component: EqlQueryReadOnly, @@ -33,44 +37,42 @@ interface TemplateProps { const Template: Story = (args) => { return ( - + - + ); }; -export const Default = Template.bind({}); +export const EqlQueryWithIndexPatterns = Template.bind({}); -Default.args = { +EqlQueryWithIndexPatterns.args = { finalDiffableRule: { - eql_query: { - query: '*', - language: 'eql', - filters: filtersMock, - }, + eql_query: eqlQuery, data_source: dataSourceWithIndexPatterns, }, kibanaServicesMock: { data: { dataViews: { - create: async (spec: Record) => { - const dataView = new DataView({ - spec: { - ...spec, - fields: { - 'Responses.message': { - name: 'Responses.message', - type: 'string', - }, - }, - }, - } as unknown as ConstructorParameters[0]); + create: async () => mockDataView(), + }, + }, + }, +}; + +export const EqlQueryWithDataView = Template.bind({}); - return dataView; - }, +EqlQueryWithDataView.args = { + finalDiffableRule: { + eql_query: eqlQuery, + data_source: dataSourceWithDataView, + }, + kibanaServicesMock: { + data: { + dataViews: { + get: async () => mockDataView(), }, }, }, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx index 85afa13b0d674..8c1f49cbb5a4d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx @@ -39,7 +39,7 @@ export const Default = Template.bind({}); Default.args = { finalDiffableRule: { esql_query: { - query: 'source.ip: *', + query: `SELECT user.name, source.ip FROM "logs-*" WHERE event.action = 'user_login' AND event.outcome = 'failure'`, language: 'esql', }, }, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx index 58164e51a36fb..b376841ff4282 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx @@ -7,24 +7,22 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { DataView } from '@kbn/data-views-plugin/common'; import { FinalReadonly } from '../../final_readonly'; -import { KqlQueryType } from '../../../../../../../../../common/api/detection_engine'; import type { DiffableAllFields, RuleKqlQuery, } from '../../../../../../../../../common/api/detection_engine'; -import { StorybookProviders } from '../../storybook/storybook_providers'; +import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; import { dataSourceWithDataView, dataSourceWithIndexPatterns, - filtersMock, inlineKqlQuery, + mockDataView, + savedKqlQuery, + savedQueryResponse, } from '../../storybook/mocks'; -type DataViewDeps = ConstructorParameters[0]; - export default { component: FinalReadonly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/kql_query', @@ -43,12 +41,12 @@ interface TemplateProps { const Template: Story = (args) => { return ( - + - + ); }; @@ -62,21 +60,7 @@ InlineKqlQueryWithIndexPatterns.args = { kibanaServicesMock: { data: { dataViews: { - create: async (spec: Record) => { - const dataView = new DataView({ - spec: { - ...spec, - fields: { - 'Responses.message': { - name: 'Responses.message', - type: 'string', - }, - }, - }, - } as unknown as DataViewDeps); - - return dataView; - }, + create: async () => mockDataView(), }, }, }, @@ -92,23 +76,29 @@ InlineKqlQueryWithDataView.args = { kibanaServicesMock: { data: { dataViews: { - get: async (id: string) => { - const dataView = new DataView({ - spec: { - id, - fields: { - 'Responses.message': { - name: 'Responses.message', - type: 'string', - }, - }, - }, - } as unknown as DataViewDeps); + get: async () => mockDataView(), + }, + }, + }, +}; + +export const SavedKqlQueryWithIndexPatterns = Template.bind({}); - return dataView; - }, +SavedKqlQueryWithIndexPatterns.args = { + kibanaServicesMock: { + data: { + dataViews: { + create: async () => mockDataView(), }, }, + http: { + get: async () => savedQueryResponse, + }, + }, + finalDiffableRule: { + kql_query: savedKqlQuery, + data_source: dataSourceWithIndexPatterns, + type: 'saved_query', }, }; @@ -118,45 +108,15 @@ SavedKqlQueryWithDataView.args = { kibanaServicesMock: { data: { dataViews: { - get: async (id: string) => { - const dataView = new DataView({ - spec: { - id, - fields: { - 'Responses.message': { - name: 'Responses.message', - type: 'string', - }, - }, - }, - } as unknown as DataViewDeps); - - return dataView; - }, + get: async () => mockDataView(), }, }, http: { - get: async () => { - const mockedSavedQuery = { - id: 'fake-saved-query-id', - attributes: { - title: 'Fake Saved Query', - description: '', - query: { query: '*', language: 'kuery' }, - filters: filtersMock, - }, - namespaces: ['default'], - }; - - return mockedSavedQuery; - }, + get: async () => savedQueryResponse, }, }, finalDiffableRule: { - kql_query: { - type: KqlQueryType.saved_query, - saved_query_id: 'fake-saved-query-id', - }, + kql_query: savedKqlQuery, data_source: dataSourceWithDataView, type: 'saved_query', }, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx index 6680928c8e996..31d7e30fdc7f0 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx @@ -11,7 +11,7 @@ import type { Story } from '@storybook/react'; import { MachineLearningJobIdReadOnly } from './machine_learning_job_id'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { FinalReadonly } from '../../final_readonly'; -import { StorybookProviders } from '../../storybook/storybook_providers'; +import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; import { GET_MODULES_QUERY_KEY } from '../../../../../../../../common/components/ml_popover/hooks/use_fetch_modules_query'; import { GET_RECOGNIZER_QUERY_KEY } from '../../../../../../../../common/components/ml_popover/hooks/use_fetch_recognizer_query'; import { GET_JOBS_SUMMARY_QUERY_KEY } from '../../../../../../../../common/components/ml/hooks/use_fetch_jobs_summary_query'; @@ -74,14 +74,14 @@ const Template: Story = (args) => { // console.log('dbg template', useSecurityJobs); return ( - + - + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx index bffa7e29bb949..0aba584d12aea 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { useQueryClient } from '@tanstack/react-query'; import type { Story } from '@storybook/react'; import { RelatedIntegrationsReadOnly } from './related_integrations'; -import { StorybookProviders } from '../../storybook/storybook_providers'; +import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; import { FinalReadonly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; @@ -50,14 +50,14 @@ interface TemplateProps { const Template: Story = (args) => { return ( - + - + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx index b71a88a747e89..b1d3af2b27084 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx @@ -7,14 +7,16 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { DataView } from '@kbn/data-views-plugin/common'; import { FinalReadonly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatQueryReadOnly } from './threat_query'; -import { dataSourceWithDataView, inlineKqlQuery } from '../../storybook/mocks'; -import { StorybookProviders } from '../../storybook/storybook_providers'; - -type DataViewDeps = ConstructorParameters[0]; +import { + dataSourceWithDataView, + dataSourceWithIndexPatterns, + inlineKqlQuery, + mockDataView, +} from '../../storybook/mocks'; +import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; export default { component: ThreatQueryReadOnly, @@ -34,40 +36,42 @@ interface TemplateProps { const Template: Story = (args) => { return ( - + - + ); }; -export const Default = Template.bind({}); +export const ThreatQueryWithIndexPatterns = Template.bind({}); -Default.args = { +ThreatQueryWithIndexPatterns.args = { finalDiffableRule: { threat_query: inlineKqlQuery, - data_source: dataSourceWithDataView, + data_source: dataSourceWithIndexPatterns, }, kibanaServicesMock: { data: { dataViews: { - get: async (id: string) => { - const dataView = new DataView({ - spec: { - id, - fields: { - 'Responses.message': { - name: 'Responses.message', - type: 'string', - }, - }, - }, - } as unknown as DataViewDeps); + create: async () => mockDataView(), + }, + }, + }, +}; + +export const ThreatQueryWithDataView = Template.bind({}); - return dataView; - }, +ThreatQueryWithDataView.args = { + finalDiffableRule: { + threat_query: inlineKqlQuery, + data_source: dataSourceWithDataView, + }, + kibanaServicesMock: { + data: { + dataViews: { + get: async () => mockDataView(), }, }, }, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/utils.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx similarity index 54% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/utils.ts rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx index 582602a0c9c55..217a14e340edf 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/utils.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx @@ -5,11 +5,14 @@ * 2.0. */ +import React from 'react'; import { merge } from 'lodash'; -import type { CoreStart } from '@kbn/core/public'; import { Subject } from 'rxjs'; +import type { CoreStart } from '@kbn/core/public'; +import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public'; +import { ReactQueryClientProvider } from '../../../../../../../common/containers/query_client/query_client_provider'; -export const createKibanaServicesMock = (overrides?: Partial) => { +function createKibanaServicesMock(overrides?: Partial) { const baseMock = { data: { dataViews: { @@ -42,4 +45,22 @@ export const createKibanaServicesMock = (overrides?: Partial) => { } as unknown as CoreStart; return merge(baseMock, overrides); -}; +} + +interface StorybookProvidersProps { + children: React.ReactNode; + kibanaServicesMock?: ReturnType; +} + +export function FinalReadOnlyStorybookProviders({ + children, + kibanaServicesMock, +}: StorybookProvidersProps) { + const KibanaReactContext = createKibanaReactContext(createKibanaServicesMock(kibanaServicesMock)); + + return ( + + {children} + + ); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts index b9f0e64539271..832b89e72d4b1 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts @@ -5,35 +5,50 @@ * 2.0. */ +import { DataView } from '@kbn/data-views-plugin/common'; import { DataSourceType, KqlQueryType } from '../../../../../../../../common/api/detection_engine'; -import type { DiffableAllFields } from '../../../../../../../../common/api/detection_engine'; +import type { + DiffableAllFields, + SavedKqlQuery, +} from '../../../../../../../../common/api/detection_engine'; -export const filtersMock = [ +export const filters = [ { meta: { disabled: false, negate: false, alias: null, - index: '', - key: 'Responses.message', - field: 'Responses.message', - params: ['test-1', 'test-2'], - value: ['test-1', 'test-2'], - type: 'phrases', + index: 'logs-*', + key: '@timestamp', + field: '@timestamp', + value: 'exists', + type: 'exists', }, query: { - bool: { - minimum_should_match: 1, - should: [ - { match_phrase: { 'Responses.message': 'test-1' } }, - { match_phrase: { 'Responses.message': 'test-2' } }, - ], + exists: { + field: '@timestamp', }, }, - $state: { store: 'appState' }, + $state: { + store: 'appState', + }, }, ]; +export const savedQueryResponse = { + id: 'fake-saved-query-id', + attributes: { + title: 'Fake Saved Query', + description: '', + query: { + query: 'file.path: "/etc/passwd" and event.action: "modification"', + language: 'kuery', + }, + filters, + }, + namespaces: ['default'], +}; + export const indexPatternsDataSource: DiffableAllFields['data_source'] = { type: DataSourceType.index_patterns, index_patterns: ['logs-*'], @@ -46,9 +61,20 @@ export const dataViewDataSource: DiffableAllFields['data_source'] = { export const inlineKqlQuery: DiffableAllFields['kql_query'] = { type: KqlQueryType.inline_query, - query: '*', + query: 'event.action: "user_login" and source.ip: "192.168.1.100"', language: 'kuery', - filters: filtersMock, + filters, +}; + +export const savedKqlQuery: SavedKqlQuery = { + type: KqlQueryType.saved_query, + saved_query_id: 'fake-saved-query-id', +}; + +export const eqlQuery: DiffableAllFields['eql_query'] = { + query: 'process where process.name == "powershell.exe" and process.args : "* -EncodedCommand *"', + language: 'eql', + filters, }; export const dataSourceWithIndexPatterns: DiffableAllFields['data_source'] = { @@ -60,3 +86,26 @@ export const dataSourceWithDataView: DiffableAllFields['data_source'] = { type: DataSourceType.data_view, data_view_id: 'logs-*', }; + +type DataViewDeps = ConstructorParameters[0]; + +export function mockDataView(spec: Partial = {}): DataView { + const dataView = new DataView({ + spec: { + fields: { + '@timestamp': { + name: '@timestamp', + type: 'date', + }, + }, + ...spec, + }, + fieldFormats: { + getDefaultInstance: () => ({ + toJSON: () => ({}), + }), + }, + } as unknown as DataViewDeps); + + return dataView; +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx deleted file mode 100644 index e8aa4d78a6abc..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/storybook_providers.tsx +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; -import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public'; -import { ReactQueryClientProvider } from '../../../../../../../common/containers/query_client/query_client_provider'; -// import { UpgradePrebuiltRulesTableContextProvider } from '../../../../../../rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context'; -import { createKibanaServicesMock } from './utils'; - -interface StorybookProvidersProps { - children: React.ReactNode; - kibanaServicesMock?: ReturnType; -} - -export function StorybookProviders({ children, kibanaServicesMock }: StorybookProvidersProps) { - const KibanaReactContext = createKibanaReactContext(createKibanaServicesMock(kibanaServicesMock)); - - return ( - - {children} - - ); -} From 833fda10d0117935704582ee2fab878accf6c5df Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Fri, 30 Aug 2024 16:56:22 +0200 Subject: [PATCH 04/18] Rename `FinalReadonly` -> `FinalReadOnly` --- .../field_components/data_source/data_source.stories.tsx | 6 +++--- .../field_components/eql_query/eql_query.stories.tsx | 4 ++-- .../field_components/esql_query/esql_query.stories.tsx | 6 +++--- .../field_components/kql_query/kql_query.stories.tsx | 6 +++--- .../machine_learning_job_id.stories.tsx | 4 ++-- .../related_integrations/related_integrations.stories.tsx | 4 ++-- .../required_fields/required_fields.stories.tsx | 4 ++-- .../risk_score_mapping/risk_score_mapping.stories.tsx | 4 ++-- .../severity_mapping/severity_mapping.stories.tsx | 4 ++-- .../field_components/threat/threat.stories.tsx | 4 ++-- .../field_components/threat_index/threat_index.stories.tsx | 4 ++-- .../threat_indicator_path/threat_indicator_path.stories.tsx | 4 ++-- .../threat_mapping/threat_mapping.stories.tsx | 4 ++-- .../field_components/threat_query/threat_query.stories.tsx | 4 ++-- .../three_way_diff/final_readonly/final_readonly.tsx | 2 +- 15 files changed, 32 insertions(+), 32 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx index a44e813655b1b..8d162ea22d162 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx @@ -7,14 +7,14 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; import { dataViewDataSource, indexPatternsDataSource } from '../../storybook/mocks'; export default { - component: FinalReadonly, + component: FinalReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/data_source', argTypes: { finalDiffableRule: { @@ -32,7 +32,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx index 15e725dc02382..958568e5567b3 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; @@ -38,7 +38,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx index 8c1f49cbb5a4d..1716f613bcb99 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx @@ -7,11 +7,11 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; export default { - component: FinalReadonly, + component: FinalReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/esql_query', argTypes: { finalDiffableRule: { @@ -27,7 +27,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx index b376841ff4282..171aceeb73077 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields, RuleKqlQuery, @@ -24,7 +24,7 @@ import { } from '../../storybook/mocks'; export default { - component: FinalReadonly, + component: FinalReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/kql_query', argTypes: { finalDiffableRule: { @@ -42,7 +42,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx index 31d7e30fdc7f0..6cd32d60fbcc1 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx @@ -10,7 +10,7 @@ import { useQueryClient } from '@tanstack/react-query'; import type { Story } from '@storybook/react'; import { MachineLearningJobIdReadOnly } from './machine_learning_job_id'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; import { GET_MODULES_QUERY_KEY } from '../../../../../../../../common/components/ml_popover/hooks/use_fetch_modules_query'; import { GET_RECOGNIZER_QUERY_KEY } from '../../../../../../../../common/components/ml_popover/hooks/use_fetch_recognizer_query'; @@ -76,7 +76,7 @@ const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx index 0aba584d12aea..40960a0914e05 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx @@ -10,7 +10,7 @@ import { useQueryClient } from '@tanstack/react-query'; import type { Story } from '@storybook/react'; import { RelatedIntegrationsReadOnly } from './related_integrations'; import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; export default { @@ -52,7 +52,7 @@ const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx index cc7b4e48bb185..12e5b4abe43f9 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; import { RequiredFieldsReadOnly } from './required_fields'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; export default { @@ -27,7 +27,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx index 7af926e816929..2e68e0ba86d5a 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { RiskScoreMappingReadOnly } from './risk_score_mapping'; @@ -29,7 +29,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx index 85d1d3081fe95..8994cc4c44cc1 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { SeverityMappingReadOnly } from './severity_mapping'; @@ -29,7 +29,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx index c2032d523e204..27a7852362ad5 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatReadOnly } from './threat'; @@ -28,7 +28,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx index 597380cc2ad27..180adf856dfd5 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatIndexReadOnly } from './threat_index'; @@ -28,7 +28,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx index 605e3a031d5d5..dc916b4de8ba1 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatIndicatorPathReadOnly } from './threat_indicator_path'; @@ -29,7 +29,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx index d480811a7e354..bb779fa0d31a6 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatMappingReadOnly } from './threat_mapping'; @@ -28,7 +28,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx index b1d3af2b27084..1a4020a83226d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadonly } from '../../final_readonly'; +import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatQueryReadOnly } from './threat_query'; import { @@ -37,7 +37,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx index 80293cf6357ca..97bad00f23551 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx @@ -28,7 +28,7 @@ interface FinalReadonlyProps { finalDiffableRule: DiffableAllFields; } -export function FinalReadonly({ fieldName, finalDiffableRule }: FinalReadonlyProps) { +export function FinalReadOnly({ fieldName, finalDiffableRule }: FinalReadonlyProps) { switch (fieldName) { case 'data_source': return ; From 07154e116f175ffa80ced062d63baaa482fd51af Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Fri, 30 Aug 2024 18:04:46 +0200 Subject: [PATCH 05/18] Remove unused changes --- .../comparison_side.stories.tsx | 2 +- .../data_source/data_source.stories.tsx | 19 ++++++------- .../eql_query/eql_query.stories.tsx | 7 ----- .../esql_query/esql_query.stories.tsx | 6 ----- .../kql_query/kql_query.stories.tsx | 27 +++++++------------ .../machine_learning_job_id.stories.tsx | 8 ------ .../related_integrations.stories.tsx | 6 ----- .../required_fields.stories.tsx | 6 ----- .../risk_score_mapping.stories.tsx | 6 ----- .../severity_mapping.stories.tsx | 6 ----- .../threat/threat.stories.tsx | 6 ----- .../field_components/threat/threat.tsx | 6 ----- .../threat_index/threat_index.stories.tsx | 6 ----- .../threat_index/threat_index.tsx | 6 ----- .../threat_indicator_path.stories.tsx | 6 ----- .../threat_indicator_path.tsx | 6 ----- .../threat_mapping/threat_mapping.stories.tsx | 6 ----- .../threat_query/threat_query.stories.tsx | 6 ----- .../threat_query/threat_query.tsx | 6 ----- .../final_readonly/storybook/mocks.ts | 11 +------- .../upgrade_prebuilt_rules_table_context.tsx | 11 +++----- 21 files changed, 24 insertions(+), 145 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/comparison_side/comparison_side.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/comparison_side/comparison_side.stories.tsx index 535c469f3aa11..37ddb71dce9f7 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/comparison_side/comparison_side.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/comparison_side/comparison_side.stories.tsx @@ -33,7 +33,7 @@ export default { }, resolvedValue: { control: 'text', - description: 'User-set resolved value', + description: 'Resolved value', }, }, }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx index 8d162ea22d162..bbe64cfc4c2d0 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx @@ -9,19 +9,16 @@ import React from 'react'; import type { Story } from '@storybook/react'; import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; - import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; -import { dataViewDataSource, indexPatternsDataSource } from '../../storybook/mocks'; +import { + dataSourceWithDataView, + dataSourceWithIndexPatterns, + mockDataView, +} from '../../storybook/mocks'; export default { component: FinalReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/data_source', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { @@ -44,7 +41,7 @@ export const DataSourceWithIndexPatterns = Template.bind({}); DataSourceWithIndexPatterns.args = { finalDiffableRule: { - data_source: indexPatternsDataSource, + data_source: dataSourceWithIndexPatterns, }, }; @@ -52,12 +49,12 @@ export const DataSourceWithDataView = Template.bind({}); DataSourceWithDataView.args = { finalDiffableRule: { - data_source: dataViewDataSource, + data_source: dataSourceWithDataView, }, kibanaServicesMock: { data: { dataViews: { - get: async () => ({ getIndexPattern: () => 'logs-*' }), + get: async () => mockDataView(), }, }, }, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx index 958568e5567b3..83beedfe043e3 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx @@ -9,7 +9,6 @@ import React from 'react'; import type { Story } from '@storybook/react'; import { FinalReadOnly } from '../../final_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; - import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; import { EqlQueryReadOnly } from './eql_query'; import { @@ -22,12 +21,6 @@ import { export default { component: EqlQueryReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/eql_query', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx index 1716f613bcb99..39f7d621e8675 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx @@ -13,12 +13,6 @@ import type { DiffableAllFields } from '../../../../../../../../../common/api/de export default { component: FinalReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/esql_query', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx index 171aceeb73077..e2ad4340d4aee 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx @@ -12,7 +12,6 @@ import type { DiffableAllFields, RuleKqlQuery, } from '../../../../../../../../../common/api/detection_engine'; - import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; import { dataSourceWithDataView, @@ -26,12 +25,6 @@ import { export default { component: FinalReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/kql_query', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { @@ -85,6 +78,11 @@ InlineKqlQueryWithDataView.args = { export const SavedKqlQueryWithIndexPatterns = Template.bind({}); SavedKqlQueryWithIndexPatterns.args = { + finalDiffableRule: { + kql_query: savedKqlQuery, + data_source: dataSourceWithIndexPatterns, + type: 'saved_query', + }, kibanaServicesMock: { data: { dataViews: { @@ -95,16 +93,16 @@ SavedKqlQueryWithIndexPatterns.args = { get: async () => savedQueryResponse, }, }, - finalDiffableRule: { - kql_query: savedKqlQuery, - data_source: dataSourceWithIndexPatterns, - type: 'saved_query', - }, }; export const SavedKqlQueryWithDataView = Template.bind({}); SavedKqlQueryWithDataView.args = { + finalDiffableRule: { + kql_query: savedKqlQuery, + data_source: dataSourceWithDataView, + type: 'saved_query', + }, kibanaServicesMock: { data: { dataViews: { @@ -115,9 +113,4 @@ SavedKqlQueryWithDataView.args = { get: async () => savedQueryResponse, }, }, - finalDiffableRule: { - kql_query: savedKqlQuery, - data_source: dataSourceWithDataView, - type: 'saved_query', - }, }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx index 6cd32d60fbcc1..7783bb9b70041 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx @@ -20,12 +20,6 @@ export default { component: MachineLearningJobIdReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/machine_learning_job_id', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; const mockedModulesData = [ @@ -71,8 +65,6 @@ interface TemplateProps { } const Template: Story = (args) => { - // console.log('dbg template', useSecurityJobs); - return ( diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx index 40960a0914e05..c2768ca9b5435 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx @@ -17,12 +17,6 @@ export default { component: RelatedIntegrationsReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/related_integrations', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; const mockedIntegrationsData = [ diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx index 12e5b4abe43f9..f0a7fbd761f62 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx @@ -13,12 +13,6 @@ import type { DiffableAllFields } from '../../../../../../../../../common/api/de export default { component: RequiredFieldsReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/required_fields', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx index 2e68e0ba86d5a..fd0a7d4f02ffb 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx @@ -15,12 +15,6 @@ export default { component: RiskScoreMappingReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/risk_score_mapping', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx index 8994cc4c44cc1..02ed154749dfb 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx @@ -15,12 +15,6 @@ export default { component: SeverityMappingReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/severity_mapping', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx index 27a7852362ad5..6991b4152a6b8 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx @@ -14,12 +14,6 @@ import { ThreatReadOnly } from './threat'; export default { component: ThreatReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx index 05a0367dda68b..3b63b618685bc 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx @@ -4,12 +4,6 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ import React from 'react'; import { EuiDescriptionList } from '@elastic/eui'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx index 180adf856dfd5..93850739e692a 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx @@ -14,12 +14,6 @@ import { ThreatIndexReadOnly } from './threat_index'; export default { component: ThreatIndexReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_index', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx index e2987b349cdd7..8419f63f6b819 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx @@ -4,12 +4,6 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ import React from 'react'; import { EuiDescriptionList } from '@elastic/eui'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx index dc916b4de8ba1..840fd36b14f9b 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx @@ -15,12 +15,6 @@ export default { component: ThreatIndicatorPathReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_indicator_path', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx index 04ce64cda5741..e42c71512cb48 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx @@ -4,12 +4,6 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ import React from 'react'; import { EuiDescriptionList } from '@elastic/eui'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx index bb779fa0d31a6..36b9c60fd4fb6 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx @@ -14,12 +14,6 @@ import { ThreatMappingReadOnly } from './threat_mapping'; export default { component: ThreatMappingReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_mapping', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx index 1a4020a83226d..a92ba1ccc460b 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx @@ -21,12 +21,6 @@ import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_ export default { component: ThreatQueryReadOnly, title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_query', - argTypes: { - finalDiffableRule: { - control: 'object', - description: 'Final value of the diffable rule', - }, - }, }; interface TemplateProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx index f76465617d558..0d54d489d8dc2 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx @@ -4,12 +4,6 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ import React from 'react'; import type { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts index 832b89e72d4b1..cb8cffecf0706 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts @@ -49,16 +49,6 @@ export const savedQueryResponse = { namespaces: ['default'], }; -export const indexPatternsDataSource: DiffableAllFields['data_source'] = { - type: DataSourceType.index_patterns, - index_patterns: ['logs-*'], -}; - -export const dataViewDataSource: DiffableAllFields['data_source'] = { - type: DataSourceType.data_view, - data_view_id: 'logs-*', -}; - export const inlineKqlQuery: DiffableAllFields['kql_query'] = { type: KqlQueryType.inline_query, query: 'event.action: "user_login" and source.ip: "192.168.1.100"', @@ -92,6 +82,7 @@ type DataViewDeps = ConstructorParameters[0]; export function mockDataView(spec: Partial = {}): DataView { const dataView = new DataView({ spec: { + title: 'logs-*', fields: { '@timestamp': { name: '@timestamp', diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context.tsx index fdbd00f22d7d5..9d1a3071b44e1 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/upgrade_prebuilt_rules_table/upgrade_prebuilt_rules_table_context.tsx @@ -107,12 +107,11 @@ const UpgradePrebuiltRulesTableContext = createContext; } -export const UpgradePrebuiltRulesTableContextProvider = ( - props: UpgradePrebuiltRulesTableContextProviderProps -) => { +export const UpgradePrebuiltRulesTableContextProvider = ({ + children, +}: UpgradePrebuiltRulesTableContextProviderProps) => { const [loadingRules, setLoadingRules] = useState([]); const [selectedRules, setSelectedRules] = useState([]); const [filterOptions, setFilterOptions] = useState({ @@ -247,7 +246,6 @@ export const UpgradePrebuiltRulesTableContextProvider = ( selectedRules, loadingRules, lastUpdated: dataUpdatedAt, - ...props.stateOverride, }, actions, }; @@ -265,7 +263,6 @@ export const UpgradePrebuiltRulesTableContextProvider = ( loadingRules, dataUpdatedAt, actions, - props.stateOverride, ]); const extraTabs = useMemo(() => { @@ -315,7 +312,7 @@ export const UpgradePrebuiltRulesTableContextProvider = ( onConfirm={handleUpgradeConfirm} /> )} - {props.children} + {children} {previewedRule && ( Date: Mon, 2 Sep 2024 17:44:17 +0200 Subject: [PATCH 06/18] Add query language support to Rule Details page --- .../review_rule_upgrade_route.ts | 2 +- .../description_step/translations.ts | 21 +++++ .../components/rule_details/helpers.ts | 12 +++ .../rule_details/rule_definition_section.tsx | 79 +++++++++++++++---- .../kql_query/inline_kql_query.tsx | 26 ++++-- .../kql_query/saved_kql_query.tsx | 5 +- .../field_components/kql_query/utils.ts | 19 ----- .../threat_query/threat_query.tsx | 16 +++- .../field_components/translations.ts | 29 ------- .../components/rule_details/translations.ts | 14 ++++ 10 files changed, 149 insertions(+), 74 deletions(-) delete mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/utils.ts delete mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/translations.ts diff --git a/x-pack/plugins/security_solution/common/api/detection_engine/prebuilt_rules/review_rule_upgrade/review_rule_upgrade_route.ts b/x-pack/plugins/security_solution/common/api/detection_engine/prebuilt_rules/review_rule_upgrade/review_rule_upgrade_route.ts index 67f000a41711e..2f2d6e3bd1c26 100644 --- a/x-pack/plugins/security_solution/common/api/detection_engine/prebuilt_rules/review_rule_upgrade/review_rule_upgrade_route.ts +++ b/x-pack/plugins/security_solution/common/api/detection_engine/prebuilt_rules/review_rule_upgrade/review_rule_upgrade_route.ts @@ -21,7 +21,7 @@ export interface RuleUpgradeStatsForReview { /** Number of installed prebuilt rules available for upgrade (stock + customized) */ num_rules_to_upgrade_total: number; - /** Number of installed prebuilt rules with upgrade conflicts (SOLVABLE or NON_SOLVALBE) */ + /** Number of installed prebuilt rules with upgrade conflicts (SOLVABLE or NON_SOLVABLE) */ num_rules_with_conflicts: number; /** Number of installed prebuilt rules with NON_SOLVABLE upgrade conflicts */ diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/description_step/translations.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/description_step/translations.ts index 27dfec9818eb9..53027ff504c24 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/description_step/translations.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/description_step/translations.ts @@ -35,6 +35,13 @@ export const ESQL_QUERY_LABEL = i18n.translate( } ); +export const QUERY_LANGUAGE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.createRule.queryLanguageLabel', + { + defaultMessage: 'Custom query language', + } +); + export const THREAT_QUERY_LABEL = i18n.translate( 'xpack.securitySolution.detectionEngine.createRule.threatQueryLabel', { @@ -42,6 +49,13 @@ export const THREAT_QUERY_LABEL = i18n.translate( } ); +export const THREAT_QUERY_LANGUAGE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.createRule.threatQueryLanguageLabel', + { + defaultMessage: 'Indicator index query language', + } +); + export const SAVED_QUERY_NAME_LABEL = i18n.translate( 'xpack.securitySolution.detectionEngine.createRule.savedIdLabel', { @@ -49,6 +63,13 @@ export const SAVED_QUERY_NAME_LABEL = i18n.translate( } ); +export const SAVED_QUERY_LANGUAGE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.createRule.savedQueryLanguageLabel', + { + defaultMessage: 'Saved query language', + } +); + export const SAVED_QUERY_FILTERS_LABEL = i18n.translate( 'xpack.securitySolution.detectionEngine.createRule.savedQueryFiltersLabel', { 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 73dbe92cebbe4..3ecdf345a5902 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 @@ -14,6 +14,7 @@ import { SCHEDULE_UPGRADE_FIELD_ORDER, SETUP_UPGRADE_FIELD_ORDER, } from './constants'; +import * as i18n from './translations'; export const getSectionedFieldDiffs = (fields: FieldsGroupDiff[]) => { const aboutFields = []; @@ -57,3 +58,14 @@ export const filterUnsupportedDiffOutcomes = ( ); }) ); + +export function getQueryLanguageLabel(language: string) { + switch (language) { + case 'kuery': + return i18n.KUERY_LANGUAGE_LABEL; + case 'lucene': + return i18n.LUCENE_LANGUAGE_LABEL; + default: + return language; + } +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx index 1743fd5292da4..037bb4187775b 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx @@ -57,6 +57,7 @@ import { queryStyles, useRequiredFieldsStyles, } from './rule_definition_section.styles'; +import { getQueryLanguageLabel } from './helpers'; interface SavedQueryNameProps { savedQueryName: string; @@ -196,12 +197,17 @@ const AnomalyThreshold = ({ anomalyThreshold }: AnomalyThresholdProps) => ( ); interface MachineLearningJobListProps { - jobIds: string | string[]; + jobIds?: string | string[]; isInteractive: boolean; } export const MachineLearningJobList = ({ jobIds, isInteractive }: MachineLearningJobListProps) => { const { jobs } = useSecurityJobs(); + + if (!jobIds) { + return null; + } + const jobIdsArray = Array.isArray(jobIds) ? jobIds : [jobIds]; if (isInteractive) { @@ -440,14 +446,28 @@ const prepareDefinitionSectionListItems = ( } if (savedQuery) { - definitionSectionListItems.push({ - title: ( - - {descriptionStepI18n.SAVED_QUERY_NAME_LABEL} - - ), - description: , - }); + definitionSectionListItems.push( + { + title: ( + + {descriptionStepI18n.SAVED_QUERY_NAME_LABEL} + + ), + description: , + }, + { + title: ( + + {descriptionStepI18n.SAVED_QUERY_LANGUAGE_LABEL} + + ), + description: ( + + {getQueryLanguageLabel(savedQuery.attributes.query.language)} + + ), + } + ); if (savedQuery.attributes.filters) { definitionSectionListItems.push({ @@ -514,12 +534,26 @@ const prepareDefinitionSectionListItems = ( description: , }); } else { - definitionSectionListItems.push({ - title: ( - {descriptionStepI18n.QUERY_LABEL} - ), - description: , - }); + definitionSectionListItems.push( + { + title: ( + {descriptionStepI18n.QUERY_LABEL} + ), + description: , + }, + { + title: ( + + {descriptionStepI18n.QUERY_LANGUAGE_LABEL} + + ), + description: ( + + {getQueryLanguageLabel(rule.language || '')} + + ), + } + ); } } @@ -639,6 +673,21 @@ const prepareDefinitionSectionListItems = ( }); } + if ('threat_language' in rule && rule.threat_language) { + definitionSectionListItems.push({ + title: ( + + {descriptionStepI18n.THREAT_QUERY_LANGUAGE_LABEL} + + ), + description: ( + + {getQueryLanguageLabel(rule.threat_language)} + + ), + }); + } + if ('new_terms_fields' in rule && rule.new_terms_fields && rule.new_terms_fields.length > 0) { definitionSectionListItems.push({ title: ( diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_kql_query.tsx index 3413ccb522f5f..93cd3884afe04 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_kql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_kql_query.tsx @@ -16,22 +16,36 @@ import type { } from '../../../../../../../../../common/api/detection_engine'; import { Query, Filters } from '../../../../rule_definition_section'; import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; -import * as i18n from '../translations'; -import { getQueryLanguageLabel } from './utils'; +import { getQueryLanguageLabel } from '../../../../helpers'; + +const defaultI18nLabels = { + query: descriptionStepI18n.QUERY_LABEL, + language: descriptionStepI18n.QUERY_LANGUAGE_LABEL, + filters: descriptionStepI18n.FILTERS_LABEL, +}; interface InlineQueryProps { kqlQuery: InlineKqlQuery; dataSource?: DiffableAllFields['data_source']; + i18nLabels?: { + query: string; + language: string; + filters: string; + }; } -export function InlineKqlQueryReadOnly({ kqlQuery, dataSource }: InlineQueryProps) { +export function InlineKqlQueryReadOnly({ + kqlQuery, + dataSource, + i18nLabels = defaultI18nLabels, +}: InlineQueryProps) { const listItems: EuiDescriptionListProps['listItems'] = [ { - title: descriptionStepI18n.QUERY_LABEL, + title: i18nLabels.query, description: , }, { - title: i18n.LANGUAGE_LABEL, + title: i18nLabels.language, description: getQueryLanguageLabel(kqlQuery.language), }, ]; @@ -44,7 +58,7 @@ export function InlineKqlQueryReadOnly({ kqlQuery, dataSource }: InlineQueryProp dataSource.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; listItems.push({ - title: descriptionStepI18n.FILTERS_LABEL, + title: i18nLabels.filters, description: ( ), diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_kql_query.tsx index ef7206af6da23..da7a358a0a53d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_kql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_kql_query.tsx @@ -17,8 +17,7 @@ import type { import { Query, SavedQueryName, Filters } from '../../../../rule_definition_section'; import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; import { useGetSavedQuery } from '../../../../../../../../detections/pages/detection_engine/rules/use_get_saved_query'; -import * as i18n from '../translations'; -import { getQueryLanguageLabel } from './utils'; +import { getQueryLanguageLabel } from '../../../../helpers'; interface SavedQueryProps { kqlQuery: SavedKqlQuery; @@ -42,7 +41,7 @@ export function SavedKqlQueryReadOnly({ kqlQuery, dataSource, ruleType }: SavedQ description: , }, { - title: i18n.LANGUAGE_LABEL, + title: descriptionStepI18n.SAVED_QUERY_LANGUAGE_LABEL, description: getQueryLanguageLabel(savedQuery.attributes.query.language), }, ]; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/utils.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/utils.ts deleted file mode 100644 index fd733b20b074b..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/utils.ts +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import * as i18n from '../translations'; - -export function getQueryLanguageLabel(language: string) { - switch (language) { - case 'kuery': - return i18n.KUERY_LABEL; - case 'lucene': - return i18n.LUCENE_LABEL; - default: - return language; - } -} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx index 0d54d489d8dc2..aac275f2a3a5c 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx @@ -10,13 +10,27 @@ import type { DiffableAllFields, InlineKqlQuery, } from '../../../../../../../../../common/api/detection_engine'; +import * as ruleDetailsI18n from '../../../../translations'; +import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; import { InlineKqlQueryReadOnly } from '../kql_query/inline_kql_query'; +const i18nLabels = { + query: descriptionStepI18n.THREAT_QUERY_LABEL, + language: descriptionStepI18n.THREAT_QUERY_LANGUAGE_LABEL, + filters: ruleDetailsI18n.THREAT_FILTERS_FIELD_LABEL, +}; + interface ThreatQueryReadOnlyProps { threatQuery: InlineKqlQuery; dataSource: DiffableAllFields['data_source']; } export const ThreatQueryReadOnly = ({ threatQuery, dataSource }: ThreatQueryReadOnlyProps) => { - return ; + return ( + + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/translations.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/translations.ts deleted file mode 100644 index f8a02217727cb..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/translations.ts +++ /dev/null @@ -1,29 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import { i18n } from '@kbn/i18n'; - -export const LANGUAGE_LABEL = i18n.translate( - 'xpack.securitySolution.detectionEngine.rules.upgradeRules.finalReadonly.languageLabel', - { - defaultMessage: 'Language', - } -); - -export const KUERY_LABEL = i18n.translate( - 'xpack.securitySolution.detectionEngine.rules.upgradeRules.finalReadonly.kueryLabel', - { - defaultMessage: 'KQL', - } -); - -export const LUCENE_LABEL = i18n.translate( - 'xpack.securitySolution.detectionEngine.rules.upgradeRules.finalReadonly.luceneLabel', - { - defaultMessage: 'Lucene', - } -); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/translations.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/translations.ts index a5fab42457e44..506fc01950d17 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/translations.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/translations.ts @@ -356,3 +356,17 @@ export const CUSTOMIZED_PREBUILT_RULE_LABEL = i18n.translate( defaultMessage: 'Customized Elastic rule', } ); + +export const KUERY_LANGUAGE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.ruleDetails.kqlLanguageLabel', + { + defaultMessage: 'KQL', + } +); + +export const LUCENE_LANGUAGE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.ruleDetails.luceneLanguageLabel', + { + defaultMessage: 'Lucene', + } +); From 1ce32e02e2b494e643c465829b9664c47c591780 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Tue, 3 Sep 2024 11:12:00 +0200 Subject: [PATCH 07/18] Rename `field_components` -> `fields` --- .../data_source/data_source.stories.tsx | 0 .../{field_components => fields}/data_source/data_source.tsx | 0 .../{field_components => fields}/eql_query/eql_query.stories.tsx | 0 .../{field_components => fields}/eql_query/eql_query.tsx | 0 .../esql_query/esql_query.stories.tsx | 0 .../{field_components => fields}/esql_query/esql_query.tsx | 0 .../{field_components => fields}/kql_query/index.tsx | 0 .../{field_components => fields}/kql_query/inline_kql_query.tsx | 0 .../{field_components => fields}/kql_query/kql_query.stories.tsx | 0 .../{field_components => fields}/kql_query/saved_kql_query.tsx | 0 .../machine_learning_job_id/machine_learning_job_id.stories.tsx | 0 .../machine_learning_job_id/machine_learning_job_id.tsx | 0 .../related_integrations/related_integrations.stories.tsx | 0 .../related_integrations/related_integrations.tsx | 0 .../required_fields/required_fields.stories.tsx | 0 .../required_fields/required_fields.tsx | 0 .../risk_score_mapping/risk_score_mapping.stories.tsx | 0 .../risk_score_mapping/risk_score_mapping.tsx | 0 .../severity_mapping/severity_mapping.stories.tsx | 0 .../severity_mapping/severity_mapping.tsx | 0 .../{field_components => fields}/threat/threat.stories.tsx | 0 .../final_readonly/{field_components => fields}/threat/threat.tsx | 0 .../threat_index/threat_index.stories.tsx | 0 .../{field_components => fields}/threat_index/threat_index.tsx | 0 .../threat_indicator_path/threat_indicator_path.stories.tsx | 0 .../threat_indicator_path/threat_indicator_path.tsx | 0 .../threat_mapping/threat_mapping.stories.tsx | 0 .../threat_mapping/threat_mapping.tsx | 0 .../threat_query/threat_query.stories.tsx | 0 .../{field_components => fields}/threat_query/threat_query.tsx | 0 30 files changed, 0 insertions(+), 0 deletions(-) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/data_source/data_source.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/data_source/data_source.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/eql_query/eql_query.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/eql_query/eql_query.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/esql_query/esql_query.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/esql_query/esql_query.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/kql_query/index.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/kql_query/inline_kql_query.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/kql_query/kql_query.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/kql_query/saved_kql_query.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/machine_learning_job_id/machine_learning_job_id.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/machine_learning_job_id/machine_learning_job_id.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/related_integrations/related_integrations.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/related_integrations/related_integrations.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/required_fields/required_fields.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/required_fields/required_fields.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/risk_score_mapping/risk_score_mapping.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/risk_score_mapping/risk_score_mapping.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/severity_mapping/severity_mapping.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/severity_mapping/severity_mapping.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat/threat.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat/threat.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat_index/threat_index.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat_index/threat_index.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat_indicator_path/threat_indicator_path.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat_indicator_path/threat_indicator_path.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat_mapping/threat_mapping.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat_mapping/threat_mapping.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat_query/threat_query.stories.tsx (100%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{field_components => fields}/threat_query/threat_query.tsx (100%) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/data_source/data_source.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/data_source/data_source.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/data_source/data_source.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/data_source/data_source.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/data_source/data_source.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/eql_query/eql_query.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/esql_query/esql_query.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/esql_query/esql_query.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/esql_query/esql_query.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/esql_query/esql_query.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/esql_query/esql_query.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/index.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/index.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/index.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/inline_kql_query.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/kql_query.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/kql_query/saved_kql_query.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/machine_learning_job_id/machine_learning_job_id.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/related_integrations/related_integrations.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/related_integrations/related_integrations.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/related_integrations/related_integrations.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/related_integrations/related_integrations.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/related_integrations/related_integrations.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/required_fields/required_fields.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/required_fields/required_fields.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/required_fields/required_fields.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/required_fields/required_fields.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/required_fields/required_fields.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/risk_score_mapping/risk_score_mapping.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/severity_mapping/severity_mapping.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat/threat.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_index/threat_index.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_indicator_path/threat_indicator_path.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_mapping/threat_mapping.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.stories.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.stories.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_components/threat_query/threat_query.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx From 47e73ebd67cd332917419d308e8bb1ec15be302b Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Tue, 3 Sep 2024 11:18:03 +0200 Subject: [PATCH 08/18] Rename path in `final_readonly.tsx` as well --- .../final_readonly/final_readonly.tsx | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx index 97bad00f23551..9305f38746dba 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx @@ -8,20 +8,20 @@ import React from 'react'; import { assertUnreachable } from '../../../../../../../common/utility_types'; import type { DiffableAllFields } from '../../../../../../../common/api/detection_engine'; -import { KqlQueryReadOnly } from './field_components/kql_query'; -import { DataSourceReadOnly } from './field_components/data_source/data_source'; -import { EqlQueryReadOnly } from './field_components/eql_query/eql_query'; -import { EsqlQueryReadOnly } from './field_components/esql_query/esql_query'; -import { MachineLearningJobIdReadOnly } from './field_components/machine_learning_job_id/machine_learning_job_id'; -import { RelatedIntegrationsReadOnly } from './field_components/related_integrations/related_integrations'; -import { RequiredFieldsReadOnly } from './field_components/required_fields/required_fields'; -import { SeverityMappingReadOnly } from './field_components/severity_mapping/severity_mapping'; -import { RiskScoreMappingReadOnly } from './field_components/risk_score_mapping/risk_score_mapping'; -import { ThreatMappingReadOnly } from './field_components/threat_mapping/threat_mapping'; -import { ThreatReadOnly } from './field_components/threat/threat'; -import { ThreatIndexReadOnly } from './field_components/threat_index/threat_index'; -import { ThreatIndicatorPathReadOnly } from './field_components/threat_indicator_path/threat_indicator_path'; -import { ThreatQueryReadOnly } from './field_components/threat_query/threat_query'; +import { KqlQueryReadOnly } from './fields/kql_query'; +import { DataSourceReadOnly } from './fields/data_source/data_source'; +import { EqlQueryReadOnly } from './fields/eql_query/eql_query'; +import { EsqlQueryReadOnly } from './fields/esql_query/esql_query'; +import { MachineLearningJobIdReadOnly } from './fields/machine_learning_job_id/machine_learning_job_id'; +import { RelatedIntegrationsReadOnly } from './fields/related_integrations/related_integrations'; +import { RequiredFieldsReadOnly } from './fields/required_fields/required_fields'; +import { SeverityMappingReadOnly } from './fields/severity_mapping/severity_mapping'; +import { RiskScoreMappingReadOnly } from './fields/risk_score_mapping/risk_score_mapping'; +import { ThreatMappingReadOnly } from './fields/threat_mapping/threat_mapping'; +import { ThreatReadOnly } from './fields/threat/threat'; +import { ThreatIndexReadOnly } from './fields/threat_index/threat_index'; +import { ThreatIndicatorPathReadOnly } from './fields/threat_indicator_path/threat_indicator_path'; +import { ThreatQueryReadOnly } from './fields/threat_query/threat_query'; interface FinalReadonlyProps { fieldName: keyof DiffableAllFields; From 50413c4d06b5a0c542a0354dbae55aa1157988f9 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Tue, 3 Sep 2024 12:02:22 +0200 Subject: [PATCH 09/18] Fix TS issues --- .../machine_learning_job_id.stories.tsx | 2 +- .../three_way_diff/final_readonly/final_readonly.tsx | 3 +-- .../storybook/final_readonly_storybook_providers.tsx | 4 ++-- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx index 7783bb9b70041..1cdb6e8f76ee2 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx @@ -66,7 +66,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - + ); default: - return assertUnreachable(fieldName); + return null; } } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx index 217a14e340edf..76cbc2f8f4b4c 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx @@ -42,14 +42,14 @@ function createKibanaServicesMock(overrides?: Partial) { }, }, uiSettings: {}, - } as unknown as CoreStart; + }; return merge(baseMock, overrides); } interface StorybookProvidersProps { children: React.ReactNode; - kibanaServicesMock?: ReturnType; + kibanaServicesMock?: Record; } export function FinalReadOnlyStorybookProviders({ From 739acb45965fab2488a4fc506238b62b5b33d1cf Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Tue, 3 Sep 2024 13:22:32 +0200 Subject: [PATCH 10/18] Rename `FinalReadOnly` -> `FieldReadOnly` --- .../{final_readonly.tsx => field_readonly.tsx} | 4 ++-- .../fields/data_source/data_source.stories.tsx | 14 +++++++------- .../fields/eql_query/eql_query.stories.tsx | 12 ++++++------ .../fields/esql_query/esql_query.stories.tsx | 8 ++++---- .../fields/kql_query/kql_query.stories.tsx | 14 +++++++------- .../machine_learning_job_id.stories.tsx | 12 ++++++------ .../related_integrations.stories.tsx | 12 ++++++------ .../required_fields/required_fields.stories.tsx | 6 +++--- .../risk_score_mapping.stories.tsx | 6 +++--- .../severity_mapping/severity_mapping.stories.tsx | 6 +++--- .../fields/threat/threat.stories.tsx | 6 +++--- .../fields/threat_index/threat_index.stories.tsx | 6 +++--- .../threat_indicator_path.stories.tsx | 6 +++--- .../threat_mapping/threat_mapping.stories.tsx | 6 +++--- .../fields/threat_query/threat_query.stories.tsx | 12 ++++++------ ....tsx => three_way_diff_storybook_providers.tsx} | 2 +- 16 files changed, 66 insertions(+), 66 deletions(-) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/{final_readonly.tsx => field_readonly.tsx} (96%) rename x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/{final_readonly_storybook_providers.tsx => three_way_diff_storybook_providers.tsx} (97%) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_readonly.tsx similarity index 96% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_readonly.tsx index 5dd9c648ae078..f3d436ad7a26a 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/final_readonly.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/field_readonly.tsx @@ -22,12 +22,12 @@ import { ThreatIndexReadOnly } from './fields/threat_index/threat_index'; import { ThreatIndicatorPathReadOnly } from './fields/threat_indicator_path/threat_indicator_path'; import { ThreatQueryReadOnly } from './fields/threat_query/threat_query'; -interface FinalReadonlyProps { +interface FieldReadOnlyProps { fieldName: keyof DiffableAllFields; finalDiffableRule: DiffableAllFields; } -export function FinalReadOnly({ fieldName, finalDiffableRule }: FinalReadonlyProps) { +export function FieldReadOnly({ fieldName, finalDiffableRule }: FieldReadOnlyProps) { switch (fieldName) { case 'data_source': return ; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/data_source/data_source.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/data_source/data_source.stories.tsx index bbe64cfc4c2d0..6ffe47a254de9 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/data_source/data_source.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/data_source/data_source.stories.tsx @@ -7,9 +7,9 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; -import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; +import { ThreeWayDiffStorybookProviders } from '../../storybook/three_way_diff_storybook_providers'; import { dataSourceWithDataView, dataSourceWithIndexPatterns, @@ -17,8 +17,8 @@ import { } from '../../storybook/mocks'; export default { - component: FinalReadOnly, - title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/data_source', + component: FieldReadOnly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/data_source', }; interface TemplateProps { @@ -28,12 +28,12 @@ interface TemplateProps { const Template: Story = (args) => { return ( - - + - + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.stories.tsx index 83beedfe043e3..205e87e209068 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.stories.tsx @@ -7,9 +7,9 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; -import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; +import { ThreeWayDiffStorybookProviders } from '../../storybook/three_way_diff_storybook_providers'; import { EqlQueryReadOnly } from './eql_query'; import { dataSourceWithDataView, @@ -20,7 +20,7 @@ import { export default { component: EqlQueryReadOnly, - title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/eql_query', + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/eql_query', }; interface TemplateProps { @@ -30,12 +30,12 @@ interface TemplateProps { const Template: Story = (args) => { return ( - - + - + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/esql_query/esql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/esql_query/esql_query.stories.tsx index 39f7d621e8675..cda1c99a218bb 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/esql_query/esql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/esql_query/esql_query.stories.tsx @@ -7,12 +7,12 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; export default { - component: FinalReadOnly, - title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/esql_query', + component: FieldReadOnly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/esql_query', }; interface TemplateProps { @@ -21,7 +21,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx index e2ad4340d4aee..86202c659ccfb 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx @@ -7,12 +7,12 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields, RuleKqlQuery, } from '../../../../../../../../../common/api/detection_engine'; -import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; +import { ThreeWayDiffStorybookProviders } from '../../storybook/three_way_diff_storybook_providers'; import { dataSourceWithDataView, dataSourceWithIndexPatterns, @@ -23,8 +23,8 @@ import { } from '../../storybook/mocks'; export default { - component: FinalReadOnly, - title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/kql_query', + component: FieldReadOnly, + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/kql_query', }; interface TemplateProps { @@ -34,12 +34,12 @@ interface TemplateProps { const Template: Story = (args) => { return ( - - + - + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx index 1cdb6e8f76ee2..1b8653257e86c 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx @@ -10,8 +10,8 @@ import { useQueryClient } from '@tanstack/react-query'; import type { Story } from '@storybook/react'; import { MachineLearningJobIdReadOnly } from './machine_learning_job_id'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; -import { FinalReadOnly } from '../../final_readonly'; -import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; +import { FieldReadOnly } from '../../field_readonly'; +import { ThreeWayDiffStorybookProviders } from '../../storybook/three_way_diff_storybook_providers'; import { GET_MODULES_QUERY_KEY } from '../../../../../../../../common/components/ml_popover/hooks/use_fetch_modules_query'; import { GET_RECOGNIZER_QUERY_KEY } from '../../../../../../../../common/components/ml_popover/hooks/use_fetch_recognizer_query'; import { GET_JOBS_SUMMARY_QUERY_KEY } from '../../../../../../../../common/components/ml/hooks/use_fetch_jobs_summary_query'; @@ -19,7 +19,7 @@ import { GET_JOBS_SUMMARY_QUERY_KEY } from '../../../../../../../../common/compo export default { component: MachineLearningJobIdReadOnly, title: - 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/machine_learning_job_id', + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/machine_learning_job_id', }; const mockedModulesData = [ @@ -66,14 +66,14 @@ interface TemplateProps { const Template: Story = (args) => { return ( - + - - + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/related_integrations/related_integrations.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/related_integrations/related_integrations.stories.tsx index c2768ca9b5435..9855e2f974096 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/related_integrations/related_integrations.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/related_integrations/related_integrations.stories.tsx @@ -9,14 +9,14 @@ import React from 'react'; import { useQueryClient } from '@tanstack/react-query'; import type { Story } from '@storybook/react'; import { RelatedIntegrationsReadOnly } from './related_integrations'; -import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; -import { FinalReadOnly } from '../../final_readonly'; +import { ThreeWayDiffStorybookProviders } from '../../storybook/three_way_diff_storybook_providers'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; export default { component: RelatedIntegrationsReadOnly, title: - 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/related_integrations', + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/related_integrations', }; const mockedIntegrationsData = [ @@ -44,14 +44,14 @@ interface TemplateProps { const Template: Story = (args) => { return ( - + - - + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/required_fields/required_fields.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/required_fields/required_fields.stories.tsx index f0a7fbd761f62..2957d8ff7ceaf 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/required_fields/required_fields.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/required_fields/required_fields.stories.tsx @@ -7,12 +7,12 @@ import React from 'react'; import type { Story } from '@storybook/react'; import { RequiredFieldsReadOnly } from './required_fields'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; export default { component: RequiredFieldsReadOnly, - title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/required_fields', + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/required_fields', }; interface TemplateProps { @@ -21,7 +21,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.stories.tsx index fd0a7d4f02ffb..76775d6da4586 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.stories.tsx @@ -7,14 +7,14 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { RiskScoreMappingReadOnly } from './risk_score_mapping'; export default { component: RiskScoreMappingReadOnly, title: - 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/risk_score_mapping', + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/risk_score_mapping', }; interface TemplateProps { @@ -23,7 +23,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx index 02ed154749dfb..8371bac3f52d5 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx @@ -7,14 +7,14 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { SeverityMappingReadOnly } from './severity_mapping'; export default { component: SeverityMappingReadOnly, title: - 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/severity_mapping', + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/severity_mapping', }; interface TemplateProps { @@ -23,7 +23,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.stories.tsx index 6991b4152a6b8..4909174dcb577 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.stories.tsx @@ -7,13 +7,13 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatReadOnly } from './threat'; export default { component: ThreatReadOnly, - title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat', + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/threat', }; interface TemplateProps { @@ -22,7 +22,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.stories.tsx index 93850739e692a..c42fa2e890c52 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.stories.tsx @@ -7,13 +7,13 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatIndexReadOnly } from './threat_index'; export default { component: ThreatIndexReadOnly, - title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_index', + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/threat_index', }; interface TemplateProps { @@ -22,7 +22,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.stories.tsx index 840fd36b14f9b..34f0cdbcac317 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.stories.tsx @@ -7,14 +7,14 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatIndicatorPathReadOnly } from './threat_indicator_path'; export default { component: ThreatIndicatorPathReadOnly, title: - 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_indicator_path', + 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/threat_indicator_path', }; interface TemplateProps { @@ -23,7 +23,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.stories.tsx index 36b9c60fd4fb6..05d1aaa6cb028 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.stories.tsx @@ -7,13 +7,13 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatMappingReadOnly } from './threat_mapping'; export default { component: ThreatMappingReadOnly, - title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_mapping', + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/threat_mapping', }; interface TemplateProps { @@ -22,7 +22,7 @@ interface TemplateProps { const Template: Story = (args) => { return ( - diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.stories.tsx index a92ba1ccc460b..5b59287255bc9 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.stories.tsx @@ -7,7 +7,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; -import { FinalReadOnly } from '../../final_readonly'; +import { FieldReadOnly } from '../../field_readonly'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import { ThreatQueryReadOnly } from './threat_query'; import { @@ -16,11 +16,11 @@ import { inlineKqlQuery, mockDataView, } from '../../storybook/mocks'; -import { FinalReadOnlyStorybookProviders } from '../../storybook/final_readonly_storybook_providers'; +import { ThreeWayDiffStorybookProviders } from '../../storybook/three_way_diff_storybook_providers'; export default { component: ThreatQueryReadOnly, - title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FinalReadonly/threat_query', + title: 'Rule Management/Prebuilt Rules/Upgrade Flyout/ThreeWayDiff/FieldReadOnly/threat_query', }; interface TemplateProps { @@ -30,12 +30,12 @@ interface TemplateProps { const Template: Story = (args) => { return ( - - + - + ); }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/three_way_diff_storybook_providers.tsx similarity index 97% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx rename to x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/three_way_diff_storybook_providers.tsx index 76cbc2f8f4b4c..5c560a61dc25a 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/final_readonly_storybook_providers.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/three_way_diff_storybook_providers.tsx @@ -52,7 +52,7 @@ interface StorybookProvidersProps { kibanaServicesMock?: Record; } -export function FinalReadOnlyStorybookProviders({ +export function ThreeWayDiffStorybookProviders({ children, kibanaServicesMock, }: StorybookProvidersProps) { From 4927101028f81f3dcf01f0cedc3d034a81ec3079 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Tue, 3 Sep 2024 13:44:52 +0200 Subject: [PATCH 11/18] Fix Storybook TS --- .../fields/risk_score_mapping/risk_score_mapping.tsx | 2 +- .../final_readonly/fields/severity_mapping/severity_mapping.tsx | 2 +- .../three_way_diff/final_readonly/fields/threat/threat.tsx | 2 +- .../final_readonly/fields/threat_index/threat_index.tsx | 2 +- .../fields/threat_indicator_path/threat_indicator_path.tsx | 2 +- .../final_readonly/fields/threat_mapping/threat_mapping.tsx | 2 +- .../final_readonly/fields/threat_query/threat_query.tsx | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.tsx index bb28d48197167..5581bd588a79e 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/risk_score_mapping/risk_score_mapping.tsx @@ -12,7 +12,7 @@ import type { RiskScoreMapping } from '../../../../../../../../../common/api/det import * as ruleDetailsI18n from '../../../../translations'; import { RiskScoreMappingItem } from '../../../../rule_about_section'; -interface RiskScoreMappingReadProps { +export interface RiskScoreMappingReadProps { riskScoreMapping: RiskScoreMapping; } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.tsx index 6499375802b24..4d7b478e00f9e 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.tsx @@ -11,7 +11,7 @@ import type { SeverityMapping } from '../../../../../../../../../common/api/dete import * as ruleDetailsI18n from '../../../../translations'; import { SeverityMappingItem } from '../../../../rule_about_section'; -interface SeverityMappingReadOnlyProps { +export interface SeverityMappingReadOnlyProps { severityMapping: SeverityMapping; } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.tsx index 3b63b618685bc..587d9addab628 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat/threat.tsx @@ -11,7 +11,7 @@ import type { Threats } from '@kbn/securitysolution-io-ts-alerting-types'; import * as ruleDetailsI18n from '../../../../translations'; import { Threat } from '../../../../rule_about_section'; -interface ThreatReadOnlyProps { +export interface ThreatReadOnlyProps { threat: Threats; } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.tsx index 8419f63f6b819..23bb2cdfc8bde 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_index/threat_index.tsx @@ -10,7 +10,7 @@ import { EuiDescriptionList } from '@elastic/eui'; import * as ruleDetailsI18n from '../../../../translations'; import { ThreatIndex } from '../../../../rule_definition_section'; -interface ThreatIndexReadOnlyProps { +export interface ThreatIndexReadOnlyProps { threatIndex: string[]; } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.tsx index e42c71512cb48..c05dfbd71e14f 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_indicator_path/threat_indicator_path.tsx @@ -10,7 +10,7 @@ import { EuiDescriptionList } from '@elastic/eui'; import * as ruleDetailsI18n from '../../../../translations'; import { ThreatIndicatorPath } from '../../../../rule_about_section'; -interface ThreatIndicatorPathReadOnlyProps { +export interface ThreatIndicatorPathReadOnlyProps { threatIndicatorPath?: string; } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.tsx index 34eb2da09dce3..37c68b34a5f38 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_mapping/threat_mapping.tsx @@ -11,7 +11,7 @@ import type { ThreatMapping } from '../../../../../../../../../common/api/detect import { ThreatMapping as ThreatMappingComponent } from '../../../../rule_definition_section'; import * as ruleDetailsI18n from '../../../../translations'; -interface ThreatMappingReadOnlyProps { +export interface ThreatMappingReadOnlyProps { threatMapping: ThreatMapping; } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx index aac275f2a3a5c..d5a9f908fbee2 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx @@ -20,7 +20,7 @@ const i18nLabels = { filters: ruleDetailsI18n.THREAT_FILTERS_FIELD_LABEL, }; -interface ThreatQueryReadOnlyProps { +export interface ThreatQueryReadOnlyProps { threatQuery: InlineKqlQuery; dataSource: DiffableAllFields['data_source']; } From a0e7132503fcefa08975ec9380aa4559fc8b4ab7 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Tue, 3 Sep 2024 15:40:11 +0200 Subject: [PATCH 12/18] Move translations into the correct file --- .../description_step/translations.ts | 21 ------------------- .../rule_details/rule_definition_section.tsx | 6 +++--- .../fields/kql_query/inline_kql_query.tsx | 3 ++- .../fields/kql_query/saved_kql_query.tsx | 3 ++- .../fields/threat_query/threat_query.tsx | 2 +- .../components/rule_details/translations.ts | 21 +++++++++++++++++++ 6 files changed, 29 insertions(+), 27 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/description_step/translations.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/description_step/translations.ts index 53027ff504c24..27dfec9818eb9 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/description_step/translations.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_creation_ui/components/description_step/translations.ts @@ -35,13 +35,6 @@ export const ESQL_QUERY_LABEL = i18n.translate( } ); -export const QUERY_LANGUAGE_LABEL = i18n.translate( - 'xpack.securitySolution.detectionEngine.createRule.queryLanguageLabel', - { - defaultMessage: 'Custom query language', - } -); - export const THREAT_QUERY_LABEL = i18n.translate( 'xpack.securitySolution.detectionEngine.createRule.threatQueryLabel', { @@ -49,13 +42,6 @@ export const THREAT_QUERY_LABEL = i18n.translate( } ); -export const THREAT_QUERY_LANGUAGE_LABEL = i18n.translate( - 'xpack.securitySolution.detectionEngine.createRule.threatQueryLanguageLabel', - { - defaultMessage: 'Indicator index query language', - } -); - export const SAVED_QUERY_NAME_LABEL = i18n.translate( 'xpack.securitySolution.detectionEngine.createRule.savedIdLabel', { @@ -63,13 +49,6 @@ export const SAVED_QUERY_NAME_LABEL = i18n.translate( } ); -export const SAVED_QUERY_LANGUAGE_LABEL = i18n.translate( - 'xpack.securitySolution.detectionEngine.createRule.savedQueryLanguageLabel', - { - defaultMessage: 'Saved query language', - } -); - export const SAVED_QUERY_FILTERS_LABEL = i18n.translate( 'xpack.securitySolution.detectionEngine.createRule.savedQueryFiltersLabel', { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx index 037bb4187775b..d1dc43ac63a1e 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx @@ -458,7 +458,7 @@ const prepareDefinitionSectionListItems = ( { title: ( - {descriptionStepI18n.SAVED_QUERY_LANGUAGE_LABEL} + {i18n.SAVED_QUERY_LANGUAGE_LABEL} ), description: ( @@ -544,7 +544,7 @@ const prepareDefinitionSectionListItems = ( { title: ( - {descriptionStepI18n.QUERY_LANGUAGE_LABEL} + {i18n.QUERY_LANGUAGE_LABEL} ), description: ( @@ -677,7 +677,7 @@ const prepareDefinitionSectionListItems = ( definitionSectionListItems.push({ title: ( - {descriptionStepI18n.THREAT_QUERY_LANGUAGE_LABEL} + {i18n.THREAT_QUERY_LANGUAGE_LABEL} ), description: ( diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx index 93cd3884afe04..5754a742b224f 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx @@ -15,12 +15,13 @@ import type { InlineKqlQuery, } from '../../../../../../../../../common/api/detection_engine'; import { Query, Filters } from '../../../../rule_definition_section'; +import * as ruleDetailsI18n from '../../../../translations'; import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; import { getQueryLanguageLabel } from '../../../../helpers'; const defaultI18nLabels = { query: descriptionStepI18n.QUERY_LABEL, - language: descriptionStepI18n.QUERY_LANGUAGE_LABEL, + language: ruleDetailsI18n.QUERY_LANGUAGE_LABEL, filters: descriptionStepI18n.FILTERS_LABEL, }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx index da7a358a0a53d..694925faa827d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx @@ -15,6 +15,7 @@ import type { DiffableAllFields, } from '../../../../../../../../../common/api/detection_engine'; import { Query, SavedQueryName, Filters } from '../../../../rule_definition_section'; +import * as ruleDetailsI18n from '../../../../translations'; import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; import { useGetSavedQuery } from '../../../../../../../../detections/pages/detection_engine/rules/use_get_saved_query'; import { getQueryLanguageLabel } from '../../../../helpers'; @@ -41,7 +42,7 @@ export function SavedKqlQueryReadOnly({ kqlQuery, dataSource, ruleType }: SavedQ description: , }, { - title: descriptionStepI18n.SAVED_QUERY_LANGUAGE_LABEL, + title: ruleDetailsI18n.SAVED_QUERY_LANGUAGE_LABEL, description: getQueryLanguageLabel(savedQuery.attributes.query.language), }, ]; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx index d5a9f908fbee2..6092fd8a0e0ce 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/threat_query/threat_query.tsx @@ -16,7 +16,7 @@ import { InlineKqlQueryReadOnly } from '../kql_query/inline_kql_query'; const i18nLabels = { query: descriptionStepI18n.THREAT_QUERY_LABEL, - language: descriptionStepI18n.THREAT_QUERY_LANGUAGE_LABEL, + language: ruleDetailsI18n.THREAT_QUERY_LANGUAGE_LABEL, filters: ruleDetailsI18n.THREAT_FILTERS_FIELD_LABEL, }; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/translations.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/translations.ts index 506fc01950d17..89c22a285e327 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/translations.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/translations.ts @@ -357,6 +357,27 @@ export const CUSTOMIZED_PREBUILT_RULE_LABEL = i18n.translate( } ); +export const QUERY_LANGUAGE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.ruleDetails.queryLanguageLabel', + { + defaultMessage: 'Custom query language', + } +); + +export const THREAT_QUERY_LANGUAGE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.ruleDetails.threatQueryLanguageLabel', + { + defaultMessage: 'Indicator index query language', + } +); + +export const SAVED_QUERY_LANGUAGE_LABEL = i18n.translate( + 'xpack.securitySolution.detectionEngine.ruleDetails.savedQueryLanguageLabel', + { + defaultMessage: 'Saved query language', + } +); + export const KUERY_LANGUAGE_LABEL = i18n.translate( 'xpack.securitySolution.detectionEngine.ruleDetails.kqlLanguageLabel', { From cc068bffbba74bc4738d1917d43e4b12c4c69d09 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Sun, 8 Sep 2024 13:10:19 +0200 Subject: [PATCH 13/18] `Filters`: Use default index pattern when `data_source` is not specified --- .../rule_details/rule_definition_section.tsx | 7 ++++- .../fields/eql_query/eql_query.tsx | 6 ++--- .../fields/kql_query/inline_kql_query.tsx | 6 ++--- .../fields/kql_query/kql_query.stories.tsx | 19 +++++++++++++ .../fields/kql_query/saved_kql_query.tsx | 6 ++--- .../three_way_diff_storybook_providers.tsx | 24 +++++++++++++++-- .../use_default_index_pattern.tsx | 27 +++++++++++++++++++ 7 files changed, 83 insertions(+), 12 deletions(-) create mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/use_default_index_pattern.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx index d1dc43ac63a1e..fb5b14b579859 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx @@ -58,6 +58,7 @@ import { useRequiredFieldsStyles, } from './rule_definition_section.styles'; import { getQueryLanguageLabel } from './helpers'; +import { useDefaultIndexPattern } from './use_default_index_pattern'; interface SavedQueryNameProps { savedQueryName: string; @@ -84,9 +85,11 @@ export const Filters = ({ }: FiltersProps) => { const flattenedFilters = mapAndFlattenFilters(filters); + const defaultIndexPattern = useDefaultIndexPattern(); + const { indexPattern } = useRuleIndexPattern({ dataSourceType: dataViewId ? DataSourceType.DataView : DataSourceType.IndexPatterns, - index: index ?? [], + index: index ?? defaultIndexPattern, dataViewId, }); @@ -480,6 +483,8 @@ const prepareDefinitionSectionListItems = ( ), }); diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx index 01f7752f8e918..6e4024fa37c0d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx @@ -27,12 +27,12 @@ export function EqlQueryReadOnly({ eqlQuery, dataSource }: EqlQueryReadOnlyProps }, ]; - if (eqlQuery.filters.length > 0 && dataSource) { + if (eqlQuery.filters.length > 0) { const index = - dataSource.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; + dataSource?.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; const dataViewId = - dataSource.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; + dataSource?.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; listItems.push({ title: descriptionStepI18n.FILTERS_LABEL, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx index 5754a742b224f..7895d3ea4e863 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx @@ -51,12 +51,12 @@ export function InlineKqlQueryReadOnly({ }, ]; - if (kqlQuery.filters.length > 0 && dataSource) { + if (kqlQuery.filters.length > 0) { const index = - dataSource.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; + dataSource?.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; const dataViewId = - dataSource.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; + dataSource?.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; listItems.push({ title: i18nLabels.filters, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx index 86202c659ccfb..61d31d983b183 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/kql_query.stories.tsx @@ -75,6 +75,25 @@ InlineKqlQueryWithDataView.args = { }, }; +export const InlineKqlQueryWithoutDataSource = Template.bind({}); + +/* + Filters should still be displayed if no `data_source` is provided. + Component would fall back to the default index pattern in such case. +*/ +InlineKqlQueryWithoutDataSource.args = { + finalDiffableRule: { + kql_query: inlineKqlQuery, + }, + kibanaServicesMock: { + data: { + dataViews: { + create: async () => mockDataView(), + }, + }, + }, +}; + export const SavedKqlQueryWithIndexPatterns = Template.bind({}); SavedKqlQueryWithIndexPatterns.args = { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx index 694925faa827d..78796ab1ac454 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx @@ -54,12 +54,12 @@ export function SavedKqlQueryReadOnly({ kqlQuery, dataSource, ruleType }: SavedQ }); } - if (savedQuery.attributes.filters && dataSource) { + if (savedQuery.attributes.filters) { const index = - dataSource.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; + dataSource?.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; const dataViewId = - dataSource.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; + dataSource?.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; listItems.push({ title: descriptionStepI18n.SAVED_QUERY_FILTERS_LABEL, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/three_way_diff_storybook_providers.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/three_way_diff_storybook_providers.tsx index 5c560a61dc25a..483624b6fb408 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/three_way_diff_storybook_providers.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/three_way_diff_storybook_providers.tsx @@ -6,8 +6,10 @@ */ import React from 'react'; +import { configureStore } from '@reduxjs/toolkit'; import { merge } from 'lodash'; import { Subject } from 'rxjs'; +import { Provider as ReduxStoreProvider } from 'react-redux'; import type { CoreStart } from '@kbn/core/public'; import { createKibanaReactContext } from '@kbn/kibana-react-plugin/public'; import { ReactQueryClientProvider } from '../../../../../../../common/containers/query_client/query_client_provider'; @@ -36,7 +38,7 @@ function createKibanaServicesMock(overrides?: Partial) { }, settings: { client: { - get: () => {}, + get: (key: string, defaultOverride?: unknown) => defaultOverride, get$: () => new Subject(), set: () => {}, }, @@ -47,6 +49,20 @@ function createKibanaServicesMock(overrides?: Partial) { return merge(baseMock, overrides); } +function createMockStore() { + const store = configureStore({ + reducer: { + app: () => ({ + enableExperimental: { + prebuiltRulesCustomizationEnabled: true, + }, + }), + }, + }); + + return store; +} + interface StorybookProvidersProps { children: React.ReactNode; kibanaServicesMock?: Record; @@ -58,9 +74,13 @@ export function ThreeWayDiffStorybookProviders({ }: StorybookProvidersProps) { const KibanaReactContext = createKibanaReactContext(createKibanaServicesMock(kibanaServicesMock)); + const store = createMockStore(); + return ( - {children} + + {children} + ); } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/use_default_index_pattern.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/use_default_index_pattern.tsx new file mode 100644 index 0000000000000..3482df562bac0 --- /dev/null +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/use_default_index_pattern.tsx @@ -0,0 +1,27 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { useKibana } from '../../../../common/lib/kibana/kibana_react'; +import { DEFAULT_INDEX_KEY, DEFAULT_INDEX_PATTERN } from '../../../../../common/constants'; +import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; + +/** + * Gets the default index pattern for cases when rule has neither index patterns or data view. + * First checks the config value. If it's not present falls back to the hardcoded default value. + */ +export function useDefaultIndexPattern() { + const { services } = useKibana(); + const isPrebuiltRulesCustomizationEnabled = useIsExperimentalFeatureEnabled( + 'prebuiltRulesCustomizationEnabled' + ); + + if (isPrebuiltRulesCustomizationEnabled) { + return services.settings.client.get(DEFAULT_INDEX_KEY, DEFAULT_INDEX_PATTERN); + } + + return []; +} From e50ece0b077172eee47edec6eb5e51959da21c93 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Sun, 8 Sep 2024 15:35:00 +0200 Subject: [PATCH 14/18] Fix override value column width for Severity Override --- .../rule_details/rule_about_section.tsx | 18 ++++++++++-------- .../severity_mapping.stories.tsx | 6 +++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_about_section.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_about_section.tsx index 281d8653960ae..c7c9ec3ca732d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_about_section.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_about_section.tsx @@ -43,10 +43,10 @@ const OverrideColumn = styled(EuiFlexItem)` text-overflow: ellipsis; `; -const OverrideValueColumn = styled(EuiFlexItem)` - width: 30px; - max-width: 30px; +const OverrideValueColumn = styled.div` + width: 50px; overflow: hidden; + white-space: nowrap; text-overflow: ellipsis; `; @@ -96,16 +96,18 @@ export const SeverityMappingItem = ({ severityMappingItem }: SeverityMappingItem {`${severityMappingItem.field}:`} - + - - {defaultToEmptyTag(severityMappingItem.value)} - + + + {defaultToEmptyTag(severityMappingItem.value)} + + - + diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx index 8371bac3f52d5..92d7b95b17c2b 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/severity_mapping/severity_mapping.stories.tsx @@ -39,13 +39,13 @@ Default.args = { field: 'event.severity', operator: 'equals', severity: 'low', - value: 'not severe', + value: 'LOW', }, { - field: 'event.severity', + field: 'google_workspace.alert.metadata.severity', operator: 'equals', severity: 'high', - value: 'pretty severe', + value: 'VERY HIGH', }, ], }, From 0c3e0a03acd32d28b287fd3e6984e26fd01d9e4e Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Sun, 8 Sep 2024 16:52:25 +0200 Subject: [PATCH 15/18] Add a runtime type check for `Filters` --- .../components/rule_details/helpers.ts | 14 ++++++++++++++ .../rule_details/rule_definition_section.tsx | 2 +- .../final_readonly/fields/eql_query/eql_query.tsx | 10 +++++----- .../fields/kql_query/inline_kql_query.tsx | 11 +++++------ 4 files changed, 25 insertions(+), 12 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 3ecdf345a5902..37b275bf3482e 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 type { Filter } from '@kbn/es-query'; import type { RuleFieldsDiff, ThreeWayDiff } from '../../../../../common/api/detection_engine'; import { ThreeWayDiffOutcome } from '../../../../../common/api/detection_engine'; import type { FieldsGroupDiff } from '../../model/rule_details/rule_field_diff'; @@ -69,3 +70,16 @@ export function getQueryLanguageLabel(language: string) { return language; } } + +/** + * Assigns type `Filter` to items that have a `meta` property. Removes any other items. + */ +export function typeCheckFilters(filters: unknown[]): Filter[] { + return filters.filter((f) => { + if (typeof f === 'object' && f !== null && 'meta' in f) { + return true; + } + + return false; + }) as Filter[]; +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx index fb5b14b579859..e0b0431138508 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/rule_definition_section.tsx @@ -481,7 +481,7 @@ const prepareDefinitionSectionListItems = ( ), description: ( 0) { + const filters = typeCheckFilters(eqlQuery.filters); + + if (filters.length > 0) { const index = dataSource?.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; @@ -36,9 +38,7 @@ export function EqlQueryReadOnly({ eqlQuery, dataSource }: EqlQueryReadOnlyProps listItems.push({ title: descriptionStepI18n.FILTERS_LABEL, - description: ( - - ), + description: , }); } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx index 7895d3ea4e863..ed588468f8125 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx @@ -8,7 +8,6 @@ import React from 'react'; import { EuiDescriptionList } from '@elastic/eui'; import type { EuiDescriptionListProps } from '@elastic/eui'; -import type { Filter } from '@kbn/es-query'; import { DataSourceType } from '../../../../../../../../../common/api/detection_engine'; import type { DiffableAllFields, @@ -17,7 +16,7 @@ import type { import { Query, Filters } from '../../../../rule_definition_section'; import * as ruleDetailsI18n from '../../../../translations'; import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; -import { getQueryLanguageLabel } from '../../../../helpers'; +import { getQueryLanguageLabel, typeCheckFilters } from '../../../../helpers'; const defaultI18nLabels = { query: descriptionStepI18n.QUERY_LABEL, @@ -51,7 +50,9 @@ export function InlineKqlQueryReadOnly({ }, ]; - if (kqlQuery.filters.length > 0) { + const filters = typeCheckFilters(kqlQuery.filters); + + if (filters.length > 0) { const index = dataSource?.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; @@ -60,9 +61,7 @@ export function InlineKqlQueryReadOnly({ listItems.push({ title: i18nLabels.filters, - description: ( - - ), + description: , }); } From b56e497fd14cd126c17c0451cd778bff5418ccde Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Sun, 8 Sep 2024 17:08:14 +0200 Subject: [PATCH 16/18] Removed redundant property in ML mock --- .../machine_learning_job_id.stories.tsx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx index 1b8653257e86c..4d334f3aa57ec 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/machine_learning_job_id/machine_learning_job_id.stories.tsx @@ -52,10 +52,7 @@ function MockMlData({ children }: { children: React.ReactNode }) { queryClient.setQueryData([GET_MODULES_QUERY_KEY, {}], mockedModulesData); - queryClient.setQueryData( - [GET_RECOGNIZER_QUERY_KEY, { indexPatternName: undefined }], - mockedCompatibleModules - ); + queryClient.setQueryData([GET_RECOGNIZER_QUERY_KEY, {}], mockedCompatibleModules); return <>{children}; } From 4b06a983a6a693f0df99d7d81cad8cef23fafcd6 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Sun, 8 Sep 2024 17:09:59 +0200 Subject: [PATCH 17/18] Simplify type casting in mocks --- .../three_way_diff/final_readonly/storybook/mocks.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts index cb8cffecf0706..2b21558e9b0ca 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/storybook/mocks.ts @@ -5,6 +5,7 @@ * 2.0. */ +import type { FieldFormatsStartCommon } from '@kbn/field-formats-plugin/common'; import { DataView } from '@kbn/data-views-plugin/common'; import { DataSourceType, KqlQueryType } from '../../../../../../../../common/api/detection_engine'; import type { @@ -87,6 +88,8 @@ export function mockDataView(spec: Partial = {}): DataView '@timestamp': { name: '@timestamp', type: 'date', + searchable: true, + aggregatable: true, }, }, ...spec, @@ -95,8 +98,8 @@ export function mockDataView(spec: Partial = {}): DataView getDefaultInstance: () => ({ toJSON: () => ({}), }), - }, - } as unknown as DataViewDeps); + } as unknown as FieldFormatsStartCommon, + }); return dataView; } From 0bead120f62732302f223c274dbdfc47b3194200 Mon Sep 17 00:00:00 2001 From: Nikita Indik Date: Sun, 8 Sep 2024 17:35:04 +0200 Subject: [PATCH 18/18] `Filters`: Extract getting data source props into a separate function --- .../components/rule_details/helpers.ts | 40 ++++++++++++++++++- .../fields/eql_query/eql_query.tsx | 11 ++--- .../fields/kql_query/inline_kql_query.tsx | 11 ++--- .../fields/kql_query/saved_kql_query.tsx | 13 ++---- 4 files changed, 47 insertions(+), 28 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 37b275bf3482e..9810cd4882cc7 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 @@ -6,8 +6,12 @@ */ import type { Filter } from '@kbn/es-query'; -import type { RuleFieldsDiff, ThreeWayDiff } from '../../../../../common/api/detection_engine'; -import { ThreeWayDiffOutcome } from '../../../../../common/api/detection_engine'; +import type { + DiffableAllFields, + RuleFieldsDiff, + ThreeWayDiff, +} from '../../../../../common/api/detection_engine'; +import { DataSourceType, ThreeWayDiffOutcome } from '../../../../../common/api/detection_engine'; import type { FieldsGroupDiff } from '../../model/rule_details/rule_field_diff'; import { ABOUT_UPGRADE_FIELD_ORDER, @@ -16,6 +20,7 @@ import { SETUP_UPGRADE_FIELD_ORDER, } from './constants'; import * as i18n from './translations'; +import { assertUnreachable } from '../../../../../common/utility_types'; export const getSectionedFieldDiffs = (fields: FieldsGroupDiff[]) => { const aboutFields = []; @@ -83,3 +88,34 @@ export function typeCheckFilters(filters: unknown[]): Filter[] { return false; }) as Filter[]; } + +type DataSourceProps = + | { + index: undefined; + dataViewId: undefined; + } + | { + index: string[]; + dataViewId: undefined; + } + | { + index: undefined; + dataViewId: string; + }; + +/** + * Extracts `index` and `dataViewId` from a `data_source` object for use in the `Filters` component. + */ +export function getDataSourceProps(dataSource: DiffableAllFields['data_source']): DataSourceProps { + if (!dataSource) { + return { index: undefined, dataViewId: undefined }; + } + + if (dataSource.type === DataSourceType.index_patterns) { + return { index: dataSource.index_patterns, dataViewId: undefined }; + } else if (dataSource.type === DataSourceType.data_view) { + return { index: undefined, dataViewId: dataSource.data_view_id }; + } + + return assertUnreachable(dataSource); +} diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx index b6304f9f98415..3238e7bb7eeef 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/eql_query/eql_query.tsx @@ -8,11 +8,10 @@ import React from 'react'; import { EuiDescriptionList } from '@elastic/eui'; import type { EuiDescriptionListProps } from '@elastic/eui'; -import { DataSourceType } from '../../../../../../../../../common/api/detection_engine'; import type { DiffableAllFields } from '../../../../../../../../../common/api/detection_engine'; import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; import { Query, Filters } from '../../../../rule_definition_section'; -import { typeCheckFilters } from '../../../../helpers'; +import { getDataSourceProps, typeCheckFilters } from '../../../../helpers'; interface EqlQueryReadOnlyProps { eqlQuery: DiffableAllFields['eql_query']; @@ -30,15 +29,11 @@ export function EqlQueryReadOnly({ eqlQuery, dataSource }: EqlQueryReadOnlyProps const filters = typeCheckFilters(eqlQuery.filters); if (filters.length > 0) { - const index = - dataSource?.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; - - const dataViewId = - dataSource?.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; + const dataSourceProps = getDataSourceProps(dataSource); listItems.push({ title: descriptionStepI18n.FILTERS_LABEL, - description: , + description: , }); } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx index ed588468f8125..a70909745d8dc 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/inline_kql_query.tsx @@ -8,7 +8,6 @@ import React from 'react'; import { EuiDescriptionList } from '@elastic/eui'; import type { EuiDescriptionListProps } from '@elastic/eui'; -import { DataSourceType } from '../../../../../../../../../common/api/detection_engine'; import type { DiffableAllFields, InlineKqlQuery, @@ -16,7 +15,7 @@ import type { import { Query, Filters } from '../../../../rule_definition_section'; import * as ruleDetailsI18n from '../../../../translations'; import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; -import { getQueryLanguageLabel, typeCheckFilters } from '../../../../helpers'; +import { getDataSourceProps, getQueryLanguageLabel, typeCheckFilters } from '../../../../helpers'; const defaultI18nLabels = { query: descriptionStepI18n.QUERY_LABEL, @@ -53,15 +52,11 @@ export function InlineKqlQueryReadOnly({ const filters = typeCheckFilters(kqlQuery.filters); if (filters.length > 0) { - const index = - dataSource?.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; - - const dataViewId = - dataSource?.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; + const dataSourceProps = getDataSourceProps(dataSource); listItems.push({ title: i18nLabels.filters, - description: , + description: , }); } diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx index 78796ab1ac454..d7741f41af820 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/components/rule_details/three_way_diff/final_readonly/fields/kql_query/saved_kql_query.tsx @@ -8,7 +8,6 @@ import React from 'react'; import { EuiDescriptionList } from '@elastic/eui'; import type { EuiDescriptionListProps } from '@elastic/eui'; -import { DataSourceType } from '../../../../../../../../../common/api/detection_engine'; import type { SavedKqlQuery, DiffableRule, @@ -18,7 +17,7 @@ import { Query, SavedQueryName, Filters } from '../../../../rule_definition_sect import * as ruleDetailsI18n from '../../../../translations'; import * as descriptionStepI18n from '../../../../../../../rule_creation_ui/components/description_step/translations'; import { useGetSavedQuery } from '../../../../../../../../detections/pages/detection_engine/rules/use_get_saved_query'; -import { getQueryLanguageLabel } from '../../../../helpers'; +import { getDataSourceProps, getQueryLanguageLabel } from '../../../../helpers'; interface SavedQueryProps { kqlQuery: SavedKqlQuery; @@ -55,17 +54,11 @@ export function SavedKqlQueryReadOnly({ kqlQuery, dataSource, ruleType }: SavedQ } if (savedQuery.attributes.filters) { - const index = - dataSource?.type === DataSourceType.index_patterns ? dataSource.index_patterns : undefined; - - const dataViewId = - dataSource?.type === DataSourceType.data_view ? dataSource.data_view_id : undefined; + const dataSourceProps = getDataSourceProps(dataSource); listItems.push({ title: descriptionStepI18n.SAVED_QUERY_FILTERS_LABEL, - description: ( - - ), + description: , }); }