From 0d2f181060af69de2b9d07f6f3128ca4e5237606 Mon Sep 17 00:00:00 2001 From: Ievgen Sorokopud Date: Thu, 21 Nov 2024 17:34:41 +0100 Subject: [PATCH] Review feedback: re-structuring --- packages/deeplinks/security/deep_links.ts | 2 +- .../security_solution/common/constants.ts | 3 +- .../rule_management/api/api.ts | 62 ---------------- .../pages/siem_migrations/index.tsx | 70 ------------------ .../public/lazy_sub_plugins.tsx | 2 + .../security_solution/public/plugin.tsx | 4 ++ .../security_solution/public/rules/links.ts | 24 +------ .../security_solution/public/rules/routes.tsx | 72 ++++++++----------- .../public/siem_migrations/constants.ts | 16 +++++ .../public/siem_migrations/index.ts | 19 +++++ .../public/siem_migrations/jest.config.js | 19 +++++ .../public/siem_migrations/links.ts | 35 +++++++++ .../public/siem_migrations/routes.tsx | 31 ++++++++ .../public/siem_migrations/rules/api/api.ts | 68 ++++++++++++++++++ .../rules/api/hooks/constants.ts | 13 ++++ .../api/hooks}/use_get_rule_migrations.ts | 8 +-- .../use_get_rule_migrations_stats_all.ts | 8 +-- .../rules/components}/constants.ts | 0 .../siem_migrations_header_buttons.tsx | 0 .../siem_migrations_no_items_message.tsx | 4 +- .../components}/siem_migrations_table.tsx | 2 +- .../siem_migrations_table_context.tsx | 10 +-- .../siem_migrations_table_filters.tsx | 4 +- .../components}/status_badge/index.test.tsx | 0 .../rules/components}/status_badge/index.tsx | 4 +- .../translation_details/constants.ts | 0 .../translation_details_flyout.tsx | 6 +- .../translation_tab/header.tsx | 0 .../translation_tab/index.tsx | 2 +- .../translation_tab/rule_query.tsx | 4 +- .../translation_tab/translations.ts | 0 .../translation_details/translations.ts | 0 .../rules/components}/translations.ts | 0 .../use_filter_siem_migrations_to_install.ts | 4 +- .../use_siem_migrations_preview_flyout.tsx | 6 +- .../use_siem_migrations_table_columns.tsx | 8 +-- .../rules/components}/utils.tsx | 2 +- .../siem_migrations/rules/pages/index.tsx | 70 ++++++++++++++++++ .../rules/pages}/translations.tsx | 0 .../plugins/security_solution/public/types.ts | 3 + 40 files changed, 350 insertions(+), 235 deletions(-) delete mode 100644 x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/siem_migrations/index.tsx create mode 100644 x-pack/plugins/security_solution/public/siem_migrations/constants.ts create mode 100644 x-pack/plugins/security_solution/public/siem_migrations/index.ts create mode 100644 x-pack/plugins/security_solution/public/siem_migrations/jest.config.js create mode 100644 x-pack/plugins/security_solution/public/siem_migrations/links.ts create mode 100644 x-pack/plugins/security_solution/public/siem_migrations/routes.tsx create mode 100644 x-pack/plugins/security_solution/public/siem_migrations/rules/api/api.ts create mode 100644 x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/constants.ts rename x-pack/plugins/security_solution/public/{detection_engine/rule_management/api/hooks/siem_migrations => siem_migrations/rules/api/hooks}/use_get_rule_migrations.ts (75%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management/api/hooks/siem_migrations => siem_migrations/rules/api/hooks}/use_get_rule_migrations_stats_all.ts (81%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/constants.ts (100%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/siem_migrations_header_buttons.tsx (100%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/siem_migrations_no_items_message.tsx (91%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/siem_migrations_table.tsx (96%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/siem_migrations_table_context.tsx (91%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/siem_migrations_table_filters.tsx (89%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/status_badge/index.test.tsx (100%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/status_badge/index.tsx (90%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/translation_details/constants.ts (100%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/translation_details/translation_details_flyout.tsx (96%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/translation_details/translation_tab/header.tsx (100%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/translation_details/translation_tab/index.tsx (97%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/translation_details/translation_tab/rule_query.tsx (80%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/translation_details/translation_tab/translations.ts (100%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/translation_details/translations.ts (100%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/translations.ts (100%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/use_filter_siem_migrations_to_install.ts (86%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/use_siem_migrations_preview_flyout.tsx (91%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/use_siem_migrations_table_columns.tsx (88%) rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/components/siem_migrations => siem_migrations/rules/components}/utils.tsx (92%) create mode 100644 x-pack/plugins/security_solution/public/siem_migrations/rules/pages/index.tsx rename x-pack/plugins/security_solution/public/{detection_engine/rule_management_ui/pages/siem_migrations => siem_migrations/rules/pages}/translations.tsx (100%) diff --git a/packages/deeplinks/security/deep_links.ts b/packages/deeplinks/security/deep_links.ts index 1da816c63ce2f..c1d9b3b3cb6af 100644 --- a/packages/deeplinks/security/deep_links.ts +++ b/packages/deeplinks/security/deep_links.ts @@ -69,7 +69,7 @@ export enum SecurityPageName { rulesAdd = 'rules-add', rulesCreate = 'rules-create', rulesLanding = 'rules-landing', - rulesSiemMigrations = 'rules-siem-migrations', + siemMigrationsRules = 'siem_migrations-rules', /* * Warning: Computed values are not permitted in an enum with string valued members * All threat intelligence page names must match `TIPageId` in x-pack/plugins/threat_intelligence/public/common/navigation/types.ts diff --git a/x-pack/plugins/security_solution/common/constants.ts b/x-pack/plugins/security_solution/common/constants.ts index 73e9ef7c39589..265af5a47e1fe 100644 --- a/x-pack/plugins/security_solution/common/constants.ts +++ b/x-pack/plugins/security_solution/common/constants.ts @@ -98,7 +98,6 @@ export const RULES_LANDING_PATH = `${RULES_PATH}/landing` as const; export const RULES_ADD_PATH = `${RULES_PATH}/add_rules` as const; export const RULES_UPDATES = `${RULES_PATH}/updates` as const; export const RULES_CREATE_PATH = `${RULES_PATH}/create` as const; -export const SIEM_MIGRATIONS_PATH = `${RULES_PATH}/siem_migrations` as const; export const EXCEPTIONS_PATH = '/exceptions' as const; export const EXCEPTION_LIST_DETAIL_PATH = `${EXCEPTIONS_PATH}/details/:detailName` as const; export const HOSTS_PATH = '/hosts' as const; @@ -139,6 +138,8 @@ export const APP_BLOCKLIST_PATH = `${APP_PATH}${BLOCKLIST_PATH}` as const; export const APP_RESPONSE_ACTIONS_HISTORY_PATH = `${APP_PATH}${RESPONSE_ACTIONS_HISTORY_PATH}` as const; export const NOTES_PATH = `${MANAGEMENT_PATH}/notes` as const; +export const SIEM_MIGRATIONS_PATH = '/siem_migrations' as const; +export const SIEM_MIGRATIONS_RULES_PATH = `${SIEM_MIGRATIONS_PATH}/rules` as const; // cloud logs to exclude from default index pattern export const EXCLUDE_ELASTIC_CLOUD_INDICES = ['-*elastic-cloud-logs-*']; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts index b7d4b59cc54bb..aea4b6672659e 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/api.ts @@ -13,15 +13,6 @@ import { INTERNAL_ALERTING_API_FIND_RULES_PATH } from '@kbn/alerting-plugin/comm import { BASE_ACTION_API_PATH } from '@kbn/actions-plugin/common'; import type { ActionType, AsApiContract } from '@kbn/actions-plugin/common'; import type { ActionResult } from '@kbn/actions-plugin/server'; -import { replaceParams } from '@kbn/openapi-common/shared'; -import type { - GetAllStatsRuleMigrationResponse, - GetRuleMigrationResponse, -} from '../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; -import { - SIEM_RULE_MIGRATIONS_ALL_STATS_PATH, - SIEM_RULE_MIGRATION_PATH, -} from '../../../../common/siem_migrations/constants'; import { convertRulesFilterToKQL } from '../../../../common/detection_engine/rule_management/rule_filtering'; import type { UpgradeSpecificRulesRequest, @@ -707,56 +698,3 @@ export const bootstrapPrebuiltRules = async (): Promise => - KibanaServices.get().http.fetch( - SIEM_RULE_MIGRATIONS_ALL_STATS_PATH, - { - method: 'GET', - version: '1', - signal, - } - ); - -/** - * Retrieves all the migration rule documents of a specific migration. - * - * @param migrationId `id` of the migration to retrieve rule documents for - * @param signal AbortSignal for cancelling request - * - * @throws An error if response is not OK - */ -export const getRuleMigrations = async ({ - migrationId, - signal, -}: { - migrationId?: string; - signal: AbortSignal | undefined; -}): Promise => { - if (!migrationId) { - return []; - } - return KibanaServices.get().http.fetch( - replaceParams(SIEM_RULE_MIGRATION_PATH, { migration_id: migrationId }), - { - method: 'GET', - version: '1', - signal, - } - ); -}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/siem_migrations/index.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/siem_migrations/index.tsx deleted file mode 100644 index 4952953664716..0000000000000 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/siem_migrations/index.tsx +++ /dev/null @@ -1,70 +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 { redirectToDetections } from '../../../../detections/pages/detection_engine/rules/helpers'; -import { SecurityPageName } from '../../../../app/types'; -import { HeaderPage } from '../../../../common/components/header_page'; -import { SecuritySolutionPageWrapper } from '../../../../common/components/page_wrapper'; -import { useKibana } from '../../../../common/lib/kibana'; -import { SpyRoute } from '../../../../common/utils/route/spy_routes'; - -import { useUserData } from '../../../../detections/components/user_info'; -import { useListsConfig } from '../../../../detections/containers/detection_engine/lists/use_lists_config'; - -import * as i18n from './translations'; -import { SiemMigrationsTable } from '../../components/siem_migrations/siem_migrations_table'; -import { SiemMigrationsTableContextProvider } from '../../components/siem_migrations/siem_migrations_table_context'; -import { APP_UI_ID } from '../../../../../common'; -import { NeedAdminForUpdateRulesCallOut } from '../../../../detections/components/callouts/need_admin_for_update_callout'; -import { MissingPrivilegesCallOut } from '../../../../detections/components/callouts/missing_privileges_callout'; -import { getDetectionEngineUrl } from '../../../../common/components/link_to'; -import { SiemMigrationsHeaderButtons } from '../../components/siem_migrations/siem_migrations_header_buttons'; - -const SiemMigrationsPageComponent: React.FC = () => { - const { navigateToApp } = useKibana().services.application; - - const [{ isSignalIndexExists, isAuthenticated, hasEncryptionKey }] = useUserData(); - const { needsConfiguration: needsListsConfiguration } = useListsConfig(); - - if ( - redirectToDetections( - isSignalIndexExists, - isAuthenticated, - hasEncryptionKey, - needsListsConfiguration - ) - ) { - navigateToApp(APP_UI_ID, { - deepLinkId: SecurityPageName.alerts, - path: getDetectionEngineUrl(), - }); - return null; - } - - return ( - <> - - - - - - - - - - - - - - - ); -}; - -export const SiemMigrationsPage = React.memo(SiemMigrationsPageComponent); -SiemMigrationsPage.displayName = 'SiemMigrationsPage'; diff --git a/x-pack/plugins/security_solution/public/lazy_sub_plugins.tsx b/x-pack/plugins/security_solution/public/lazy_sub_plugins.tsx index 8bbba3885a2ab..1be423c988397 100644 --- a/x-pack/plugins/security_solution/public/lazy_sub_plugins.tsx +++ b/x-pack/plugins/security_solution/public/lazy_sub_plugins.tsx @@ -29,6 +29,7 @@ import { EntityAnalytics } from './entity_analytics'; import { Assets } from './assets'; import { Investigations } from './investigations'; import { MachineLearning } from './machine_learning'; +import { SiemMigrations } from './siem_migrations'; /** * The classes used to instantiate the sub plugins. These are grouped into a single object for the sake of bundling them in a single dynamic import. @@ -53,5 +54,6 @@ const subPluginClasses = { Assets, Investigations, MachineLearning, + SiemMigrations, }; export { subPluginClasses }; diff --git a/x-pack/plugins/security_solution/public/plugin.tsx b/x-pack/plugins/security_solution/public/plugin.tsx index b74d0cffdc88d..f933832264247 100644 --- a/x-pack/plugins/security_solution/public/plugin.tsx +++ b/x-pack/plugins/security_solution/public/plugin.tsx @@ -245,6 +245,7 @@ export class Plugin implements IPlugin { - return [ - { - path: '/rules/id/:detailName/edit', - main: EditRulePage, - exact: true, - }, - { - path: `/rules/id/:detailName/:tabName(${RuleDetailTabs.alerts}|${RuleDetailTabs.exceptions}|${RuleDetailTabs.endpointExceptions}|${RuleDetailTabs.executionResults}|${RuleDetailTabs.executionEvents})`, - main: RuleDetailsPage, - exact: true, - }, - { - path: '/rules/create', - main: CreateRulePage, - exact: true, - }, - { - path: `/rules/:tabName(${AllRulesTabs.management}|${AllRulesTabs.monitoring}|${AllRulesTabs.updates})`, - main: RulesPage, - exact: true, - }, - { - path: '/rules/add_rules', - main: AddRulesPage, - exact: true, - }, - ...(isSiemMigrationsEnabled - ? [ - { - path: '/rules/siem_migrations', - main: SiemMigrationsPage, - exact: true, - }, - ] - : []), - ]; -}; +const RulesSubRoutes = [ + { + path: '/rules/id/:detailName/edit', + main: EditRulePage, + exact: true, + }, + { + path: `/rules/id/:detailName/:tabName(${RuleDetailTabs.alerts}|${RuleDetailTabs.exceptions}|${RuleDetailTabs.endpointExceptions}|${RuleDetailTabs.executionResults}|${RuleDetailTabs.executionEvents})`, + main: RuleDetailsPage, + exact: true, + }, + { + path: '/rules/create', + main: CreateRulePage, + exact: true, + }, + { + path: `/rules/:tabName(${AllRulesTabs.management}|${AllRulesTabs.monitoring}|${AllRulesTabs.updates})`, + main: RulesPage, + exact: true, + }, + { + path: '/rules/add_rules', + main: AddRulesPage, + exact: true, + }, +]; const RulesContainerComponent: React.FC = () => { useReadonlyHeader(i18n.READ_ONLY_BADGE_TOOLTIP); - const isSiemMigrationsEnabled = useIsSiemMigrationsEnabled(); - const rulesSubRoutes = getRulesSubRoutes(isSiemMigrationsEnabled); - return ( @@ -103,7 +87,7 @@ const RulesContainerComponent: React.FC = () => { - {rulesSubRoutes.map((route) => ( + {RulesSubRoutes.map((route) => ( /x-pack/plugins/security_solution/public/siem_migrations'], + coverageDirectory: + '/target/kibana-coverage/jest/x-pack/plugins/security_solution/public/siem_migrations', + coverageReporters: ['text', 'html'], + collectCoverageFrom: [ + '/x-pack/plugins/security_solution/public/siem_migrations/**/*.{ts,tsx}', + ], + moduleNameMapper: require('../../server/__mocks__/module_name_map'), +}; diff --git a/x-pack/plugins/security_solution/public/siem_migrations/links.ts b/x-pack/plugins/security_solution/public/siem_migrations/links.ts new file mode 100644 index 0000000000000..bcdd75baad40d --- /dev/null +++ b/x-pack/plugins/security_solution/public/siem_migrations/links.ts @@ -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. + */ + +import { i18n } from '@kbn/i18n'; +import { + SecurityPageName, + SERVER_APP_ID, + SIEM_MIGRATIONS_RULES_PATH, +} from '../../common/constants'; +import { SIEM_MIGRATIONS } from '../app/translations'; +import type { LinkItem } from '../common/links/types'; +import { IconConsoleCloud } from '../common/icons/console_cloud'; + +export const siemMigrationsLinks: LinkItem = { + id: SecurityPageName.siemMigrationsRules, + title: SIEM_MIGRATIONS, + description: i18n.translate('xpack.securitySolution.appLinks.siemMigrationsRulesDescription', { + defaultMessage: 'SIEM Rules Migrations.', + }), + landingIcon: IconConsoleCloud, + path: SIEM_MIGRATIONS_RULES_PATH, + capabilities: [`${SERVER_APP_ID}.show`], + skipUrlState: true, + hideTimeline: true, + globalSearchKeywords: [ + i18n.translate('xpack.securitySolution.appLinks.siemMigrationsRules', { + defaultMessage: 'SIEM Rules Migrations', + }), + ], + experimentalKey: 'siemMigrationsEnabled', +}; diff --git a/x-pack/plugins/security_solution/public/siem_migrations/routes.tsx b/x-pack/plugins/security_solution/public/siem_migrations/routes.tsx new file mode 100644 index 0000000000000..3d6455911ab17 --- /dev/null +++ b/x-pack/plugins/security_solution/public/siem_migrations/routes.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 { TrackApplicationView } from '@kbn/usage-collection-plugin/public'; +import type { SecuritySubPluginRoutes } from '../app/types'; +import { SIEM_MIGRATIONS_RULES_PATH, SecurityPageName } from '../../common/constants'; +import { RulesPage } from './rules/pages'; +import { PluginTemplateWrapper } from '../common/components/plugin_template_wrapper'; + +export const RulesRoutes = () => { + return ( + + + + + + ); +}; + +export const routes: SecuritySubPluginRoutes = [ + { + path: SIEM_MIGRATIONS_RULES_PATH, + component: RulesRoutes, + }, +]; diff --git a/x-pack/plugins/security_solution/public/siem_migrations/rules/api/api.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/api/api.ts new file mode 100644 index 0000000000000..599bf10f22262 --- /dev/null +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/api/api.ts @@ -0,0 +1,68 @@ +/* + * 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 { replaceParams } from '@kbn/openapi-common/shared'; + +import { KibanaServices } from '../../../common/lib/kibana'; + +import { + SIEM_RULE_MIGRATIONS_ALL_STATS_PATH, + SIEM_RULE_MIGRATION_PATH, +} from '../../../../common/siem_migrations/constants'; +import type { + GetAllStatsRuleMigrationResponse, + GetRuleMigrationResponse, +} from '../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; + +/** + * Retrieves the stats for all the existing migrations, aggregated by `migration_id`. + * + * @param signal AbortSignal for cancelling request + * + * @throws An error if response is not OK + */ +export const getRuleMigrationsStatsAll = async ({ + signal, +}: { + signal: AbortSignal | undefined; +}): Promise => + KibanaServices.get().http.fetch( + SIEM_RULE_MIGRATIONS_ALL_STATS_PATH, + { + method: 'GET', + version: '1', + signal, + } + ); + +/** + * Retrieves all the migration rule documents of a specific migration. + * + * @param migrationId `id` of the migration to retrieve rule documents for + * @param signal AbortSignal for cancelling request + * + * @throws An error if response is not OK + */ +export const getRuleMigrations = async ({ + migrationId, + signal, +}: { + migrationId?: string; + signal: AbortSignal | undefined; +}): Promise => { + if (!migrationId) { + return []; + } + return KibanaServices.get().http.fetch( + replaceParams(SIEM_RULE_MIGRATION_PATH, { migration_id: migrationId }), + { + method: 'GET', + version: '1', + signal, + } + ); +}; diff --git a/x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/constants.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/constants.ts new file mode 100644 index 0000000000000..61e0d1e05f7f0 --- /dev/null +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/constants.ts @@ -0,0 +1,13 @@ +/* + * 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. + */ + +const ONE_MINUTE = 60000; + +export const DEFAULT_QUERY_OPTIONS = { + refetchIntervalInBackground: false, + staleTime: ONE_MINUTE * 5, +}; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/siem_migrations/use_get_rule_migrations.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/use_get_rule_migrations.ts similarity index 75% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/siem_migrations/use_get_rule_migrations.ts rename to x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/use_get_rule_migrations.ts index a295c376c30e3..56c6240213056 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/siem_migrations/use_get_rule_migrations.ts +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/use_get_rule_migrations.ts @@ -8,10 +8,10 @@ import type { UseQueryOptions } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query'; import { replaceParams } from '@kbn/openapi-common/shared'; -import type { GetRuleMigrationResponse } from '../../../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; -import { SIEM_RULE_MIGRATION_PATH } from '../../../../../../common/siem_migrations/constants'; -import { getRuleMigrations } from '../../api'; -import { DEFAULT_QUERY_OPTIONS } from '../constants'; +import { DEFAULT_QUERY_OPTIONS } from './constants'; +import { getRuleMigrations } from '../api'; +import type { GetRuleMigrationResponse } from '../../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; +import { SIEM_RULE_MIGRATION_PATH } from '../../../../../common/siem_migrations/constants'; export const useGetRuleMigrationsQuery = ( migrationId?: string, diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/siem_migrations/use_get_rule_migrations_stats_all.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/use_get_rule_migrations_stats_all.ts similarity index 81% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/siem_migrations/use_get_rule_migrations_stats_all.ts rename to x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/use_get_rule_migrations_stats_all.ts index bb87f874632ec..026e407050e97 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management/api/hooks/siem_migrations/use_get_rule_migrations_stats_all.ts +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/api/hooks/use_get_rule_migrations_stats_all.ts @@ -7,10 +7,10 @@ import type { UseQueryOptions } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query'; -import type { GetAllStatsRuleMigrationResponse } from '../../../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; -import { SIEM_RULE_MIGRATIONS_ALL_STATS_PATH } from '../../../../../../common/siem_migrations/constants'; -import { getRuleMigrationsStatsAll } from '../../api'; -import { DEFAULT_QUERY_OPTIONS } from '../constants'; +import { DEFAULT_QUERY_OPTIONS } from './constants'; +import { getRuleMigrationsStatsAll } from '../api'; +import type { GetAllStatsRuleMigrationResponse } from '../../../../../common/siem_migrations/model/api/rules/rule_migration.gen'; +import { SIEM_RULE_MIGRATIONS_ALL_STATS_PATH } from '../../../../../common/siem_migrations/constants'; export const GET_RULE_MIGRATIONS_STATS_ALL_QUERY_KEY = ['GET', SIEM_RULE_MIGRATIONS_ALL_STATS_PATH]; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/constants.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/constants.ts similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/constants.ts rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/constants.ts diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_header_buttons.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_header_buttons.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_header_buttons.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_header_buttons.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_no_items_message.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_no_items_message.tsx similarity index 91% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_no_items_message.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_no_items_message.tsx index 291fe8e49f400..3ce9e21227471 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_no_items_message.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_no_items_message.tsx @@ -7,8 +7,8 @@ import { EuiButton, EuiEmptyPrompt, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React from 'react'; -import { SecurityPageName } from '../../../../../common'; -import { useGetSecuritySolutionLinkProps } from '../../../../common/components/links'; +import { SecurityPageName } from '../../../../common'; +import { useGetSecuritySolutionLinkProps } from '../../../common/components/links'; import * as i18n from './translations'; const SiemMigrationsTableNoItemsMessageComponent = () => { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_table.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_table.tsx similarity index 96% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_table.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_table.tsx index 79769fcb3d461..25aafd004ce96 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_table.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_table.tsx @@ -19,7 +19,7 @@ import React from 'react'; import { RULES_TABLE_INITIAL_PAGE_SIZE, RULES_TABLE_PAGE_SIZE_OPTIONS, -} from '../rules_table/constants'; +} from '../../../detection_engine/rule_management_ui/components/rules_table/constants'; import { SiemMigrationsTableNoItemsMessage } from './siem_migrations_no_items_message'; import { useSiemMigrationsTableContext } from './siem_migrations_table_context'; import { SiemMigrationsTableFilters } from './siem_migrations_table_filters'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_table_context.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_table_context.tsx similarity index 91% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_table_context.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_table_context.tsx index 8b66dbd4a8485..6cca599f53a4d 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_table_context.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_table_context.tsx @@ -7,14 +7,14 @@ import type { Dispatch, SetStateAction } from 'react'; import React, { createContext, useCallback, useContext, useEffect, useMemo, useState } from 'react'; -import type { RuleMigration } from '../../../../../common/siem_migrations/model/rule_migration.gen'; -import { useGetRuleMigrationsStatsAllQuery } from '../../../rule_management/api/hooks/siem_migrations/use_get_rule_migrations_stats_all'; -import { useGetRuleMigrationsQuery } from '../../../rule_management/api/hooks/siem_migrations/use_get_rule_migrations'; -import type { RuleSignatureId } from '../../../../../common/api/detection_engine'; -import { invariant } from '../../../../../common/utils/invariant'; +import type { RuleMigration } from '../../../../common/siem_migrations/model/rule_migration.gen'; +import type { RuleSignatureId } from '../../../../common/api/detection_engine'; +import { invariant } from '../../../../common/utils/invariant'; import type { SiemMigrationsTableFilterOptions } from './use_filter_siem_migrations_to_install'; import { useFilterSiemMigrationsToInstall } from './use_filter_siem_migrations_to_install'; import { useSiemMigrationsPreviewFlyout } from './use_siem_migrations_preview_flyout'; +import { useGetRuleMigrationsStatsAllQuery } from '../api/hooks/use_get_rule_migrations_stats_all'; +import { useGetRuleMigrationsQuery } from '../api/hooks/use_get_rule_migrations'; export interface SiemMigrationsTableState { /** diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_table_filters.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_table_filters.tsx similarity index 89% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_table_filters.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_table_filters.tsx index a8e3f6764d2b5..8faa94f289a62 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/siem_migrations_table_filters.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/siem_migrations_table_filters.tsx @@ -10,8 +10,8 @@ import { isEqual } from 'lodash/fp'; import React, { useCallback } from 'react'; import styled from 'styled-components'; import * as i18n from './translations'; -import { TagsFilterPopover } from '../rules_table/rules_table_filters/tags_filter_popover'; -import { RuleSearchField } from '../rules_table/rules_table_filters/rule_search_field'; +import { TagsFilterPopover } from '../../../detection_engine/rule_management_ui/components/rules_table/rules_table_filters/tags_filter_popover'; +import { RuleSearchField } from '../../../detection_engine/rule_management_ui/components/rules_table/rules_table_filters/rule_search_field'; import { useSiemMigrationsTableContext } from './siem_migrations_table_context'; const FilterWrapper = styled(EuiFlexGroup)` diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/status_badge/index.test.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/status_badge/index.test.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/status_badge/index.test.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/status_badge/index.test.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/status_badge/index.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/status_badge/index.tsx similarity index 90% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/status_badge/index.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/status_badge/index.tsx index 1088805c127f2..7f5728ac9bb96 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/status_badge/index.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/status_badge/index.tsx @@ -8,8 +8,8 @@ import React from 'react'; import { euiLightVars } from '@kbn/ui-theme'; -import type { RuleMigrationTranslationResult } from '../../../../../../common/siem_migrations/model/rule_migration.gen'; -import { HealthTruncateText } from '../../../../../common/components/health_truncate_text'; +import type { RuleMigrationTranslationResult } from '../../../../../common/siem_migrations/model/rule_migration.gen'; +import { HealthTruncateText } from '../../../../common/components/health_truncate_text'; import { convertTranslationResultIntoText } from '../utils'; const { euiColorVis0, euiColorVis7, euiColorVis9 } = euiLightVars; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/constants.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/constants.ts similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/constants.ts rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/constants.ts diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_details_flyout.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_details_flyout.tsx similarity index 96% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_details_flyout.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_details_flyout.tsx index 3a0793a320ebc..e33526e885c5a 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_details_flyout.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_details_flyout.tsx @@ -25,15 +25,15 @@ import { } from '@elastic/eui'; import type { EuiTabbedContentTab, EuiTabbedContentProps, EuiFlyoutProps } from '@elastic/eui'; -import type { RuleMigration } from '../../../../../../common/siem_migrations/model/rule_migration.gen'; +import type { RuleMigration } from '../../../../../common/siem_migrations/model/rule_migration.gen'; import { RuleOverviewTab, useOverviewTabSections, -} from '../../../../rule_management/components/rule_details/rule_overview_tab'; +} from '../../../../detection_engine/rule_management/components/rule_details/rule_overview_tab'; import { type RuleResponse, type Severity, -} from '../../../../../../common/api/detection_engine/model/rule_schema'; +} from '../../../../../common/api/detection_engine/model/rule_schema'; import * as i18n from './translations'; import { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/header.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/header.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/header.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/header.tsx diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/index.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/index.tsx similarity index 97% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/index.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/index.tsx index 5772b737e227b..b3dcd8530ed2f 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/index.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/index.tsx @@ -20,7 +20,7 @@ import { } from '@elastic/eui'; import { css } from '@emotion/css'; import { FormattedMessage } from '@kbn/i18n-react'; -import type { RuleMigration } from '../../../../../../../common/siem_migrations/model/rule_migration.gen'; +import type { RuleMigration } from '../../../../../../common/siem_migrations/model/rule_migration.gen'; import { TranslationTabHeader } from './header'; import { RuleQueryComponent } from './rule_query'; import * as i18n from './translations'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/rule_query.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/rule_query.tsx similarity index 80% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/rule_query.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/rule_query.tsx index ee66cf0f0be8d..50977cafb18d0 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/rule_query.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/rule_query.tsx @@ -7,8 +7,8 @@ import React, { useMemo } from 'react'; import { EuiMarkdownEditor, EuiMarkdownFormat, EuiTitle } from '@elastic/eui'; -import { SideHeader } from '../../../../../rule_management/components/rule_details/three_way_diff/components/side_header'; -import { FinalSideHelpInfo } from '../../../../../rule_management/components/rule_details/three_way_diff/final_side/final_side_help_info'; +import { SideHeader } from '../../../../../detection_engine/rule_management/components/rule_details/three_way_diff/components/side_header'; +import { FinalSideHelpInfo } from '../../../../../detection_engine/rule_management/components/rule_details/three_way_diff/final_side/final_side_help_info'; import * as i18n from './translations'; interface RuleQueryProps { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/translations.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/translations.ts similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translation_tab/translations.ts rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translation_tab/translations.ts diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translations.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translations.ts similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translation_details/translations.ts rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/translation_details/translations.ts diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translations.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/translations.ts similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/translations.ts rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/translations.ts diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/use_filter_siem_migrations_to_install.ts b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/use_filter_siem_migrations_to_install.ts similarity index 86% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/use_filter_siem_migrations_to_install.ts rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/use_filter_siem_migrations_to_install.ts index ef9f4a7369dc6..bd4e20ba8e3de 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/use_filter_siem_migrations_to_install.ts +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/use_filter_siem_migrations_to_install.ts @@ -6,8 +6,8 @@ */ import { useMemo } from 'react'; -import type { RuleMigration } from '../../../../../common/siem_migrations/model/rule_migration.gen'; -import type { FilterOptions } from '../../../rule_management/logic/types'; +import type { RuleMigration } from '../../../../common/siem_migrations/model/rule_migration.gen'; +import type { FilterOptions } from '../../../detection_engine/rule_management/logic/types'; export type SiemMigrationsTableFilterOptions = Pick; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/use_siem_migrations_preview_flyout.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/use_siem_migrations_preview_flyout.tsx similarity index 91% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/use_siem_migrations_preview_flyout.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/use_siem_migrations_preview_flyout.tsx index ede9acad5798a..455d38fb4edf3 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/use_siem_migrations_preview_flyout.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/use_siem_migrations_preview_flyout.tsx @@ -8,9 +8,9 @@ import type { ReactNode } from 'react'; import React, { useCallback, useState, useMemo } from 'react'; import type { EuiTabbedContentTab } from '@elastic/eui'; -import type { RuleMigration } from '../../../../../common/siem_migrations/model/rule_migration.gen'; -import { invariant } from '../../../../../common/utils/invariant'; -import type { RuleSignatureId } from '../../../../../common/api/detection_engine'; +import type { RuleMigration } from '../../../../common/siem_migrations/model/rule_migration.gen'; +import { invariant } from '../../../../common/utils/invariant'; +import type { RuleSignatureId } from '../../../../common/api/detection_engine'; import { TranslationDetailsFlyout } from './translation_details/translation_details_flyout'; interface UseSiemMigrationsPreviewFlyoutParams { diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/use_siem_migrations_table_columns.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/use_siem_migrations_table_columns.tsx similarity index 88% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/use_siem_migrations_table_columns.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/use_siem_migrations_table_columns.tsx index 63a2cb9eee93f..e4f20866c5d42 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/use_siem_migrations_table_columns.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/use_siem_migrations_table_columns.tsx @@ -9,12 +9,12 @@ import type { EuiBasicTableColumn } from '@elastic/eui'; import { EuiText, EuiLink } from '@elastic/eui'; import React, { useMemo } from 'react'; import type { Severity } from '@kbn/securitysolution-io-ts-alerting-types'; -import type { RuleMigration } from '../../../../../common/siem_migrations/model/rule_migration.gen'; -import { SeverityBadge } from '../../../../common/components/severity_badge'; -import * as rulesI18n from '../../../../detections/pages/detection_engine/rules/translations'; +import type { RuleMigration } from '../../../../common/siem_migrations/model/rule_migration.gen'; +import { SeverityBadge } from '../../../common/components/severity_badge'; +import * as rulesI18n from '../../../detections/pages/detection_engine/rules/translations'; import * as i18n from './translations'; import { useSiemMigrationsTableContext } from './siem_migrations_table_context'; -import { getNormalizedSeverity } from '../rules_table/helpers'; +import { getNormalizedSeverity } from '../../../detection_engine/rule_management_ui/components/rules_table/helpers'; import { StatusBadge } from './status_badge'; import { DEFAULT_TRANSLATION_RISK_SCORE, DEFAULT_TRANSLATION_SEVERITY } from './constants'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/utils.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/utils.tsx similarity index 92% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/utils.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/components/utils.tsx index c75fc775a6832..cd49311db21eb 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/siem_migrations/utils.tsx +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/components/utils.tsx @@ -8,7 +8,7 @@ import { RuleMigrationTranslationResultEnum, type RuleMigrationTranslationResult, -} from '../../../../../common/siem_migrations/model/rule_migration.gen'; +} from '../../../../common/siem_migrations/model/rule_migration.gen'; import * as i18n from './translations'; export const convertTranslationResultIntoText = (status?: RuleMigrationTranslationResult) => { diff --git a/x-pack/plugins/security_solution/public/siem_migrations/rules/pages/index.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/pages/index.tsx new file mode 100644 index 0000000000000..ad438e41c1285 --- /dev/null +++ b/x-pack/plugins/security_solution/public/siem_migrations/rules/pages/index.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 { redirectToDetections } from '../../../detections/pages/detection_engine/rules/helpers'; +import { SecurityPageName } from '../../../app/types'; +import { HeaderPage } from '../../../common/components/header_page'; +import { SecuritySolutionPageWrapper } from '../../../common/components/page_wrapper'; +import { useKibana } from '../../../common/lib/kibana'; +import { SpyRoute } from '../../../common/utils/route/spy_routes'; + +import { useUserData } from '../../../detections/components/user_info'; +import { useListsConfig } from '../../../detections/containers/detection_engine/lists/use_lists_config'; + +import * as i18n from './translations'; +import { SiemMigrationsTable } from '../components/siem_migrations_table'; +import { SiemMigrationsTableContextProvider } from '../components/siem_migrations_table_context'; +import { APP_UI_ID } from '../../../../common'; +import { NeedAdminForUpdateRulesCallOut } from '../../../detections/components/callouts/need_admin_for_update_callout'; +import { MissingPrivilegesCallOut } from '../../../detections/components/callouts/missing_privileges_callout'; +import { getDetectionEngineUrl } from '../../../common/components/link_to'; +import { SiemMigrationsHeaderButtons } from '../components/siem_migrations_header_buttons'; + +const RulesPageComponent: React.FC = () => { + const { navigateToApp } = useKibana().services.application; + + const [{ isSignalIndexExists, isAuthenticated, hasEncryptionKey }] = useUserData(); + const { needsConfiguration: needsListsConfiguration } = useListsConfig(); + + if ( + redirectToDetections( + isSignalIndexExists, + isAuthenticated, + hasEncryptionKey, + needsListsConfiguration + ) + ) { + navigateToApp(APP_UI_ID, { + deepLinkId: SecurityPageName.alerts, + path: getDetectionEngineUrl(), + }); + return null; + } + + return ( + <> + + + + + + + + + + + + + + + ); +}; + +export const RulesPage = React.memo(RulesPageComponent); +RulesPage.displayName = 'RulesPage'; diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/siem_migrations/translations.tsx b/x-pack/plugins/security_solution/public/siem_migrations/rules/pages/translations.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/pages/siem_migrations/translations.tsx rename to x-pack/plugins/security_solution/public/siem_migrations/rules/pages/translations.tsx diff --git a/x-pack/plugins/security_solution/public/types.ts b/x-pack/plugins/security_solution/public/types.ts index 6642e02d5ecd6..9829fe2ad0c25 100644 --- a/x-pack/plugins/security_solution/public/types.ts +++ b/x-pack/plugins/security_solution/public/types.ts @@ -83,6 +83,7 @@ import type { EntityAnalytics } from './entity_analytics'; import type { Assets } from './assets'; import type { Investigations } from './investigations'; import type { MachineLearning } from './machine_learning'; +import type { SiemMigrations } from './siem_migrations'; import type { Dashboards } from './dashboards'; import type { BreadcrumbsNav } from './common/breadcrumbs/types'; @@ -243,6 +244,7 @@ export interface SubPlugins { assets: Assets; investigations: Investigations; machineLearning: MachineLearning; + siemMigrations: SiemMigrations; } // TODO: find a better way to defined these types @@ -266,4 +268,5 @@ export interface StartedSubPlugins { assets: ReturnType; investigations: ReturnType; machineLearning: ReturnType; + siemMigrations: ReturnType; }