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

[Security Solution][threat hunting explore] EUI refresh: Remove custom color hex #204631

Merged
merged 23 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
32e0057
remove custom color hex
angorayc Dec 17, 2024
487fdb4
donut chart
angorayc Dec 18, 2024
e3f218a
euiTheme
angorayc Dec 18, 2024
3ce96d5
clean up
angorayc Dec 18, 2024
fff228f
Merge branch 'main' of github.com:elastic/kibana into eui-color-palette
angorayc Dec 18, 2024
90608ca
unit tests
angorayc Dec 18, 2024
f316083
use color tokens from useEuiTheme
angorayc Dec 18, 2024
b2fe0d9
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine Dec 18, 2024
1a8c80a
lint
angorayc Dec 18, 2024
59bf4fe
Merge branch 'eui-color-palette' of github.com:angorayc/kibana into e…
angorayc Dec 18, 2024
099e29d
unit tests
angorayc Dec 19, 2024
8a6f3a0
update unit tests
angorayc Dec 19, 2024
539ae10
Merge branch 'main' into eui-color-palette
angorayc Dec 30, 2024
ef93cd0
revert changes about severity colors
angorayc Jan 2, 2025
7b36fc5
Merge branch 'eui-color-palette' of github.com:angorayc/kibana into e…
angorayc Jan 2, 2025
d4722cc
Merge branch 'main' into eui-color-palette
angorayc Jan 2, 2025
955ef20
update attributes
angorayc Jan 3, 2025
acf2576
types
angorayc Jan 3, 2025
a699234
design review
angorayc Jan 6, 2025
3c71074
Merge branch 'main' into eui-color-palette
angorayc Jan 6, 2025
78d3884
[CI] Auto-commit changed files from 'node scripts/styled_components_m…
kibanamachine Jan 6, 2025
d8fe7ee
Merge branch 'main' into eui-color-palette
angorayc Jan 8, 2025
97996ea
Merge branch 'main' into eui-color-palette
angorayc Jan 9, 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
1 change: 0 additions & 1 deletion packages/kbn-babel-preset/styled_components_files.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -353,8 +353,6 @@ describe.each(chartDataSets)('BarChart with stackByField', () => {
},
];

const expectedColors = ['#1EA593', '#2B70F7', '#CE0060'];

const stackByField = 'process.name';

