From 21fcf020b7587dc16a3072d3b7b721db86904e97 Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Thu, 1 Oct 2020 15:35:53 +0100 Subject: [PATCH] fix from server side --- .../timelines/components/notes/index.tsx | 19 ++----------------- .../components/notes/translations.ts | 4 ---- .../body/actions/add_note_icon_item.tsx | 3 --- .../body/events/event_column_view.tsx | 1 - .../timeline/properties/helpers.tsx | 6 ------ .../timeline/properties/properties_left.tsx | 1 - .../timeline/properties/properties_right.tsx | 1 - .../server/lib/note/saved_object.ts | 9 +++++---- 8 files changed, 7 insertions(+), 37 deletions(-) diff --git a/x-pack/plugins/security_solution/public/timelines/components/notes/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/notes/index.tsx index 124a8c1c42584..7d083735e6c71 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/notes/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/notes/index.tsx @@ -10,7 +10,6 @@ import { EuiModalBody, EuiModalHeader, EuiSpacer, - EuiCallOut, } from '@elastic/eui'; import React, { useState } from 'react'; import styled from 'styled-components'; @@ -21,10 +20,6 @@ import { AddNote } from './add_note'; import { columns } from './columns'; import { AssociateNote, GetNewNoteId, NotesCount, search, UpdateNote } from './helpers'; import { TimelineStatusLiteral, TimelineStatus } from '../../../../common/types/timeline'; -import { Loader } from '../../../common/components/loader'; -import { useShallowEqualSelector } from '../../../common/hooks/use_selector'; -import { timelineSelectors } from '../../store/timeline'; -import { SAVE_NOTE_HINT } from './translations'; interface Props { associateNote: AssociateNote; @@ -32,7 +27,6 @@ interface Props { getNewNoteId: GetNewNoteId; noteIds: string[]; status: TimelineStatusLiteral; - timelineId: string; updateNote: UpdateNote; } @@ -48,15 +42,10 @@ InMemoryTable.displayName = 'InMemoryTable'; /** A view for entering and reviewing notes */ export const Notes = React.memo( - ({ associateNote, getNotesByIds, getNewNoteId, noteIds, status, timelineId, updateNote }) => { + ({ associateNote, getNotesByIds, getNewNoteId, noteIds, status, updateNote }) => { const [newNote, setNewNote] = useState(''); const isImmutable = status === TimelineStatus.immutable; - const currentTimeline = useShallowEqualSelector((state) => - timelineSelectors.selectTimeline(state, timelineId) - ); - const showAddNote = !isImmutable && currentTimeline.savedObjectId != null; - return ( <> @@ -64,7 +53,7 @@ export const Notes = React.memo( - {showAddNote && ( + {!isImmutable && ( ( updateNote={updateNote} /> )} - {!showAddNote && currentTimeline.isSaving && ( - - )} - {!showAddNote && !currentTimeline.isSaving && } void; updateNote: UpdateNote; } @@ -32,7 +31,6 @@ const AddEventNoteActionComponent: React.FC = ({ showNotes, status, timelineType, - timelineId, toggleShowNotes, updateNote, }) => ( @@ -47,7 +45,6 @@ const AddEventNoteActionComponent: React.FC = ({ size="s" status={status} timelineType={timelineType} - timelineId={timelineId} toggleShowNotes={toggleShowNotes} toolTip={ timelineType === TimelineType.template ? i18n.NOTES_DISABLE_TOOLTIP : i18n.NOTES_TOOLTIP diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/event_column_view.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/event_column_view.tsx index f6dda1b714864..3b6585013c8d3 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/event_column_view.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/events/event_column_view.tsx @@ -141,7 +141,6 @@ export const EventColumnView = React.memo( updateNote={updateNote} status={status} timelineType={timelineType} - timelineId={timelineId} />, uuid.v4(); @@ -367,7 +366,6 @@ const NotesButtonComponent = React.memo( text, updateNote, timelineType, - timelineId, }) => ( <> @@ -388,7 +386,6 @@ const NotesButtonComponent = React.memo( getNewNoteId={getNewNoteId} getNotesByIds={getNotesByIds} status={status} - timelineId={timelineId} noteIds={noteIds} updateNote={updateNote} /> @@ -411,7 +408,6 @@ export const NotesButton = React.memo( size, status, timelineType, - timelineId, toggleShowNotes, toolTip, text, @@ -430,7 +426,6 @@ export const NotesButton = React.memo( text={text} updateNote={updateNote} timelineType={timelineType} - timelineId={timelineId} /> ) : ( @@ -446,7 +441,6 @@ export const NotesButton = React.memo( text={text} updateNote={updateNote} timelineType={timelineType} - timelineId={timelineId} /> ) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/properties_left.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/properties_left.tsx index 97b37a3d03bf4..a3cd8802c36bc 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/properties_left.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/properties_left.tsx @@ -137,7 +137,6 @@ export const PropertiesLeft = React.memo( toolTip={i18n.NOTES_TOOL_TIP} updateNote={updateNote} timelineType={timelineType} - timelineId={timelineId} /> ) : null} diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/properties_right.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/properties_right.tsx index 864f2ca87fc25..12eab4942128f 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/properties_right.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/properties/properties_right.tsx @@ -207,7 +207,6 @@ const PropertiesRightComponent: React.FC = ({ toggleShowNotes={onToggleShowNotes} toolTip={i18n.NOTES_TOOL_TIP} updateNote={updateNote} - timelineId={timelineId} /> ) : null} diff --git a/x-pack/plugins/security_solution/server/lib/note/saved_object.ts b/x-pack/plugins/security_solution/server/lib/note/saved_object.ts index 0b043d4e2fdd0..a3291709b02c9 100644 --- a/x-pack/plugins/security_solution/server/lib/note/saved_object.ts +++ b/x-pack/plugins/security_solution/server/lib/note/saved_object.ts @@ -32,6 +32,7 @@ import { noteSavedObjectType } from './saved_object_mappings'; import { pickSavedTimeline } from '../timeline/pick_saved_timeline'; import { convertSavedObjectToSavedTimeline } from '../timeline/convert_saved_object_to_savedtimeline'; import { timelineSavedObjectType } from '../timeline/saved_object_mappings'; +import { TimelineStatus } from '../../../common/types/timeline'; export interface Note { deleteNote: (request: FrameworkRequest, noteIds: string[]) => Promise; @@ -148,10 +149,10 @@ export const persistNote = async ( note.timelineId == null ? await (async () => { const timelineResult = convertSavedObjectToSavedTimeline( - await savedObjectsClient.create( - timelineSavedObjectType, - pickSavedTimeline(null, {}, request.user) - ) + await savedObjectsClient.create(timelineSavedObjectType, { + ...pickSavedTimeline(null, {}, request.user), + status: TimelineStatus.draft, + }) ); note.timelineId = timelineResult.savedObjectId; return timelineResult.version;