Skip to content

Commit

Permalink
[Security] Add Timeline improvements (#71506)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Jul 14, 2020
1 parent f74340f commit 824ce51
Show file tree
Hide file tree
Showing 5 changed files with 78 additions and 42 deletions.
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

0 comments on commit 824ce51

Please sign in to comment.