From 8bc051ac49a63402f520676fcafe5182b16ecac4 Mon Sep 17 00:00:00 2001 From: Robert Oskamp Date: Tue, 10 Mar 2020 18:10:59 +0100 Subject: [PATCH 01/17] [ML] Functional tests - stabilize saved search tests (#59652) This PR stabilizes the saved search functional UI tests by adding a retry to navigateToApp('ml') --- .../machine_learning/anomaly_detection/saved_search_job.ts | 3 +-- .../test/functional/services/machine_learning/navigation.ts | 5 ++++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job.ts b/x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job.ts index 66b2f00009b18..a13cf3d61128e 100644 --- a/x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job.ts +++ b/x-pack/test/functional/apps/machine_learning/anomaly_detection/saved_search_job.ts @@ -271,8 +271,7 @@ export default function({ getService }: FtrProviderContext) { }, ]; - // test failures, see #59354 - describe.skip('saved search', function() { + describe('saved search', function() { this.tags(['smoke', 'mlqa']); before(async () => { await esArchiver.load('ml/farequote'); diff --git a/x-pack/test/functional/services/machine_learning/navigation.ts b/x-pack/test/functional/services/machine_learning/navigation.ts index 06ab99b3dcb9f..b0f993eab1a2b 100644 --- a/x-pack/test/functional/services/machine_learning/navigation.ts +++ b/x-pack/test/functional/services/machine_learning/navigation.ts @@ -17,7 +17,10 @@ export function MachineLearningNavigationProvider({ return { async navigateToMl() { - return await PageObjects.common.navigateToApp('ml'); + await retry.tryForTime(60 * 1000, async () => { + await PageObjects.common.navigateToApp('ml'); + await testSubjects.existOrFail('mlPageOverview', { timeout: 2000 }); + }); }, async assertTabsExist(tabTypeSubject: string, areaSubjects: string[]) { From ecac63f258a645723a82db838b78073bef335e44 Mon Sep 17 00:00:00 2001 From: Steph Milovic Date: Tue, 10 Mar 2020 12:49:55 -0500 Subject: [PATCH 02/17] [SIEM] [Case] Insert timeline into case textarea (#59586) --- .../components/markdown_editor/form.tsx | 28 +- .../components/markdown_editor/index.tsx | 177 ++++++----- .../insert_timeline_popover/index.tsx | 85 ++++++ .../use_insert_timeline.tsx | 44 +++ .../timeline/search_super_select/index.tsx | 283 ++---------------- .../timeline/selectable_timeline/index.tsx | 276 +++++++++++++++++ .../{search_super_select => }/translations.ts | 4 + .../siem/public/containers/case/api.ts | 12 +- .../containers/case/use_update_comment.tsx | 11 +- .../case/components/add_comment/index.tsx | 19 +- .../case/components/all_cases/index.test.tsx | 8 +- .../pages/case/components/create/index.tsx | 16 +- .../components/user_action_tree/index.tsx | 2 +- .../components/user_action_tree/schema.ts | 23 ++ .../user_action_tree/user_action_markdown.tsx | 64 ++-- .../siem/public/pages/case/translations.ts | 4 + .../components/description_step/index.tsx | 2 +- .../step_about_rule/default_value.ts | 2 +- .../api/cases/comments/patch_comment.ts | 2 +- 19 files changed, 692 insertions(+), 370 deletions(-) create mode 100644 x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/index.tsx create mode 100644 x-pack/legacy/plugins/siem/public/components/timeline/insert_timeline_popover/use_insert_timeline.tsx create mode 100644 x-pack/legacy/plugins/siem/public/components/timeline/selectable_timeline/index.tsx rename x-pack/legacy/plugins/siem/public/components/timeline/{search_super_select => }/translations.ts (84%) create mode 100644 x-pack/legacy/plugins/siem/public/pages/case/components/user_action_tree/schema.ts diff --git a/x-pack/legacy/plugins/siem/public/components/markdown_editor/form.tsx b/x-pack/legacy/plugins/siem/public/components/markdown_editor/form.tsx index 3c5287a6fac24..17c321b15418c 100644 --- a/x-pack/legacy/plugins/siem/public/components/markdown_editor/form.tsx +++ b/x-pack/legacy/plugins/siem/public/components/markdown_editor/form.tsx @@ -8,23 +8,27 @@ import { EuiFormRow } from '@elastic/eui'; import React, { useCallback } from 'react'; import { FieldHook, getFieldValidityAndErrorMessage } from '../../shared_imports'; -import { MarkdownEditor } from '.'; +import { CursorPosition, MarkdownEditor } from '.'; interface IMarkdownEditorForm { + bottomRightContent?: React.ReactNode; dataTestSubj: string; field: FieldHook; idAria: string; isDisabled: boolean; + onCursorPositionUpdate?: (cursorPosition: CursorPosition) => void; placeholder?: string; - footerContentRight?: React.ReactNode; + topRightContent?: React.ReactNode; } export const MarkdownEditorForm = ({ + bottomRightContent, dataTestSubj, field, idAria, isDisabled = false, + onCursorPositionUpdate, placeholder, - footerContentRight, + topRightContent, }: IMarkdownEditorForm) => { const { isInvalid, errorMessage } = getFieldValidityAndErrorMessage(field); @@ -37,21 +41,23 @@ export const MarkdownEditorForm = ({ return ( ); diff --git a/x-pack/legacy/plugins/siem/public/components/markdown_editor/index.tsx b/x-pack/legacy/plugins/siem/public/components/markdown_editor/index.tsx index 8572b447cced8..ee004a3c572bb 100644 --- a/x-pack/legacy/plugins/siem/public/components/markdown_editor/index.tsx +++ b/x-pack/legacy/plugins/siem/public/components/markdown_editor/index.tsx @@ -12,7 +12,7 @@ import { EuiTabbedContent, EuiTextArea, } from '@elastic/eui'; -import React, { useEffect, useMemo, useState } from 'react'; +import React, { useMemo, useCallback, ChangeEvent } from 'react'; import styled, { css } from 'styled-components'; import { Markdown } from '../markdown'; @@ -28,9 +28,25 @@ const Container = styled(EuiPanel)` padding: 0; background: ${theme.eui.euiColorLightestShade}; position: relative; + .markdown-tabs-header { + position: absolute; + top: ${theme.eui.euiSizeS}; + right: ${theme.eui.euiSizeS}; + z-index: ${theme.eui.euiZContentMenu}; + } .euiTab { padding: 10px; } + .markdown-tabs { + width: 100%; + } + .markdown-tabs-footer { + height: 41px; + padding: 0 ${theme.eui.euiSizeM}; + .euiLink { + font-size: ${theme.eui.euiSizeM}; + } + } .euiFormRow__labelWrapper { position: absolute; top: -${theme.eui.euiSizeL}; @@ -41,81 +57,108 @@ const Container = styled(EuiPanel)` `} `; -const Tabs = styled(EuiTabbedContent)` - width: 100%; -`; - -const Footer = styled(EuiFlexGroup)` - ${({ theme }) => css` - height: 41px; - padding: 0 ${theme.eui.euiSizeM}; - .euiLink { - font-size: ${theme.eui.euiSizeM}; - } - `} -`; - const MarkdownContainer = styled(EuiPanel)` min-height: 150px; overflow: auto; `; +export interface CursorPosition { + start: number; + end: number; +} + /** An input for entering a new case description */ export const MarkdownEditor = React.memo<{ - placeholder?: string; - footerContentRight?: React.ReactNode; - initialContent: string; + bottomRightContent?: React.ReactNode; + topRightContent?: React.ReactNode; + content: string; isDisabled?: boolean; onChange: (description: string) => void; -}>(({ placeholder, footerContentRight, initialContent, isDisabled = false, onChange }) => { - const [content, setContent] = useState(initialContent); - useEffect(() => { - onChange(content); - }, [content]); - const tabs = useMemo( - () => [ - { - id: 'comment', - name: i18n.MARKDOWN, - content: ( -