diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 450fbb023af95..b74db49fc30ea 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -762,6 +762,7 @@ x-pack/packages/security/plugin_types_common @elastic/kibana-security x-pack/packages/security/plugin_types_public @elastic/kibana-security x-pack/packages/security/plugin_types_server @elastic/kibana-security x-pack/packages/security/role_management_model @elastic/kibana-security +x-pack/packages/security-solution/common @elastic/security-threat-hunting-investigations x-pack/packages/security-solution/distribution_bar @elastic/kibana-cloud-security-posture x-pack/plugins/security_solution_ess @elastic/security-solution x-pack/packages/security-solution/features @elastic/security-threat-hunting-explore @@ -931,7 +932,7 @@ test/plugin_functional/plugins/ui_settings_plugin @elastic/kibana-core packages/kbn-ui-shared-deps-npm @elastic/kibana-operations packages/kbn-ui-shared-deps-src @elastic/kibana-operations packages/kbn-ui-theme @elastic/kibana-operations -packages/kbn-unified-data-table @elastic/kibana-data-discovery +packages/kbn-unified-data-table @elastic/kibana-data-discovery @elastic/security-threat-hunting-investigations packages/kbn-unified-doc-viewer @elastic/kibana-data-discovery examples/unified_doc_viewer @elastic/kibana-core src/plugins/unified_doc_viewer @elastic/kibana-data-discovery @@ -1036,6 +1037,7 @@ packages/kbn-zod-helpers @elastic/security-detection-rule-management /x-pack/test_serverless/functional/test_suites/common/examples/search_examples @elastic/kibana-data-discovery /x-pack/test_serverless/functional/test_suites/common/examples/unified_field_list_examples @elastic/kibana-data-discovery /x-pack/test_serverless/functional/test_suites/common/management/data_views @elastic/kibana-data-discovery +src/plugins/discover/public/context_awareness/profile_providers/security @elastic/kibana-data-discovery @elastic/security-threat-hunting-investigations # Visualizations /src/plugins/visualize/ @elastic/kibana-visualizations diff --git a/package.json b/package.json index c07597726ca47..78d2e97408fa0 100644 --- a/package.json +++ b/package.json @@ -778,6 +778,7 @@ "@kbn/security-plugin-types-public": "link:x-pack/packages/security/plugin_types_public", "@kbn/security-plugin-types-server": "link:x-pack/packages/security/plugin_types_server", "@kbn/security-role-management-model": "link:x-pack/packages/security/role_management_model", + "@kbn/security-solution-common": "link:x-pack/packages/security-solution/common", "@kbn/security-solution-distribution-bar": "link:x-pack/packages/security-solution/distribution_bar", "@kbn/security-solution-ess": "link:x-pack/plugins/security_solution_ess", "@kbn/security-solution-features": "link:x-pack/packages/security-solution/features", diff --git a/packages/kbn-discover-utils/index.ts b/packages/kbn-discover-utils/index.ts index 656d3e1cf0fec..d494955d8d644 100644 --- a/packages/kbn-discover-utils/index.ts +++ b/packages/kbn-discover-utils/index.ts @@ -50,6 +50,7 @@ export { getLogLevelCoalescedValueLabel, LogLevelCoalescedValue, LogLevelBadge, + getFieldValue, } from './src'; export type { LogsContextService } from './src'; diff --git a/packages/kbn-discover-utils/src/utils/get_field_value.test.ts b/packages/kbn-discover-utils/src/utils/get_field_value.test.ts new file mode 100644 index 0000000000000..fcdc151f54947 --- /dev/null +++ b/packages/kbn-discover-utils/src/utils/get_field_value.test.ts @@ -0,0 +1,33 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { DataTableRecord } from '../types'; +import { getFieldValue } from './get_field_value'; + +const dataTableRecord: DataTableRecord = { + id: '1', + raw: {}, + flattened: { + 'field1.value': 'value1', + 'field2.value': ['value2'], + }, +}; + +describe('getFieldValue', () => { + it('should return the value of field correctly', () => { + expect(getFieldValue(dataTableRecord, 'field1.value')).toBe('value1'); + }); + + it('should return the first value of field correctly if field has a value of Array type', () => { + expect(getFieldValue(dataTableRecord, 'field2.value')).toBe('value2'); + }); + + it('should return undefined when field is not available', () => { + expect(getFieldValue(dataTableRecord, 'field3.value')).toBeUndefined(); + }); +}); diff --git a/packages/kbn-discover-utils/src/utils/get_field_value.ts b/packages/kbn-discover-utils/src/utils/get_field_value.ts new file mode 100644 index 0000000000000..043b5f2458a7a --- /dev/null +++ b/packages/kbn-discover-utils/src/utils/get_field_value.ts @@ -0,0 +1,14 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { DataTableRecord } from '../types'; + +export const getFieldValue = (record: DataTableRecord, field: string) => { + const value = record.flattened[field]; + return Array.isArray(value) ? value[0] : value; +}; diff --git a/packages/kbn-discover-utils/src/utils/index.ts b/packages/kbn-discover-utils/src/utils/index.ts index fd368beda5d7c..6c719f74dfa7a 100644 --- a/packages/kbn-discover-utils/src/utils/index.ts +++ b/packages/kbn-discover-utils/src/utils/index.ts @@ -15,5 +15,6 @@ export * from './get_log_document_overview'; export * from './get_message_field_with_fallbacks'; export * from './get_should_show_field_handler'; export * from './nested_fields'; +export * from './get_field_value'; export * from './calc_field_counts'; export { isLegacyTableEnabled } from './is_legacy_table_enabled'; diff --git a/packages/kbn-expandable-flyout/__mocks__/index.tsx b/packages/kbn-expandable-flyout/__mocks__/index.tsx new file mode 100644 index 0000000000000..1b35419219fbb --- /dev/null +++ b/packages/kbn-expandable-flyout/__mocks__/index.tsx @@ -0,0 +1,39 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; + +export const useExpandableFlyoutApi = jest.fn(() => ({ + openFlyout: jest.fn(), + closeFlyout: jest.fn(), + openPanels: jest.fn(), + openRightPanel: jest.fn(), + openLeftPanel: jest.fn(), + openPreviewPanel: jest.fn(), + closeRightPanel: jest.fn(), + closeLeftPanel: jest.fn(), + closePreviewPanel: jest.fn(), + closePanels: jest.fn(), + previousPreviewPanel: jest.fn(), +})); + +export const useExpandableFlyoutState = jest.fn(); + +export const ExpandableFlyoutProvider = jest.fn(({ children }: React.PropsWithChildren<{}>) => { + return <>{children}; +}); + +export const withExpandableFlyoutProvider = ( + Component: React.ComponentType +) => { + return (props: T) => { + return ; + }; +}; + +export const ExpandableFlyout = jest.fn(); diff --git a/packages/kbn-expandable-flyout/index.ts b/packages/kbn-expandable-flyout/index.ts index e5eaae99c26f8..00f9b1521cc4d 100644 --- a/packages/kbn-expandable-flyout/index.ts +++ b/packages/kbn-expandable-flyout/index.ts @@ -14,6 +14,7 @@ export { useExpandableFlyoutState } from './src/hooks/use_expandable_flyout_stat export { type FlyoutState as ExpandableFlyoutState } from './src/state'; export { ExpandableFlyoutProvider } from './src/provider'; +export { withExpandableFlyoutProvider } from './src/with_provider'; export type { ExpandableFlyoutProps } from './src'; export type { FlyoutPanelProps, PanelPath, ExpandableFlyoutApi } from './src/types'; diff --git a/packages/kbn-expandable-flyout/src/index.test.tsx b/packages/kbn-expandable-flyout/src/index.test.tsx index d08a78c706781..2235cbd5d408b 100644 --- a/packages/kbn-expandable-flyout/src/index.test.tsx +++ b/packages/kbn-expandable-flyout/src/index.test.tsx @@ -110,4 +110,27 @@ describe('ExpandableFlyout', () => { expect(getByTestId(PREVIEW_SECTION_TEST_ID)).toBeInTheDocument(); }); + + it('should not render flyout when right has value but does not matches registered panels', () => { + const state = { + byId: { + [id]: { + right: { + id: 'key1', + }, + left: undefined, + preview: undefined, + }, + }, + }; + + const { queryByTestId } = render( + + + + ); + + expect(queryByTestId('my-test-flyout')).toBeNull(); + expect(queryByTestId(RIGHT_SECTION_TEST_ID)).toBeNull(); + }); }); diff --git a/packages/kbn-expandable-flyout/src/index.tsx b/packages/kbn-expandable-flyout/src/index.tsx index ba11b597e0b06..a112187bd733b 100644 --- a/packages/kbn-expandable-flyout/src/index.tsx +++ b/packages/kbn-expandable-flyout/src/index.tsx @@ -86,7 +86,8 @@ export const ExpandableFlyout: React.FC = ({ showPreview, }); - const hideFlyout = !left && !right && !preview?.length; + const hideFlyout = !(left && leftSection) && !(right && rightSection) && !preview?.length; + if (hideFlyout) { return null; } @@ -94,6 +95,7 @@ export const ExpandableFlyout: React.FC = ({ return ( { diff --git a/packages/kbn-expandable-flyout/src/with_provider.test.tsx b/packages/kbn-expandable-flyout/src/with_provider.test.tsx new file mode 100644 index 0000000000000..e262157048778 --- /dev/null +++ b/packages/kbn-expandable-flyout/src/with_provider.test.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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { render } from '@testing-library/react'; +import { useExpandableFlyoutApi } from './hooks/use_expandable_flyout_api'; +import React from 'react'; +import { withExpandableFlyoutProvider } from './with_provider'; + +const TestComponent = () => { + useExpandableFlyoutApi(); + + return
; +}; + +describe('withExpandableFlyoutProvider', () => { + it('should throw when rendered without Expandable Provider', () => { + expect(() => render()).toThrow(); + }); + + it('should not throw when rendered with Expandable Provider', () => { + const TestComponentWithProvider = withExpandableFlyoutProvider(TestComponent); + expect(() => render()).not.toThrow(); + }); +}); diff --git a/packages/kbn-expandable-flyout/src/with_provider.tsx b/packages/kbn-expandable-flyout/src/with_provider.tsx new file mode 100644 index 0000000000000..a12b46a6405d0 --- /dev/null +++ b/packages/kbn-expandable-flyout/src/with_provider.tsx @@ -0,0 +1,25 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { ComponentType } from 'react'; +import { ExpandableFlyoutContextProviderProps } from './context'; +import { ExpandableFlyoutProvider } from './provider'; + +export const withExpandableFlyoutProvider = ( + Component: ComponentType, + expandableProviderProps?: ExpandableFlyoutContextProviderProps +) => { + return (props: Props) => { + return ( + + + + ); + }; +}; diff --git a/packages/kbn-unified-data-table/kibana.jsonc b/packages/kbn-unified-data-table/kibana.jsonc index 3fe1b76b931c3..b80f8b6a55596 100644 --- a/packages/kbn-unified-data-table/kibana.jsonc +++ b/packages/kbn-unified-data-table/kibana.jsonc @@ -2,5 +2,8 @@ "type": "shared-browser", "id": "@kbn/unified-data-table", "description": "Contains functionality for the unified data table which can be integrated into apps", - "owner": "@elastic/kibana-data-discovery" + "owner": [ + "@elastic/kibana-data-discovery", + "@elastic/security-threat-hunting-investigations" + ] } diff --git a/src/plugins/discover/public/context_awareness/profile_providers/example_data_source_profile/profile.tsx b/src/plugins/discover/public/context_awareness/profile_providers/example_data_source_profile/profile.tsx index 747bada5b0284..2d30aeee2e2c3 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/example_data_source_profile/profile.tsx +++ b/src/plugins/discover/public/context_awareness/profile_providers/example_data_source_profile/profile.tsx @@ -7,7 +7,7 @@ */ import { EuiBadge } from '@elastic/eui'; -import type { DataTableRecord } from '@kbn/discover-utils'; +import { getFieldValue } from '@kbn/discover-utils'; import type { RowControlColumn } from '@kbn/unified-data-table'; import { isOfAggregateQueryType } from '@kbn/es-query'; import { getIndexPatternFromESQLQuery } from '@kbn/esql-utils'; @@ -19,6 +19,7 @@ import { DataSourceCategory, DataSourceProfileProvider } from '../../profiles'; export const exampleDataSourceProfileProvider: DataSourceProfileProvider = { profileId: 'example-data-source-profile', + isExperimental: true, profile: { getCellRenderers: (prev) => () => ({ ...prev(), @@ -137,8 +138,3 @@ export const exampleDataSourceProfileProvider: DataSourceProfileProvider = { }; }, }; - -const getFieldValue = (record: DataTableRecord, field: string) => { - const value = record.flattened[field]; - return Array.isArray(value) ? value[0] : value; -}; diff --git a/src/plugins/discover/public/context_awareness/profile_providers/example_document_profile/profile.ts b/src/plugins/discover/public/context_awareness/profile_providers/example_document_profile/profile.ts index 9739430e08000..61045fe37c342 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/example_document_profile/profile.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/example_document_profile/profile.ts @@ -6,11 +6,12 @@ * Side Public License, v 1. */ -import type { DataTableRecord } from '@kbn/discover-utils'; +import { getFieldValue } from '@kbn/discover-utils'; import { DocumentProfileProvider, DocumentType } from '../../profiles'; export const exampleDocumentProfileProvider: DocumentProfileProvider = { profileId: 'example-document-profile', + isExperimental: true, profile: {}, resolve: (params) => { if (getFieldValue(params.record, 'data_stream.type') !== 'example') { @@ -25,8 +26,3 @@ export const exampleDocumentProfileProvider: DocumentProfileProvider = { }; }, }; - -const getFieldValue = (record: DataTableRecord, field: string) => { - const value = record.flattened[field]; - return Array.isArray(value) ? value[0] : value; -}; diff --git a/src/plugins/discover/public/context_awareness/profile_providers/example_root_pofile/profile.tsx b/src/plugins/discover/public/context_awareness/profile_providers/example_root_pofile/profile.tsx index 389059c518217..4d00318018a48 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/example_root_pofile/profile.tsx +++ b/src/plugins/discover/public/context_awareness/profile_providers/example_root_pofile/profile.tsx @@ -13,6 +13,7 @@ import { RootProfileProvider, SolutionType } from '../../profiles'; export const exampleRootProfileProvider: RootProfileProvider = { profileId: 'example-root-profile', + isExperimental: true, profile: { getCellRenderers: (prev) => () => ({ ...prev(), diff --git a/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.test.ts b/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.test.ts index 78048cdcbad60..de404317b1a39 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.test.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.test.ts @@ -12,34 +12,51 @@ import { exampleDataSourceProfileProvider } from './example_data_source_profile' import { exampleDocumentProfileProvider } from './example_document_profile'; import { exampleRootProfileProvider } from './example_root_pofile'; import { - registerEnabledProfileProviders, registerProfileProviders, + registerEnabledProfileProviders, } from './register_profile_providers'; describe('registerEnabledProfileProviders', () => { - it('should register enabled profile providers', async () => { + it('should register all profile providers', async () => { const { rootProfileServiceMock, rootProfileProviderMock } = createContextAwarenessMocks({ shouldRegisterProviders: false, }); registerEnabledProfileProviders({ profileService: rootProfileServiceMock, - availableProviders: [rootProfileProviderMock], - enabledProfileIds: ['root-profile'], + providers: [rootProfileProviderMock], + enabledExperimentalProfileIds: [], }); const context = await rootProfileServiceMock.resolve({ solutionNavId: null }); expect(rootProfileServiceMock.getProfile(context)).toBe(rootProfileProviderMock.profile); }); - it('should not register disabled profile providers', async () => { + it('should not register experimental profile providers by default', async () => { + const { rootProfileServiceMock } = createContextAwarenessMocks({ + shouldRegisterProviders: false, + }); + + registerEnabledProfileProviders({ + profileService: rootProfileServiceMock, + providers: [exampleRootProfileProvider], + enabledExperimentalProfileIds: [], + }); + const context = await rootProfileServiceMock.resolve({ solutionNavId: null }); + expect(rootProfileServiceMock.getProfile(context)).not.toBe(exampleRootProfileProvider.profile); + expect(rootProfileServiceMock.getProfile(context)).toMatchObject({}); + }); + + it('should register experimental profile providers when enabled by config', async () => { const { rootProfileServiceMock, rootProfileProviderMock } = createContextAwarenessMocks({ shouldRegisterProviders: false, }); + registerEnabledProfileProviders({ profileService: rootProfileServiceMock, - availableProviders: [rootProfileProviderMock], - enabledProfileIds: [], + providers: [exampleRootProfileProvider], + enabledExperimentalProfileIds: [exampleRootProfileProvider.profileId], }); const context = await rootProfileServiceMock.resolve({ solutionNavId: null }); + expect(rootProfileServiceMock.getProfile(context)).toBe(exampleRootProfileProvider.profile); expect(rootProfileServiceMock.getProfile(context)).not.toBe(rootProfileProviderMock.profile); }); }); @@ -54,7 +71,7 @@ describe('registerProfileProviders', () => { rootProfileService: rootProfileServiceMock, dataSourceProfileService: dataSourceProfileServiceMock, documentProfileService: documentProfileServiceMock, - experimentalProfileIds: [ + enabledExperimentalProfileIds: [ exampleRootProfileProvider.profileId, exampleDataSourceProfileProvider.profileId, exampleDocumentProfileProvider.profileId, @@ -93,7 +110,7 @@ describe('registerProfileProviders', () => { rootProfileService: rootProfileServiceMock, dataSourceProfileService: dataSourceProfileServiceMock, documentProfileService: documentProfileServiceMock, - experimentalProfileIds: [], + enabledExperimentalProfileIds: [], }); const rootContext = await rootProfileServiceMock.resolve({ solutionNavId: null }); const dataSourceContext = await dataSourceProfileServiceMock.resolve({ diff --git a/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.ts b/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.ts index 22ed673cd9558..ffbad9bfe6f71 100644 --- a/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.ts +++ b/src/plugins/discover/public/context_awareness/profile_providers/register_profile_providers.ts @@ -6,11 +6,9 @@ * Side Public License, v 1. */ -import { uniq } from 'lodash'; import type { DataSourceProfileService, DocumentProfileService, - RootProfileProvider, RootProfileService, } from '../profiles'; import type { BaseProfileProvider, BaseProfileService } from '../profile_service'; @@ -19,6 +17,7 @@ import { exampleDocumentProfileProvider } from './example_document_profile'; import { exampleRootProfileProvider } from './example_root_pofile'; import { createLogsDataSourceProfileProviders } from './logs_data_source_profile'; import { createLogDocumentProfileProvider } from './log_document_profile'; +import { createSecurityRootProfileProvider } from './security/security_root_profile'; import { createProfileProviderServices, ProfileProviderServices, @@ -28,40 +27,37 @@ export const registerProfileProviders = ({ rootProfileService, dataSourceProfileService, documentProfileService, - experimentalProfileIds, + enabledExperimentalProfileIds, }: { rootProfileService: RootProfileService; dataSourceProfileService: DataSourceProfileService; documentProfileService: DocumentProfileService; - experimentalProfileIds: string[]; + /** + * List of experimental profile Ids which are enabled in kibana config. + * */ + enabledExperimentalProfileIds: string[]; }) => { const providerServices = createProfileProviderServices(); const rootProfileProviders = createRootProfileProviders(providerServices); const dataSourceProfileProviders = createDataSourceProfileProviders(providerServices); const documentProfileProviders = createDocumentProfileProviders(providerServices); - const enabledProfileIds = uniq([ - ...extractProfileIds(rootProfileProviders), - ...extractProfileIds(dataSourceProfileProviders), - ...extractProfileIds(documentProfileProviders), - ...experimentalProfileIds, - ]); registerEnabledProfileProviders({ profileService: rootProfileService, - availableProviders: [exampleRootProfileProvider, ...rootProfileProviders], - enabledProfileIds, + providers: [...rootProfileProviders], + enabledExperimentalProfileIds, }); registerEnabledProfileProviders({ profileService: dataSourceProfileService, - availableProviders: [exampleDataSourceProfileProvider, ...dataSourceProfileProviders], - enabledProfileIds, + providers: [...dataSourceProfileProviders], + enabledExperimentalProfileIds, }); registerEnabledProfileProviders({ profileService: documentProfileService, - availableProviders: [exampleDocumentProfileProvider, ...documentProfileProviders], - enabledProfileIds, + providers: [...documentProfileProviders], + enabledExperimentalProfileIds, }); }; @@ -70,30 +66,37 @@ export const registerEnabledProfileProviders = < TService extends BaseProfileService >({ profileService, - availableProviders, - enabledProfileIds, + providers: availableProviders, + enabledExperimentalProfileIds = [], }: { profileService: TService; - availableProviders: TProvider[]; - enabledProfileIds: string[]; + providers: TProvider[]; + /** + * List of experimental profile Ids which are enabled in kibana config. + * */ + enabledExperimentalProfileIds?: string[]; }) => { for (const provider of availableProviders) { - if (enabledProfileIds.includes(provider.profileId)) { + const isProfileExperimental = provider.isExperimental ?? false; + const isProfileEnabled = + enabledExperimentalProfileIds.includes(provider.profileId) || !isProfileExperimental; + if (isProfileEnabled) { profileService.registerProvider(provider); } } }; -const extractProfileIds = (providers: Array>) => - providers.map(({ profileId }) => profileId); - -const createRootProfileProviders = (_providerServices: ProfileProviderServices) => - [] as RootProfileProvider[]; +const createRootProfileProviders = (_providerServices: ProfileProviderServices) => [ + exampleRootProfileProvider, + createSecurityRootProfileProvider(_providerServices), +]; const createDataSourceProfileProviders = (providerServices: ProfileProviderServices) => [ + exampleDataSourceProfileProvider, ...createLogsDataSourceProfileProviders(providerServices), ]; const createDocumentProfileProviders = (providerServices: ProfileProviderServices) => [ + exampleDocumentProfileProvider, createLogDocumentProfileProvider(providerServices), ]; diff --git a/src/plugins/discover/public/context_awareness/profile_providers/security/security_root_profile/index.ts b/src/plugins/discover/public/context_awareness/profile_providers/security/security_root_profile/index.ts new file mode 100644 index 0000000000000..b6bf175abed4d --- /dev/null +++ b/src/plugins/discover/public/context_awareness/profile_providers/security/security_root_profile/index.ts @@ -0,0 +1,9 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +export { createSecurityRootProfileProvider } from './profile'; diff --git a/src/plugins/discover/public/context_awareness/profile_providers/security/security_root_profile/profile.tsx b/src/plugins/discover/public/context_awareness/profile_providers/security/security_root_profile/profile.tsx new file mode 100644 index 0000000000000..1bd58e361d88b --- /dev/null +++ b/src/plugins/discover/public/context_awareness/profile_providers/security/security_root_profile/profile.tsx @@ -0,0 +1,38 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import React from 'react'; +import { getDiscoverCellRenderer } from '@kbn/security-solution-common'; +import { RootProfileProvider, SolutionType } from '../../../profiles'; +import { ProfileProviderServices } from '../../profile_provider_services'; +import { SecurityProfileProviderFactory } from '../types'; + +export const createSecurityRootProfileProvider: SecurityProfileProviderFactory< + RootProfileProvider +> = (services: ProfileProviderServices) => ({ + profileId: 'security-root-profile', + isExperimental: true, + profile: { + getCellRenderers: (prev) => () => ({ + ...prev(), + 'host.name': (props) => { + const CellRenderer = getDiscoverCellRenderer({ + fieldName: 'host.name', + }); + return ; + }, + }), + }, + resolve: (params) => { + if (params.solutionNavId === SolutionType.Security) { + return { isMatch: true, context: { solutionType: SolutionType.Security } }; + } + + return { isMatch: false }; + }, +}); diff --git a/src/plugins/discover/public/context_awareness/profile_providers/security/types.ts b/src/plugins/discover/public/context_awareness/profile_providers/security/types.ts new file mode 100644 index 0000000000000..f04ec6f00efb1 --- /dev/null +++ b/src/plugins/discover/public/context_awareness/profile_providers/security/types.ts @@ -0,0 +1,11 @@ +/* + * 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 and the Server Side Public License, v 1; you may not use this file except + * in compliance with, at your election, the Elastic License 2.0 or the Server + * Side Public License, v 1. + */ + +import { ProfileProviderServices } from '../profile_provider_services'; + +export type SecurityProfileProviderFactory = (services: ProfileProviderServices) => T; diff --git a/src/plugins/discover/public/context_awareness/profile_service.ts b/src/plugins/discover/public/context_awareness/profile_service.ts index efc143e222414..ac4f4eacee42c 100644 --- a/src/plugins/discover/public/context_awareness/profile_service.ts +++ b/src/plugins/discover/public/context_awareness/profile_service.ts @@ -20,6 +20,18 @@ export type ContextWithProfileId = TContext & { profileId: string }; export interface BaseProfileProvider { profileId: string; profile: ComposableProfile; + /** + * isExperimental Flag can be used for any profile which is under development and should not be enabled by default. + * + * Experimental profiles can still be enabled in kibana config with option `discover.experimental.enabledProfiles` as shown in example below: + * + * ```yaml + * discover.experimental.enabledProfiles: + * - example-root-profile + * - example-data-source-profile + * ``` + */ + isExperimental?: boolean; } export interface ProfileProvider diff --git a/src/plugins/discover/public/plugin.tsx b/src/plugins/discover/public/plugin.tsx index d81bacb958d38..61a205be2cff5 100644 --- a/src/plugins/discover/public/plugin.tsx +++ b/src/plugins/discover/public/plugin.tsx @@ -306,13 +306,13 @@ export class DiscoverPlugin const rootProfileService = new RootProfileService(); const dataSourceProfileService = new DataSourceProfileService(); const documentProfileService = new DocumentProfileService(); - const experimentalProfileIds = this.experimentalFeatures.enabledProfiles ?? []; + const enabledExperimentalProfileIds = this.experimentalFeatures.enabledProfiles ?? []; registerProfileProviders({ rootProfileService, dataSourceProfileService, documentProfileService, - experimentalProfileIds, + enabledExperimentalProfileIds, }); return { rootProfileService, dataSourceProfileService, documentProfileService }; diff --git a/src/plugins/discover/tsconfig.json b/src/plugins/discover/tsconfig.json index 526b3ea6ddf3c..a363981a5d731 100644 --- a/src/plugins/discover/tsconfig.json +++ b/src/plugins/discover/tsconfig.json @@ -94,7 +94,10 @@ "@kbn/search-types", "@kbn/presentation-containers", "@kbn/observability-ai-assistant-plugin", - "@kbn/fields-metadata-plugin" + "@kbn/fields-metadata-plugin", + "@kbn/security-solution-common" ], - "exclude": ["target/**/*"] + "exclude": [ + "target/**/*" + ] } diff --git a/tsconfig.base.json b/tsconfig.base.json index 846a51191ab72..d6b0733743929 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1518,6 +1518,8 @@ "@kbn/security-plugin-types-server/*": ["x-pack/packages/security/plugin_types_server/*"], "@kbn/security-role-management-model": ["x-pack/packages/security/role_management_model"], "@kbn/security-role-management-model/*": ["x-pack/packages/security/role_management_model/*"], + "@kbn/security-solution-common": ["x-pack/packages/security-solution/common"], + "@kbn/security-solution-common/*": ["x-pack/packages/security-solution/common/*"], "@kbn/security-solution-distribution-bar": ["x-pack/packages/security-solution/distribution_bar"], "@kbn/security-solution-distribution-bar/*": ["x-pack/packages/security-solution/distribution_bar/*"], "@kbn/security-solution-ess": ["x-pack/plugins/security_solution_ess"], diff --git a/x-pack/packages/security-solution/common/index.ts b/x-pack/packages/security-solution/common/index.ts new file mode 100644 index 0000000000000..ba5d797648f13 --- /dev/null +++ b/x-pack/packages/security-solution/common/index.ts @@ -0,0 +1,11 @@ +/* + * 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. + */ + +export { HostDetailsButton } from './src/cells/renderers/host'; + +export * from './src/flyout'; +export * from './src/cells/renderers'; diff --git a/x-pack/packages/security-solution/common/jest.config.js b/x-pack/packages/security-solution/common/jest.config.js new file mode 100644 index 0000000000000..7047e229df092 --- /dev/null +++ b/x-pack/packages/security-solution/common/jest.config.js @@ -0,0 +1,12 @@ +/* + * 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. + */ + +module.exports = { + preset: '@kbn/test', + rootDir: '../../../..', + roots: ['/x-pack/packages/security-solution/common'], +}; diff --git a/x-pack/packages/security-solution/common/kibana.jsonc b/x-pack/packages/security-solution/common/kibana.jsonc new file mode 100644 index 0000000000000..708feab435425 --- /dev/null +++ b/x-pack/packages/security-solution/common/kibana.jsonc @@ -0,0 +1,5 @@ +{ + "type": "shared-browser", + "id": "@kbn/security-solution-common", + "owner": "@elastic/security-threat-hunting-investigations" +} diff --git a/x-pack/packages/security-solution/common/package.json b/x-pack/packages/security-solution/common/package.json new file mode 100644 index 0000000000000..ce355e927c3df --- /dev/null +++ b/x-pack/packages/security-solution/common/package.json @@ -0,0 +1,8 @@ +{ + "name": "@kbn/security-solution-common", + "version": "1.0.0", + "description": "security solution common components which can be used in multiple plugins such as custom discover and timeline", + "license": "Elastic License 2.0", + "private": true, + "sideEffects": false +} \ No newline at end of file diff --git a/x-pack/packages/security-solution/common/src/cells/renderers/discover.ts b/x-pack/packages/security-solution/common/src/cells/renderers/discover.ts new file mode 100644 index 0000000000000..8d0393a3c6f2b --- /dev/null +++ b/x-pack/packages/security-solution/common/src/cells/renderers/discover.ts @@ -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 { DataGridCellValueElementProps } from '@kbn/unified-data-table'; +import { ComponentType, PropsWithChildren } from 'react'; +import { HostCellWithFlyoutRenderer } from './host'; + +export type DiscoverCellRenderer = ComponentType>; + +const RENDERERS: Record = { + 'host.name': HostCellWithFlyoutRenderer, +}; + +interface GetRendererArgs { + fieldName: string; +} + +export const getDiscoverCellRenderer = ({ fieldName }: GetRendererArgs) => { + return RENDERERS[fieldName]; +}; diff --git a/x-pack/packages/security-solution/common/src/cells/renderers/get.ts b/x-pack/packages/security-solution/common/src/cells/renderers/get.ts new file mode 100644 index 0000000000000..3102c520e31db --- /dev/null +++ b/x-pack/packages/security-solution/common/src/cells/renderers/get.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export { getDiscoverCellRenderer } from './discover'; +export type { DiscoverCellRenderer } from './discover'; diff --git a/x-pack/packages/security-solution/common/src/cells/renderers/host/button.test.tsx b/x-pack/packages/security-solution/common/src/cells/renderers/host/button.test.tsx new file mode 100644 index 0000000000000..d49af3ed50518 --- /dev/null +++ b/x-pack/packages/security-solution/common/src/cells/renderers/host/button.test.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 { HostDetailsButton } from './button'; +import { render, screen } from '@testing-library/react'; + +const onClickMock = jest.fn(); +const TestComponent = () => { + return {'Test'}; +}; + +describe('Host Button', () => { + it('should render as button with link formatting', () => { + render(); + expect(screen.getByTestId('host-details-button')).toBeVisible(); + expect(screen.getByTestId('host-details-button')).toHaveAttribute('type', 'button'); + expect(screen.getByTestId('host-details-button')).toHaveClass('euiLink'); + }); + + it('should perform onClick Correctly', () => { + render(); + screen.getByTestId('host-details-button').click(); + expect(onClickMock).toHaveBeenCalled(); + }); +}); diff --git a/x-pack/packages/security-solution/common/src/cells/renderers/host/button.tsx b/x-pack/packages/security-solution/common/src/cells/renderers/host/button.tsx new file mode 100644 index 0000000000000..b478ee17bf9d4 --- /dev/null +++ b/x-pack/packages/security-solution/common/src/cells/renderers/host/button.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, { SyntheticEvent } from 'react'; +import { EuiLink } from '@elastic/eui'; + +interface HostDetailsButtonProps { + children?: React.ReactNode; + onClick?: (e: SyntheticEvent) => void; + title?: string; +} + +export const HostDetailsButton: React.FC = ({ + children, + onClick, + title, +}) => { + return ( + + {children} + + ); +}; diff --git a/x-pack/packages/security-solution/common/src/cells/renderers/host/index.tsx b/x-pack/packages/security-solution/common/src/cells/renderers/host/index.tsx new file mode 100644 index 0000000000000..a39397b233d60 --- /dev/null +++ b/x-pack/packages/security-solution/common/src/cells/renderers/host/index.tsx @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export * from './button'; +export * from './with_expandable_flyout'; diff --git a/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.test.tsx b/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.test.tsx new file mode 100644 index 0000000000000..0568c656cdbe5 --- /dev/null +++ b/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.test.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 { + HostCellWithFlyoutRenderer, + HostCellWithFlyoutRendererProps, +} from './with_expandable_flyout'; +import React from 'react'; +import { render, screen } from '@testing-library/react'; + +const renderTestComponents = (props?: Partial) => { + const finalProps: HostCellWithFlyoutRendererProps = { + rowIndex: 0, + columnId: 'test', + setCellProps: jest.fn(), + isExpandable: false, + isExpanded: true, + isDetails: false, + colIndex: 0, + fieldFormats: {} as HostCellWithFlyoutRendererProps['fieldFormats'], + dataView: {} as HostCellWithFlyoutRendererProps['dataView'], + closePopover: jest.fn(), + row: { + id: '1', + raw: { + _source: { + host: { + name: 'test-host-name', + }, + }, + }, + flattened: { + 'host.name': 'test-host-name', + }, + }, + ...props, + }; + return render(); +}; + +describe('With Expandable Flyout', () => { + it('should open Expandable Flyout on Click', () => { + renderTestComponents(); + + expect(screen.getByTestId('host-details-button')).toBeVisible(); + screen.getByTestId('host-details-button').click(); + expect(screen.getByTestId('host-name-flyout')).toBeVisible(); + expect(screen.getByText('Host Flyout Header - test-host-name')).toBeVisible(); + }); +}); diff --git a/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.tsx b/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.tsx new file mode 100644 index 0000000000000..f870fd9f7d04e --- /dev/null +++ b/x-pack/packages/security-solution/common/src/cells/renderers/host/with_expandable_flyout.tsx @@ -0,0 +1,66 @@ +/* + * 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, { useCallback, useMemo } from 'react'; +import { getFieldValue } from '@kbn/discover-utils'; +import type { PropsWithChildren } from 'react'; +import type { DataGridCellValueElementProps } from '@kbn/unified-data-table'; +import { + ExpandableFlyout, + type ExpandableFlyoutProps, + useExpandableFlyoutApi, + withExpandableFlyoutProvider, +} from '@kbn/expandable-flyout'; +import { HostRightPanel, HostRightPanelProps } from '../../../flyout/panels'; +import { HostDetailsButton } from './button'; + +export type HostCellWithFlyoutRendererProps = PropsWithChildren; + +const HostCellWithFlyoutRendererComp = React.memo(function HostCellWithFlyoutRendererComp( + props: HostCellWithFlyoutRendererProps +) { + const hostName = getFieldValue(props.row, 'host.name'); + + const { openFlyout } = useExpandableFlyoutApi(); + + const onClick = useCallback(() => { + openFlyout({ + right: { + id: `host-panel-${hostName}-${props.rowIndex}`, + params: { + hostName, + }, + } as HostRightPanelProps, + }); + }, [openFlyout, hostName, props.rowIndex]); + + const panels: ExpandableFlyoutProps['registeredPanels'] = useMemo(() => { + return [ + { + key: `host-panel-${hostName}-${props.rowIndex}`, + component: (panelProps) => { + return ; + }, + }, + ]; + }, [hostName, props.rowIndex]); + + return ( + <> + + {hostName} + + ); +}); + +export const HostCellWithFlyoutRenderer = withExpandableFlyoutProvider( + HostCellWithFlyoutRendererComp +); diff --git a/x-pack/packages/security-solution/common/src/cells/renderers/index.ts b/x-pack/packages/security-solution/common/src/cells/renderers/index.ts new file mode 100644 index 0000000000000..e42333a710c04 --- /dev/null +++ b/x-pack/packages/security-solution/common/src/cells/renderers/index.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export * from './get'; diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/expandable_panel.stories.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/expandable_panel.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/expandable_panel.stories.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/expandable_panel.stories.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/expandable_panel.test.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/expandable_panel.test.tsx similarity index 97% rename from x-pack/plugins/security_solution/public/flyout/shared/components/expandable_panel.test.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/expandable_panel.test.tsx index 483ee3d378bbd..cc282eb1156b5 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/expandable_panel.test.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/expandable_panel.test.tsx @@ -13,12 +13,12 @@ import { EXPANDABLE_PANEL_CONTENT_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from './test_ids'; -import { ThemeProvider } from 'styled-components'; -import { getMockTheme } from '../../../common/lib/kibana/kibana_react.mock'; +} from '../test_ids'; +import { ThemeProvider } from '@emotion/react'; import { ExpandablePanel } from './expandable_panel'; -const mockTheme = getMockTheme({ eui: { euiColorMediumShade: '#ece' } }); +const mockTheme = { eui: { euiColorMediumShade: '#ece' } }; + const TEST_ID = 'test-id'; const defaultProps = { header: { diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/expandable_panel.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/expandable_panel.tsx similarity index 97% rename from x-pack/plugins/security_solution/public/flyout/shared/components/expandable_panel.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/expandable_panel.tsx index aa97446f701e1..4f1890e58554f 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/expandable_panel.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/expandable_panel.tsx @@ -102,7 +102,7 @@ export const ExpandablePanel: FC> = > = diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_body.test.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_body.test.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_body.test.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_body.test.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_body.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_body.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_body.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_body.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_error.stories.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_error.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_error.stories.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_error.stories.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_error.test.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_error.test.tsx similarity index 94% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_error.test.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_error.test.tsx index e58d586a063b5..f0565fe1df43f 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_error.test.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_error.test.tsx @@ -9,7 +9,7 @@ import React from 'react'; import { __IntlProvider as IntlProvider } from '@kbn/i18n-react'; import { render } from '@testing-library/react'; import { FlyoutError } from './flyout_error'; -import { FLYOUT_ERROR_TEST_ID } from './test_ids'; +import { FLYOUT_ERROR_TEST_ID } from '../test_ids'; describe('', () => { it('should render error title and body', () => { diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_error.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_error.tsx similarity index 84% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_error.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_error.tsx index 9ebef345540fe..f319d80dafe12 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_error.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_error.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { EuiEmptyPrompt, EuiFlexItem } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; -import { FLYOUT_ERROR_TEST_ID } from './test_ids'; +import { FLYOUT_ERROR_TEST_ID } from '../test_ids'; /** * Use this when you need to show an error state in the flyout @@ -21,7 +21,7 @@ export const FlyoutError: React.VFC = () => ( title={

@@ -30,7 +30,7 @@ export const FlyoutError: React.VFC = () => ( body={

diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_footer.test.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_footer.test.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_footer.test.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_footer.test.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_footer.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_footer.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_footer.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_footer.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_header.test.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_header.test.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_header.test.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_header.test.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_header.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_header.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_header.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_header.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_header_tabs.test.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_header_tabs.test.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_header_tabs.test.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_header_tabs.test.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_header_tabs.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_header_tabs.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_header_tabs.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_header_tabs.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_loading.stories.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_loading.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_loading.stories.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_loading.stories.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_loading.test.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_loading.test.tsx similarity index 94% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_loading.test.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_loading.test.tsx index a164db8a6ce01..d55e85b3e978b 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_loading.test.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_loading.test.tsx @@ -7,7 +7,7 @@ import React from 'react'; import { render } from '@testing-library/react'; -import { FLYOUT_LOADING_TEST_ID } from './test_ids'; +import { FLYOUT_LOADING_TEST_ID } from '../test_ids'; import { FlyoutLoading } from './flyout_loading'; describe('', () => { diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_loading.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_loading.tsx similarity index 94% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_loading.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_loading.tsx index 0c98957dd929b..cffe17c8ccbf1 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_loading.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_loading.tsx @@ -8,7 +8,7 @@ import React from 'react'; import { EuiFlexItem, EuiLoadingSpinner } from '@elastic/eui'; import { css } from '@emotion/react'; -import { FLYOUT_LOADING_TEST_ID } from './test_ids'; +import { FLYOUT_LOADING_TEST_ID } from '../test_ids'; export interface FlyoutLoadingProps { /** diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_navigation.stories.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_navigation.stories.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_navigation.stories.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_navigation.stories.tsx diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_navigation.test.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_navigation.test.tsx similarity index 78% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_navigation.test.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_navigation.test.tsx index 321245ccde86e..d010796008880 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_navigation.test.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_navigation.test.tsx @@ -8,39 +8,61 @@ import type { FC, PropsWithChildren } from 'react'; import React from 'react'; import { act, render } from '@testing-library/react'; -import { TestProviders } from '../../../common/mock'; import { FlyoutNavigation } from './flyout_navigation'; import { COLLAPSE_DETAILS_BUTTON_TEST_ID, EXPAND_DETAILS_BUTTON_TEST_ID, HEADER_ACTIONS_TEST_ID, -} from './test_ids'; -import type { ExpandableFlyoutState } from '@kbn/expandable-flyout'; +} from '../test_ids'; import { + ExpandableFlyoutApi, + ExpandableFlyoutProvider, + ExpandableFlyoutState, useExpandableFlyoutApi, - type ExpandableFlyoutApi, useExpandableFlyoutState, } from '@kbn/expandable-flyout'; +import { I18nProvider } from '@kbn/i18n-react'; const expandDetails = jest.fn(); - -const ExpandableFlyoutTestProviders: FC> = ({ children }) => { - return {children}; -}; +const mockFlyoutCloseLeftPanel = jest.fn(); jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), + useExpandableFlyoutApi: jest.fn(() => { + return { + closeFlyout: jest.fn(), + closeLeftPanel: jest.fn(), + closePreviewPanel: jest.fn(), + closeRightPanel: jest.fn(), + previousPreviewPanel: jest.fn(), + openFlyout: jest.fn(), + openLeftPanel: jest.fn(), + openPreviewPanel: jest.fn(), + openRightPanel: jest.fn(), + }; + }), useExpandableFlyoutState: jest.fn(), ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, + withExpandableFlyoutProvider: (Component: React.ComponentType) => { + return (props: T) => { + return ; + }; + }, + ExpandableFlyout: jest.fn(), })); -const flyoutContextValue = { - closeLeftPanel: jest.fn(), -} as unknown as ExpandableFlyoutApi; +const ExpandableFlyoutTestProviders: FC> = ({ children }) => { + return ( + + {children} + + ); +}; describe('', () => { beforeEach(() => { - jest.mocked(useExpandableFlyoutApi).mockReturnValue(flyoutContextValue); + jest.mocked(useExpandableFlyoutApi).mockReturnValue({ + closeLeftPanel: mockFlyoutCloseLeftPanel, + } as unknown as ExpandableFlyoutApi); jest.mocked(useExpandableFlyoutState).mockReturnValue({} as unknown as ExpandableFlyoutState); }); @@ -75,7 +97,7 @@ describe('', () => { expect(queryByTestId(EXPAND_DETAILS_BUTTON_TEST_ID)).not.toBeInTheDocument(); getByTestId(COLLAPSE_DETAILS_BUTTON_TEST_ID).click(); - expect(flyoutContextValue.closeLeftPanel).toHaveBeenCalled(); + expect(mockFlyoutCloseLeftPanel).toHaveBeenCalled(); }); }); diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_navigation.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_navigation.tsx similarity index 91% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_navigation.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_navigation.tsx index 35e684e35613a..c67f20119031e 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_navigation.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_navigation.tsx @@ -23,7 +23,7 @@ import { COLLAPSE_DETAILS_BUTTON_TEST_ID, EXPAND_DETAILS_BUTTON_TEST_ID, HEADER_NAVIGATION_BUTTON_TEST_ID, -} from './test_ids'; +} from '../test_ids'; export interface FlyoutNavigationProps { /** @@ -62,14 +62,14 @@ export const FlyoutNavigation: FC = memo( size="s" data-test-subj={COLLAPSE_DETAILS_BUTTON_TEST_ID} aria-label={i18n.translate( - 'xpack.securitySolution.flyout.right.header.collapseDetailButtonAriaLabel', + 'securitySolutionPackages.flyout.right.header.collapseDetailButtonAriaLabel', { defaultMessage: 'Collapse details', } )} > @@ -86,14 +86,14 @@ export const FlyoutNavigation: FC = memo( size="s" data-test-subj={EXPAND_DETAILS_BUTTON_TEST_ID} aria-label={i18n.translate( - 'xpack.securitySolution.flyout.right.header.expandDetailButtonAriaLabel', + 'securitySolutionPackages.flyout.right.header.expandDetailButtonAriaLabel', { defaultMessage: 'Expand details', } )} > diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_title.stories.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_title.stories.tsx similarity index 98% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_title.stories.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_title.stories.tsx index 063e9fe9ef38f..867430167a349 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_title.stories.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_title.stories.tsx @@ -8,7 +8,7 @@ import React from 'react'; import type { Story } from '@storybook/react'; import { EuiLink } from '@elastic/eui'; -import styled from 'styled-components'; +import styled from '@emotion/styled'; import { FlyoutTitle } from './flyout_title'; const FixWidthWrapper = styled.div` diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_title.test.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_title.test.tsx similarity index 98% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_title.test.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_title.test.tsx index 1f2d0c128f411..3fde2b034219b 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_title.test.tsx +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_title.test.tsx @@ -12,7 +12,7 @@ import { TITLE_HEADER_ICON_TEST_ID, TITLE_HEADER_TEXT_TEST_ID, TITLE_LINK_ICON_TEST_ID, -} from './test_ids'; +} from '../test_ids'; const title = 'test title'; const TEST_ID = 'test'; diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/flyout_title.tsx b/x-pack/packages/security-solution/common/src/flyout/common/components/flyout_title.tsx similarity index 100% rename from x-pack/plugins/security_solution/public/flyout/shared/components/flyout_title.tsx rename to x-pack/packages/security-solution/common/src/flyout/common/components/flyout_title.tsx diff --git a/x-pack/packages/security-solution/common/src/flyout/common/components/index.ts b/x-pack/packages/security-solution/common/src/flyout/common/components/index.ts new file mode 100644 index 0000000000000..4624ae2f70c55 --- /dev/null +++ b/x-pack/packages/security-solution/common/src/flyout/common/components/index.ts @@ -0,0 +1,16 @@ +/* + * 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. + */ + +export { FlyoutFooter } from './flyout_footer'; +export { FlyoutError } from './flyout_error'; +export { FlyoutLoading } from './flyout_loading'; +export { FlyoutNavigation } from './flyout_navigation'; +export { FlyoutTitle } from './flyout_title'; +export { FlyoutBody } from './flyout_body'; +export { FlyoutHeader } from './flyout_header'; +export { FlyoutHeaderTabs } from './flyout_header_tabs'; +export { ExpandablePanel } from './expandable_panel'; diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/test_ids.ts b/x-pack/packages/security-solution/common/src/flyout/common/test_ids.ts similarity index 97% rename from x-pack/plugins/security_solution/public/flyout/shared/components/test_ids.ts rename to x-pack/packages/security-solution/common/src/flyout/common/test_ids.ts index 9df26dbfb694d..60ccb0a234fde 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/test_ids.ts +++ b/x-pack/packages/security-solution/common/src/flyout/common/test_ids.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { PREFIX } from '../test_ids'; +export const PREFIX = 'securitySolutionFlyout' as const; export const FLYOUT_ERROR_TEST_ID = `${PREFIX}Error` as const; export const FLYOUT_LOADING_TEST_ID = `${PREFIX}Loading` as const; diff --git a/x-pack/packages/security-solution/common/src/flyout/index.tsx b/x-pack/packages/security-solution/common/src/flyout/index.tsx new file mode 100644 index 0000000000000..e919538d497c6 --- /dev/null +++ b/x-pack/packages/security-solution/common/src/flyout/index.tsx @@ -0,0 +1,10 @@ +/* + * 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. + */ + +export * from './common/components'; +export * from './common/test_ids'; +export { HostRightPanel } from './panels'; diff --git a/x-pack/packages/security-solution/common/src/flyout/panels/host/right/index.tsx b/x-pack/packages/security-solution/common/src/flyout/panels/host/right/index.tsx new file mode 100644 index 0000000000000..d877695f5b170 --- /dev/null +++ b/x-pack/packages/security-solution/common/src/flyout/panels/host/right/index.tsx @@ -0,0 +1,37 @@ +/* + * 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 { FlyoutPanelProps } from '@kbn/expandable-flyout'; +import React from 'react'; +import { + FlyoutBody, + FlyoutFooter, + FlyoutHeader, + FlyoutNavigation, +} from '../../../common/components'; +// import { getEntityTableColumns } from './columns'; +// import type { BasicEntityData, EntityTableRows } from './types'; + +export interface HostRightPanelParamProps extends Record { + hostName: string; +} + +export interface HostRightPanelProps extends FlyoutPanelProps { + key: 'host'; + params: HostRightPanelParamProps; +} + +export const HostRightPanel = (props: HostRightPanelParamProps) => { + return ( + <> + + {`Host Flyout Header - ${props.hostName}`} + {'Host Flyout'} + {'Host Flyout Footer'} + + ); +}; diff --git a/x-pack/packages/security-solution/common/src/flyout/panels/index.ts b/x-pack/packages/security-solution/common/src/flyout/panels/index.ts new file mode 100644 index 0000000000000..3134078ebdf7f --- /dev/null +++ b/x-pack/packages/security-solution/common/src/flyout/panels/index.ts @@ -0,0 +1,9 @@ +/* + * 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. + */ + +export * from './host/right'; +export * from './keys'; diff --git a/x-pack/packages/security-solution/common/src/flyout/panels/keys.ts b/x-pack/packages/security-solution/common/src/flyout/panels/keys.ts new file mode 100644 index 0000000000000..fe06cf652d016 --- /dev/null +++ b/x-pack/packages/security-solution/common/src/flyout/panels/keys.ts @@ -0,0 +1,8 @@ +/* + * 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. + */ + +export const HOST_PANEL = 'host-panel'; diff --git a/x-pack/packages/security-solution/common/tsconfig.json b/x-pack/packages/security-solution/common/tsconfig.json new file mode 100644 index 0000000000000..fb0d3709961d8 --- /dev/null +++ b/x-pack/packages/security-solution/common/tsconfig.json @@ -0,0 +1,28 @@ +{ + "extends": "../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": [ + "jest", + "node", + "react", + "@testing-library/jest-dom", + "@testing-library/react", + "@emotion/react/types/css-prop" + ] + }, + "include": [ + "**/*.ts", + "**/*.tsx" + ], + "kbn_references": [ + "@kbn/unified-data-table", + "@kbn/discover-utils", + "@kbn/expandable-flyout", + "@kbn/i18n", + "@kbn/i18n-react" + ], + "exclude": [ + "target/**/*" + ] +} diff --git a/x-pack/plugins/security_solution/public/attack_discovery/attack_discovery_markdown_formatter/field_markdown_renderer/index.test.tsx b/x-pack/plugins/security_solution/public/attack_discovery/attack_discovery_markdown_formatter/field_markdown_renderer/index.test.tsx index 8f647d02a626f..344370c0f165f 100644 --- a/x-pack/plugins/security_solution/public/attack_discovery/attack_discovery_markdown_formatter/field_markdown_renderer/index.test.tsx +++ b/x-pack/plugins/security_solution/public/attack_discovery/attack_discovery_markdown_formatter/field_markdown_renderer/index.test.tsx @@ -11,10 +11,9 @@ import React from 'react'; import { TestProviders } from '../../../common/mock'; import { getFieldMarkdownRenderer } from '.'; +import { createExpandableFlyoutApiMock } from '../../../common/mock/expandable_flyout'; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), -})); +jest.mock('@kbn/expandable-flyout'); describe('getFieldMarkdownRenderer', () => { const mockOpenRightPanel = jest.fn(); @@ -26,14 +25,7 @@ describe('getFieldMarkdownRenderer', () => { jest.clearAllMocks(); mockUseExpandableFlyoutApi.mockReturnValue({ - closeFlyout: jest.fn(), - closeLeftPanel: jest.fn(), - closePreviewPanel: jest.fn(), - closeRightPanel: jest.fn(), - previousPreviewPanel: jest.fn(), - openFlyout: jest.fn(), - openLeftPanel: jest.fn(), - openPreviewPanel: jest.fn(), + ...createExpandableFlyoutApiMock(), openRightPanel: mockOpenRightPanel, }); }); diff --git a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.test.tsx b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.test.tsx index a680590d3752a..17039cd443888 100644 --- a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.test.tsx @@ -16,6 +16,9 @@ import type { RouteSpyState } from '../../../utils/route/types'; import { SecurityPageName } from '@kbn/deeplinks-security'; import { createTelemetryServiceMock } from '../../../lib/telemetry/telemetry_service.mock'; import { DocumentDetailsRightPanelKey } from '../../../../flyout/document_details/shared/constants/panel_keys'; +import type { ExpandableFlyoutState } from '@kbn/expandable-flyout'; +import { useExpandableFlyoutApi, useExpandableFlyoutState } from '@kbn/expandable-flyout'; +import { createExpandableFlyoutApiMock } from '../../../mock/expandable_flyout'; const mockDispatch = jest.fn(); jest.mock('react-redux', () => { @@ -26,16 +29,11 @@ jest.mock('react-redux', () => { useDispatch: () => mockDispatch, }; }); -const mockOpenFlyout = jest.fn(); jest.mock('../../../utils/route/use_route_spy'); -jest.mock('@kbn/expandable-flyout', () => { - return { - useExpandableFlyoutApi: () => ({ openFlyout: mockOpenFlyout }), - useExpandableFlyoutState: () => ({ left: false }), - }; -}); +const mockOpenFlyout = jest.fn(); +jest.mock('@kbn/expandable-flyout'); const mockedTelemetry = createTelemetryServiceMock(); jest.mock('../../../lib/kibana', () => { @@ -102,6 +100,11 @@ describe('RowAction', () => { }; beforeEach(() => { + jest.mocked(useExpandableFlyoutApi).mockReturnValue({ + ...createExpandableFlyoutApiMock(), + openFlyout: mockOpenFlyout, + }); + jest.mocked(useExpandableFlyoutState).mockReturnValue({} as unknown as ExpandableFlyoutState); (useRouteSpy as jest.Mock).mockReturnValue([mockRouteSpy]); jest.clearAllMocks(); }); diff --git a/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts b/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts index 14800d0a2b78f..27a6d28418e9e 100644 --- a/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts +++ b/x-pack/plugins/security_solution/public/common/lib/kibana/kibana_react.mock.ts @@ -58,6 +58,7 @@ import { indexPatternFieldEditorPluginMock } from '@kbn/data-view-field-editor-p import { UpsellingService } from '@kbn/security-solution-upselling/service'; import { calculateBounds } from '@kbn/data-plugin/common'; import { alertingPluginMock } from '@kbn/alerting-plugin/public/mocks'; +import { createTelemetryServiceMock } from '../telemetry/telemetry_service.mock'; const mockUiSettings: Record = { [DEFAULT_TIME_RANGE]: { from: 'now-15m', to: 'now', mode: 'quick' }, @@ -214,7 +215,7 @@ export const createStartServicesMock = ( ml: { locator, }, - telemetry: {}, + telemetry: createTelemetryServiceMock(), theme: themeServiceMock.createSetupContract(), timelines: { getLastUpdated: jest.fn(), diff --git a/x-pack/plugins/security_solution/public/common/mock/expandable_flyout.tsx b/x-pack/plugins/security_solution/public/common/mock/expandable_flyout.tsx new file mode 100644 index 0000000000000..a987e99a67d0e --- /dev/null +++ b/x-pack/plugins/security_solution/public/common/mock/expandable_flyout.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'; + +export const createExpandableFlyoutApiMock = () => ({ + closeFlyout: jest.fn(), + closeLeftPanel: jest.fn(), + closePreviewPanel: jest.fn(), + closeRightPanel: jest.fn(), + previousPreviewPanel: jest.fn(), + openFlyout: jest.fn(), + openLeftPanel: jest.fn(), + openPreviewPanel: jest.fn(), + openRightPanel: jest.fn(), +}); + +export const createExpandableFlyoutMock = () => { + return { + useExpandableFlyoutApi: jest.fn().mockReturnValue(createExpandableFlyoutApiMock()), + useExpandableFlyoutState: jest.fn(), + ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, + withExpandableFlyoutProvider: (Component: React.ComponentType) => { + return (props: T) => { + return ; + }; + }, + ExpandableFlyout: jest.fn(), + }; +}; diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_risk_score/index.test.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_risk_score/index.test.tsx index 7de22b5a529b0..d398d380f8a5d 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_risk_score/index.test.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_analytics_risk_score/index.test.tsx @@ -15,6 +15,7 @@ import { useKibana as mockUseKibana } from '../../../common/lib/kibana/__mocks__ import { createTelemetryServiceMock } from '../../../common/lib/telemetry/telemetry_service.mock'; import { useRiskScore } from '../../api/hooks/use_risk_score'; import { useRiskScoreKpi } from '../../api/hooks/use_risk_score_kpi'; +import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; const mockedTelemetry = createTelemetryServiceMock(); const mockedUseKibana = mockUseKibana(); @@ -70,18 +71,15 @@ jest.mock('../../../common/hooks/use_navigate_to_alerts_page_with_filters', () = }); const mockOpenRightPanel = jest.fn(); -jest.mock('@kbn/expandable-flyout', () => { - return { - useExpandableFlyoutApi: () => ({ - openRightPanel: mockOpenRightPanel, - }), - }; -}); +jest.mock('@kbn/expandable-flyout'); describe.each([RiskScoreEntity.host, RiskScoreEntity.user])( 'EntityAnalyticsRiskScores entityType: %s', (riskEntity) => { beforeEach(() => { + (useExpandableFlyoutApi as jest.Mock).mockReturnValue({ + openRightPanel: mockOpenRightPanel, + }); jest.clearAllMocks(); mockUseRiskScoreKpi.mockReturnValue({ severityCount: mockSeverityCount, diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/risk_summary_flyout/risk_summary.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/risk_summary_flyout/risk_summary.tsx index d9c7f61201789..21ea627d3f65d 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/risk_summary_flyout/risk_summary.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/risk_summary_flyout/risk_summary.tsx @@ -22,6 +22,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import { euiThemeVars } from '@kbn/ui-theme'; import dateMath from '@kbn/datemath'; import { i18n } from '@kbn/i18n'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { ENABLE_ASSET_CRITICALITY_SETTING } from '../../../../common/constants'; import { useKibana, useUiSetting$ } from '../../../common/lib/kibana/kibana_react'; @@ -32,7 +33,6 @@ import { ONE_WEEK_IN_HOURS } from '../../../flyout/entity_details/shared/constan import { FormattedRelativePreferenceDate } from '../../../common/components/formatted_date'; import { RiskScoreEntity } from '../../../../common/entity_analytics/risk_engine'; import { VisualizationEmbeddable } from '../../../common/components/visualization_actions/visualization_embeddable'; -import { ExpandablePanel } from '../../../flyout/shared/components/expandable_panel'; import type { RiskScoreState } from '../../api/hooks/use_risk_score'; import { getRiskScoreSummaryAttributes } from '../../lens_attributes/risk_score_summary'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/alert_reason/alert_reason.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/alert_reason/alert_reason.tsx index 62e6e9f492b2f..03b84bc625552 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/alert_reason/alert_reason.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/alert_reason/alert_reason.tsx @@ -10,11 +10,11 @@ import { EuiPanel, EuiSpacer, EuiTitle } from '@elastic/eui'; import styled from '@emotion/styled'; import { euiThemeVars } from '@kbn/ui-theme'; import { FormattedMessage } from '@kbn/i18n-react'; +import { FlyoutError } from '@kbn/security-solution-common'; import { ALERT_REASON_BODY_TEST_ID } from './test_ids'; import { useAlertReasonPanelContext } from './context'; import { getRowRenderer } from '../../../timelines/components/timeline/body/renderers/get_row_renderer'; import { defaultRowRenderers } from '../../../timelines/components/timeline/body/renderers'; -import { FlyoutError } from '../../shared/components/flyout_error'; const ReasonContainerWrapper = styled.div` overflow-x: auto; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/alert_reason/context.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/alert_reason/context.tsx index b67c9af508d96..ec8096d60e72c 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/alert_reason/context.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/alert_reason/context.tsx @@ -7,9 +7,8 @@ import React, { createContext, memo, useContext, useMemo } from 'react'; import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs'; +import { FlyoutError, FlyoutLoading } from '@kbn/security-solution-common'; import { useEventDetails } from '../shared/hooks/use_event_details'; -import { FlyoutError } from '../../shared/components/flyout_error'; -import { FlyoutLoading } from '../../shared/components/flyout_loading'; import type { AlertReasonPanelProps } from '.'; export interface AlertReasonPanelContext { diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/content.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/content.tsx index 0c9f05391d82a..6ae172ca62556 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/content.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/content.tsx @@ -8,6 +8,7 @@ import type { FC } from 'react'; import React, { useCallback } from 'react'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { FlyoutBody } from '@kbn/security-solution-common'; import { DocumentDetailsRightPanelKey } from '../shared/constants/panel_keys'; import { useBasicDataFromDetailsData } from '../shared/hooks/use_basic_data_from_details_data'; import { @@ -16,7 +17,6 @@ import { } from '../../../common/components/endpoint/host_isolation'; import { useHostIsolation } from '../shared/hooks/use_host_isolation'; import { useIsolateHostPanelContext } from './context'; -import { FlyoutBody } from '../../shared/components/flyout_body'; /** * Document details expandable flyout section content for the isolate host component, displaying the form or the success banner diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/context.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/context.tsx index 53393e2f8a79b..6abfe1c4e8650 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/context.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/context.tsx @@ -8,9 +8,8 @@ import type { TimelineEventsDetailsItem } from '@kbn/timelines-plugin/common'; import React, { createContext, memo, useContext, useMemo } from 'react'; +import { FlyoutError, FlyoutLoading } from '@kbn/security-solution-common'; import { useEventDetails } from '../shared/hooks/use_event_details'; -import { FlyoutError } from '../../shared/components/flyout_error'; -import { FlyoutLoading } from '../../shared/components/flyout_loading'; import type { IsolateHostPanelProps } from '.'; export interface IsolateHostPanelContext { diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.tsx index aa4c04623dfba..80f75f9808620 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/isolate_host/header.tsx @@ -8,12 +8,12 @@ import { EuiBetaBadge, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiTitle } from '@elastic/eui'; import type { FC } from 'react'; import React, { useMemo } from 'react'; +import { FlyoutHeader } from '@kbn/security-solution-common'; import { AgentTypeIntegration } from '../../../common/components/endpoint/agents/agent_type_integration'; import { useAlertResponseActionsSupport } from '../../../common/hooks/endpoint/use_alert_response_actions_support'; import { TECHNICAL_PREVIEW, TECHNICAL_PREVIEW_TOOLTIP } from '../../../common/translations'; import { useIsolateHostPanelContext } from './context'; import { FLYOUT_HEADER_TITLE_TEST_ID } from './test_ids'; -import { FlyoutHeader } from '../../shared/components/flyout_header'; import { ISOLATE_HOST, UNISOLATE_HOST } from '../../../common/components/endpoint'; /** diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details.test.tsx index b3b129a75c13d..859da37c4082d 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details.test.tsx @@ -28,7 +28,7 @@ import { useFetchRelatedAlertsBySameSourceEvent } from '../../shared/hooks/use_f import { useFetchRelatedCases } from '../../shared/hooks/use_fetch_related_cases'; import { mockContextValue } from '../../shared/mocks/mock_context'; import { useTimelineDataFilters } from '../../../../timelines/containers/use_timeline_data_filters'; -import { EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID } from '../../../shared/components/test_ids'; +import { EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID } from '@kbn/security-solution-common'; jest.mock('react-router-dom', () => { const actual = jest.requireActual('react-router-dom'); diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.test.tsx index f9391fe8fec06..ddf05af5d3908 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.test.tsx @@ -22,10 +22,7 @@ jest.mock('../hooks/use_paginated_alerts'); jest.mock('../../../../common/hooks/use_experimental_features'); const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); const TEST_ID = 'TEST'; const alertIds = ['id1', 'id2', 'id3']; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.tsx index 178adabb80700..70b238825d66a 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.tsx @@ -14,12 +14,12 @@ import { isRight } from 'fp-ts/lib/Either'; import { ALERT_REASON, ALERT_RULE_NAME } from '@kbn/rule-data-utils'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; import { CellTooltipWrapper } from '../../shared/components/cell_tooltip_wrapper'; import type { DataProvider } from '../../../../../common/types'; import { SeverityBadge } from '../../../../common/components/severity_badge'; import { usePaginatedAlerts } from '../hooks/use_paginated_alerts'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; import { InvestigateInTimelineButton } from '../../../../common/components/event_details/table/investigate_in_timeline_button'; import { ACTION_INVESTIGATE_IN_TIMELINE } from '../../../../detections/components/alerts_table/translations'; import { getDataProvider } from '../../../../common/components/event_details/table/use_action_cell_data_provider'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/entities_details.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/entities_details.test.tsx index d9d468649a221..b6c5dc0078b02 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/entities_details.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/entities_details.test.tsx @@ -13,7 +13,7 @@ import { TestProviders } from '../../../../common/mock'; import { EntitiesDetails } from './entities_details'; import { ENTITIES_DETAILS_TEST_ID, HOST_DETAILS_TEST_ID, USER_DETAILS_TEST_ID } from './test_ids'; import { mockContextValue } from '../../shared/mocks/mock_context'; -import { EXPANDABLE_PANEL_CONTENT_TEST_ID } from '../../../shared/components/test_ids'; +import { EXPANDABLE_PANEL_CONTENT_TEST_ID } from '@kbn/security-solution-common'; import type { Anomalies } from '../../../../common/components/ml/types'; import { useMlCapabilities } from '../../../../common/components/ml/hooks/use_ml_capabilities'; import { mockAnomalies } from '../../../../common/components/ml/mock'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/host_details.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/host_details.test.tsx index 213bfbbecaa25..7ba3d7823f24d 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/host_details.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/host_details.test.tsx @@ -24,7 +24,7 @@ import { HOST_DETAILS_LINK_TEST_ID, HOST_DETAILS_RELATED_USERS_LINK_TEST_ID, } from './test_ids'; -import { EXPANDABLE_PANEL_CONTENT_TEST_ID } from '../../../shared/components/test_ids'; +import { EXPANDABLE_PANEL_CONTENT_TEST_ID } from '@kbn/security-solution-common'; import { useRiskScore } from '../../../../entity_analytics/api/hooks/use_risk_score'; import { mockContextValue } from '../../shared/mocks/mock_context'; import { mockFlyoutApi } from '../../shared/mocks/mock_flyout_context'; @@ -34,10 +34,7 @@ import { HOST_PREVIEW_BANNER } from '../../right/components/host_entity_overview import { UserPreviewPanelKey } from '../../../entity_details/user_right'; import { USER_PREVIEW_BANNER } from '../../right/components/user_entity_overview'; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); jest.mock('../../../../common/hooks/use_experimental_features'); const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/host_details.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/host_details.tsx index 594409c82f880..49813f43d3de1 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/host_details.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/host_details.tsx @@ -24,8 +24,8 @@ import type { EuiBasicTableColumn } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; import type { RelatedUser } from '../../../../../common/search_strategy/security_solution/related_entities/related_users'; import type { RiskSeverity } from '../../../../../common/search_strategy'; import { HostOverview } from '../../../../overview/components/host_overview'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/investigation_guide.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/investigation_guide.tsx index ee1bebdb336ce..f39057a16bfdb 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/investigation_guide.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/investigation_guide.tsx @@ -7,11 +7,11 @@ import React from 'react'; import { EuiLink } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; +import { FlyoutLoading } from '@kbn/security-solution-common'; import { useInvestigationGuide } from '../../shared/hooks/use_investigation_guide'; import { useDocumentDetailsContext } from '../../shared/context'; import { INVESTIGATION_GUIDE_TEST_ID, INVESTIGATION_GUIDE_LOADING_TEST_ID } from './test_ids'; import { InvestigationGuideView } from './investigation_guide_view'; -import { FlyoutLoading } from '../../../shared/components/flyout_loading'; /** * Investigation guide displayed in the left panel. diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.test.tsx index 5b7da67186e34..f1abc48f0e87a 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.test.tsx @@ -33,10 +33,7 @@ import { HOST_PREVIEW_BANNER } from '../../right/components/host_entity_overview import { UserPreviewPanelKey } from '../../../entity_details/user_right'; import { USER_PREVIEW_BANNER } from '../../right/components/user_entity_overview'; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); jest.mock('../../../../common/hooks/use_experimental_features'); const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_ancestry.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_ancestry.test.tsx index 52468f0aedbb9..62012b72052bc 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_ancestry.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_ancestry.test.tsx @@ -20,7 +20,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; import { usePaginatedAlerts } from '../hooks/use_paginated_alerts'; jest.mock('../../shared/hooks/use_fetch_related_alerts_by_ancestry'); diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_same_source_event.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_same_source_event.test.tsx index 3cf2d93896bc3..f4244fcc59a04 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_same_source_event.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_same_source_event.test.tsx @@ -20,7 +20,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; import { usePaginatedAlerts } from '../hooks/use_paginated_alerts'; jest.mock('../../shared/hooks/use_fetch_related_alerts_by_same_source_event'); diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_session.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_session.test.tsx index 0120f462b9ac5..54df7e8924f68 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_session.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_alerts_by_session.test.tsx @@ -21,7 +21,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; jest.mock('../../shared/hooks/use_fetch_related_alerts_by_session'); jest.mock('../hooks/use_paginated_alerts'); diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_cases.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_cases.test.tsx index db9eb7bdfb3ae..4d90cc7f56133 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_cases.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_cases.test.tsx @@ -18,7 +18,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; jest.mock('../../shared/hooks/use_fetch_related_cases'); jest.mock('../../../../common/components/links', () => ({ diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_cases.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_cases.tsx index 13df33a2deb1b..8e00e0e65478b 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_cases.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/related_cases.tsx @@ -10,6 +10,7 @@ import type { EuiBasicTableColumn } from '@elastic/eui'; import { EuiInMemoryTable } from '@elastic/eui'; import type { RelatedCase } from '@kbn/cases-plugin/common'; import { FormattedMessage } from '@kbn/i18n-react'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { CellTooltipWrapper } from '../../shared/components/cell_tooltip_wrapper'; import { CaseDetailsLink } from '../../../../common/components/links'; import { @@ -17,7 +18,6 @@ import { CORRELATIONS_DETAILS_CASES_SECTION_TEST_ID, } from './test_ids'; import { useFetchRelatedCases } from '../../shared/hooks/use_fetch_related_cases'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; const ICON = 'warning'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/suppressed_alerts.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/suppressed_alerts.test.tsx index 3b73199494187..a97a601f082dd 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/suppressed_alerts.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/suppressed_alerts.test.tsx @@ -17,7 +17,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_ICON_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; import { DocumentDetailsContext } from '../../shared/context'; import { mockContextValue } from '../../shared/mocks/mock_context'; import { isSuppressionRuleInGA } from '../../../../../common/detection_engine/utils'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/suppressed_alerts.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/suppressed_alerts.tsx index 02f00264470e0..efd1628f9d70a 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/suppressed_alerts.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/suppressed_alerts.tsx @@ -11,7 +11,7 @@ import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs'; import { ALERT_RULE_TYPE } from '@kbn/rule-data-utils'; import { EuiBetaBadge, EuiFlexItem, EuiFlexGroup } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { CORRELATIONS_DETAILS_SUPPRESSED_ALERTS_SECTION_TEST_ID, SUPPRESSED_ALERTS_SECTION_TECHNICAL_PREVIEW_TEST_ID, diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/threat_intelligence_details.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/threat_intelligence_details.tsx index f473ae2c3262b..6ac43fbe5cd31 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/threat_intelligence_details.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/threat_intelligence_details.tsx @@ -9,6 +9,7 @@ import React, { memo } from 'react'; import { EuiHorizontalRule, EuiSpacer } from '@elastic/eui'; import isEmpty from 'lodash/isEmpty'; import { groupBy } from 'lodash'; +import { FlyoutLoading } from '@kbn/security-solution-common'; import { EnrichmentSection } from './threat_details_view_enrichment_section'; import { ENRICHMENT_TYPES } from '../../../../../common/cti/constants'; import { EnrichmentRangePicker } from './threat_intelligence_view_enrichment_range_picker'; @@ -19,7 +20,6 @@ import { THREAT_INTELLIGENCE_ENRICHMENTS_TEST_ID, THREAT_INTELLIGENCE_MATCHES_TEST_ID, } from './test_ids'; -import { FlyoutLoading } from '../../../shared/components/flyout_loading'; export const THREAT_INTELLIGENCE_TAB_ID = 'threatIntelligence'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/tour.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/tour.tsx index c1bafab10d9a7..196d9113457a3 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/tour.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/tour.tsx @@ -10,9 +10,9 @@ import { useWhichFlyout } from '../../shared/hooks/use_which_flyout'; import { getField } from '../../shared/utils'; import { EventKind } from '../../shared/constants/event_kinds'; import { useDocumentDetailsContext } from '../../shared/context'; -import { FlyoutTour } from '../../shared/components/flyout_tour'; import { getLeftSectionTourSteps } from '../../shared/utils/tour_step_config'; import { Flyouts } from '../../shared/constants/flyouts'; +import { FlyoutTour } from '../../shared/components/flyout_tour'; /** * Guided tour for the left panel in details flyout diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/user_details.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/user_details.test.tsx index 02764d25b975e..ddf0b51f929b8 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/user_details.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/user_details.test.tsx @@ -24,7 +24,7 @@ import { USER_DETAILS_RELATED_HOSTS_TABLE_TEST_ID, USER_DETAILS_RELATED_HOSTS_LINK_TEST_ID, } from './test_ids'; -import { EXPANDABLE_PANEL_CONTENT_TEST_ID } from '../../../shared/components/test_ids'; +import { EXPANDABLE_PANEL_CONTENT_TEST_ID } from '@kbn/security-solution-common'; import { useRiskScore } from '../../../../entity_analytics/api/hooks/use_risk_score'; import { mockContextValue } from '../../shared/mocks/mock_context'; import { mockFlyoutApi } from '../../shared/mocks/mock_flyout_context'; @@ -34,10 +34,7 @@ import { HOST_PREVIEW_BANNER } from '../../right/components/host_entity_overview import { UserPreviewPanelKey } from '../../../entity_details/user_right'; import { USER_PREVIEW_BANNER } from '../../right/components/user_entity_overview'; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); jest.mock('../../../../common/hooks/use_experimental_features'); const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/user_details.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/user_details.tsx index a3d335b913148..1a93eab1c46e4 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/components/user_details.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/components/user_details.tsx @@ -24,8 +24,8 @@ import type { EuiBasicTableColumn } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; import type { RelatedHost } from '../../../../../common/search_strategy/security_solution/related_entities/related_hosts'; import type { RiskSeverity } from '../../../../../common/search_strategy'; import { UserOverview } from '../../../../overview/components/user_overview'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/content.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/content.tsx index 53d2efe883397..226765e6c4e37 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/content.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/content.tsx @@ -9,9 +9,9 @@ import { useEuiBackgroundColor } from '@elastic/eui'; import type { FC } from 'react'; import React, { useMemo } from 'react'; import { css } from '@emotion/react'; +import { FlyoutBody } from '@kbn/security-solution-common'; import type { LeftPanelPaths } from '.'; import type { LeftPanelTabType } from './tabs'; -import { FlyoutBody } from '../../shared/components/flyout_body'; export interface PanelContentProps { /** diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/header.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/header.tsx index 2b61a97577e06..f276ccca842be 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/header.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/header.tsx @@ -9,8 +9,8 @@ import { EuiTab, EuiTabs, useEuiBackgroundColor } from '@elastic/eui'; import type { FC } from 'react'; import React, { memo } from 'react'; import { css } from '@emotion/react'; +import { FlyoutHeader } from '@kbn/security-solution-common'; import type { LeftPanelPaths } from '.'; -import { FlyoutHeader } from '../../shared/components/flyout_header'; import type { LeftPanelTabType } from './tabs'; import { getField } from '../shared/utils'; import { EventKind } from '../shared/constants/event_kinds'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/test_ids.ts b/x-pack/plugins/security_solution/public/flyout/document_details/left/test_ids.ts index 9f5eeb035786c..4e2c1be90b01c 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/test_ids.ts +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/test_ids.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { PREFIX } from '../../shared/test_ids'; +import { PREFIX } from '@kbn/security-solution-common'; export const VISUALIZE_TAB_TEST_ID = `${PREFIX}VisualizeTab` as const; export const INSIGHTS_TAB_TEST_ID = `${PREFIX}InsightsTab` as const; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/preview/footer.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/preview/footer.test.tsx index d0b46038f44e0..2bf185a44942d 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/preview/footer.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/preview/footer.test.tsx @@ -15,10 +15,7 @@ import { DocumentDetailsContext } from '../shared/context'; import { PreviewPanelFooter } from './footer'; import { PREVIEW_FOOTER_TEST_ID, PREVIEW_FOOTER_LINK_TEST_ID } from './test_ids'; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); describe('', () => { beforeAll(() => { diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/preview/footer.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/preview/footer.tsx index 0ab0c9f44eb15..404a3debefc2e 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/preview/footer.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/preview/footer.tsx @@ -9,7 +9,7 @@ import { EuiLink, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React, { useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -import { FlyoutFooter } from '../../shared/components/flyout_footer'; +import { FlyoutFooter } from '@kbn/security-solution-common'; import { DocumentDetailsRightPanelKey } from '../shared/constants/panel_keys'; import { useDocumentDetailsContext } from '../shared/context'; import { PREVIEW_FOOTER_TEST_ID, PREVIEW_FOOTER_LINK_TEST_ID } from './test_ids'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.test.tsx index c8a00cf0837fa..4949b97e87917 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_description.test.tsx @@ -34,7 +34,7 @@ jest.mock('../../../../common/lib/kibana', () => { }; }); -jest.mock('@kbn/expandable-flyout', () => ({ useExpandableFlyoutApi: jest.fn() })); +jest.mock('@kbn/expandable-flyout'); const ruleUuid = { category: 'kibana', diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.tsx index 8d3b0577230a8..a54a3a027fad1 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.tsx @@ -10,6 +10,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiPanel, useEuiTheme, EuiLink } import { css } from '@emotion/css'; import { ALERT_WORKFLOW_ASSIGNEE_IDS } from '@kbn/rule-data-utils'; import { i18n } from '@kbn/i18n'; +import { FlyoutTitle } from '@kbn/security-solution-common'; import { useRuleDetailsLink } from '../../shared/hooks/use_rule_details_link'; import { DocumentStatus } from './status'; import { DocumentSeverity } from './severity'; @@ -20,7 +21,6 @@ import { useDocumentDetailsContext } from '../../shared/context'; import { PreferenceFormattedDate } from '../../../../common/components/formatted_date'; import { FLYOUT_ALERT_HEADER_TITLE_TEST_ID, ALERT_SUMMARY_PANEL_TEST_ID } from './test_ids'; import { Assignees } from './assignees'; -import { FlyoutTitle } from '../../../shared/components/flyout_title'; /** * Alert details flyout right section header diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/analyzer_preview_container.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/analyzer_preview_container.test.tsx index 7dae9400358c5..550bda40e5e68 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/analyzer_preview_container.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/analyzer_preview_container.test.tsx @@ -21,7 +21,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; import { mockDataFormattedForFieldBrowser } from '../../shared/mocks/mock_data_formatted_for_field_browser'; import { useInvestigateInTimeline } from '../../../../detections/components/alerts_table/timeline_actions/use_investigate_in_timeline'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/analyzer_preview_container.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/analyzer_preview_container.tsx index ad85e8e8701e1..f3d99d9144ad2 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/analyzer_preview_container.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/analyzer_preview_container.tsx @@ -10,6 +10,7 @@ import { useDispatch } from 'react-redux'; import { TimelineTabs } from '@kbn/securitysolution-data-table'; import { EuiLink, EuiMark } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { useStartTransaction } from '../../../../common/lib/apm/use_start_transaction'; import { useInvestigateInTimeline } from '../../../../detections/components/alerts_table/timeline_actions/use_investigate_in_timeline'; import { ALERTS_ACTIONS } from '../../../../common/lib/apm/user_actions'; @@ -19,7 +20,6 @@ import { useDocumentDetailsContext } from '../../shared/context'; import { useIsInvestigateInResolverActionEnabled } from '../../../../detections/components/alerts_table/timeline_actions/investigate_in_resolver'; import { AnalyzerPreview } from './analyzer_preview'; import { ANALYZER_PREVIEW_TEST_ID } from './test_ids'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; const timelineId = 'timeline-1'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.test.tsx index fb6b2f4edcfb2..f4a97b7deed11 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.test.tsx @@ -39,7 +39,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; import { useTourContext } from '../../../../common/components/guided_onboarding_tour'; import { AlertsCasesTourSteps } from '../../../../common/components/guided_onboarding_tour/tour_config'; @@ -92,10 +92,7 @@ const flyoutContextValue = { openLeftPanel: jest.fn(), } as unknown as ExpandableFlyoutApi; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); jest.mock('../../../../timelines/containers/use_timeline_data_filters', () => ({ useTimelineDataFilters: jest.fn(), diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.tsx index d4e9a6fe58113..058db7c8dc79e 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/correlations_overview.tsx @@ -12,7 +12,7 @@ import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { FormattedMessage } from '@kbn/i18n-react'; import { ALERT_RULE_TYPE } from '@kbn/rule-data-utils'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { useShowRelatedAlertsBySession } from '../../shared/hooks/use_show_related_alerts_by_session'; import { RelatedAlertsBySession } from './related_alerts_by_session'; import { useShowRelatedAlertsBySameSourceEvent } from '../../shared/hooks/use_show_related_alerts_by_same_source_event'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.test.tsx index 92248c6de2828..e4975d3136424 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.test.tsx @@ -24,7 +24,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; import { useRiskScore } from '../../../../entity_analytics/api/hooks/use_risk_score'; const from = '2022-04-05T12:00:00.000Z'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.tsx index 16fe6cbe1c1e0..60657a1346101 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/entities_overview.tsx @@ -9,8 +9,8 @@ import React, { useCallback, useMemo } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiSpacer } from '@elastic/eui'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { FormattedMessage } from '@kbn/i18n-react'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { INSIGHTS_ENTITIES_TEST_ID } from './test_ids'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; import { useDocumentDetailsContext } from '../../shared/context'; import { getField } from '../../shared/utils'; import { HostEntityOverview } from './host_entity_overview'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/event_header_title.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/event_header_title.tsx index 953a2371ffa88..f93b8451c744a 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/event_header_title.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/event_header_title.tsx @@ -9,7 +9,7 @@ import React, { memo, useMemo } from 'react'; import { startCase } from 'lodash'; import { EuiSpacer } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; -import { FlyoutTitle } from '../../../shared/components/flyout_title'; +import { FlyoutTitle } from '@kbn/security-solution-common'; import { DocumentSeverity } from './severity'; import { useBasicDataFromDetailsData } from '../../shared/hooks/use_basic_data_from_details_data'; import { useDocumentDetailsContext } from '../../shared/context'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx index 3ebb00c3b7c75..0426d9861b93c 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx @@ -30,10 +30,7 @@ import { USER_PREVIEW_BANNER } from './user_entity_overview'; jest.mock('../../../../management/hooks'); jest.mock('../../../../management/hooks/agents/use_get_agent_status'); -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); const useGetAgentStatusMock = useGetAgentStatus as jest.Mock; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.test.tsx index f554f578c86cd..dcaf51761239d 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.test.tsx @@ -44,10 +44,7 @@ const panelContextValue = { dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser, }; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); jest.mock('../../../../common/hooks/use_experimental_features'); const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.test.tsx index 74f532fc6809b..f70039230cc45 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/investigation_guide.test.tsx @@ -23,7 +23,7 @@ import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; import { LeftPanelInvestigationTab } from '../../left'; jest.mock('../../shared/hooks/use_investigation_guide'); -jest.mock('@kbn/expandable-flyout', () => ({ useExpandableFlyoutApi: jest.fn() })); +jest.mock('@kbn/expandable-flyout'); const mockFlyoutContextValue = { openLeftPanel: jest.fn() }; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.test.tsx index 6b3e287d80915..a47ed04c85b5a 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.test.tsx @@ -20,7 +20,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_LOADING_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; import { usePrevalence } from '../../shared/hooks/use_prevalence'; import { mockContextValue } from '../../shared/mocks/mock_context'; import { type ExpandableFlyoutApi, useExpandableFlyoutApi } from '@kbn/expandable-flyout'; @@ -38,10 +38,7 @@ const flyoutContextValue = { openLeftPanel: jest.fn(), } as unknown as ExpandableFlyoutApi; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); const renderPrevalenceOverview = (contextValue: DocumentDetailsContext = mockContextValue) => render( diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.tsx index 3776e486b426b..96ee603607742 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/prevalence_overview.tsx @@ -10,7 +10,7 @@ import React, { useCallback, useMemo } from 'react'; import { EuiFlexGroup } from '@elastic/eui'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { FormattedMessage } from '@kbn/i18n-react'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { usePrevalence } from '../../shared/hooks/use_prevalence'; import { PREVALENCE_TEST_ID } from './test_ids'; import { useDocumentDetailsContext } from '../../shared/context'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.test.tsx index e69f2d833e949..f4faa9a3d730e 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/reason.test.tsx @@ -33,10 +33,7 @@ jest.mock('../../../../common/lib/kibana', () => { }; }); -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); const panelContextValue = { eventId: 'event id', diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/session_preview_container.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/session_preview_container.test.tsx index f6f56f1c9cd2a..26bbdcebe22f1 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/session_preview_container.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/session_preview_container.test.tsx @@ -19,7 +19,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_LINK_TEST_ID, EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; import { mockGetFieldsData } from '../../shared/mocks/mock_get_fields_data'; jest.mock('../hooks/use_session_preview'); diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/session_preview_container.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/session_preview_container.tsx index 43a19667d4fb6..aa97b904c1381 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/session_preview_container.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/session_preview_container.tsx @@ -11,13 +11,13 @@ import { useDispatch } from 'react-redux'; import { EuiLink, useEuiTheme } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { css } from '@emotion/css'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { useLicense } from '../../../../common/hooks/use_license'; import { SessionPreview } from './session_preview'; import { useSessionPreview } from '../hooks/use_session_preview'; import { useInvestigateInTimeline } from '../../../../detections/components/alerts_table/timeline_actions/use_investigate_in_timeline'; import { useDocumentDetailsContext } from '../../shared/context'; import { ALERTS_ACTIONS } from '../../../../common/lib/apm/user_actions'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; import { SESSION_PREVIEW_TEST_ID } from './test_ids'; import { useStartTransaction } from '../../../../common/lib/apm/use_start_transaction'; import { setActiveTabTimeline } from '../../../../timelines/store/actions'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.test.tsx index 2e2ffa99efe42..af92283b781b5 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.test.tsx @@ -23,7 +23,7 @@ import { EXPANDABLE_PANEL_HEADER_TITLE_TEXT_TEST_ID, EXPANDABLE_PANEL_LOADING_TEST_ID, EXPANDABLE_PANEL_TOGGLE_ICON_TEST_ID, -} from '../../../shared/components/test_ids'; +} from '@kbn/security-solution-common'; jest.mock('../hooks/use_fetch_threat_intelligence'); @@ -48,10 +48,7 @@ const panelContextValue = { dataFormattedForFieldBrowser: [], } as unknown as DocumentDetailsContext; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); const renderThreatIntelligenceOverview = (contextValue: DocumentDetailsContext) => ( diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.tsx index ca47113ad12c3..10b23ecfc2340 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/threat_intelligence_overview.tsx @@ -10,7 +10,7 @@ import React, { useCallback, useMemo } from 'react'; import { EuiFlexGroup } from '@elastic/eui'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { FormattedMessage } from '@kbn/i18n-react'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { useFetchThreatIntelligence } from '../hooks/use_fetch_threat_intelligence'; import { InsightsSummaryRow } from './insights_summary_row'; import { useDocumentDetailsContext } from '../../shared/context'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/tour.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/tour.tsx index 093a93149285c..839b77766886a 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/tour.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/tour.tsx @@ -10,7 +10,6 @@ import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { useWhichFlyout } from '../../shared/hooks/use_which_flyout'; import { Flyouts } from '../../shared/constants/flyouts'; import { useDocumentDetailsContext } from '../../shared/context'; -import { FlyoutTour } from '../../shared/components/flyout_tour'; import { getRightSectionTourSteps, getLeftSectionTourSteps, @@ -24,6 +23,7 @@ import { EventKind } from '../../shared/constants/event_kinds'; import { useTourContext } from '../../../../common/components/guided_onboarding_tour/tour'; import { SecurityStepId } from '../../../../common/components/guided_onboarding_tour/tour_config'; import { useKibana } from '../../../../common/lib/kibana'; +import { FlyoutTour } from '../../shared/components/flyout_tour'; /** * Guided tour for the right panel in details flyout diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.test.tsx index d1d9651b9d5f1..000da8946ff61 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.test.tsx @@ -44,19 +44,11 @@ const panelContextValue = { dataFormattedForFieldBrowser: mockDataFormattedForFieldBrowser, }; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); jest.mock('../../../../common/hooks/use_experimental_features'); const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); - const mockUseGlobalTime = jest.fn().mockReturnValue({ from, to }); jest.mock('../../../../common/containers/use_global_time', () => { return { diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/content.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/content.tsx index dbc530a4dd3f6..075921de192b8 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/content.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/content.tsx @@ -7,10 +7,10 @@ import type { FC } from 'react'; import React, { useMemo } from 'react'; +import { FlyoutBody } from '@kbn/security-solution-common'; import { FLYOUT_BODY_TEST_ID } from './test_ids'; import type { RightPanelPaths } from '.'; import type { RightPanelTabType } from './tabs'; -import { FlyoutBody } from '../../shared/components/flyout_body'; export interface PanelContentProps { /** diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/header.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/header.tsx index 3bf4e1a741251..189fe250fbab2 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/header.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/header.tsx @@ -9,10 +9,9 @@ import type { EuiFlyoutHeader } from '@elastic/eui'; import { EuiSpacer, EuiTab } from '@elastic/eui'; import type { FC } from 'react'; import React, { memo, useMemo } from 'react'; +import { FlyoutHeader, FlyoutHeaderTabs } from '@kbn/security-solution-common'; import type { RightPanelPaths } from '.'; import type { RightPanelTabType } from './tabs'; -import { FlyoutHeader } from '../../shared/components/flyout_header'; -import { FlyoutHeaderTabs } from '../../shared/components/flyout_header_tabs'; import { AlertHeaderTitle } from './components/alert_header_title'; import { EventHeaderTitle } from './components/event_header_title'; import { useDocumentDetailsContext } from '../shared/context'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx index b4f12fbabf94f..79aad96c209db 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/navigation.tsx @@ -8,9 +8,9 @@ import type { FC } from 'react'; import React, { memo, useCallback } from 'react'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { FlyoutNavigation } from '@kbn/security-solution-common'; import { useKibana } from '../../../common/lib/kibana'; import { HeaderActions } from './components/header_actions'; -import { FlyoutNavigation } from '../../shared/components/flyout_navigation'; import { DocumentDetailsLeftPanelKey } from '../shared/constants/panel_keys'; import { useDocumentDetailsContext } from '../shared/context'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/components/footer.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/components/footer.tsx index ebc204f8cb921..aca0d23027a61 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/components/footer.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/components/footer.tsx @@ -8,8 +8,8 @@ import React, { memo } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiLink } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { FlyoutFooter } from '@kbn/security-solution-common'; import { useRuleOverviewPanelContext } from '../context'; -import { FlyoutFooter } from '../../../shared/components/flyout_footer'; import { RULE_OVERVIEW_FOOTER_TEST_ID, RULE_OVERVIEW_NAVIGATE_TO_RULE_TEST_ID } from './test_ids'; import { useRuleDetailsLink } from '../../shared/hooks/use_rule_details_link'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/components/rule_overview.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/components/rule_overview.tsx index 73f9cc12dd053..2e61501241899 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/components/rule_overview.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/components/rule_overview.tsx @@ -8,6 +8,7 @@ import React, { memo, useState, useEffect } from 'react'; import { EuiText, EuiHorizontalRule, EuiSpacer, EuiPanel } from '@elastic/eui'; import { css } from '@emotion/css'; import { FormattedMessage } from '@kbn/i18n-react'; +import { FlyoutLoading, FlyoutError } from '@kbn/security-solution-common'; import { useRuleOverviewPanelContext } from '../context'; import { ExpandableSection } from '../../right/components/expandable_section'; import { useRuleWithFallback } from '../../../../detection_engine/rule_management/logic/use_rule_with_fallback'; @@ -17,8 +18,6 @@ import { RuleAboutSection } from '../../../../detection_engine/rule_management/c import { RuleScheduleSection } from '../../../../detection_engine/rule_management/components/rule_details/rule_schedule_section'; import { RuleDefinitionSection } from '../../../../detection_engine/rule_management/components/rule_details/rule_definition_section'; import { StepRuleActionsReadOnly } from '../../../../detection_engine/rule_creation/components/step_rule_actions'; -import { FlyoutLoading } from '../../../shared/components/flyout_loading'; -import { FlyoutError } from '../../../shared/components/flyout_error'; import { RULE_OVERVIEW_BODY_TEST_ID, RULE_OVERVIEW_ABOUT_TEST_ID, diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/context.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/context.tsx index 1b379b3c3ece8..cae182b839e6d 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/context.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/context.tsx @@ -6,7 +6,7 @@ */ import React, { createContext, memo, useContext, useMemo } from 'react'; -import { FlyoutError } from '../../shared/components/flyout_error'; +import { FlyoutError } from '@kbn/security-solution-common'; import type { RuleOverviewPanelProps } from '.'; export interface RuleOverviewPanelContext { diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/index.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/index.tsx index 504be510a09f7..b978a1697bbd5 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/rule_overview/index.tsx @@ -7,7 +7,7 @@ import React, { memo } from 'react'; import type { FlyoutPanelProps } from '@kbn/expandable-flyout'; -import { FlyoutBody } from '../../shared/components/flyout_body'; +import { FlyoutBody } from '@kbn/security-solution-common'; import type { DocumentDetailsRuleOverviewPanelKey } from '../shared/constants/panel_keys'; import { RuleOverview } from './components/rule_overview'; import { RuleFooter } from './components/footer'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/shared/context.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/shared/context.tsx index 12e2ad4f2a0b6..f2c5d8bfa530f 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/shared/context.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/shared/context.tsx @@ -9,9 +9,8 @@ import type { BrowserFields, TimelineEventsDetailsItem } from '@kbn/timelines-pl import React, { createContext, memo, useContext, useMemo } from 'react'; import type { EcsSecurityExtension as Ecs } from '@kbn/securitysolution-ecs'; import { TableId } from '@kbn/securitysolution-data-table'; +import { FlyoutError, FlyoutLoading } from '@kbn/security-solution-common/src/flyout'; import { useEventDetails } from './hooks/use_event_details'; -import { FlyoutError } from '../../shared/components/flyout_error'; -import { FlyoutLoading } from '../../shared/components/flyout_loading'; import type { SearchHit } from '../../../../common/search_strategy'; import { useBasicDataFromDetailsData } from './hooks/use_basic_data_from_details_data'; import type { DocumentDetailsProps } from './types'; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/shared/utils/tour_step_config.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/shared/utils/tour_step_config.tsx index 7b850cca82450..3f597e47c770c 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/shared/utils/tour_step_config.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/shared/utils/tour_step_config.tsx @@ -9,7 +9,7 @@ import { EuiText, EuiCode, type EuiTourStepProps } from '@elastic/eui'; import React from 'react'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; -import { HEADER_NAVIGATION_BUTTON_TEST_ID } from '../../../shared/components/test_ids'; +import { HEADER_NAVIGATION_BUTTON_TEST_ID } from '@kbn/security-solution-common'; import { OVERVIEW_TAB_LABEL_TEST_ID } from '../../right/test_ids'; import { RULE_SUMMARY_BUTTON_TEST_ID } from '../../right/components/test_ids'; import { diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/host_preview/footer.test.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/host_preview/footer.test.tsx index 8bfc575e5b573..403e9cf1c0ed0 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/host_preview/footer.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/host_preview/footer.test.tsx @@ -12,10 +12,7 @@ import { mockFlyoutApi } from '../../document_details/shared/mocks/mock_flyout_c import type { HostPreviewPanelFooterProps } from './footer'; import { HostPreviewPanelFooter } from './footer'; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); const mockProps: HostPreviewPanelFooterProps = { hostName: 'test', diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/host_preview/footer.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/host_preview/footer.tsx index e550da28b532a..3ea6d7a5e0438 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/host_preview/footer.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/host_preview/footer.tsx @@ -9,7 +9,7 @@ import { EuiLink, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React, { useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -import { FlyoutFooter } from '../../shared/components/flyout_footer'; +import { FlyoutFooter } from '@kbn/security-solution-common'; import { HostPanelKey } from '../host_right'; export interface HostPreviewPanelFooterProps { diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/content.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/content.tsx index af3eae38fc1f8..27e824d39c913 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/content.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/content.tsx @@ -7,11 +7,11 @@ import React from 'react'; import { EuiHorizontalRule } from '@elastic/eui'; +import { FlyoutBody } from '@kbn/security-solution-common'; import { AssetCriticalityAccordion } from '../../../entity_analytics/components/asset_criticality/asset_criticality_selector'; import { FlyoutRiskSummary } from '../../../entity_analytics/components/risk_summary_flyout/risk_summary'; import type { RiskScoreState } from '../../../entity_analytics/api/hooks/use_risk_score'; import type { RiskScoreEntity, HostItem } from '../../../../common/search_strategy'; -import { FlyoutBody } from '../../shared/components/flyout_body'; import { ObservedEntity } from '../shared/components/observed_entity'; import { HOST_PANEL_OBSERVED_HOST_QUERY_ID, HOST_PANEL_RISK_SCORE_QUERY_ID } from '.'; import type { ObservedEntityData } from '../shared/components/observed_entity/types'; diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/header.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/header.tsx index b5df2f81d1b0a..706790770eb6c 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/header.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/header.tsx @@ -9,12 +9,11 @@ import { EuiSpacer, EuiBadge, EuiText, EuiFlexItem, EuiFlexGroup } from '@elasti import { FormattedMessage } from '@kbn/i18n-react'; import React, { useMemo } from 'react'; import { SecurityPageName } from '@kbn/security-solution-navigation'; +import { FlyoutHeader, FlyoutTitle } from '@kbn/security-solution-common'; import type { HostItem } from '../../../../common/search_strategy'; import { getHostDetailsUrl } from '../../../common/components/link_to'; import { SecuritySolutionLinkAnchor } from '../../../common/components/links'; import { PreferenceFormattedDate } from '../../../common/components/formatted_date'; -import { FlyoutHeader } from '../../shared/components/flyout_header'; -import { FlyoutTitle } from '../../shared/components/flyout_title'; import type { ObservedEntityData } from '../shared/components/observed_entity/types'; interface HostPanelHeaderProps { diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/index.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/index.tsx index 798bff18b9c16..4799c396a7be3 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/host_right/index.tsx @@ -9,6 +9,7 @@ import React, { useCallback, useMemo } from 'react'; import type { FlyoutPanelProps } from '@kbn/expandable-flyout'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { FlyoutLoading, FlyoutNavigation } from '@kbn/security-solution-common'; import { useRefetchQueryById } from '../../../entity_analytics/api/hooks/use_refetch_query_by_id'; import { RISK_INPUTS_TAB_QUERY_ID } from '../../../entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs_tab'; import type { Refetch } from '../../../common/types'; @@ -21,8 +22,6 @@ import { useGlobalTime } from '../../../common/containers/use_global_time'; import type { HostItem } from '../../../../common/search_strategy'; import { buildHostNamesFilter } from '../../../../common/search_strategy'; import { RiskScoreEntity } from '../../../../common/entity_analytics/risk_engine'; -import { FlyoutLoading } from '../../shared/components/flyout_loading'; -import { FlyoutNavigation } from '../../shared/components/flyout_navigation'; import { HostPanelContent } from './content'; import { HostPanelHeader } from './header'; import { AnomalyTableProvider } from '../../../common/components/ml/anomaly/anomaly_table_provider'; diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/left_panel/left_panel_content.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/left_panel/left_panel_content.tsx index 5a66a5b305611..f52480285a567 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/left_panel/left_panel_content.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/left_panel/left_panel_content.tsx @@ -9,7 +9,7 @@ import { useEuiBackgroundColor } from '@elastic/eui'; import type { VFC } from 'react'; import React, { useMemo } from 'react'; import { css } from '@emotion/react'; -import { FlyoutBody } from '../../../../shared/components/flyout_body'; +import { FlyoutBody } from '@kbn/security-solution-common'; import type { EntityDetailsLeftPanelTab, LeftPanelTabsType } from './left_panel_header'; export interface PanelContentProps { diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/left_panel/left_panel_header.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/left_panel/left_panel_header.tsx index ea62ce25f3ca4..7a537d64aa755 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/left_panel/left_panel_header.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/shared/components/left_panel/left_panel_header.tsx @@ -9,7 +9,7 @@ import { EuiTab, EuiTabs, useEuiBackgroundColor } from '@elastic/eui'; import type { ReactElement, VFC } from 'react'; import React, { memo } from 'react'; import { css } from '@emotion/react'; -import { FlyoutHeader } from '../../../../shared/components/flyout_header'; +import { FlyoutHeader } from '@kbn/security-solution-common'; export type LeftPanelTabsType = Array<{ id: EntityDetailsLeftPanelTab; diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/user_details_left/index.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/user_details_left/index.tsx index 2ba1e274e0c5b..a04bd739eb299 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/user_details_left/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/user_details_left/index.tsx @@ -8,9 +8,9 @@ import React, { useMemo } from 'react'; import type { FlyoutPanelProps, PanelPath } from '@kbn/expandable-flyout'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { FlyoutLoading } from '@kbn/security-solution-common'; import { useManagedUser } from '../shared/hooks/use_managed_user'; import { useTabs } from './tabs'; -import { FlyoutLoading } from '../../shared/components/flyout_loading'; import type { EntityDetailsLeftPanelTab, LeftPanelTabsType, diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/user_details_left/tabs/asset_document.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/user_details_left/tabs/asset_document.tsx index 3aa4a72ffe898..31053cf88d931 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/user_details_left/tabs/asset_document.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/user_details_left/tabs/asset_document.tsx @@ -12,10 +12,10 @@ import { FormattedMessage } from '@kbn/i18n-react'; import type { EuiButtonGroupOptionProps } from '@elastic/eui'; import { EuiButtonGroup } from '@elastic/eui'; import { i18n } from '@kbn/i18n'; +import { FlyoutBody } from '@kbn/security-solution-common'; import { JsonTab } from '../../../document_details/right/tabs/json_tab'; import { TableTab } from '../../../document_details/right/tabs/table_tab'; import { FLYOUT_BODY_TEST_ID, JSON_TAB_TEST_ID, TABLE_TAB_TEST_ID } from './test_ids'; -import { FlyoutBody } from '../../../shared/components/flyout_body'; export type RightPanelPaths = 'overview' | 'table' | 'json'; export interface AssetDocumentPanelProps extends FlyoutPanelProps { diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/user_preview/footer.test.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/user_preview/footer.test.tsx index 52fcee31028e1..93d14644476ef 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/user_preview/footer.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/user_preview/footer.test.tsx @@ -12,10 +12,7 @@ import { mockFlyoutApi } from '../../document_details/shared/mocks/mock_flyout_c import type { UserPreviewPanelFooterProps } from './footer'; import { UserPreviewPanelFooter } from './footer'; -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: jest.fn(), - ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}, -})); +jest.mock('@kbn/expandable-flyout'); const mockProps: UserPreviewPanelFooterProps = { userName: 'test', diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/user_preview/footer.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/user_preview/footer.tsx index 7f55feb7a347c..6921d1a73d4e2 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/user_preview/footer.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/user_preview/footer.tsx @@ -9,7 +9,7 @@ import { EuiLink, EuiFlexGroup, EuiFlexItem } from '@elastic/eui'; import React, { useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -import { FlyoutFooter } from '../../shared/components/flyout_footer'; +import { FlyoutFooter } from '@kbn/security-solution-common'; import { UserPanelKey } from '../user_right'; export interface UserPreviewPanelFooterProps { diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/components/managed_user_accordion.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/components/managed_user_accordion.tsx index 8d9007713549e..84f6c96cb772b 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/components/managed_user_accordion.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/components/managed_user_accordion.tsx @@ -11,13 +11,14 @@ import React from 'react'; import { css } from '@emotion/react'; import { FormattedMessage } from '@kbn/i18n-react'; import { get } from 'lodash/fp'; +import { ExpandablePanel } from '@kbn/security-solution-common'; import { EntityDetailsLeftPanelTab } from '../../shared/components/left_panel/left_panel_header'; -import { ExpandablePanel } from '../../../shared/components/expandable_panel'; import type { ManagedUserFields } from '../../../../../common/search_strategy/security_solution/users/managed_details'; import { FormattedRelativePreferenceDate } from '../../../../common/components/formatted_date'; import { ONE_WEEK_IN_HOURS } from '../../shared/constants'; import { UserAssetTableType } from '../../../../explore/users/store/model'; + interface ManagedUserAccordionProps { children: React.ReactNode; title: string; diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/content.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/content.tsx index d06309ea09d02..26945a12f8bd6 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/content.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/content.tsx @@ -8,6 +8,7 @@ import { EuiHorizontalRule } from '@elastic/eui'; import React from 'react'; +import { FlyoutBody } from '@kbn/security-solution-common'; import { useIsExperimentalFeatureEnabled } from '../../../common/hooks/use_experimental_features'; import { AssetCriticalityAccordion } from '../../../entity_analytics/components/asset_criticality/asset_criticality_selector'; @@ -18,7 +19,6 @@ import { ManagedUser } from './components/managed_user'; import type { ManagedUserData } from './types'; import type { RiskScoreEntity, UserItem } from '../../../../common/search_strategy'; import { USER_PANEL_RISK_SCORE_QUERY_ID } from '.'; -import { FlyoutBody } from '../../shared/components/flyout_body'; import { ObservedEntity } from '../shared/components/observed_entity'; import type { ObservedEntityData } from '../shared/components/observed_entity/types'; import { useObservedUserItems } from './hooks/use_observed_user_items'; diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/header.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/header.tsx index e141779b559cf..8fb54478b3c4f 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/header.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/header.tsx @@ -10,6 +10,7 @@ import { FormattedMessage } from '@kbn/i18n-react'; import React, { useMemo } from 'react'; import { max } from 'lodash/fp'; import { SecurityPageName } from '@kbn/security-solution-navigation'; +import { FlyoutHeader, FlyoutTitle } from '@kbn/security-solution-common'; import type { UserItem } from '../../../../common/search_strategy'; import { ManagedUserDatasetKey } from '../../../../common/search_strategy/security_solution/users/managed_details'; import { getUsersDetailsUrl } from '../../../common/components/link_to/redirect_to_users'; @@ -17,8 +18,6 @@ import type { ManagedUserData } from './types'; import { SecuritySolutionLinkAnchor } from '../../../common/components/links'; import { PreferenceFormattedDate } from '../../../common/components/formatted_date'; -import { FlyoutHeader } from '../../shared/components/flyout_header'; -import { FlyoutTitle } from '../../shared/components/flyout_title'; import type { ObservedEntityData } from '../shared/components/observed_entity/types'; interface UserPanelHeaderProps { diff --git a/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/index.tsx b/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/index.tsx index 6addcd92b6602..15ebee33010a0 100644 --- a/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/entity_details/user_right/index.tsx @@ -8,6 +8,7 @@ import React, { useCallback, useMemo } from 'react'; import type { FlyoutPanelProps } from '@kbn/expandable-flyout'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { FlyoutLoading, FlyoutNavigation } from '@kbn/security-solution-common/src/flyout'; import { useRefetchQueryById } from '../../../entity_analytics/api/hooks/use_refetch_query_by_id'; import type { Refetch } from '../../../common/types'; import { RISK_INPUTS_TAB_QUERY_ID } from '../../../entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs_tab'; @@ -23,8 +24,6 @@ import { useGlobalTime } from '../../../common/containers/use_global_time'; import { AnomalyTableProvider } from '../../../common/components/ml/anomaly/anomaly_table_provider'; import { buildUserNamesFilter } from '../../../../common/search_strategy'; import { RiskScoreEntity } from '../../../../common/entity_analytics/risk_engine'; -import { FlyoutLoading } from '../../shared/components/flyout_loading'; -import { FlyoutNavigation } from '../../shared/components/flyout_navigation'; import { UserPanelContent } from './content'; import { UserPanelHeader } from './header'; import { UserDetailsPanelKey } from '../user_details_left'; diff --git a/x-pack/plugins/security_solution/public/flyout/network_details/content.tsx b/x-pack/plugins/security_solution/public/flyout/network_details/content.tsx index 8c9aa355ed43a..3634f73ef5a7f 100644 --- a/x-pack/plugins/security_solution/public/flyout/network_details/content.tsx +++ b/x-pack/plugins/security_solution/public/flyout/network_details/content.tsx @@ -8,8 +8,8 @@ import type { FC } from 'react'; import React, { memo } from 'react'; import { EuiSpacer } from '@elastic/eui'; +import { FlyoutBody } from '@kbn/security-solution-common'; import { NetworkDetails } from './components/network_details'; -import { FlyoutBody } from '../shared/components/flyout_body'; import type { FlowTargetSourceDest } from '../../../common/search_strategy'; export interface PanelContentProps { diff --git a/x-pack/plugins/security_solution/public/flyout/network_details/header.tsx b/x-pack/plugins/security_solution/public/flyout/network_details/header.tsx index 8ffceb345b1e0..1ef47c00689d9 100644 --- a/x-pack/plugins/security_solution/public/flyout/network_details/header.tsx +++ b/x-pack/plugins/security_solution/public/flyout/network_details/header.tsx @@ -9,11 +9,10 @@ import type { FC } from 'react'; import React, { memo, useMemo } from 'react'; import type { EuiFlyoutHeader } from '@elastic/eui'; import { SecurityPageName } from '@kbn/deeplinks-security'; +import { FlyoutHeader, FlyoutTitle } from '@kbn/security-solution-common'; import { getNetworkDetailsUrl } from '../../common/components/link_to'; import { SecuritySolutionLinkAnchor } from '../../common/components/links'; import type { FlowTargetSourceDest } from '../../../common/search_strategy'; -import { FlyoutHeader } from '../shared/components/flyout_header'; -import { FlyoutTitle } from '../shared/components/flyout_title'; import { encodeIpv6 } from '../../common/lib/helpers'; export interface PanelHeaderProps extends React.ComponentProps { diff --git a/x-pack/plugins/security_solution/public/flyout/shared/components/alert_preview_button.test.tsx b/x-pack/plugins/security_solution/public/flyout/shared/components/alert_preview_button.test.tsx index f478812f96f93..1d9358cb1bb31 100644 --- a/x-pack/plugins/security_solution/public/flyout/shared/components/alert_preview_button.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/shared/components/alert_preview_button.test.tsx @@ -11,11 +11,14 @@ import React from 'react'; import { AlertPreviewButton } from './alert_preview_button'; import { DocumentDetailsPreviewPanelKey } from '../../document_details/shared/constants/panel_keys'; import { ALERT_PREVIEW_BANNER } from '../../document_details/preview/constants'; +import { createExpandableFlyoutApiMock } from '../../../common/mock/expandable_flyout'; const mockOpenPreviewPanel = jest.fn(); +const mockExpandableFlyoutApi = createExpandableFlyoutApiMock(); jest.mock('@kbn/expandable-flyout', () => { return { useExpandableFlyoutApi: () => ({ + ...mockExpandableFlyoutApi, openPreviewPanel: mockOpenPreviewPanel, }), }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/formatted_ip/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/formatted_ip/index.test.tsx index 8a4f911468e4a..04cfeaff92d0b 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/formatted_ip/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/formatted_ip/index.test.tsx @@ -13,6 +13,8 @@ import { TestProviders } from '../../../common/mock'; import { TimelineId, TimelineTabs } from '../../../../common/types/timeline'; import { StatefulEventContext } from '../../../common/components/events_viewer/stateful_event_context'; import { NetworkPanelKey } from '../../../flyout/network_details'; +import { createExpandableFlyoutApiMock } from '../../../common/mock/expandable_flyout'; +import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; jest.mock('react-redux', () => { const origin = jest.requireActual('react-redux'); @@ -46,13 +48,15 @@ jest.mock('../../../common/components/drag_and_drop/draggable_wrapper', () => { jest.mock('../../store'); const mockOpenFlyout = jest.fn(); -jest.mock('@kbn/expandable-flyout', () => ({ - useExpandableFlyoutApi: () => ({ - openFlyout: mockOpenFlyout, - }), -})); +jest.mock('@kbn/expandable-flyout'); describe('FormattedIp', () => { + beforeEach(() => { + jest.mocked(useExpandableFlyoutApi).mockReturnValue({ + ...createExpandableFlyoutApiMock(), + openFlyout: mockOpenFlyout, + }); + }); const props = { value: '192.168.1.1', contextId: 'test-context-id', diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx index 98d3ea8f507bb..9674b9146ecb0 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/index.test.tsx @@ -39,6 +39,8 @@ import type { } from '@hello-pangea/dnd'; import { DocumentDetailsRightPanelKey } from '../../../../flyout/document_details/shared/constants/panel_keys'; import { createTelemetryServiceMock } from '../../../../common/lib/telemetry/telemetry_service.mock'; +import { createExpandableFlyoutApiMock } from '../../../../common/mock/expandable_flyout'; +import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; jest.mock('../../../../common/hooks/use_app_toasts'); jest.mock('../../../../common/components/guided_onboarding_tour/tour_step'); @@ -99,11 +101,7 @@ jest.mock('react-redux', () => { }); const mockOpenFlyout = jest.fn(); -jest.mock('@kbn/expandable-flyout', () => { - return { - useExpandableFlyoutApi: () => ({ openFlyout: mockOpenFlyout }), - }; -}); +jest.mock('@kbn/expandable-flyout'); const mockedTelemetry = createTelemetryServiceMock(); @@ -236,6 +234,11 @@ describe('Body', () => { let appToastsMock: jest.Mocked>; beforeEach(() => { + jest.mocked(useExpandableFlyoutApi).mockReturnValue({ + ...createExpandableFlyoutApiMock(), + openFlyout: mockOpenFlyout, + }); + mockUseCurrentUser.mockReturnValue({ username: 'test-username' }); mockUseKibana.mockReturnValue({ services: { diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/host_name.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/host_name.test.tsx index d00ad83b9b556..52344857a07c1 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/host_name.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/host_name.test.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import React, { type PropsWithChildren } from 'react'; +import React from 'react'; import { mount } from 'enzyme'; import { waitFor } from '@testing-library/react'; @@ -14,18 +14,13 @@ import { TimelineId, TimelineTabs } from '../../../../../../common/types/timelin import { StatefulEventContext } from '../../../../../common/components/events_viewer/stateful_event_context'; import { createTelemetryServiceMock } from '../../../../../common/lib/telemetry/telemetry_service.mock'; import { TableId } from '@kbn/securitysolution-data-table'; +import { createExpandableFlyoutApiMock } from '../../../../../common/mock/expandable_flyout'; +import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; const mockedTelemetry = createTelemetryServiceMock(); const mockOpenRightPanel = jest.fn(); -jest.mock('@kbn/expandable-flyout', () => { - return { - useExpandableFlyoutApi: () => ({ - openRightPanel: mockOpenRightPanel, - }), - TestProvider: ({ children }: PropsWithChildren<{}>) => <>{children}, - }; -}); +jest.mock('@kbn/expandable-flyout'); jest.mock('../../../../../common/lib/kibana/kibana_react', () => { return { @@ -46,6 +41,13 @@ jest.mock('../../../../../common/components/draggables', () => ({ })); describe('HostName', () => { + beforeEach(() => { + jest.mocked(useExpandableFlyoutApi).mockReturnValue({ + ...createExpandableFlyoutApiMock(), + openRightPanel: mockOpenRightPanel, + }); + }); + afterEach(() => { jest.clearAllMocks(); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.test.tsx index 471d43dcf8462..6c3dffc58ce25 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/renderers/user_name.test.tsx @@ -4,7 +4,7 @@ * 2.0; you may not use this file except in compliance with the Elastic License * 2.0. */ -import React, { type PropsWithChildren } from 'react'; +import React from 'react'; import { mount } from 'enzyme'; import { waitFor } from '@testing-library/react'; @@ -14,18 +14,13 @@ import { UserName } from './user_name'; import { StatefulEventContext } from '../../../../../common/components/events_viewer/stateful_event_context'; import { createTelemetryServiceMock } from '../../../../../common/lib/telemetry/telemetry_service.mock'; import { TableId } from '@kbn/securitysolution-data-table'; +import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { createExpandableFlyoutApiMock } from '../../../../../common/mock/expandable_flyout'; const mockedTelemetry = createTelemetryServiceMock(); const mockOpenRightPanel = jest.fn(); -jest.mock('@kbn/expandable-flyout', () => { - return { - useExpandableFlyoutApi: () => ({ - openRightPanel: mockOpenRightPanel, - }), - TestProvider: ({ children }: PropsWithChildren<{}>) => <>{children}, - }; -}); +jest.mock('@kbn/expandable-flyout'); jest.mock('../../../../../common/lib/kibana/kibana_react', () => { return { @@ -46,6 +41,12 @@ jest.mock('../../../../../common/components/draggables', () => ({ })); describe('UserName', () => { + beforeEach(() => { + jest.mocked(useExpandableFlyoutApi).mockReturnValue({ + ...createExpandableFlyoutApiMock(), + openRightPanel: mockOpenRightPanel, + }); + }); afterEach(() => { jest.clearAllMocks(); }); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/query_tab_unified_components.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/query_tab_unified_components.test.tsx index 8b7b3742f0f27..973e0626aacc2 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/query_tab_unified_components.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/query_tab_unified_components.test.tsx @@ -5,7 +5,7 @@ * 2.0. */ -import type { ComponentProps, FunctionComponent, PropsWithChildren } from 'react'; +import type { ComponentProps, FunctionComponent } from 'react'; import React, { useEffect } from 'react'; import QueryTabContent from '.'; import { defaultRowRenderers } from '../../body/renderers'; @@ -35,6 +35,8 @@ import { defaultColumnHeaderType } from '../../body/column_headers/default_heade import { useUserPrivileges } from '../../../../../common/components/user_privileges'; import { getEndpointPrivilegesInitialStateMock } from '../../../../../common/components/user_privileges/endpoint/mocks'; import * as timelineActions from '../../../../store/actions'; +import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import { createExpandableFlyoutApiMock } from '../../../../../common/mock/expandable_flyout'; jest.mock('../../../../../common/components/user_privileges'); @@ -87,15 +89,7 @@ jest.mock(`@elastic/ebt/client`); const mockOpenFlyout = jest.fn(); const mockCloseFlyout = jest.fn(); -jest.mock('@kbn/expandable-flyout', () => { - return { - useExpandableFlyoutApi: () => ({ - openFlyout: mockOpenFlyout, - closeFlyout: mockCloseFlyout, - }), - TestProvider: ({ children }: PropsWithChildren<{}>) => <>{children}, - }; -}); +jest.mock('@kbn/expandable-flyout'); const TestComponent = (props: Partial>) => { const testComponentDefaultProps: ComponentProps = { @@ -162,6 +156,13 @@ let useTimelineEventsMock = jest.fn(); describe('query tab with unified timeline', () => { beforeAll(() => { // https://github.com/atlassian/react-beautiful-dnd/blob/4721a518356f72f1dac45b5fd4ee9d466aa2996b/docs/guides/setup-problem-detection-and-error-recovery.md#disable-logging + + jest.mocked(useExpandableFlyoutApi).mockImplementation(() => ({ + ...createExpandableFlyoutApiMock(), + openFlyout: mockOpenFlyout, + closeFlyout: mockCloseFlyout, + })); + Object.defineProperty(window, '__@hello-pangea/dnd-disable-dev-warnings', { get() { return true; diff --git a/x-pack/plugins/security_solution/tsconfig.json b/x-pack/plugins/security_solution/tsconfig.json index 8ae0addf01d43..a2a9fda8ecc44 100644 --- a/x-pack/plugins/security_solution/tsconfig.json +++ b/x-pack/plugins/security_solution/tsconfig.json @@ -15,7 +15,11 @@ "public/**/*.json", "../../../typings/**/*" ], - "exclude": ["target/**/*", "**/cypress/**", "public/management/cypress.config.ts"], + "exclude": [ + "target/**/*", + "**/cypress/**", + "public/management/cypress.config.ts" + ], "kbn_references": [ "@kbn/core", { @@ -208,6 +212,7 @@ "@kbn/core-theme-browser", "@kbn/integration-assistant-plugin", "@kbn/avc-banner", + "@kbn/security-solution-common", "@kbn/esql-ast", "@kbn/esql-validation-autocomplete", "@kbn/config", diff --git a/x-pack/plugins/translations/translations/fr-FR.json b/x-pack/plugins/translations/translations/fr-FR.json index 3b5a402334797..53dcc0869d477 100644 --- a/x-pack/plugins/translations/translations/fr-FR.json +++ b/x-pack/plugins/translations/translations/fr-FR.json @@ -6791,7 +6791,6 @@ "searchResponseWarnings.title.clustersClause": "Un problème est survenu avec {nonSuccessfulClustersCount} {nonSuccessfulClustersCount, plural, one {cluster} other {clusters}}", "searchResponseWarnings.title.clustersClauseAndRequestsClause": "{clustersClause} pour {requestsCount} requêtes", "searchResponseWarnings.viewDetailsButtonLabel": "Afficher les détails", - "securitySolutionPackages.alertAssignments.upsell": "Passer à {requiredLicense} pour utiliser les affectations d'alertes", "securitySolutionPackages.alertSuppressionRuleDetails.upsell": "La suppression d'alertes est configurée mais elle ne sera pas appliquée en raison d'une licence insuffisante", "securitySolutionPackages.alertSuppressionRuleForm.upsell": "La suppression d'alertes est activée avec la licence {requiredLicense} ou supérieure", "securitySolutionPackages.beta.label": "Bêta", @@ -39269,10 +39268,10 @@ "xpack.securitySolution.flyout.right.alertPreview.ariaLabel": "Voir un aperçu de l'alerte avec l'id {id}", "xpack.securitySolution.flyout.right.eventCategoryText": "Catégorie d'événement", "xpack.securitySolution.flyout.right.header.assignedTitle": "Utilisateurs affectés", - "xpack.securitySolution.flyout.right.header.collapseDetailButtonAriaLabel": "Réduire les détails", - "xpack.securitySolution.flyout.right.header.collapseDetailButtonLabel": "Réduire les détails", - "xpack.securitySolution.flyout.right.header.expandDetailButtonAriaLabel": "Développer les détails", - "xpack.securitySolution.flyout.right.header.expandDetailButtonLabel": "Développer les détails", + "securitySolutionPackages.flyout.right.header.collapseDetailButtonAriaLabel": "Réduire les détails", + "securitySolutionPackages.flyout.right.header.collapseDetailButtonLabel": "Réduire les détails", + "securitySolutionPackages.flyout.right.header.expandDetailButtonAriaLabel": "Développer les détails", + "securitySolutionPackages.flyout.right.header.expandDetailButtonLabel": "Développer les détails", "xpack.securitySolution.flyout.right.header.headerTitle": "Détails des documents", "xpack.securitySolution.flyout.right.header.jsonTabLabel": "JSON", "xpack.securitySolution.flyout.right.header.overviewTabLabel": "Aperçu", @@ -39359,10 +39358,10 @@ "xpack.securitySolution.flyout.right.visualizations.sessionPreview.timeDescription": "à", "xpack.securitySolution.flyout.right.visualizations.sessionPreview.upsellDescription": "Cette fonctionnalité requiert un {subscription}", "xpack.securitySolution.flyout.right.visualizations.sessionPreview.upsellLinkText": "Abonnement Enterprise", - "xpack.securitySolution.flyout.shared.errorDescription": "Une erreur est survenue lors de l'affichage de {message}.", - "xpack.securitySolution.flyout.shared.errorTitle": "Impossible d'afficher {title}.", - "xpack.securitySolution.flyout.shared.ExpandablePanelButtonIconAriaLabel": "Activer/Désactiver le panneau extensible", - "xpack.securitySolution.flyout.shared.expandablePanelLoadingAriaLabel": "panneau extensible", + "securitySolutionPackages.flyout.shared.errorDescription": "Une erreur est survenue lors de l'affichage de {message}.", + "securitySolutionPackages.flyout.shared.errorTitle": "Impossible d'afficher {title}.", + "securitySolutionPackages.flyout.shared.ExpandablePanelButtonIconAriaLabel": "Activer/Désactiver le panneau extensible", + "securitySolutionPackages.flyout.shared.expandablePanelLoadingAriaLabel": "panneau extensible", "xpack.securitySolution.flyout.tour.entities.description": "Consultez la vue {entities} étendue pour en savoir plus sur les hôtes et les utilisateurs liés à l'alerte.", "xpack.securitySolution.flyout.tour.entities.text": "Entités", "xpack.securitySolution.flyout.tour.entities.title": "De nouvelles informations sur les hôtes et les utilisateurs sont disponibles", diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index f88fabd25833d..e89e452923f30 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -39251,10 +39251,10 @@ "xpack.securitySolution.flyout.right.alertPreview.ariaLabel": "ID {id}のアラートをプレビュー", "xpack.securitySolution.flyout.right.eventCategoryText": "イベントカテゴリ", "xpack.securitySolution.flyout.right.header.assignedTitle": "担当者", - "xpack.securitySolution.flyout.right.header.collapseDetailButtonAriaLabel": "詳細を折りたたむ", - "xpack.securitySolution.flyout.right.header.collapseDetailButtonLabel": "詳細を折りたたむ", - "xpack.securitySolution.flyout.right.header.expandDetailButtonAriaLabel": "詳細を展開", - "xpack.securitySolution.flyout.right.header.expandDetailButtonLabel": "詳細を展開", + "securitySolutionPackages.flyout.right.header.collapseDetailButtonAriaLabel": "詳細を折りたたむ", + "securitySolutionPackages.flyout.right.header.collapseDetailButtonLabel": "詳細を折りたたむ", + "securitySolutionPackages.flyout.right.header.expandDetailButtonAriaLabel": "詳細を展開", + "securitySolutionPackages.flyout.right.header.expandDetailButtonLabel": "詳細を展開", "xpack.securitySolution.flyout.right.header.headerTitle": "ドキュメント詳細", "xpack.securitySolution.flyout.right.header.jsonTabLabel": "JSON", "xpack.securitySolution.flyout.right.header.overviewTabLabel": "概要", @@ -39341,10 +39341,10 @@ "xpack.securitySolution.flyout.right.visualizations.sessionPreview.timeDescription": "に", "xpack.securitySolution.flyout.right.visualizations.sessionPreview.upsellDescription": "この機能には{subscription}が必要です", "xpack.securitySolution.flyout.right.visualizations.sessionPreview.upsellLinkText": "エンタープライズサブスクリプション", - "xpack.securitySolution.flyout.shared.errorDescription": "{message}の表示中にエラーが発生しました。", - "xpack.securitySolution.flyout.shared.errorTitle": "{title}を表示できません。", - "xpack.securitySolution.flyout.shared.ExpandablePanelButtonIconAriaLabel": "展開可能なパネルトグル", - "xpack.securitySolution.flyout.shared.expandablePanelLoadingAriaLabel": "展開可能なパネル", + "securitySolutionPackages.flyout.shared.errorDescription": "{message}の表示中にエラーが発生しました。", + "securitySolutionPackages.flyout.shared.errorTitle": "{title}を表示できません。", + "securitySolutionPackages.flyout.shared.ExpandablePanelButtonIconAriaLabel": "展開可能なパネルトグル", + "securitySolutionPackages.flyout.shared.expandablePanelLoadingAriaLabel": "展開可能なパネル", "xpack.securitySolution.flyout.tour.entities.description": "アラートに関連付けられたホストとユーザーの詳細については、展開された{entities}ビューを確認してください。", "xpack.securitySolution.flyout.tour.entities.text": "エンティティ", "xpack.securitySolution.flyout.tour.entities.title": "新しいホストとユーザーのインサイトがあります", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 2ae9e055b1f01..30cfd990ff4ee 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -39295,10 +39295,10 @@ "xpack.securitySolution.flyout.right.alertPreview.ariaLabel": "预览 ID 为 {id} 的告警", "xpack.securitySolution.flyout.right.eventCategoryText": "事件类别", "xpack.securitySolution.flyout.right.header.assignedTitle": "被分配人", - "xpack.securitySolution.flyout.right.header.collapseDetailButtonAriaLabel": "折叠详情", - "xpack.securitySolution.flyout.right.header.collapseDetailButtonLabel": "折叠详情", - "xpack.securitySolution.flyout.right.header.expandDetailButtonAriaLabel": "展开详情", - "xpack.securitySolution.flyout.right.header.expandDetailButtonLabel": "展开详情", + "securitySolutionPackages.flyout.right.header.collapseDetailButtonAriaLabel": "折叠详情", + "securitySolutionPackages.flyout.right.header.collapseDetailButtonLabel": "折叠详情", + "securitySolutionPackages.flyout.right.header.expandDetailButtonAriaLabel": "展开详情", + "securitySolutionPackages.flyout.right.header.expandDetailButtonLabel": "展开详情", "xpack.securitySolution.flyout.right.header.headerTitle": "文档详情", "xpack.securitySolution.flyout.right.header.jsonTabLabel": "JSON", "xpack.securitySolution.flyout.right.header.overviewTabLabel": "概览", @@ -39384,10 +39384,10 @@ "xpack.securitySolution.flyout.right.visualizations.sessionPreview.timeDescription": "处于", "xpack.securitySolution.flyout.right.visualizations.sessionPreview.upsellDescription": "此功能需要{subscription}", "xpack.securitySolution.flyout.right.visualizations.sessionPreview.upsellLinkText": "企业级订阅", - "xpack.securitySolution.flyout.shared.errorDescription": "显示 {message} 时出现错误。", - "xpack.securitySolution.flyout.shared.errorTitle": "无法显示 {title}。", - "xpack.securitySolution.flyout.shared.ExpandablePanelButtonIconAriaLabel": "可展开面板切换按钮", - "xpack.securitySolution.flyout.shared.expandablePanelLoadingAriaLabel": "可展开面板", + "securitySolutionPackages.flyout.shared.errorDescription": "显示 {message} 时出现错误。", + "securitySolutionPackages.flyout.shared.errorTitle": "无法显示 {title}。", + "securitySolutionPackages.flyout.shared.ExpandablePanelButtonIconAriaLabel": "可展开面板切换按钮", + "securitySolutionPackages.flyout.shared.expandablePanelLoadingAriaLabel": "可展开面板", "xpack.securitySolution.flyout.tour.entities.description": "请查阅展开的 {entities} 视图以了解与该告警有关的主机和用户的更多信息。", "xpack.securitySolution.flyout.tour.entities.text": "实体", "xpack.securitySolution.flyout.tour.entities.title": "有新主机和用户洞见可用", diff --git a/yarn.lock b/yarn.lock index 127cdf45ea4ae..15ae0b8e5fcee 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6291,6 +6291,10 @@ version "0.0.0" uid "" +"@kbn/security-solution-common@link:x-pack/packages/security-solution/common": + version "0.0.0" + uid "" + "@kbn/security-solution-distribution-bar@link:x-pack/packages/security-solution/distribution_bar": version "0.0.0" uid ""