Skip to content

Commit

Permalink
[SecuritySolution] Fix dashboard page when the entity store state is …
Browse files Browse the repository at this point in the history
…stopped (elastic#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:
elastic/security-team#11035

(cherry picked from commit 34aab05)
  • Loading branch information
machadoum committed Nov 1, 2024
1 parent d74f8a7 commit de77bed
Showing 1 changed file with 31 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
<EnableEntityStore
enablements="both"
onEnable={() => 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
<EnableEntityStore
enablements="both"
onEnable={() => setModalState({ visible: true })}
loadingRiskEngine={riskEngineInitializing}
/>
)}

{entityStore.status === 'not_installed' && isRiskScoreAvailable && (
<>
<EuiFlexItem>
<EnableEntityStore
enablements="store"
onEnable={() =>
setModalState({
visible: true,
})
}
/>
</EuiFlexItem>
<EuiFlexItem>
<EntityAnalyticsRiskScores riskEntity={RiskScoreEntity.user} />
</EuiFlexItem>
<EuiFlexItem>
<EntityAnalyticsRiskScores riskEntity={RiskScoreEntity.host} />
</EuiFlexItem>
</>
)}
{(entityStore.status === 'not_installed' || entityStore.status === 'stopped') &&
isRiskScoreAvailable && (
<>
<EuiFlexItem>
<EnableEntityStore
enablements="store"
onEnable={() =>
setModalState({
visible: true,
})
}
/>
</EuiFlexItem>
<EuiFlexItem>
<EntityAnalyticsRiskScores riskEntity={RiskScoreEntity.user} />
</EuiFlexItem>
<EuiFlexItem>
<EntityAnalyticsRiskScores riskEntity={RiskScoreEntity.host} />
</EuiFlexItem>
</>
)}

<EntityStoreEnablementModal
visible={modal.visible}
Expand Down

0 comments on commit de77bed

Please sign in to comment.