Skip to content
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

Merged
merged 47 commits into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
351e900
asset criticality badge colors update to use euiTheme Colors
CAWilson94 Dec 11, 2024
f0692f2
color tokens updated, util functions and json tokens removed
CAWilson94 Dec 5, 2024
a5a8653
JSON tokens updated to pull in from euiTheme instead; index text for …
CAWilson94 Dec 3, 2024
4d94311
EUI refresh theme colors update
CAWilson94 Nov 30, 2024
ed7b515
change theme colors to use from themeProvider instead of useEuiTheme …
CAWilson94 Dec 5, 2024
9d5a020
restore missing word in filepicker step
CAWilson94 Dec 12, 2024
0164b9a
risk severity hook to use the useEuiTheme hook instead of - definitio…
CAWilson94 Dec 12, 2024
7304fdb
Merge branch 'elastic:main' into eui
CAWilson94 Dec 13, 2024
087a782
riskSeverityColors hook used instead of static color mapping to use e…
CAWilson94 Dec 13, 2024
64b11f9
riskSeverity hook used instead of static mapping to use euiTheme hook…
CAWilson94 Dec 15, 2024
3cd2bd1
Merge branch 'main' into eui
CAWilson94 Dec 16, 2024
51aa944
Merge branch 'main' into eui
CAWilson94 Dec 16, 2024
7cd0188
moved static definitions to hook usage in risk severity colors
CAWilson94 Dec 16, 2024
8dba690
asset criticality update with new hook using euiTheme hook
CAWilson94 Dec 16, 2024
8175763
fieldColumn update with euiTheme hook
CAWilson94 Dec 16, 2024
76ae25d
empty space cleanup
CAWilson94 Dec 16, 2024
4ff2336
Merge branch 'main' into eui
CAWilson94 Dec 16, 2024
6502b52
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Dec 16, 2024
0302b32
conditional for criticality mappings to always align correct colours …
CAWilson94 Dec 16, 2024
f1e30ab
risk severity colors with conditional for correct mapping across both…
CAWilson94 Dec 16, 2024
dd4d06f
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Dec 16, 2024
16a3bcd
Merge branch 'main' into eui
hop-dev Dec 19, 2024
da530ac
fix types
hop-dev Dec 19, 2024
404c2ab
some PR feedback
hop-dev Dec 19, 2024
7c00b6e
euiThemeSize reverted back to small from xs, typo previously.
CAWilson94 Jan 6, 2025
4b89342
[CI] Auto-commit changed files from 'node scripts/yarn_deduplicate'
kibanamachine Jan 6, 2025
17100c2
riskBadge color fix
CAWilson94 Jan 7, 2025
46283ba
Merge branch 'main' into eui
CAWilson94 Jan 7, 2025
6170244
revert criticality level colors hook; will be updated with shared hoo…
CAWilson94 Jan 7, 2025
436a96e
Merge branch 'main' into eui
CAWilson94 Jan 7, 2025
0990008
update correct color palette
CAWilson94 Jan 7, 2025
8759c94
revert colors in test for severity colors
CAWilson94 Jan 8, 2025
d34804b
Merge branch 'main' into eui
CAWilson94 Jan 8, 2025
9843d7b
risk colors updated for borealis and amsterdam in interim of shared hook
CAWilson94 Jan 15, 2025
21611e2
Merge branch 'main' into eui
CAWilson94 Jan 15, 2025
4796135
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jan 15, 2025
4dbc25e
Merge branch 'main' into eui
CAWilson94 Jan 20, 2025
2b82ee5
fixing a couple of errors
CAWilson94 Jan 20, 2025
0eb1ddd
Merge branch 'main' into eui
CAWilson94 Jan 23, 2025
9607bb0
Update Severity colors in utils to use previous colors matching Amste…
CAWilson94 Jan 23, 2025
6c7b3f0
revert risk severity colors palette changes; blocked until security s…
CAWilson94 Jan 24, 2025
02e5883
Merge branch 'main' into eui
CAWilson94 Jan 24, 2025
adc05df
background color changed to euiTheme.colors.backgroundBaseDanger for …
CAWilson94 Jan 24, 2025
8528f33
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Jan 24, 2025
7592982
update unknown colors for testing risk severity
CAWilson94 Jan 24, 2025
ef6a5eb
Merge branch 'main' into eui
CAWilson94 Jan 27, 2025
d8ad739
Merge branch 'main' into eui
CAWilson94 Jan 27, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,9 @@
*/
import React from 'react';
import { EuiHealth } from '@elastic/eui';
import { euiLightVars } from '@kbn/ui-theme';
import { CRITICALITY_LEVEL_TITLE } from './translations';
import type { CriticalityLevelWithUnassigned } from '../../../../common/entity_analytics/asset_criticality/types';

