From 66f0a2988f58d4099a62829a44e943363ac216fd Mon Sep 17 00:00:00 2001 From: Angela Chuang <6295984+angorayc@users.noreply.github.com> Date: Wed, 29 Jul 2020 00:31:26 +0100 Subject: [PATCH] [7.8] [Security Solution] Super select (#73271) (#73523) * [Security Solution] Super select (#73271) * fix icon * fix items * Cleanup * match styling Co-authored-by: Elastic Machine Co-authored-by: Patryk Kopycinski # Conflicts: # x-pack/plugins/security_solution/public/timelines/components/timeline/search_super_select/index.tsx # x-pack/plugins/security_solution/public/timelines/components/timeline/selectable_timeline/index.tsx * backport Co-authored-by: Elastic Machine --- .../timeline/search_super_select/index.tsx | 63 ++++++++++--------- .../timeline/selectable_timeline/index.tsx | 2 +- 2 files changed, 34 insertions(+), 31 deletions(-) diff --git a/x-pack/plugins/siem/public/components/timeline/search_super_select/index.tsx b/x-pack/plugins/siem/public/components/timeline/search_super_select/index.tsx index c0366a4ccabad..80d5d4221144e 100644 --- a/x-pack/plugins/siem/public/components/timeline/search_super_select/index.tsx +++ b/x-pack/plugins/siem/public/components/timeline/search_super_select/index.tsx @@ -4,19 +4,41 @@ * you may not use this file except in compliance with the Elastic License. */ -import { EuiInputPopover, EuiSelectableOption, EuiSuperSelect } from '@elastic/eui'; +import { EuiInputPopover, EuiSelectableOption, EuiFieldText } from '@elastic/eui'; import React, { memo, useCallback, useMemo, useState } from 'react'; -import { createGlobalStyle } from 'styled-components'; +import styled from 'styled-components'; import { OpenTimelineResult } from '../../open_timeline/types'; import { SelectableTimeline } from '../selectable_timeline'; import * as i18n from '../translations'; import { TimelineType, TimelineTypeLiteral } from '../../../../common/types/timeline'; -const SearchTimelineSuperSelectGlobalStyle = createGlobalStyle` - .euiPopover__panel.euiPopover__panel-isOpen.timeline-search-super-select-popover__popoverPanel { - visibility: hidden; - z-index: 0; +const StyledEuiFieldText = styled(EuiFieldText)` + padding-left: 12px; + padding-right: 40px; + + &[readonly] { + cursor: pointer; + background-size: 0 100%; + background-repeat: no-repeat; + + // To match EuiFieldText focus state + &:focus { + background-color: #fff; + background-image: linear-gradient( + to top, + #006bb4, + #006bb4 2px, + transparent 2px, + transparent 100% + ); + background-size: 100% 100%; + } + } + + & + .euiFormControlLayoutIcons { + left: unset; + right: 12px; } `; @@ -29,13 +51,6 @@ interface SearchTimelineSuperSelectProps { onTimelineChange: (timelineTitle: string, timelineId: string | null) => void; } -const basicSuperSelectOptions = [ - { - value: '-1', - inputDisplay: i18n.DEFAULT_TIMELINE_TITLE, - }, -]; - const getBasicSelectableOptions = (timelineId: string) => [ { description: i18n.DEFAULT_TIMELINE_DESCRIPTION, @@ -67,26 +82,15 @@ const SearchTimelineSuperSelectComponent: React.FC ( - ), - [handleOpenPopover, isDisabled, timelineId, timelineTitle] + [handleOpenPopover, isDisabled, timelineTitle] ); const handleGetSelectableOptions = useCallback( @@ -126,7 +130,6 @@ const SearchTimelineSuperSelectComponent: React.FC - ); }; diff --git a/x-pack/plugins/siem/public/components/timeline/selectable_timeline/index.tsx b/x-pack/plugins/siem/public/components/timeline/selectable_timeline/index.tsx index 04bc415194cb5..bb5db5a7b7946 100644 --- a/x-pack/plugins/siem/public/components/timeline/selectable_timeline/index.tsx +++ b/x-pack/plugins/siem/public/components/timeline/selectable_timeline/index.tsx @@ -161,7 +161,7 @@ const SelectableTimelineComponent: React.FC = ({ responsive={false} > - +