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][THI] - replace usages of EUI vis colors #205218

Merged
merged 2 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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,7 +6,6 @@
*/

import {
EuiAvatar,
EuiBadge,
EuiFlexGroup,
EuiFlexItem,
Expand All @@ -15,9 +14,7 @@ import {
EuiText,
EuiTextColor,
EuiTitle,
useEuiTheme,
} from '@elastic/eui';
import { euiThemeVars } from '@kbn/ui-theme';
import { isArray } from 'lodash/fp';
import React from 'react';
import type { GroupPanelRenderer } from '@kbn/grouping/src';
Expand All @@ -44,11 +41,32 @@ export const renderGroupPanel: GroupPanelRenderer<AlertsGroupingAggregation> = (
/>
) : undefined;
case 'host.name':
return <HostNameGroupContent hostName={bucket.key} nullGroupMessage={nullGroupMessage} />;
return (
<GroupContent
title={bucket.key}
icon="storage"
nullGroupMessage={nullGroupMessage}
dataTestSubj="host-name"
/>
);
case 'user.name':
return <UserNameGroupContent userName={bucket.key} nullGroupMessage={nullGroupMessage} />;
return (
<GroupContent
title={bucket.key}
icon="user"
nullGroupMessage={nullGroupMessage}
dataTestSubj="user-name"
/>
);
case 'source.ip':
return <SourceIpGroupContent sourceIp={bucket.key} nullGroupMessage={nullGroupMessage} />;
return (
<GroupContent
title={bucket.key}
icon="globe"
nullGroupMessage={nullGroupMessage}
dataTestSubj="source-ip"
/>
);
}
};

Expand All @@ -64,7 +82,7 @@ const RuleNameGroupContent = React.memo<{
);
return (
<div style={{ display: 'table', tableLayout: 'fixed', width: '100%' }}>
<EuiFlexGroup data-test-subj="rule-name-group-renderer" gutterSize="m" alignItems="center">
<EuiFlexGroup data-test-subj="rule-name-group-renderer" gutterSize="s" alignItems="center">
<EuiFlexItem grow={false} style={{ display: 'contents' }}>
<EuiTitle size="xs">
<h5 className="eui-textTruncate">{ruleName.trim()}</h5>
Expand Down Expand Up @@ -94,87 +112,30 @@ const RuleNameGroupContent = React.memo<{
});
RuleNameGroupContent.displayName = 'RuleNameGroup';

const HostNameGroupContent = React.memo<{ hostName: string | string[]; nullGroupMessage?: string }>(
({ hostName, nullGroupMessage }) => {
const { euiTheme } = useEuiTheme();
return (
<EuiFlexGroup data-test-subj="host-name-group-renderer" gutterSize="s" alignItems="center">
<EuiFlexItem
grow={false}
style={{
backgroundColor: euiTheme.colors.vis.euiColorVis1,
borderRadius: '50%',
}}
>
<EuiIcon type="database" size="l" style={{ padding: 4 }} />
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiTitle size="xs">
<h5>{hostName}</h5>
</EuiTitle>
</EuiFlexItem>
{nullGroupMessage && (
<EuiFlexItem grow={false}>
<EuiIconTip content={nullGroupMessage} position="right" />
</EuiFlexItem>
)}
</EuiFlexGroup>
);
}
);
HostNameGroupContent.displayName = 'HostNameGroupContent';

const UserNameGroupContent = React.memo<{ userName: string | string[]; nullGroupMessage?: string }>(
({ userName, nullGroupMessage }) => {
const userNameValue = firstNonNullValue(userName) ?? '-';
const { euiTheme } = useEuiTheme();

return (
<EuiFlexGroup data-test-subj="user-name-group-renderer" gutterSize="s" alignItems="center">
<EuiFlexItem grow={false}>
<EuiAvatar name={userNameValue} color={euiTheme.colors.accentSecondary} />
</EuiFlexItem>

<EuiFlexItem grow={false}>
<EuiTitle size="xs">
<h5>{userName}</h5>
</EuiTitle>
</EuiFlexItem>
{nullGroupMessage && (
<EuiFlexItem grow={false}>
<EuiIconTip content={nullGroupMessage} position="right" />
</EuiFlexItem>
)}
</EuiFlexGroup>
);
}
);
UserNameGroupContent.displayName = 'UserNameGroupContent';