export const CRITICALITY_LEVEL_COLOR: Record<CriticalityLevelWithUnassigned, string> = {
extreme_impact: '#E7664C',
high_impact: '#DA8B45',
medium_impact: 'D6BF57',
low_impact: '#54B399',
unassigned: euiLightVars.euiColorMediumShade,
};
import { useCriticalityLevelColors } from '../../hooks/use_criticality_level_colors';
Copy link
Contributor Author

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.


export const AssetCriticalityBadge: React.FC<{
criticalityLevel?: CriticalityLevelWithUnassigned;
Expand All @@ -29,10 +21,11 @@ export const AssetCriticalityBadge: React.FC<{
dataTestSubj = 'asset-criticality-badge',
className,
}) => {
const criticalityColors = useCriticalityLevelColors();
return (
<EuiHealth
data-test-subj={dataTestSubj}
color={CRITICALITY_LEVEL_COLOR[criticalityLevel]}
color={criticalityColors[criticalityLevel]}
style={style}
className={className}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import {
EuiSpacer,
EuiText,
EuiTitle,
useEuiFontSize,
useEuiTheme,
} from '@elastic/eui';

import { css } from '@emotion/css';
import React from 'react';
import { FormattedMessage } from '@kbn/i18n-react';

import { euiThemeVars } from '@kbn/ui-theme';
import {
CRITICALITY_CSV_MAX_SIZE_BYTES,
ValidCriticalityLevels,
Expand All @@ -35,17 +36,18 @@ interface AssetCriticalityFilePickerStepProps {

const sampleCSVContent = `user,user-001,low_impact\nuser,user-002,medium_impact\nhost,host-001,extreme_impact`;

const listStyle = css`
list-style-type: disc;
margin-bottom: ${euiThemeVars.euiSizeL};
margin-left: ${euiThemeVars.euiSizeL};
line-height: ${euiThemeVars.euiLineHeight};
`;

export const AssetCriticalityFilePickerStep: React.FC<AssetCriticalityFilePickerStepProps> =
React.memo(({ onFileChange, errorMessage, isLoading }) => {
const formatBytes = useFormatBytes();
const { euiTheme } = useEuiTheme();

const listStyle = css`
list-style-type: disc;
margin-bottom: ${euiTheme.size.l};
margin-left: ${euiTheme.size.l};
line-height: ${useEuiFontSize('s').lineHeight};
`;

return (
<>
<EuiSpacer size="m" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ export const AssetCriticalityValidationStep: React.FC<AssetCriticalityValidation
language="CSV"
isVirtualized
css={css`
border: 1px solid ${euiTheme.colors.success};
border: 1px solid ${euiTheme.colors.accentSecondary};
hop-dev marked this conversation as resolved.
Show resolved Hide resolved
`}
>
{validLines.text}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const RiskInformationFlyout = ({ handleOnClose }: { handleOnClose: () =>
label={BETA}
size="s"
css={css`
color: ${euiTheme.colors.text};
color: ${euiTheme.colors.textParagraph};
margin-top: ${euiTheme.size.xxs};
`}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
} from '@elastic/eui';
import { css } from '@emotion/react';
import { FormattedMessage } from '@kbn/i18n-react';
import { euiThemeVars } from '@kbn/ui-theme';
import dateMath from '@kbn/datemath';
import { i18n } from '@kbn/i18n';
import { useKibana } from '../../../common/lib/kibana/kibana_react';
Expand Down Expand Up @@ -243,7 +242,7 @@ const FlyoutRiskSummaryComponent = <T extends RiskScoreEntity>({
css={css`
position: absolute;
right: 0;
top: -${euiThemeVars.euiSize};
top: -${euiTheme.size};
hop-dev marked this conversation as resolved.
Show resolved Hide resolved
`}
>
<InspectButton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Copy link
Contributor Author

@CAWilson94 CAWilson94 Dec 12, 2024

Choose a reason for hiding this comment

The 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');
Expand All @@ -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
);
});
Expand All @@ -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
);
});
Expand All @@ -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
);
});
Expand All @@ -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
);
});
Expand All @@ -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
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<{
Expand Down Expand Up @@ -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();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the change

return (
<RiskBadge
color={euiTheme.colors.danger}
Copy link
Contributor Author

Choose a reason for hiding this comment

The 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
};
};