-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Eui Refresh #204007
Eui Refresh #204007
Changes from 6 commits
351e900
f0692f2
a5a8653
4d94311
ed7b515
9d5a020
0164b9a
7304fdb
087a782
64b11f9
3cd2bd1
51aa944
7cd0188
8dba690
8175763
76ae25d
4ff2336
6502b52
0302b32
f1e30ab
dd4d06f
16a3bcd
da530ac
404c2ab
7c00b6e
4b89342
17100c2
46283ba
6170244
436a96e
0990008
8759c94
d34804b
9843d7b
21611e2
4796135
4dbc25e
2b82ee5
0eb1ddd
9607bb0
6c7b3f0
02e5883
adc05df
8528f33
7592982
ef6a5eb
d8ad739
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,10 +13,9 @@ import { TestProviders } from '../../../../common/mock'; | |
import type { EuiHealthProps } from '@elastic/eui'; | ||
import { EuiHealth } from '@elastic/eui'; | ||
|
||
import { euiThemeVars } from '@kbn/ui-theme'; | ||
import { RiskSeverity } from '../../../../../common/search_strategy'; | ||
import { RiskScoreLevel } from '.'; | ||
import { SEVERITY_COLOR } from '../../../../overview/components/detection_response/utils'; | ||
import { RISK_SEVERITY_COLOUR } from '../../../common/utils'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated RISK_SEVERITY_COLOUR to match updates previously made to index from SEVERITY --> RISK_SEVERITY |
||
|
||
jest.mock('@elastic/eui', () => { | ||
const original = jest.requireActual('@elastic/eui'); | ||
|
@@ -38,7 +37,7 @@ describe('RiskScore', () => { | |
expect(container).toHaveTextContent(RiskSeverity.Critical); | ||
|
||
expect(EuiHealth as jest.Mock).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ color: SEVERITY_COLOR.critical }), | ||
expect.objectContaining({ color: RISK_SEVERITY_COLOUR.Critical }), | ||
context | ||
); | ||
}); | ||
|
@@ -53,7 +52,7 @@ describe('RiskScore', () => { | |
expect(container).toHaveTextContent(RiskSeverity.High); | ||
|
||
expect(EuiHealth as jest.Mock).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ color: SEVERITY_COLOR.high }), | ||
expect.objectContaining({ color: RISK_SEVERITY_COLOUR.High }), | ||
context | ||
); | ||
}); | ||
|
@@ -68,7 +67,7 @@ describe('RiskScore', () => { | |
expect(container).toHaveTextContent(RiskSeverity.Moderate); | ||
|
||
expect(EuiHealth as jest.Mock).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ color: SEVERITY_COLOR.medium }), | ||
expect.objectContaining({ color: RISK_SEVERITY_COLOUR.Moderate }), | ||
context | ||
); | ||
}); | ||
|
@@ -83,7 +82,7 @@ describe('RiskScore', () => { | |
expect(container).toHaveTextContent(RiskSeverity.Low); | ||
|
||
expect(EuiHealth as jest.Mock).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ color: SEVERITY_COLOR.low }), | ||
expect.objectContaining({ color: RISK_SEVERITY_COLOUR.Low }), | ||
context | ||
); | ||
}); | ||
|
@@ -98,7 +97,7 @@ describe('RiskScore', () => { | |
expect(container).toHaveTextContent(RiskSeverity.Unknown); | ||
|
||
expect(EuiHealth as jest.Mock).toHaveBeenLastCalledWith( | ||
expect.objectContaining({ color: euiThemeVars.euiColorMediumShade }), | ||
expect.objectContaining({ color: RISK_SEVERITY_COLOUR.Unknown }), | ||
context | ||
); | ||
}); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,31 +7,33 @@ | |
|
||
import React from 'react'; | ||
|
||
import { EuiHealth, EuiTextColor, transparentize } from '@elastic/eui'; | ||
import { EuiHealth, EuiTextColor, useEuiTheme } from '@elastic/eui'; | ||
|
||
import styled, { css } from 'styled-components'; | ||
import { euiLightVars } from '@kbn/ui-theme'; | ||
|
||
import { RISK_SEVERITY_COLOUR } from '../../../common/utils'; | ||
import { HoverPopover } from '../../../../common/components/hover_popover'; | ||
import type { RiskSeverity } from '../../../../../common/search_strategy'; | ||
|
||
const RiskBadge = styled.div<{ $severity: RiskSeverity; $hideBackgroundColor: boolean }>` | ||
const RiskBadge = styled.div<{ | ||
$severity: RiskSeverity; | ||
$hideBackgroundColor: boolean; | ||
}>` | ||
${({ theme, $severity, $hideBackgroundColor }) => css` | ||
width: fit-content; | ||
padding-right: ${theme.eui.euiSizeS}; | ||
padding-right: ${theme.eui.euiSizeXS}; | ||
CAWilson94 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
padding-left: ${theme.eui.euiSizeXS}; | ||
|
||
${($severity === 'Critical' || $severity === 'High') && | ||
!$hideBackgroundColor && | ||
css` | ||
background-color: ${transparentize(theme.eui.euiColorDanger, 0.2)}; | ||
background-color: ${theme.eui.euiColorDanger}; | ||
hop-dev marked this conversation as resolved.
Show resolved
Hide resolved
|
||
border-radius: 999px; // pill shaped | ||
`}; | ||
`} | ||
`; | ||
const TooltipContainer = styled.div` | ||
padding: ${({ theme }) => theme.eui.euiSizeS}; | ||
padding: ${({ theme }) => theme.euiSizeS}; | ||
`; | ||
|
||
export const RiskScoreLevel: React.FC<{ | ||
|
@@ -68,18 +70,21 @@ const RiskScoreBadge: React.FC<{ | |
severity: RiskSeverity; | ||
hideBackgroundColor?: boolean; | ||
['data-test-subj']?: string; | ||
}> = React.memo(({ severity, hideBackgroundColor = false, 'data-test-subj': dataTestSubj }) => ( | ||
<RiskBadge | ||
color={euiLightVars.euiColorDanger} | ||
$severity={severity} | ||
$hideBackgroundColor={hideBackgroundColor} | ||
data-test-subj={dataTestSubj ?? 'risk-score'} | ||
> | ||
<EuiTextColor color="default"> | ||
<EuiHealth className="eui-alignMiddle" color={RISK_SEVERITY_COLOUR[severity]}> | ||
{severity} | ||
</EuiHealth> | ||
</EuiTextColor> | ||
</RiskBadge> | ||
)); | ||
}> = React.memo(({ severity, hideBackgroundColor = false, 'data-test-subj': dataTestSubj }) => { | ||
const { euiTheme } = useEuiTheme(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is the change |
||
return ( | ||
<RiskBadge | ||
color={euiTheme.colors.danger} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. along with this change, the others I think just formatter |
||
$severity={severity} | ||
$hideBackgroundColor={hideBackgroundColor} | ||
data-test-subj={dataTestSubj ?? 'risk-score'} | ||
> | ||
<EuiTextColor color="default"> | ||
<EuiHealth className="eui-alignMiddle" color={RISK_SEVERITY_COLOUR[severity]}> | ||
{severity} | ||
</EuiHealth> | ||
</EuiTextColor> | ||
</RiskBadge> | ||
); | ||
}); | ||
RiskScoreBadge.displayName = 'RiskScoreBadge'; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
import { useEuiTheme } from '@elastic/eui'; | ||
import type { CriticalityLevelWithUnassigned } from '../../../common/entity_analytics/asset_criticality/types'; | ||
// TODO: update these colors once severity color palette is available | ||
export const useCriticalityLevelColors = (): Record<CriticalityLevelWithUnassigned, string> => { | ||
const { euiTheme } = useEuiTheme(); | ||
return { | ||
extreme_impact: '#F66D64', // TODO change to euiTheme.colors.vis.euiColorVis6 when borealis is available, | ||
high_impact: euiTheme.colors.vis.euiColorVisWarm1, | ||
medium_impact: euiTheme.colors.vis.euiColorVis9, | ||
low_impact: euiTheme.colors.vis.euiColorVisSuccess0, | ||
unassigned: euiTheme.colors.vis.euiColorVisNeutral0, // TODO: this is a closest guess based on severity colors, change to grey20 when available | ||
}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved this to a hook in the hooks folder. Noticed some hooks in asset_criticality aren’t in hooks; both locations make sense, but this follows a better convention.