From 4552bd4926ee76ae8b19471accd5161500958b3d Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Tue, 25 Feb 2025 03:47:08 +1100 Subject: [PATCH] [8.18] [Security Solution] Fix Incorrect Enable Button Behavior in Entity Store Modal (#212078) (#212250) # Backport This will backport the following commits from `main` to `8.18`: - [[Security Solution] Fix Incorrect Enable Button Behavior in Entity Store Modal (#212078)](https://github.com/elastic/kibana/pull/212078) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) Co-authored-by: Charlotte Alexandra Wilson --- .../components/enablement_modal.test.tsx | 18 ++++++++++++++++ .../components/enablement_modal.tsx | 21 ++++++++++++++++++- 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/enablement_modal.test.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/enablement_modal.test.tsx index b2c97a33b2ff4..7b51958df18b3 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/enablement_modal.test.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/enablement_modal.test.tsx @@ -146,6 +146,24 @@ describe('EntityStoreEnablementModal', () => { expect(enableButton).toBeDisabled(); }); + it('should show proceed warning when riskScore is enabled but entityStore is disabled and unchecked', () => { + renderComponent({ + ...defaultProps, + riskScore: { disabled: false, checked: false }, // Enabled & Checked + entityStore: { disabled: true, checked: false }, // Disabled & Unchecked + }); + expect(screen.getByText('Please enable at least one option to proceed.')).toBeInTheDocument(); + }); + + it('should show proceed warning when entityStore is enabled but riskScore is disabled and unchecked', () => { + renderComponent({ + ...defaultProps, + entityStore: { disabled: false, checked: false }, // Enabled & Checked + riskScore: { disabled: true, checked: false }, // Disabled & Unchecked + }); + expect(screen.getByText('Please enable at least one option to proceed.')).toBeInTheDocument(); + }); + it('should not show entity engine missing privileges warning when no missing privileges', () => { renderComponent(); expect( diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/enablement_modal.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/enablement_modal.tsx index 6ece2fea1b223..e104c6a76bb88 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/enablement_modal.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/enablement_modal.tsx @@ -54,6 +54,20 @@ interface EntityStoreEnablementModalProps { }; } +const shouldAllowEnablement = ( + riskScoreEnabled: boolean, + entityStoreEnabled: boolean, + enablements: Enablements +) => { + if (riskScoreEnabled) { + return enablements.entityStore; + } + if (entityStoreEnabled) { + return enablements.riskScore; + } + return enablements.riskScore || enablements.entityStore; +}; + export const EntityStoreEnablementModal: React.FC = ({ visible, toggle, @@ -69,7 +83,12 @@ export const EntityStoreEnablementModal: React.FC