From de77bed2a15a5b8890254070fe551b08df646dce Mon Sep 17 00:00:00 2001 From: Pablo Machado Date: Fri, 1 Nov 2024 12:58:01 +0100 Subject: [PATCH] [SecuritySolution] Fix dashboard page when the entity store state is stopped (#198645) ## Summary Fix the dashboard page when the entity store state is stopped Previously, the EntityStoreDashboardPanels component didn't account for the installed but disabled state (stopped). I made the minimum changes necessary to fix the bug, but this component needs to be refactored, unit-tested, and written in a storybook with all possible states. Technical debt Issue: https://github.com/elastic/security-team/issues/11035 (cherry picked from commit 34aab05595115289ed7b7f8c1fad7f282292a25b) --- .../components/dashboard_panels.tsx | 59 ++++++++++--------- 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_store/components/dashboard_panels.tsx b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_store/components/dashboard_panels.tsx index 99e2475f95a78..63ffcf7b9eae1 100644 --- a/x-pack/plugins/security_solution/public/entity_analytics/components/entity_store/components/dashboard_panels.tsx +++ b/x-pack/plugins/security_solution/public/entity_analytics/components/entity_store/components/dashboard_panels.tsx @@ -141,6 +141,7 @@ const EntityStoreDashboardPanelsComponent = () => { ); } + // TODO Rename variable because the Risk score could be installed but disabled const isRiskScoreAvailable = riskEngineStatus.data && riskEngineStatus.data.risk_engine_status !== RiskEngineStatusEnum.NOT_INSTALLED; @@ -199,35 +200,37 @@ const EntityStoreDashboardPanelsComponent = () => { )} - {entityStore.status === 'not_installed' && !isRiskScoreAvailable && ( - // TODO: Move modal inside EnableEntityStore component, eliminating the onEnable prop in favour of forwarding the riskScoreEnabled status - setModalState({ visible: true })} - loadingRiskEngine={riskEngineInitializing} - /> - )} + {(entityStore.status === 'not_installed' || entityStore.status === 'stopped') && + !isRiskScoreAvailable && ( + // TODO: Move modal inside EnableEntityStore component, eliminating the onEnable prop in favour of forwarding the riskScoreEnabled status + setModalState({ visible: true })} + loadingRiskEngine={riskEngineInitializing} + /> + )} - {entityStore.status === 'not_installed' && isRiskScoreAvailable && ( - <> - - - setModalState({ - visible: true, - }) - } - /> - - - - - - - - - )} + {(entityStore.status === 'not_installed' || entityStore.status === 'stopped') && + isRiskScoreAvailable && ( + <> + + + setModalState({ + visible: true, + }) + } + /> + + + + + + + + + )}