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

[7.x] [SIEM] Fix doubled drag handles in Timeline (#52679) #54130

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
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ import {
Droppable,
} from 'react-beautiful-dnd';
import { connect } from 'react-redux';
import styled, { css } from 'styled-components';
import styled from 'styled-components';
import { ActionCreator } from 'typescript-fsa';

import { EuiPortal } from '@elastic/eui';
import { dragAndDropActions } from '../../store/drag_and_drop';
import { DataProvider } from '../timeline/data_providers/data_provider';
import { STATEFUL_EVENT_CSS_CLASS_NAME } from '../timeline/helpers';
import { TruncatableText } from '../truncatable_text';
import { getDraggableId, getDroppableId } from './helpers';
import { ProviderContainer } from './provider_container';

// As right now, we do not know what we want there, we will keep it as a placeholder
export const DragEffects = styled.div``;
Expand All @@ -42,143 +42,12 @@ const Wrapper = styled.div`

Wrapper.displayName = 'Wrapper';

const ProviderContainer = styled.div<{ isDragging: boolean }>`
&,
&::before,
&::after {
transition: background ${({ theme }) => theme.eui.euiAnimSpeedFast} ease,
color ${({ theme }) => theme.eui.euiAnimSpeedFast} ease;
const ProviderContentWrapper = styled.span`
> span.euiToolTipAnchor {
display: block; /* allow EuiTooltip content to be truncatable */
}

${({ isDragging }) =>
!isDragging &&
css`
& {
border-radius: 2px;
padding: 0 4px 0 8px;
position: relative;
z-index: ${({ theme }) => theme.eui.euiZLevel0} !important;

&::before {
background-image: linear-gradient(
135deg,
${({ theme }) => theme.eui.euiColorMediumShade} 25%,
transparent 25%
),
linear-gradient(
-135deg,
${({ theme }) => theme.eui.euiColorMediumShade} 25%,
transparent 25%
),
linear-gradient(
135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorMediumShade} 75%
),
linear-gradient(
-135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorMediumShade} 75%
);
background-position: 0 0, 1px 0, 1px -1px, 0px 1px;
background-size: 2px 2px;
bottom: 2px;
content: '';
display: block;
left: 2px;
position: absolute;
top: 2px;
width: 4px;
}
}

&:hover {
&,
& .euiBadge,
& .euiBadge__text {
cursor: move; /* Fallback for IE11 */
cursor: grab;
}
}

.${STATEFUL_EVENT_CSS_CLASS_NAME}:hover &,
tr:hover & {
background-color: ${({ theme }) => theme.eui.euiColorLightShade};

&::before {
background-image: linear-gradient(
135deg,
${({ theme }) => theme.eui.euiColorDarkShade} 25%,
transparent 25%
),
linear-gradient(
-135deg,
${({ theme }) => theme.eui.euiColorDarkShade} 25%,
transparent 25%
),
linear-gradient(
135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorDarkShade} 75%
),
linear-gradient(
-135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorDarkShade} 75%
);
}
}

&:hover,
&:focus,
.${STATEFUL_EVENT_CSS_CLASS_NAME}:hover &:hover,
.${STATEFUL_EVENT_CSS_CLASS_NAME}:focus &:focus,
tr:hover &:hover,
tr:hover &:focus {
background-color: ${({ theme }) => theme.eui.euiColorPrimary};

&,
& a,
& a:hover {
color: ${({ theme }) => theme.eui.euiColorEmptyShade};
}

&::before {
background-image: linear-gradient(
135deg,
${({ theme }) => theme.eui.euiColorEmptyShade} 25%,
transparent 25%
),
linear-gradient(
-135deg,
${({ theme }) => theme.eui.euiColorEmptyShade} 25%,
transparent 25%
),
linear-gradient(
135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorEmptyShade} 75%
),
linear-gradient(
-135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorEmptyShade} 75%
);
}
}
`}

${({ isDragging }) =>
isDragging &&
css`
& {
z-index: 9999 !important;
}
`}
`;

ProviderContainer.displayName = 'ProviderContainer';

interface OwnProps {
dataProvider: DataProvider;
inline?: boolean;
Expand Down Expand Up @@ -244,9 +113,11 @@ const DraggableWrapperComponent = React.memo<Props>(
{render(dataProvider, provided, snapshot)}
</TruncatableText>
) : (
<span data-test-subj={`draggable-content-${dataProvider.queryMatch.field}`}>
<ProviderContentWrapper
data-test-subj={`draggable-content-${dataProvider.queryMatch.field}`}
>
{render(dataProvider, provided, snapshot)}
</span>
</ProviderContentWrapper>
)}
</ProviderContainer>
</ConditionalPortal>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License;
* you may not use this file except in compliance with the Elastic License.
*/

import React from 'react';
import styled, { css } from 'styled-components';
import { STATEFUL_EVENT_CSS_CLASS_NAME } from '../timeline/helpers';

interface ProviderContainerProps {
isDragging: boolean;
}