beforeAll(() => {
Expand All @@ -369,12 +367,6 @@ describe.each(chartDataSets)('BarChart with stackByField', () => {
expect(wrapper.find('[data-test-subj="draggable-legend"]').exists()).toBe(true);
});

expectedColors.forEach((color, i) => {
test(`it renders the expected legend color ${color} for legend item ${i}`, () => {
expect(wrapper.find(`div [color="${color}"]`).exists()).toBe(true);
});
});

data.forEach((datum) => {
test(`it renders the expected draggable legend text for datum ${datum.key}`, () => {
const dataProviderId = `draggableId.content.draggable-legend-item-uuid_v4()-${escapeDataProviderId(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import deepEqual from 'fast-deep-equal';

import { escapeDataProviderId } from '../drag_and_drop/helpers';
import { useTimeZone } from '../../lib/kibana';
import { defaultLegendColors } from '../matrix_histogram/utils';
import { useThrottledResizeObserver } from '../utils';
import { hasValueToDisplay } from '../../utils/validators';
import { EMPTY_VALUE_LABEL } from './translation';
Expand Down Expand Up @@ -192,8 +191,8 @@ export const BarChartComponent: React.FC<BarChartComponentProps> = ({
const legendItems: LegendItem[] = useMemo(
() =>
barChart != null && stackByField != null
? barChart.map((d, i) => ({
color: d.color ?? (i < defaultLegendColors.length ? defaultLegendColors[i] : undefined),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

defaultLegendColors is removed as we don't want hard coded colors:
x-pack/solutions/security/plugins/security_solution/public/common/components/matrix_histogram/utils.ts

? barChart.map((d) => ({
color: d.color,
dataProviderId: escapeDataProviderId(
`draggable-legend-item-${uuidv4()}-${stackByField}-${d.key}`
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,54 @@
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import type { EuiThemeComputed } from '@elastic/eui';
import { useEuiTheme } from '@elastic/eui';
import { css } from '@emotion/react';
import React from 'react';
import styled from 'styled-components';
import { useEuiBackgroundColor } from '@elastic/eui';

interface DonutChartEmptyProps {
size?: number;
donutWidth?: number;
}

/*
** @deprecated use getEmptyDonutColor instead
*/
export const emptyDonutColor = '#FAFBFD';

const BigRing = styled.div<DonutChartEmptyProps>`
border-radius: 50%;
${({ size }) =>
`height: ${size}px;
width: ${size}px;
background-color: ${emptyDonutColor};
text-align: center;
line-height: ${size}px;`}
`;

const SmallRing = styled.div<DonutChartEmptyProps>`
border-radius: 50%;
${({ size }) => `
height: ${size}px;
width: ${size}px;
background-color: ${useEuiBackgroundColor('plain')};
display: inline-block;
vertical-align: middle;`}
`;
export const getEmptyDonutColor = (euiTheme: EuiThemeComputed) => euiTheme.colors.textSubdued;

const EmptyDonutChartComponent: React.FC<DonutChartEmptyProps> = ({ size = 90, donutWidth = 20 }) =>
size - donutWidth > 0 ? (
<BigRing size={size} data-test-subj="empty-donut">
<SmallRing size={size - donutWidth} data-test-subj="empty-donut-small" />
</BigRing>
const EmptyDonutChartComponent: React.FC<DonutChartEmptyProps> = ({
size = 90,
donutWidth = 20,
}) => {
const { euiTheme } = useEuiTheme();
const middleSize = size - donutWidth;
return size - donutWidth > 0 ? (
<div
data-test-subj="empty-donut"
css={css`
border-radius: 50%;
height: ${size}px;
width: ${size}px;
background-color: ${euiTheme.colors.backgroundBaseSubdued};
text-align: center;
line-height: ${size}px;
`}
>
<div
data-test-subj="empty-donut-small"
css={css`
border-radius: 50%;
height: ${middleSize}px;
width: ${middleSize}px;
background-color: ${euiTheme.colors.backgroundBasePlain};
display: inline-block;
vertical-align: middle;
`}
/>
</div>
) : null;
};

export const DonutChartEmpty = React.memo(EmptyDonutChartComponent);

This file was deleted.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,11 @@ import { useLensAttributes } from '../../../use_lens_attributes';
import { getAlertsByStatusAttributes } from './alerts_by_status_donut';

jest.mock('uuid', () => ({
v4: jest.fn().mockReturnValue('b9b43606-7ff7-46ae-a47c-85bed80fab9a'),
v4: jest
.fn()
.mockReturnValueOnce('b9b43606-7ff7-46ae-a47c-85bed80fab9a')
.mockReturnValueOnce('a9b43606-7ff7-46ae-a47c-85bed80fab9a')
.mockReturnValueOnce('21cc4a49-3780-4b1a-be28-f02fa5303d24'),
}));

jest.mock('../../../../../../sourcerer/containers', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
import { v4 as uuidv4 } from 'uuid';
import type { GetLensAttributes } from '../../../types';
const layerId = uuidv4();
const columnSeverity = uuidv4();
const columnRecord = uuidv4();

export const getAlertsByStatusAttributes: GetLensAttributes = (
export const getAlertsByStatusAttributes: GetLensAttributes = ({
stackByField = 'kibana.alert.workflow_status',
extraOptions
) => {
extraOptions,
}) => {
return {
title: 'Alerts',
description: '',
Expand All @@ -22,8 +24,8 @@ export const getAlertsByStatusAttributes: GetLensAttributes = (
layers: [
{
layerId,
primaryGroups: ['a9b43606-7ff7-46ae-a47c-85bed80fab9a'],
metrics: ['21cc4a49-3780-4b1a-be28-f02fa5303d24'],
primaryGroups: [columnSeverity],
metrics: [columnRecord],
numberDisplay: 'value',
categoryDisplay: 'hide',
legendDisplay: 'hide',
Expand Down Expand Up @@ -69,7 +71,7 @@ export const getAlertsByStatusAttributes: GetLensAttributes = (
layers: {
[layerId]: {
columns: {
'a9b43606-7ff7-46ae-a47c-85bed80fab9a': {
[columnSeverity]: {
label: 'Filters',
dataType: 'string',
operationType: 'filters',
Expand Down Expand Up @@ -108,7 +110,7 @@ export const getAlertsByStatusAttributes: GetLensAttributes = (
],
},
},
'21cc4a49-3780-4b1a-be28-f02fa5303d24': {
[columnRecord]: {
label: 'Count of records',
dataType: 'number',
operationType: 'count',
Expand All @@ -124,10 +126,7 @@ export const getAlertsByStatusAttributes: GetLensAttributes = (
},
},
},
columnOrder: [
'a9b43606-7ff7-46ae-a47c-85bed80fab9a',
'21cc4a49-3780-4b1a-be28-f02fa5303d24',
],
columnOrder: [columnSeverity, columnRecord],
sampling: 1,
incompleteColumns: {},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import { useLensAttributes } from '../../../use_lens_attributes';
import { getAlertsHistogramLensAttributes } from './alerts_histogram';

jest.mock('uuid', () => ({
v4: jest.fn().mockReturnValue('0039eb0c-9a1a-4687-ae54-0f4e239bec75'),
v4: jest
.fn()
.mockReturnValueOnce('0039eb0c-9a1a-4687-ae54-0f4e239bec75')
.mockReturnValueOnce('e09e0380-0740-4105-becc-0a4ca12e3944')
.mockReturnValueOnce('34919782-4546-43a5-b668-06ac934d3acd')
.mockReturnValueOnce('aac9d7d0-13a3-480a-892b-08207a787926'),
}));

jest.mock('../../../../../../sourcerer/containers', () => ({
Expand Down
Loading
Loading