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] Add Timeline improvements #71506

Merged
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
3 changes: 3 additions & 0 deletions x-pack/plugins/security_solution/cypress/tasks/timeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ import {

import { drag, drop } from '../tasks/common';

export const hostExistsQuery = 'host.name: *';

export const addDescriptionToTimeline = (description: string) => {
cy.get(TIMELINE_DESCRIPTION).type(`${description}{enter}`);
cy.get(DATE_PICKER_APPLY_BUTTON_TIMELINE).click().invoke('text').should('not.equal', 'Updating');
Expand Down Expand Up @@ -77,6 +79,7 @@ export const openTimelineSettings = () => {
};

export const populateTimeline = () => {
executeTimelineKQL(hostExistsQuery);
cy.get(SERVER_SIDE_EVENT_COUNT)
.invoke('text')
.then((strCount) => {
Expand Down

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 @@ -7,6 +7,7 @@
import React, { useCallback, useMemo, useState } from 'react';
import {
EuiButton,
EuiButtonEmpty,
EuiContextMenu,
EuiText,
EuiPopover,
Expand Down Expand Up @@ -139,21 +140,33 @@ const AddDataProviderPopoverComponent: React.FC<AddDataProviderPopoverProps> = (
[browserFields, handleDataProviderEdited, timelineId, timelineType]
);

const button = useMemo(
() => (
<EuiButton
const button = useMemo(() => {
if (timelineType === TimelineType.template) {
return (
<EuiButton
size="s"
onClick={handleOpenPopover}
data-test-subj="addFilter"
iconType="arrowDown"
fill
iconSide="right"
>
<EuiText size="s">{ADD_FIELD_LABEL}</EuiText>
</EuiButton>
);
}

return (
<EuiButtonEmpty
size="s"
onClick={handleOpenPopover}
data-test-subj="addFilter"
iconType="arrowDown"
fill
iconSide="right"
>
<EuiText size="s">{ADD_FIELD_LABEL}</EuiText>
</EuiButton>
),
[handleOpenPopover]
);
<EuiText size="s">{`+ ${ADD_FIELD_LABEL}`}</EuiText>
</EuiButtonEmpty>
);
}, [handleOpenPopover, timelineType]);

const content = useMemo(() => {
if (timelineType === TimelineType.template) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,10 @@ const Parens = styled.span`
`}
`;

const AndOrBadgeContainer = styled.div`
width: 121px;
display: flex;
justify-content: flex-end;
const AndOrBadgeContainer = styled.div<{ hideBadge: boolean }>`
span {
visibility: ${({ hideBadge }) => (hideBadge ? 'hidden' : 'inherit')};
}
`;

const LastAndOrBadgeInGroup = styled.div`
Expand Down Expand Up @@ -113,10 +113,6 @@ const ParensContainer = styled(EuiFlexItem)`
align-self: center;
`;

const AddDataProviderContainer = styled.div`
padding-right: 9px;
`;

const getDataProviderValue = (dataProvider: DataProvidersAnd) =>
dataProvider.queryMatch.displayValue ?? dataProvider.queryMatch.value;

Expand Down Expand Up @@ -152,15 +148,9 @@ export const Providers = React.memo<Props>(

<EuiFlexGroup alignItems="center" gutterSize="none">
<OrFlexItem grow={false}>
{groupIndex === 0 ? (
<AddDataProviderContainer>
<AddDataProviderPopover browserFields={browserFields} timelineId={timelineId} />
</AddDataProviderContainer>
) : (
<AndOrBadgeContainer>
<AndOrBadge type="or" />
</AndOrBadgeContainer>
)}
<AndOrBadgeContainer hideBadge={groupIndex === 0}>
<AndOrBadge type="or" />
</AndOrBadgeContainer>
</OrFlexItem>
<ParensContainer grow={false}>
<Parens>{'('}</Parens>
Expand Down Expand Up @@ -300,6 +290,9 @@ export const Providers = React.memo<Props>(
<ParensContainer grow={false}>
<Parens>{')'}</Parens>
</ParensContainer>
{groupIndex === dataProviderGroups.length - 1 && (
<AddDataProviderPopover browserFields={browserFields} timelineId={timelineId} />
)}
</EuiFlexGroup>
</Fragment>
))}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ const makeMapStateToProps = () => {

// return events on empty search
const kqlQueryExpression =
isEmpty(dataProviders) && isEmpty(kqlQueryTimeline) ? ' ' : kqlQueryTimeline;
isEmpty(dataProviders) && isEmpty(kqlQueryTimeline) && timelineType === 'template'
? ' '
: kqlQueryTimeline;
return {
columns,
dataProviders,
Expand Down