const ProviderContainerComponent = styled.div<ProviderContainerProps>`
&,
&::before,
&::after {
transition: background ${({ theme }) => theme.eui.euiAnimSpeedFast} ease,
color ${({ theme }) => theme.eui.euiAnimSpeedFast} ease;
}

${({ isDragging }) =>
!isDragging &&
css`
& {
border-radius: 2px;
padding: 0 4px 0 8px;
position: relative;
z-index: ${({ theme }) => theme.eui.euiZLevel0} !important;

&::before {
background-image: linear-gradient(
135deg,
${({ theme }) => theme.eui.euiColorMediumShade} 25%,
transparent 25%
),
linear-gradient(
-135deg,
${({ theme }) => theme.eui.euiColorMediumShade} 25%,
transparent 25%
),
linear-gradient(
135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorMediumShade} 75%
),
linear-gradient(
-135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorMediumShade} 75%
);
background-position: 0 0, 1px 0, 1px -1px, 0px 1px;
background-size: 2px 2px;
bottom: 2px;
content: '';
display: block;
left: 2px;
position: absolute;
top: 2px;
width: 4px;
}
}

&:hover {
&,
& .euiBadge,
& .euiBadge__text {
cursor: move; /* Fallback for IE11 */
cursor: grab;
}
}

.${STATEFUL_EVENT_CSS_CLASS_NAME}:hover &,
tr:hover & {
background-color: ${({ theme }) => theme.eui.euiColorLightShade};

&::before {
background-image: linear-gradient(
135deg,
${({ theme }) => theme.eui.euiColorDarkShade} 25%,
transparent 25%
),
linear-gradient(
-135deg,
${({ theme }) => theme.eui.euiColorDarkShade} 25%,
transparent 25%
),
linear-gradient(
135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorDarkShade} 75%
),
linear-gradient(
-135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorDarkShade} 75%
);
}
}

&:hover,
&:focus,
.${STATEFUL_EVENT_CSS_CLASS_NAME}:hover &:hover,
.${STATEFUL_EVENT_CSS_CLASS_NAME}:focus &:focus,
tr:hover &:hover,
tr:hover &:focus {
background-color: ${({ theme }) => theme.eui.euiColorPrimary};

&,
& a,
& a:hover {
color: ${({ theme }) => theme.eui.euiColorEmptyShade};
}

&::before {
background-image: linear-gradient(
135deg,
${({ theme }) => theme.eui.euiColorEmptyShade} 25%,
transparent 25%
),
linear-gradient(
-135deg,
${({ theme }) => theme.eui.euiColorEmptyShade} 25%,
transparent 25%
),
linear-gradient(
135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorEmptyShade} 75%
),
linear-gradient(
-135deg,
transparent 75%,
${({ theme }) => theme.eui.euiColorEmptyShade} 75%
);
}
}
`}

${({ isDragging }) =>
isDragging &&
css`
& {
z-index: 9999 !important;
}
`}
`;

ProviderContainerComponent.displayName = 'ProviderContainerComponent';

export const ProviderContainer = React.memo(ProviderContainerComponent);

ProviderContainer.displayName = 'ProviderContainer';
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,14 @@ import { WithCopyToClipboard } from '../../lib/clipboard/with_copy_to_clipboard'
import { DragEffects } from '../drag_and_drop/draggable_wrapper';
import { DroppableWrapper } from '../drag_and_drop/droppable_wrapper';
import { getDroppableId, getDraggableFieldId, DRAG_TYPE_FIELD } from '../drag_and_drop/helpers';
import { DefaultDraggable } from '../draggables';
import { DraggableFieldBadge } from '../draggables/field_badge';
import { EVENT_DURATION_FIELD_NAME } from '../duration';
import { FieldName } from '../fields_browser/field_name';
import { SelectableText } from '../selectable_text';
import { OverflowField } from '../tables/helpers';
import { ColumnHeader } from '../timeline/body/column_headers/column_header';
import { defaultColumnHeaderType } from '../timeline/body/column_headers/default_headers';
import { DEFAULT_COLUMN_MIN_WIDTH } from '../timeline/body/helpers';
import { DATE_FIELD_TYPE, MESSAGE_FIELD_NAME } from '../timeline/body/renderers/constants';
import { MESSAGE_FIELD_NAME } from '../timeline/body/renderers/constants';
import { FormattedFieldValue } from '../timeline/body/renderers/formatted_field';
import { OnUpdateColumns } from '../timeline/events';
import { WithHoverActions } from '../with_hover_actions';
Expand Down Expand Up @@ -180,28 +178,14 @@ export const getColumns = ({
data.field === MESSAGE_FIELD_NAME ? (
<OverflowField value={value} />
) : (
<DefaultDraggable
data-test-subj="ip"
field={data.field}
id={`event-details-value-default-draggable-${contextId}-${eventId}-${data.field}-${i}-${value}`}
tooltipContent={
data.type === DATE_FIELD_TYPE || data.field === EVENT_DURATION_FIELD_NAME
? null
: data.field
}
<FormattedFieldValue
contextId={`event-details-value-formatted-field-value-${contextId}-${eventId}-${data.field}-${i}-${value}`}
eventId={eventId}
fieldFormat={data.format}
fieldName={data.field}
fieldType={data.type}
value={value}
>
<EuiText size="xs">
<FormattedFieldValue
contextId={`event-details-value-formatted-field-value-${contextId}-${eventId}-${data.field}-${i}-${value}`}
eventId={eventId}
fieldFormat={data.format}
fieldName={data.field}
fieldType={data.type}
value={value}
/>
</EuiText>
</DefaultDraggable>
/>
)
}
/>
Expand Down
Loading