const SourceIpGroupContent = React.memo<{ sourceIp: string | string[]; nullGroupMessage?: string }>(
({ sourceIp, nullGroupMessage }) => (
<EuiFlexGroup data-test-subj="source-ip-group-renderer" gutterSize="s" alignItems="center">
<EuiFlexItem
grow={false}
style={{
backgroundColor: euiThemeVars.euiColorVis3_behindText,
borderRadius: '50%',
}}
>
<EuiIcon style={{ padding: 4 }} type="ip" size="l" />
</EuiFlexItem>
const GroupContent = React.memo<{
title: string | string[];
icon: string;
nullGroupMessage?: string;
dataTestSubj?: string;
}>(({ title, icon, nullGroupMessage, dataTestSubj }) => (
<EuiFlexGroup
data-test-subj={`${dataTestSubj}-group-renderer`}
gutterSize="s"
alignItems="center"
>
<EuiFlexItem grow={false}>
<EuiIcon type={icon} size="m" />
</EuiFlexItem>
<EuiFlexItem grow={false}>
<EuiTitle size="xs">
<h5>{title}</h5>
</EuiTitle>
</EuiFlexItem>
{nullGroupMessage && (
<EuiFlexItem grow={false}>
<EuiTitle size="xs">
<h5>{sourceIp}</h5>
</EuiTitle>
<EuiIconTip content={nullGroupMessage} position="right" />
</EuiFlexItem>
{nullGroupMessage && (
<EuiFlexItem grow={false}>
<EuiIconTip content={nullGroupMessage} position="right" />
</EuiFlexItem>
)}
</EuiFlexGroup>
)
);
SourceIpGroupContent.displayName = 'SourceIpGroupContent';
)}
</EuiFlexGroup>
));
GroupContent.displayName = 'GroupContent';
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ export const usePaneStyles = () => {
&:not(.timeline-portal-overlay-mask--full-screen) .timeline-container {
margin: ${euiTheme.size.m};
border-radius: ${euiTheme.border.radius.medium};

.timeline-template-badge {
border-radius: ${euiTheme.border.radius.medium} ${euiTheme.border.radius.medium} 0 0; // top corners only
}
}
`;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ ProviderBadgeStyled.displayName = 'ProviderBadgeStyled';

const ProviderFieldBadge = styled.div`
display: block;
color: #fff;
padding: 6px 8px;
padding: ${({ theme }) => `${theme.eui.euiSizeXS} ${theme.eui.euiSizeS}`};
mgadewoll marked this conversation as resolved.
Show resolved Hide resolved
font-size: 0.6em;
`;

const StyledTemplateFieldBadge = styled(ProviderFieldBadge)`
background: ${({ theme }) => theme.eui.euiColorVis3_behindText};
background: ${({ theme }) => theme.eui.euiPanelBackgroundColorModifiers.accent};
color: ${({ theme }) => theme.eui.euiColorAccentText};
text-transform: uppercase;
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*/

import { pick } from 'lodash/fp';
import { EuiProgress } from '@elastic/eui';
import { EuiPanel, EuiProgress, EuiText } from '@elastic/eui';
import React, { useCallback, useEffect, useMemo, useRef, createContext } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import styled from 'styled-components';
Expand All @@ -31,13 +31,6 @@ import { useResolveConflict } from '../../../common/hooks/use_resolve_conflict';
import { sourcererSelectors } from '../../../common/store';
import { defaultUdtHeaders } from './body/column_headers/default_headers';

const TimelineTemplateBadge = styled.div`
background: ${({ theme }) => theme.eui.euiColorVis3_behindText};
color: #fff;
padding: 10px 15px;
font-size: 0.8em;
`;

const TimelineBody = styled.div`
height: 100%;
display: flex;
Expand Down Expand Up @@ -206,9 +199,11 @@ const StatefulTimelineComponent: React.FC<Props> = ({
<TimelineSavingProgress timelineId={timelineId} />
<TimelineBody data-test-subj="timeline-body">
{timelineType === TimelineTypeEnum.template && (
<TimelineTemplateBadge className="timeline-template-badge">
{i18n.TIMELINE_TEMPLATE}
</TimelineTemplateBadge>
<EuiPanel color="accent" grow={false} paddingSize="s">
<EuiText size="xs" color="accent">
{i18n.TIMELINE_TEMPLATE}
</EuiText>
</EuiPanel>
)}
{resolveConflictComponent}
<HideShowContainer
Expand Down
Loading