From a011519d81dd506d37605d579df7bfa22470c95f Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Thu, 9 Jul 2020 23:08:21 +0100 Subject: [PATCH 1/4] fix tooltip of notes --- .../timeline/body/actions/index.test.tsx | 31 +++++++++++++++++++ .../timeline/body/actions/index.tsx | 7 ++++- .../components/timeline/body/translations.ts | 4 +-- 3 files changed, 39 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.test.tsx index 53b018fb00adf..e4a97ce1358a3 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.test.tsx @@ -9,6 +9,7 @@ import { useSelector } from 'react-redux'; import { TestProviders, mockTimelineModel } from '../../../../../common/mock'; import { DEFAULT_ACTIONS_COLUMN_WIDTH } from '../constants'; +import * as i18n from '../translations'; import { Actions } from '.'; @@ -202,6 +203,36 @@ describe('Actions', () => { expect(toggleShowNotes).toBeCalled(); }); + test('it renders correct tooltip for NotesButton', () => { + const toggleShowNotes = jest.fn(); + + const wrapper = mount( + + + + ); + + expect(wrapper.find('[data-test-subj="add-note"]').prop('toolTip')).toEqual(i18n.NOTES_TOOLTIP); + }); + test('it does NOT render a pin button when isEventViewer is true', () => { const onPinClicked = jest.fn(); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.tsx index 2039307691321..2facb2b3d0ede 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.tsx @@ -9,6 +9,7 @@ import { EuiButtonIcon, EuiCheckbox, EuiLoadingSpinner, EuiToolTip } from '@elas import { Note } from '../../../../../common/lib/note'; import { StoreState } from '../../../../../common/store/types'; +import { TimelineType } from '../../../../../../common/types/timeline'; import { TimelineModel } from '../../../../store/timeline/model'; @@ -170,7 +171,11 @@ export const Actions = React.memo( status={timeline.status} timelineType={timeline.timelineType} toggleShowNotes={toggleShowNotes} - toolTip={timeline.timelineType ? i18n.NOTES_DISABLE_TOOLTIP : i18n.NOTES_TOOLTIP} + toolTip={ + timeline.timelineType === TimelineType.template + ? i18n.NOTES_DISABLE_TOOLTIP + : i18n.NOTES_TOOLTIP + } updateNote={updateNote} /> diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/translations.ts b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/translations.ts index 5af2f3ef488b0..9ec07935cb9fc 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/translations.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/translations.ts @@ -16,7 +16,7 @@ export const NOTES_TOOLTIP = i18n.translate( export const NOTES_DISABLE_TOOLTIP = i18n.translate( 'xpack.securitySolution.timeline.body.notes.disableEventTooltip', { - defaultMessage: 'Add notes for event filtered by a timeline template is not allowed', + defaultMessage: 'Notes may not be added here while editing a template timeline', } ); @@ -48,7 +48,7 @@ export const PINNED_WITH_NOTES = i18n.translate( export const DISABLE_PIN = i18n.translate( 'xpack.securitySolution.timeline.body.pinning.disablePinnnedTooltip', { - defaultMessage: 'This event cannot be pinned because it is filtered by a timeline template', + defaultMessage: 'This event may not be pinned while editing a template timeline', } ); From 65db38eab9e54028371f950b1a9d6b64a051548e Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Fri, 10 Jul 2020 00:08:23 +0100 Subject: [PATCH 2/4] fix unit test --- .../timeline/body/actions/index.test.tsx | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.test.tsx index e4a97ce1358a3..78ee9bdd053b2 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/actions/index.test.tsx @@ -12,6 +12,7 @@ import { DEFAULT_ACTIONS_COLUMN_WIDTH } from '../constants'; import * as i18n from '../translations'; import { Actions } from '.'; +import { TimelineType } from '../../../../../../common/types/timeline'; jest.mock('react-redux', () => { const origin = jest.requireActual('react-redux'); @@ -203,7 +204,7 @@ describe('Actions', () => { expect(toggleShowNotes).toBeCalled(); }); - test('it renders correct tooltip for NotesButton', () => { + test('it renders correct tooltip for NotesButton - timeline', () => { const toggleShowNotes = jest.fn(); const wrapper = mount( @@ -233,6 +234,43 @@ describe('Actions', () => { expect(wrapper.find('[data-test-subj="add-note"]').prop('toolTip')).toEqual(i18n.NOTES_TOOLTIP); }); + test('it renders correct tooltip for NotesButton - timeline template', () => { + (useSelector as jest.Mock).mockReturnValue({ + ...mockTimelineModel, + timelineType: TimelineType.template, + }); + const toggleShowNotes = jest.fn(); + + const wrapper = mount( + + + + ); + + expect(wrapper.find('[data-test-subj="add-note"]').prop('toolTip')).toEqual( + i18n.NOTES_DISABLE_TOOLTIP + ); + (useSelector as jest.Mock).mockReturnValue(mockTimelineModel); + }); + test('it does NOT render a pin button when isEventViewer is true', () => { const onPinClicked = jest.fn(); From 655d98135e6832aa27001d7a44da34c2d4baa23b Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Fri, 10 Jul 2020 01:06:36 +0100 Subject: [PATCH 3/4] update notes tooltip --- .../public/timelines/components/timeline/body/translations.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/translations.ts b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/translations.ts index 9ec07935cb9fc..20467af290b19 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/translations.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/translations.ts @@ -9,7 +9,7 @@ import { i18n } from '@kbn/i18n'; export const NOTES_TOOLTIP = i18n.translate( 'xpack.securitySolution.timeline.body.notes.addOrViewNotesForThisEventTooltip', { - defaultMessage: 'Add or view notes for this event', + defaultMessage: 'Add notes for this event', } ); From 695d9c5585584a0968056b472eb93c0b09511ad5 Mon Sep 17 00:00:00 2001 From: Angela Chuang Date: Fri, 10 Jul 2020 08:37:06 +0100 Subject: [PATCH 4/4] fix unit test --- .../public/timelines/components/timeline/body/helpers.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.test.ts b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.test.ts index 7ecd7ec5ed35c..8ba1a999e2b2a 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.test.ts +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/body/helpers.test.ts @@ -223,7 +223,7 @@ describe('helpers', () => { eventHasNotes: false, timelineType: TimelineType.template, }) - ).toEqual('This event cannot be pinned because it is filtered by a timeline template'); + ).toEqual('This event may not be pinned while editing a template timeline'); }); });