From 74665d2ee423c9603745eeb395a54dc4ef69770b Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Thu, 27 Feb 2025 20:25:37 +1100 Subject: [PATCH] [8.18] [refactoring] Distinguish User Controls from Risk Engine in DashboardEnablementPanel (#212441) (#212519) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Backport This will backport the following commits from `main` to `8.18`: - [[refactoring] Distinguish User Controls from Risk Engine in DashboardEnablementPanel (#212441)](https://github.com/elastic/kibana/pull/212441) ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) Co-authored-by: Charlotte Alexandra Wilson --- .../components/dashboard_enablement_panel.tsx | 4 ++-- .../components/enablement_modal.test.tsx | 12 +++++------ .../components/enablement_modal.tsx | 20 +++++++++---------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/dashboard_enablement_panel.tsx b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/dashboard_enablement_panel.tsx index 9f5a70b3f7332..984c00fac579b 100644 --- a/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/dashboard_enablement_panel.tsx +++ b/x-pack/solutions/security/plugins/security_solution/public/entity_analytics/components/entity_store/components/dashboard_enablement_panel.tsx @@ -223,11 +223,11 @@ export const EnablementPanel: React.FC = ({ state } toggle={(visible) => setModalState({ visible })} enableStore={enableEntityStore} riskScore={{ - disabled: riskEngineStatus !== RiskEngineStatusEnum.NOT_INSTALLED, + canToggle: riskEngineStatus === RiskEngineStatusEnum.NOT_INSTALLED, checked: riskEngineStatus === RiskEngineStatusEnum.NOT_INSTALLED, }} entityStore={{ - disabled: entityStoreStatus === 'running', + canToggle: entityStoreStatus !== 'running', checked: entityStoreStatus === 'not_installed', }} /> 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 7b51958df18b3..80a16e18ef6c8 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 @@ -35,8 +35,8 @@ const defaultProps = { visible: true, toggle: mockToggle, enableStore: mockEnableStore, - riskScore: { disabled: false, checked: false }, - entityStore: { disabled: false, checked: false }, + riskScore: { canToggle: false, checked: false }, + entityStore: { canToggle: false, checked: false }, }; const allEntityEnginePrivileges: EntityAnalyticsPrivileges = { @@ -149,8 +149,8 @@ describe('EntityStoreEnablementModal', () => { 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 + riskScore: { canToggle: false, checked: false }, // Enabled & Checked + entityStore: { canToggle: true, checked: false }, // Disabled & Unchecked }); expect(screen.getByText('Please enable at least one option to proceed.')).toBeInTheDocument(); }); @@ -158,8 +158,8 @@ describe('EntityStoreEnablementModal', () => { 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 + entityStore: { canToggle: false, checked: false }, // Enabled & Checked + riskScore: { canToggle: true, checked: false }, // Disabled & Unchecked }); expect(screen.getByText('Please enable at least one option to proceed.')).toBeInTheDocument(); }); 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 e104c6a76bb88..9347273ce5590 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 @@ -45,11 +45,11 @@ interface EntityStoreEnablementModalProps { toggle: (visible: boolean) => void; enableStore: (enablements: Enablements) => () => void; riskScore: { - disabled?: boolean; + canToggle?: boolean; checked?: boolean; }; entityStore: { - disabled?: boolean; + canToggle?: boolean; checked?: boolean; }; } @@ -57,15 +57,15 @@ interface EntityStoreEnablementModalProps { const shouldAllowEnablement = ( riskScoreEnabled: boolean, entityStoreEnabled: boolean, - enablements: Enablements + userHasEnabled: Enablements ) => { if (riskScoreEnabled) { - return enablements.entityStore; + return userHasEnabled.entityStore; } if (entityStoreEnabled) { - return enablements.riskScore; + return userHasEnabled.riskScore; } - return enablements.riskScore || enablements.entityStore; + return userHasEnabled.riskScore || userHasEnabled.entityStore; }; export const EntityStoreEnablementModal: React.FC = ({ @@ -85,8 +85,8 @@ export const EntityStoreEnablementModal: React.FC setEnablements((prev) => ({ ...prev, riskScore: !prev.riskScore }))} @@ -156,7 +156,7 @@ export const EntityStoreEnablementModal: React.FC