From aed00108282ca0cb6bd34fdb002f50a96b0247ff Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Wed, 18 Dec 2024 11:09:50 +1100 Subject: [PATCH] [8.x] [Security Solution] Remove feature flag `entityAlertPreviewDisabled` (#203171) (#204664) # Backport This will backport the following commits from `main` to `8.x`: - [[Security Solution] Remove feature flag `entityAlertPreviewDisabled` (#203171)](https://github.com/elastic/kibana/pull/203171) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) Co-authored-by: christineweng <18648970+christineweng@users.noreply.github.com> --- .../common/experimental_features.ts | 5 -- .../tabs/risk_inputs/risk_inputs.test.tsx | 31 +--------- .../tabs/risk_inputs/risk_inputs_tab.tsx | 31 ++++------ ...correlations_details_alerts_table.test.tsx | 19 ++----- .../correlations_details_alerts_table.tsx | 53 +++++++----------- .../left/components/host_details.test.tsx | 19 ++----- .../left/components/host_details.tsx | 46 ++++++--------- .../components/prevalence_details.test.tsx | 12 +--- .../left/components/prevalence_details.tsx | 11 +--- .../left/components/user_details.test.tsx | 19 ++----- .../left/components/user_details.tsx | 46 ++++++--------- .../highlighted_fields_cell.test.tsx | 33 ++--------- .../components/highlighted_fields_cell.tsx | 38 ++----------- .../components/host_entity_overview.test.tsx | 29 +--------- .../right/components/host_entity_overview.tsx | 55 ++++-------------- .../table_field_value_cell.test.tsx | 7 +-- .../components/table_field_value_cell.tsx | 4 +- .../components/user_entity_overview.test.tsx | 35 +----------- .../right/components/user_entity_overview.tsx | 56 ++++--------------- 19 files changed, 124 insertions(+), 425 deletions(-) diff --git a/x-pack/solutions/security/plugins/security_solution/common/experimental_features.ts b/x-pack/solutions/security/plugins/security_solution/common/experimental_features.ts index 428a48cf4b7be..2367793e4c9fc 100644 --- a/x-pack/solutions/security/plugins/security_solution/common/experimental_features.ts +++ b/x-pack/solutions/security/plugins/security_solution/common/experimental_features.ts @@ -109,11 +109,6 @@ export const allowedExperimentalValues = Object.freeze({ */ securitySolutionNotesDisabled: false, - /** - * Disables entity and alert previews - */ - entityAlertPreviewDisabled: false, - /** * Enables the Assistant Model Evaluation advanced setting and API endpoint, introduced in `8.11.0`. */ diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs.test.tsx index 6995656db31a5..7ff2a6feb958f 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs.test.tsx @@ -49,12 +49,6 @@ const riskScore = { }, }; -const mockUseIsExperimentalFeatureEnabled = jest.fn().mockReturnValue(false); - -jest.mock('../../../../../common/hooks/use_experimental_features', () => ({ - useIsExperimentalFeatureEnabled: () => mockUseIsExperimentalFeatureEnabled(), -})); - const riskScoreWithAssetCriticalityContribution = (contribution: number) => { const score = JSON.parse(JSON.stringify(riskScore)); score.user.risk.category_2_score = contribution; @@ -129,8 +123,7 @@ describe('RiskInputsTab', () => { expect(queryByTestId('risk-input-contexts-title')).toBeInTheDocument(); }); - it('it renders alert preview button when feature flag is enable', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('it renders alert preview button', () => { mockUseRiskScore.mockReturnValue({ loading: false, error: false, @@ -151,28 +144,6 @@ describe('RiskInputsTab', () => { expect(getByTestId(EXPAND_ALERT_TEST_ID)).toBeInTheDocument(); }); - it('it does not render alert preview button when feature flag is disable', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(true); - mockUseRiskScore.mockReturnValue({ - loading: false, - error: false, - data: [riskScore], - }); - mockUseRiskContributingAlerts.mockReturnValue({ - loading: false, - error: false, - data: [alertInputDataMock], - }); - - const { queryByTestId } = render( - - - - ); - - expect(queryByTestId(EXPAND_ALERT_TEST_ID)).not.toBeInTheDocument(); - }); - it('Displays 0.00 for the asset criticality contribution if the contribution value is less than -0.01', () => { mockUseUiSetting.mockReturnValue([true]); diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs_tab.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs_tab.tsx index 78010434ee593..72a6af0fe768f 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs_tab.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_details_flyout/tabs/risk_inputs/risk_inputs_tab.tsx @@ -14,7 +14,6 @@ import { ALERT_RULE_NAME } from '@kbn/rule-data-utils'; import { get } from 'lodash/fp'; import { AlertPreviewButton } from '../../../../../flyout/shared/components/alert_preview_button'; -import { useIsExperimentalFeatureEnabled } from '../../../../../common/hooks/use_experimental_features'; import { useGlobalTime } from '../../../../../common/containers/use_global_time'; import { useQueryInspector } from '../../../../../common/components/page/manage_query'; import { formatRiskScore } from '../../../../common'; @@ -98,26 +97,20 @@ export const RiskInputsTab = ({ entityType, entityName, scopeId }: RiskInputsTab }), [] ); - const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled'); const inputColumns: Array> = useMemo( () => [ - ...(isPreviewEnabled - ? [ - { - render: (data: InputAlert) => ( - - ), - width: '5%', - }, - ] - : []), - + { + render: (data: InputAlert) => ( + + ), + width: '5%', + }, { name: ( describe('CorrelationsDetailsAlertsTable', () => { beforeEach(() => { jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(true); jest.mocked(usePaginatedAlerts).mockReturnValue({ setPagination: jest.fn(), setSorting: jest.fn(), @@ -88,16 +84,16 @@ describe('CorrelationsDetailsAlertsTable', () => { }); it('renders EuiBasicTable with correct props', () => { - const { getByTestId, queryByTestId, queryAllByRole } = + const { getByTestId, getAllByTestId, queryAllByRole } = renderCorrelationsTable(mockContextValue); expect(getByTestId(`${TEST_ID}InvestigateInTimeline`)).toBeInTheDocument(); expect(getByTestId(`${TEST_ID}Table`)).toBeInTheDocument(); - expect(queryByTestId(`${TEST_ID}AlertPreviewButton`)).not.toBeInTheDocument(); + expect(getAllByTestId(`${TEST_ID}AlertPreviewButton`)).toHaveLength(2); expect(jest.mocked(usePaginatedAlerts)).toHaveBeenCalled(); - expect(queryAllByRole('columnheader').length).toBe(4); + expect(queryAllByRole('columnheader').length).toBe(5); expect(queryAllByRole('row').length).toBe(3); // 1 header row and 2 data rows expect(queryAllByRole('row')[1].textContent).toContain('Jan 1, 2022 @ 00:00:00.000'); expect(queryAllByRole('row')[1].textContent).toContain('Reason1'); @@ -105,8 +101,7 @@ describe('CorrelationsDetailsAlertsTable', () => { expect(queryAllByRole('row')[1].textContent).toContain('Severity1'); }); - it('renders open preview button when feature flag is on', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('renders open preview button', () => { const { getByTestId, getAllByTestId } = renderCorrelationsTable({ ...mockContextValue, isPreviewMode: true, @@ -128,8 +123,7 @@ describe('CorrelationsDetailsAlertsTable', () => { }); }); - it('opens rule preview when feature flag is on and isPreview is false', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('opens rule preview when isPreview is false', () => { const { getAllByTestId } = renderCorrelationsTable(mockContextValue); expect(getAllByTestId(`${TEST_ID}RulePreview`).length).toBe(2); @@ -145,8 +139,7 @@ describe('CorrelationsDetailsAlertsTable', () => { }); }); - it('does not render preview link when feature flag is on and isPreview is true', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('does not render preview link when isPreview is true', () => { const { queryByTestId } = renderCorrelationsTable({ ...mockContextValue, isPreview: true }); expect(queryByTestId(`${TEST_ID}RulePreview`)).not.toBeInTheDocument(); }); diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.tsx index d8497ca984ea8..4d757b46edb27 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/correlations_details_alerts_table.tsx @@ -14,7 +14,6 @@ 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 { 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'; @@ -82,8 +81,6 @@ export const CorrelationsDetailsAlertsTable: FC [ - ...(isPreviewEnabled - ? [ - { - render: (row: Record) => ( - - ), - width: '5%', - }, - ] - : []), + { + render: (row: Record) => ( + + ), + width: '5%', + }, { field: '@timestamp', name: ( @@ -176,20 +169,16 @@ export const CorrelationsDetailsAlertsTable: FC - {isPreviewEnabled ? ( - - {ruleName} - - ) : ( + {ruleName} - )} + ); }, @@ -229,7 +218,7 @@ export const CorrelationsDetailsAlertsTable: FC { const actual = jest.requireActual('react-router-dom'); return { ...actual, useLocation: jest.fn().mockReturnValue({ pathname: '' }) }; @@ -178,20 +174,18 @@ describe('', () => { mockUseHostDetails.mockReturnValue(mockHostDetailsResponse); mockUseRiskScore.mockReturnValue(mockRiskScoreResponse); mockUseHostsRelatedUsers.mockReturnValue(mockRelatedUsersResponse); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(true); (useMisconfigurationPreview as jest.Mock).mockReturnValue({}); (useVulnerabilitiesPreview as jest.Mock).mockReturnValue({}); (useAlertsByStatus as jest.Mock).mockReturnValue({ isLoading: false, items: {} }); }); it('should render host details correctly', () => { - const { getByTestId, queryByTestId } = renderHostDetails(mockContextValue); + const { getByTestId } = renderHostDetails(mockContextValue); expect(getByTestId(EXPANDABLE_PANEL_CONTENT_TEST_ID(HOST_DETAILS_TEST_ID))).toBeInTheDocument(); - expect(queryByTestId(HOST_DETAILS_LINK_TEST_ID)).not.toBeInTheDocument(); + expect(getByTestId(HOST_DETAILS_LINK_TEST_ID)).toBeInTheDocument(); }); - it('should render host name as clicable link when preview is not disabled', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('should render host name as clicable link', () => { const { getByTestId } = renderHostDetails(mockContextValue); expect(getByTestId(HOST_DETAILS_LINK_TEST_ID)).toBeInTheDocument(); @@ -240,7 +234,7 @@ describe('', () => { describe('Related users', () => { it('should render the related user table with correct dates and indices', () => { - const { getByTestId, queryByTestId } = renderHostDetails(mockContextValue); + const { getByTestId } = renderHostDetails(mockContextValue); expect(mockUseHostsRelatedUsers).toBeCalledWith({ from: timestamp, hostName: 'test host', @@ -248,7 +242,7 @@ describe('', () => { skip: false, }); expect(getByTestId(HOST_DETAILS_RELATED_USERS_TABLE_TEST_ID)).toBeInTheDocument(); - expect(queryByTestId(HOST_DETAILS_RELATED_USERS_LINK_TEST_ID)).not.toBeInTheDocument(); + expect(getByTestId(HOST_DETAILS_RELATED_USERS_LINK_TEST_ID)).toBeInTheDocument(); }); it('should render user risk score column when license and capabilities are valid', () => { @@ -294,8 +288,7 @@ describe('', () => { ); }); - it('should render user name as clicable link when preview is not disabled', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('should render user name as clicable link', () => { const { getAllByTestId } = renderHostDetails(mockContextValue); expect(getAllByTestId(HOST_DETAILS_RELATED_USERS_LINK_TEST_ID).length).toBe(1); diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/host_details.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/host_details.tsx index e3fd2fef8bc6e..9555860a329b3 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/host_details.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/host_details.tsx @@ -25,14 +25,12 @@ import type { EuiBasicTableColumn } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -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'; import { AnomalyTableProvider } from '../../../../common/components/ml/anomaly/anomaly_table_provider'; import { InspectButton, InspectButtonContainer } from '../../../../common/components/inspect'; -import { NetworkDetailsLink } from '../../../../common/components/links'; import { RiskScoreEntity } from '../../../../../common/search_strategy'; import { RiskScoreLevel } from '../../../../entity_analytics/components/severity/common'; import { DefaultFieldRenderer } from '../../../../timelines/components/field_renderers/default_renderer'; @@ -110,7 +108,6 @@ export const HostDetails: React.FC = ({ hostName, timestamp, s const isEntityAnalyticsAuthorized = isPlatinumOrTrialLicense && hasEntityAnalyticsCapability; const { openPreviewPanel } = useExpandableFlyoutApi(); - const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled'); const narrowDateRange = useCallback( (score, interval) => { @@ -176,16 +173,12 @@ export const HostDetails: React.FC = ({ hostName, timestamp, s render: (user: string) => ( - {isPreviewEnabled ? ( - - ) : ( - <>{user} - )} + ), @@ -208,15 +201,13 @@ export const HostDetails: React.FC = ({ hostName, timestamp, s render={(ip) => ip == null ? ( getEmptyTagValue() - ) : isPreviewEnabled ? ( + ) : ( - ) : ( - ) } scopeId={scopeId} @@ -242,7 +233,7 @@ export const HostDetails: React.FC = ({ hostName, timestamp, s ] : []), ], - [isEntityAnalyticsAuthorized, scopeId, isPreviewEnabled] + [isEntityAnalyticsAuthorized, scopeId] ); const relatedUsersCount = useMemo( @@ -273,19 +264,14 @@ export const HostDetails: React.FC = ({ hostName, timestamp, s }; const hostLink = useMemo( - () => - isPreviewEnabled - ? { - callback: openHostPreview, - tooltip: i18n.translate( - 'xpack.securitySolution.flyout.left.insights.entities.host.hostPreviewTitle', - { - defaultMessage: 'Preview host', - } - ), - } - : undefined, - [isPreviewEnabled, openHostPreview] + () => ({ + callback: openHostPreview, + tooltip: i18n.translate( + 'xpack.securitySolution.flyout.left.insights.entities.host.hostPreviewTitle', + { defaultMessage: 'Preview host' } + ), + }), + [openHostPreview] ); return ( diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.test.tsx index e8b1b71e9cd0f..e0bef746b213b 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.test.tsx @@ -24,7 +24,6 @@ import { import { usePrevalence } from '../../shared/hooks/use_prevalence'; import { TestProviders } from '../../../../common/mock'; import { licenseService } from '../../../../common/hooks/use_license'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; import { mockFlyoutApi } from '../../shared/mocks/mock_flyout_context'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import { HostPreviewPanelKey } from '../../../entity_details/host_right'; @@ -46,9 +45,6 @@ jest.mock('../../../../common/lib/kibana', () => { }; }); -jest.mock('../../../../common/hooks/use_experimental_features'); -const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; - jest.mock('../../shared/hooks/use_prevalence'); const mockDispatch = jest.fn(); @@ -138,7 +134,6 @@ describe('PrevalenceDetails', () => { jest.clearAllMocks(); licenseServiceMock.isPlatinumPlus.mockReturnValue(true); jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(true); }); it('should render the table with all data if license is platinum', () => { @@ -162,13 +157,10 @@ describe('PrevalenceDetails', () => { ).toBeGreaterThan(1); expect(queryByTestId(PREVALENCE_DETAILS_UPSELL_TEST_ID)).not.toBeInTheDocument(); expect(queryByText(NO_DATA_MESSAGE)).not.toBeInTheDocument(); - expect( - queryByTestId(PREVALENCE_DETAILS_TABLE_PREVIEW_LINK_CELL_TEST_ID) - ).not.toBeInTheDocument(); + expect(getAllByTestId(PREVALENCE_DETAILS_TABLE_PREVIEW_LINK_CELL_TEST_ID)).toHaveLength(2); }); - it('should render host and user name as clickable link if preview is enabled', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('should render host and user name as clickable link', () => { (usePrevalence as jest.Mock).mockReturnValue(mockPrevelanceReturnValue); const { getAllByTestId } = renderPrevalenceDetails(); diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.tsx index 6491bc9ad2747..77ab6eb66df31 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/prevalence_details.tsx @@ -22,7 +22,6 @@ import { useEuiTheme, } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; import { FormattedCount } from '../../../../common/components/formatted_number'; import { useLicense } from '../../../../common/hooks/use_license'; import { InvestigateInTimelineButton } from '../../../../common/components/event_details/investigate_in_timeline_button'; @@ -81,10 +80,6 @@ interface PrevalenceDetailsRow extends PrevalenceData { * License to drive the rendering of the last 2 prevalence columns */ isPlatinumPlus: boolean; - /** - * If enabled, clicking host or user should open an entity preview - */ - isPreviewEnabled: boolean; /** * Scope id to pass to the preview link */ @@ -115,7 +110,7 @@ const columns: Array> = [ render: (data: PrevalenceDetailsRow) => ( {data.values.map((value) => { - if (data.isPreviewEnabled && hasPreview(data.field)) { + if (hasPreview(data.field)) { return ( @@ -331,7 +326,6 @@ export const PrevalenceDetails: React.FC = () => { useDocumentDetailsContext(); const isPlatinumPlus = useLicense().isPlatinumPlus(); - const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled'); // these two are used by the usePrevalence hook to fetch the data const [start, setStart] = useState(DEFAULT_FROM); @@ -382,10 +376,9 @@ export const PrevalenceDetails: React.FC = () => { from: absoluteStart, to: absoluteEnd, isPlatinumPlus, - isPreviewEnabled, scopeId, })), - [data, absoluteStart, absoluteEnd, isPlatinumPlus, isPreviewEnabled, scopeId] + [data, absoluteStart, absoluteEnd, isPlatinumPlus, scopeId] ); const upsell = ( diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/user_details.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/user_details.test.tsx index a5b09ce19bfb0..2ba6345cb1663 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/user_details.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/user_details.test.tsx @@ -16,7 +16,6 @@ import { useMlCapabilities } from '../../../../common/components/ml/hooks/use_ml import { mockAnomalies } from '../../../../common/components/ml/mock'; import { useObservedUserDetails } from '../../../../explore/users/containers/users/observed_details'; import { useUserRelatedHosts } from '../../../../common/containers/related_entities/related_hosts'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; import { RiskSeverity } from '../../../../../common/search_strategy'; import { USER_DETAILS_TEST_ID, @@ -43,9 +42,6 @@ import { useAlertsByStatus } from '../../../../overview/components/detection_res jest.mock('@kbn/expandable-flyout'); jest.mock('@kbn/cloud-security-posture/src/hooks/use_misconfiguration_preview'); -jest.mock('../../../../common/hooks/use_experimental_features'); -const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; - jest.mock('react-router-dom', () => { const actual = jest.requireActual('react-router-dom'); return { ...actual, useLocation: jest.fn().mockReturnValue({ pathname: '' }) }; @@ -172,19 +168,17 @@ describe('', () => { mockUseObservedUserDetails.mockReturnValue(mockUserDetailsResponse); mockUseRiskScore.mockReturnValue(mockRiskScoreResponse); mockUseUsersRelatedHosts.mockReturnValue(mockRelatedHostsResponse); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(true); (useMisconfigurationPreview as jest.Mock).mockReturnValue({}); (useAlertsByStatus as jest.Mock).mockReturnValue({ isLoading: false, items: {} }); }); it('should render user details correctly', () => { - const { getByTestId, queryByTestId } = renderUserDetails(mockContextValue); + const { getByTestId } = renderUserDetails(mockContextValue); expect(getByTestId(EXPANDABLE_PANEL_CONTENT_TEST_ID(USER_DETAILS_TEST_ID))).toBeInTheDocument(); - expect(queryByTestId(USER_DETAILS_LINK_TEST_ID)).not.toBeInTheDocument(); + expect(getByTestId(USER_DETAILS_LINK_TEST_ID)).toBeInTheDocument(); }); - it('should render user name as clicable link when feature flag is true', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('should render user name as clicable link', () => { const { getByTestId } = renderUserDetails(mockContextValue); expect(getByTestId(USER_DETAILS_LINK_TEST_ID)).toBeInTheDocument(); @@ -231,7 +225,7 @@ describe('', () => { describe('Related hosts', () => { it('should render the related host table with correct dates and indices', () => { - const { getByTestId, queryByTestId } = renderUserDetails(mockContextValue); + const { getByTestId } = renderUserDetails(mockContextValue); expect(mockUseUsersRelatedHosts).toBeCalledWith({ from: timestamp, userName: 'test user', @@ -239,7 +233,7 @@ describe('', () => { skip: false, }); expect(getByTestId(USER_DETAILS_RELATED_HOSTS_TABLE_TEST_ID)).toBeInTheDocument(); - expect(queryByTestId(USER_DETAILS_RELATED_HOSTS_LINK_TEST_ID)).not.toBeInTheDocument(); + expect(getByTestId(USER_DETAILS_RELATED_HOSTS_LINK_TEST_ID)).toBeInTheDocument(); }); it('should render host risk score column when license is valid', () => { @@ -272,8 +266,7 @@ describe('', () => { ); }); - it('should render host name and ip as clicable link when preview is enabled', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('should render host name and ip as clicable link', () => { const { getAllByTestId } = renderUserDetails(mockContextValue); expect(getAllByTestId(USER_DETAILS_RELATED_HOSTS_LINK_TEST_ID).length).toBe(1); diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/user_details.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/user_details.tsx index e88cbb54f9471..00366a367a81f 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/user_details.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/left/components/user_details.tsx @@ -25,14 +25,12 @@ import type { EuiBasicTableColumn } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { i18n } from '@kbn/i18n'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -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'; import { AnomalyTableProvider } from '../../../../common/components/ml/anomaly/anomaly_table_provider'; import { InspectButton, InspectButtonContainer } from '../../../../common/components/inspect'; -import { NetworkDetailsLink } from '../../../../common/components/links'; import { RiskScoreEntity } from '../../../../../common/search_strategy'; import { RiskScoreLevel } from '../../../../entity_analytics/components/severity/common'; import { DefaultFieldRenderer } from '../../../../timelines/components/field_renderers/default_renderer'; @@ -109,7 +107,6 @@ export const UserDetails: React.FC = ({ userName, timestamp, s const isEntityAnalyticsAuthorized = isPlatinumOrTrialLicense && hasEntityAnalyticsCapability; const { openPreviewPanel } = useExpandableFlyoutApi(); - const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled'); const narrowDateRange = useCallback( (score, interval) => { @@ -175,16 +172,12 @@ export const UserDetails: React.FC = ({ userName, timestamp, s render: (host: string) => ( - {isPreviewEnabled ? ( - - ) : ( - <>{host} - )} + ), @@ -207,15 +200,13 @@ export const UserDetails: React.FC = ({ userName, timestamp, s render={(ip) => ip == null ? ( getEmptyTagValue() - ) : isPreviewEnabled ? ( + ) : ( - ) : ( - ) } scopeId={scopeId} @@ -241,7 +232,7 @@ export const UserDetails: React.FC = ({ userName, timestamp, s ] : []), ], - [isEntityAnalyticsAuthorized, scopeId, isPreviewEnabled] + [isEntityAnalyticsAuthorized, scopeId] ); const relatedHostsCount = useMemo( @@ -272,19 +263,14 @@ export const UserDetails: React.FC = ({ userName, timestamp, s }; const userLink = useMemo( - () => - isPreviewEnabled - ? { - callback: openUserPreview, - tooltip: i18n.translate( - 'xpack.securitySolution.flyout.left.insights.entities.user.userPreviewTitle', - { - defaultMessage: 'Preview user', - } - ), - } - : undefined, - [isPreviewEnabled, openUserPreview] + () => ({ + callback: openUserPreview, + tooltip: i18n.translate( + 'xpack.securitySolution.flyout.left.insights.entities.user.userPreviewTitle', + { defaultMessage: 'Preview user' } + ), + }), + [openUserPreview] ); return ( diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx index ff003813f260d..e6f88498b2605 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.test.tsx @@ -14,11 +14,7 @@ import { } from './test_ids'; import { HighlightedFieldsCell } from './highlighted_fields_cell'; import { DocumentDetailsContext } from '../../shared/context'; -import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; -import { LeftPanelInsightsTab } from '../../left'; import { TestProviders } from '../../../../common/mock'; -import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; import { useGetAgentStatus } from '../../../../management/hooks/agents/use_get_agent_status'; import { mockFlyoutApi } from '../../shared/mocks/mock_flyout_context'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; @@ -47,9 +43,6 @@ jest.mock('../../../../common/lib/kibana', () => { const useGetAgentStatusMock = useGetAgentStatus as jest.Mock; -jest.mock('../../../../common/hooks/use_experimental_features'); -const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; - const panelContextValue = { eventId: 'event id', indexName: 'indexName', @@ -68,7 +61,6 @@ const renderHighlightedFieldsCell = (values: string[], field: string) => describe('', () => { beforeAll(() => { jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(true); }); it('should render a basic cell', () => { @@ -83,23 +75,7 @@ describe('', () => { expect(getByTestId(HIGHLIGHTED_FIELDS_BASIC_CELL_TEST_ID)).toBeInTheDocument(); }); - it('should open left panel when clicking on the link within a a link cell when preview is disabled', () => { - const { getByTestId } = renderHighlightedFieldsCell(['value'], 'user.name'); - - getByTestId(HIGHLIGHTED_FIELDS_LINKED_CELL_TEST_ID).click(); - expect(mockFlyoutApi.openLeftPanel).toHaveBeenCalledWith({ - id: DocumentDetailsLeftPanelKey, - path: { tab: LeftPanelInsightsTab, subTab: ENTITIES_TAB_ID }, - params: { - id: panelContextValue.eventId, - indexName: panelContextValue.indexName, - scopeId: panelContextValue.scopeId, - }, - }); - }); - - it('should open host preview when click on host when preview is not disabled', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('should open host preview when click on host', () => { const { getByTestId } = renderHighlightedFieldsCell(['test host'], 'host.name'); expect(getByTestId(HIGHLIGHTED_FIELDS_LINKED_CELL_TEST_ID)).toBeInTheDocument(); @@ -114,8 +90,7 @@ describe('', () => { }); }); - it('should open user preview when click on user when preview is not disabled', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('should open user preview when click on user', () => { const { getByTestId } = renderHighlightedFieldsCell(['test user'], 'user.name'); expect(getByTestId(HIGHLIGHTED_FIELDS_LINKED_CELL_TEST_ID)).toBeInTheDocument(); @@ -130,8 +105,7 @@ describe('', () => { }); }); - it('should open ip preview when click on ip when preview is not disabled', () => { - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('should open ip preview when click on ip', () => { const { getByTestId } = renderHighlightedFieldsCell(['100:XXX:XXX'], 'source.ip'); expect(getByTestId(HIGHLIGHTED_FIELDS_LINKED_CELL_TEST_ID)).toBeInTheDocument(); @@ -204,6 +178,7 @@ describe('', () => { expect(getByTestId(HIGHLIGHTED_FIELDS_AGENT_STATUS_CELL_TEST_ID)).toBeInTheDocument(); }); + it('should not render if values is null', () => { const { container } = render( diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.tsx index e11dee4a74adf..b6fc98653f896 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/highlighted_fields_cell.tsx @@ -5,19 +5,14 @@ * 2.0. */ -import type { VFC } from 'react'; -import React, { useCallback, useMemo } from 'react'; -import { EuiFlexItem, EuiLink } from '@elastic/eui'; -import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; +import type { FC } from 'react'; +import React, { useMemo } from 'react'; +import { EuiFlexItem } from '@elastic/eui'; import { getAgentTypeForAgentIdField } from '../../../../common/lib/endpoint/utils/get_agent_type_for_agent_id_field'; import type { ResponseActionAgentType } from '../../../../../common/endpoint/service/response_actions/constants'; import { AgentStatus } from '../../../../common/components/endpoint/agents/agent_status'; import { useDocumentDetailsContext } from '../../shared/context'; import { AGENT_STATUS_FIELD_NAME } from '../../../../timelines/components/timeline/body/renderers/constants'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; -import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; -import { LeftPanelInsightsTab } from '../../left'; -import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; import { HIGHLIGHTED_FIELDS_AGENT_STATUS_CELL_TEST_ID, HIGHLIGHTED_FIELDS_BASIC_CELL_TEST_ID, @@ -44,26 +39,12 @@ export interface HighlightedFieldsCellProps { /** * Renders a component in the highlighted fields table cell based on the field name */ -export const HighlightedFieldsCell: VFC = ({ +export const HighlightedFieldsCell: FC = ({ values, field, originalField = '', }) => { - const { scopeId, eventId, indexName } = useDocumentDetailsContext(); - const { openLeftPanel } = useExpandableFlyoutApi(); - const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled'); - - const goToInsightsEntities = useCallback(() => { - openLeftPanel({ - id: DocumentDetailsLeftPanelKey, - path: { tab: LeftPanelInsightsTab, subTab: ENTITIES_TAB_ID }, - params: { - id: eventId, - indexName, - scopeId, - }, - }); - }, [eventId, indexName, openLeftPanel, scopeId]); + const { scopeId } = useDocumentDetailsContext(); const agentType: ResponseActionAgentType = useMemo(() => { return getAgentTypeForAgentIdField(originalField); @@ -79,20 +60,13 @@ export const HighlightedFieldsCell: VFC = ({ key={`${i}-${value}`} data-test-subj={`${value}-${HIGHLIGHTED_FIELDS_CELL_TEST_ID}`} > - {isPreviewEnabled && hasPreview(field) ? ( + {hasPreview(field) ? ( - ) : hasPreview(field) ? ( - - {value} - ) : field === AGENT_STATUS_FIELD_NAME ? ( { }; }); -jest.mock('../../../../common/hooks/use_experimental_features'); -const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; - const mockUseGlobalTime = jest.fn().mockReturnValue({ from, to }); jest.mock('../../../../common/containers/use_global_time', () => { return { @@ -124,7 +117,6 @@ const renderHostEntityContent = () => describe('', () => { beforeAll(() => { jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(true); (useMisconfigurationPreview as jest.Mock).mockReturnValue({}); (useVulnerabilitiesPreview as jest.Mock).mockReturnValue({}); (useAlertsByStatus as jest.Mock).mockReturnValue({ isLoading: false, items: {} }); @@ -204,28 +196,9 @@ describe('', () => { expect(getByTestId(ENTITIES_HOST_OVERVIEW_LAST_SEEN_TEST_ID)).toHaveTextContent('—'); }); - it('should navigate to left panel entities tab when clicking on title when feature flag is off', () => { - mockUseHostDetails.mockReturnValue([false, { hostDetails: hostData }]); - mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: true }); - - const { getByTestId } = renderHostEntityContent(); - - getByTestId(ENTITIES_HOST_OVERVIEW_LINK_TEST_ID).click(); - expect(mockFlyoutApi.openLeftPanel).toHaveBeenCalledWith({ - id: DocumentDetailsLeftPanelKey, - path: { tab: LeftPanelInsightsTab, subTab: ENTITIES_TAB_ID }, - params: { - id: panelContextValue.eventId, - indexName: panelContextValue.indexName, - scopeId: panelContextValue.scopeId, - }, - }); - }); - - it('should open host preview when clicking on title when feature flag is on', () => { + it('should open host preview when clicking on title', () => { mockUseHostDetails.mockReturnValue([false, { hostDetails: hostData }]); mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: true }); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); const { getByTestId } = renderHostEntityContent(); diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.tsx index 9b60eefbb5f61..eb1ca093fbb03 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/host_entity_overview.tsx @@ -5,11 +5,10 @@ * 2.0. */ -import React, { useCallback, useMemo } from 'react'; +import React, { useMemo } from 'react'; import { EuiFlexGroup, EuiFlexItem, - EuiLink, EuiText, EuiIcon, useEuiTheme, @@ -19,8 +18,6 @@ import { import { css } from '@emotion/css'; import { getOr } from 'lodash/fp'; import { i18n } from '@kbn/i18n'; -import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; import { HOST_NAME_FIELD_NAME } from '../../../../timelines/components/timeline/body/renderers/constants'; import { useRiskScore } from '../../../../entity_analytics/api/hooks/use_risk_score'; import { useDocumentDetailsContext } from '../../shared/context'; @@ -44,7 +41,6 @@ import { LAST_SEEN, HOST_RISK_LEVEL, } from '../../../../overview/components/host_overview/translations'; -import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; import { ENTITIES_HOST_OVERVIEW_TEST_ID, ENTITIES_HOST_OVERVIEW_OS_FAMILY_TEST_ID, @@ -56,8 +52,6 @@ import { ENTITIES_HOST_OVERVIEW_MISCONFIGURATIONS_TEST_ID, ENTITIES_HOST_OVERVIEW_VULNERABILITIES_TEST_ID, } from './test_ids'; -import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; -import { LeftPanelInsightsTab } from '../../left'; import { RiskScoreDocTooltip } from '../../../../overview/components/common'; import { PreviewLink } from '../../../shared/components/preview_link'; import { MisconfigurationsInsight } from '../../shared/components/misconfiguration_insight'; @@ -85,21 +79,7 @@ export const HOST_PREVIEW_BANNER = { * Host preview content for the entities preview in right flyout. It contains ip addresses and risk level */ export const HostEntityOverview: React.FC = ({ hostName }) => { - const { eventId, indexName, scopeId } = useDocumentDetailsContext(); - const { openLeftPanel } = useExpandableFlyoutApi(); - const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled'); - - const goToEntitiesTab = useCallback(() => { - openLeftPanel({ - id: DocumentDetailsLeftPanelKey, - path: { tab: LeftPanelInsightsTab, subTab: ENTITIES_TAB_ID }, - params: { - id: eventId, - indexName, - scopeId, - }, - }); - }, [eventId, openLeftPanel, indexName, scopeId]); + const { scopeId } = useDocumentDetailsContext(); const { from, to } = useGlobalTime(); const { selectedPatterns } = useSourcererDataView(); @@ -212,34 +192,21 @@ export const HostEntityOverview: React.FC = ({ hostName - {isPreviewEnabled ? ( - - - {hostName} - - - ) : ( - + {hostName} - - )} + + diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/table_field_value_cell.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/table_field_value_cell.test.tsx index eec53dbe3d262..2c7abe5bb1d27 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/table_field_value_cell.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/table_field_value_cell.test.tsx @@ -9,7 +9,6 @@ import { render, screen } from '@testing-library/react'; import React from 'react'; import type { FieldSpec } from '@kbn/data-plugin/common'; import { DocumentDetailsContext } from '../../shared/context'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; import type { EventFieldsData } from '../../../../common/components/event_details/types'; import { TableFieldValueCell } from './table_field_value_cell'; @@ -35,9 +34,6 @@ jest.mock('../../../../common/lib/kibana', () => { }; }); -jest.mock('../../../../common/hooks/use_experimental_features'); -const mockUseIsExperimentalFeatureEnabled = useIsExperimentalFeatureEnabled as jest.Mock; - const panelContextValue = { eventId: 'event id', indexName: 'indexName', @@ -66,7 +62,6 @@ describe('TableFieldValueCell', () => { beforeAll(() => { jest.clearAllMocks(); jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); }); describe('common behavior', () => { @@ -213,7 +208,7 @@ describe('TableFieldValueCell', () => { }); }); - it('should open preview when preview is not disabled', () => { + it('should open preview', () => { screen.getByTestId(`${FLYOUT_TABLE_PREVIEW_LINK_FIELD_TEST_ID}-0`).click(); expect(mockFlyoutApi.openPreviewPanel).toHaveBeenCalledWith({ diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/table_field_value_cell.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/table_field_value_cell.tsx index a0095bb8eadf0..17ea9980f1ee0 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/table_field_value_cell.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/table_field_value_cell.tsx @@ -8,7 +8,6 @@ import React, { memo } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiText } from '@elastic/eui'; import type { FieldSpec } from '@kbn/data-plugin/common'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; import { getFieldFormat } from '../utils/get_field_format'; import type { EventFieldsData } from '../../../../common/components/event_details/types'; import { OverflowField } from '../../../../common/components/tables/helpers'; @@ -66,7 +65,6 @@ export const TableFieldValueCell = memo( values, isPreview, }: FieldValueCellProps) => { - const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled'); if (values == null) { return null; } @@ -92,7 +90,7 @@ export const TableFieldValueCell = memo( {data.field === MESSAGE_FIELD_NAME ? ( - ) : isPreviewEnabled && hasPreview(data.field) ? ( + ) : hasPreview(data.field) ? ( { return { @@ -109,7 +102,6 @@ const renderUserEntityOverview = () => describe('', () => { beforeAll(() => { jest.mocked(useExpandableFlyoutApi).mockReturnValue(mockFlyoutApi); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(true); (useMisconfigurationPreview as jest.Mock).mockReturnValue({}); (useAlertsByStatus as jest.Mock).mockReturnValue({ isLoading: false, items: {} }); }); @@ -190,34 +182,9 @@ describe('', () => { expect(queryByTestId(ENTITIES_USER_OVERVIEW_DOMAIN_TEST_ID)).not.toBeInTheDocument(); }); - it('should navigate to left panel entities tab when clicking on title when feature flag is off', () => { - mockUseUserDetails.mockReturnValue([false, { userDetails: userData }]); - mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: true }); - - const { getByTestId } = render( - - - - - - ); - - getByTestId(ENTITIES_USER_OVERVIEW_LINK_TEST_ID).click(); - expect(mockFlyoutApi.openLeftPanel).toHaveBeenCalledWith({ - id: DocumentDetailsLeftPanelKey, - path: { tab: LeftPanelInsightsTab, subTab: ENTITIES_TAB_ID }, - params: { - id: panelContextValue.eventId, - indexName: panelContextValue.indexName, - scopeId: panelContextValue.scopeId, - }, - }); - }); - - it('should open user preview if feature flag is true', () => { + it('should open user preview', () => { mockUseUserDetails.mockReturnValue([false, { userDetails: userData }]); mockUseRiskScore.mockReturnValue({ data: riskLevel, isAuthorized: true }); - mockUseIsExperimentalFeatureEnabled.mockReturnValue(false); const { getByTestId } = render( diff --git a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.tsx b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.tsx index 1008f6139cd67..22f889a61c54e 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/flyout/document_details/right/components/user_entity_overview.tsx @@ -5,13 +5,12 @@ * 2.0. */ -import React, { useCallback, useMemo } from 'react'; +import React, { useMemo } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText, - EuiLink, useEuiTheme, useEuiFontSize, EuiSkeletonText, @@ -19,11 +18,6 @@ import { import { css } from '@emotion/css'; import { getOr } from 'lodash/fp'; import { i18n } from '@kbn/i18n'; -import { useExpandableFlyoutApi } from '@kbn/expandable-flyout'; -import { useIsExperimentalFeatureEnabled } from '../../../../common/hooks/use_experimental_features'; -import { DocumentDetailsLeftPanelKey } from '../../shared/constants/panel_keys'; -import { LeftPanelInsightsTab } from '../../left'; -import { ENTITIES_TAB_ID } from '../../left/components/entities_details'; import { useDocumentDetailsContext } from '../../shared/context'; import type { DescriptionList } from '../../../../../common/utility_types'; import { USER_NAME_FIELD_NAME } from '../../../../timelines/components/timeline/body/renderers/constants'; @@ -83,22 +77,7 @@ export const USER_PREVIEW_BANNER = { * User preview content for the entities preview in right flyout. It contains ip addresses and risk level */ export const UserEntityOverview: React.FC = ({ userName }) => { - const { eventId, indexName, scopeId } = useDocumentDetailsContext(); - const { openLeftPanel } = useExpandableFlyoutApi(); - - const isPreviewEnabled = !useIsExperimentalFeatureEnabled('entityAlertPreviewDisabled'); - - const goToEntitiesTab = useCallback(() => { - openLeftPanel({ - id: DocumentDetailsLeftPanelKey, - path: { tab: LeftPanelInsightsTab, subTab: ENTITIES_TAB_ID }, - params: { - id: eventId, - indexName, - scopeId, - }, - }); - }, [eventId, openLeftPanel, indexName, scopeId]); + const { scopeId } = useDocumentDetailsContext(); const { from, to } = useGlobalTime(); const { selectedPatterns } = useSourcererDataView(); @@ -210,34 +189,21 @@ export const UserEntityOverview: React.FC = ({ userName - {isPreviewEnabled ? ( - - - {userName} - - - ) : ( - + {userName} - - )} + +