diff --git a/x-pack/plugins/security_solution/common/experimental_features.ts b/x-pack/plugins/security_solution/common/experimental_features.ts index 792b6352912b3..113a232b5775e 100644 --- a/x-pack/plugins/security_solution/common/experimental_features.ts +++ b/x-pack/plugins/security_solution/common/experimental_features.ts @@ -94,9 +94,9 @@ export const allowedExperimentalValues = Object.freeze({ endpointManagementSpaceAwarenessEnabled: false, /** - * Enables new notes + * Disables new notes */ - securitySolutionNotesEnabled: false, + securitySolutionNotesDisabled: false, /** * Disables entity and alert previews diff --git a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx index 931c519ae9b57..5ec3e0c2d0e3d 100644 --- a/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx +++ b/x-pack/plugins/security_solution/public/common/components/control_columns/row_action/index.tsx @@ -93,8 +93,8 @@ const RowActionComponent = ({ [columnHeaders, timelineNonEcsData] ); - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const handleOnEventDetailPanelOpened = useCallback(() => { @@ -175,12 +175,12 @@ const RowActionComponent = ({ showCheckboxes={showCheckboxes} tabType={tabType} timelineId={tableId} - toggleShowNotes={securitySolutionNotesEnabled ? toggleShowNotes : undefined} + toggleShowNotes={securitySolutionNotesDisabled ? undefined : toggleShowNotes} width={width} setEventsLoading={setEventsLoading} setEventsDeleted={setEventsDeleted} refetch={refetch} - showNotes={securitySolutionNotesEnabled ? true : false} + showNotes={!securitySolutionNotesDisabled} /> )} diff --git a/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.test.tsx b/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.test.tsx index dd5cbb4131b4c..0a5156bddcc99 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.test.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.test.tsx @@ -16,6 +16,9 @@ import { useGlobalFullScreen } from '../../containers/use_full_screen'; import { licenseService } from '../../hooks/use_license'; import { mockHistory } from '../../mock/router'; import { DEFAULT_EVENTS_STACK_BY_VALUE } from './histogram_configurations'; +import { useIsExperimentalFeatureEnabled } from '../../hooks/use_experimental_features'; + +jest.mock('../../hooks/use_experimental_features'); const mockGetDefaultControlColumn = jest.fn(); jest.mock('../../../timelines/components/timeline/body/control_columns', () => ({ @@ -95,6 +98,7 @@ describe('EventsQueryTabBody', () => { }; beforeEach(() => { + (useIsExperimentalFeatureEnabled as jest.Mock).mockReturnValue(false); jest.clearAllMocks(); }); @@ -106,7 +110,7 @@ describe('EventsQueryTabBody', () => { ); expect(queryByText('MockedStatefulEventsViewer')).toBeInTheDocument(); - expect(mockGetDefaultControlColumn).toHaveBeenCalledWith(4); + expect(mockGetDefaultControlColumn).toHaveBeenCalledWith(5); }); it('renders the matrix histogram when globalFullScreen is false', () => { @@ -186,7 +190,19 @@ describe('EventsQueryTabBody', () => { expect(spy).toHaveBeenCalled(); }); - it('only have 4 columns on Action bar for non-Enterprise user', () => { + it('should have 5 columns on Action bar for non-Enterprise user', () => { + render( + + + + ); + + expect(mockGetDefaultControlColumn).toHaveBeenCalledWith(5); + }); + + it('should have 4 columns on Action bar for non-Enterprise user and securitySolutionNotesDisabled is true', () => { + (useIsExperimentalFeatureEnabled as jest.Mock).mockReturnValue(true); + render( @@ -196,10 +212,23 @@ describe('EventsQueryTabBody', () => { expect(mockGetDefaultControlColumn).toHaveBeenCalledWith(4); }); - it('shows 5 columns on Action bar for Enterprise user', () => { + it('should 6 columns on Action bar for Enterprise user', () => { const licenseServiceMock = licenseService as jest.Mocked; + licenseServiceMock.isEnterprise.mockReturnValue(true); + render( + + + + ); + + expect(mockGetDefaultControlColumn).toHaveBeenCalledWith(6); + }); + + it('should 6 columns on Action bar for Enterprise user and securitySolutionNotesDisabled is true', () => { + const licenseServiceMock = licenseService as jest.Mocked; licenseServiceMock.isEnterprise.mockReturnValue(true); + (useIsExperimentalFeatureEnabled as jest.Mock).mockReturnValue(true); render( diff --git a/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.tsx b/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.tsx index 92c94549ca891..70e56f4a8b4d2 100644 --- a/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.tsx +++ b/x-pack/plugins/security_solution/public/common/components/events_tab/events_query_tab_body.tsx @@ -75,10 +75,10 @@ const EventsQueryTabBodyComponent: React.FC = const [defaultNumberFormat] = useUiSetting$(DEFAULT_NUMBER_FORMAT); const isEnterprisePlus = useLicense().isEnterprise(); let ACTION_BUTTON_COUNT = isEnterprisePlus ? 6 : 5; - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); - if (!securitySolutionNotesEnabled) { + if (securitySolutionNotesDisabled) { ACTION_BUTTON_COUNT--; } const leadingControlColumns = useMemo( diff --git a/x-pack/plugins/security_solution/public/common/components/header_actions/actions.tsx b/x-pack/plugins/security_solution/public/common/components/header_actions/actions.tsx index 2f27b1c8d8d9f..4775b8f889028 100644 --- a/x-pack/plugins/security_solution/public/common/components/header_actions/actions.tsx +++ b/x-pack/plugins/security_solution/public/common/components/header_actions/actions.tsx @@ -255,8 +255,8 @@ const ActionsComponent: React.FC = ({ onEventDetailsPanelOpened(); }, [activeStep, incrementStep, isTourAnchor, isTourShown, onEventDetailsPanelOpened]); - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); /* only applicable for new event based notes */ @@ -270,7 +270,7 @@ const ActionsComponent: React.FC = ({ /* note ids associated with the document AND attached to the current timeline, used for pinning */ const timelineNoteIds = useMemo(() => { - if (securitySolutionNotesEnabled) { + if (!securitySolutionNotesDisabled) { // if timeline is unsaved, there is no notes associated to timeline yet return savedObjectId ? documentBasedNotesInTimeline.map((note) => note.noteId) : []; } @@ -280,13 +280,13 @@ const ActionsComponent: React.FC = ({ eventId, documentBasedNotesInTimeline, savedObjectId, - securitySolutionNotesEnabled, + securitySolutionNotesDisabled, ]); /* note count of the document */ const notesCount = useMemo( - () => (securitySolutionNotesEnabled ? documentBasedNotes.length : timelineNoteIds.length), - [documentBasedNotes, timelineNoteIds, securitySolutionNotesEnabled] + () => (securitySolutionNotesDisabled ? timelineNoteIds.length : documentBasedNotes.length), + [documentBasedNotes, timelineNoteIds, securitySolutionNotesDisabled] ); // we hide the analyzer icon if the data is not available for the resolver diff --git a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_actions_column.tsx b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_actions_column.tsx index 39b8d7cad3f60..286d377d86f56 100644 --- a/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_actions_column.tsx +++ b/x-pack/plugins/security_solution/public/detections/hooks/trigger_actions_alert_table/use_actions_column.tsx @@ -47,10 +47,10 @@ export const getUseActionColumnHook = } // we only want to show the note icon if the new notes system feature flag is enabled - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); - if (!securitySolutionNotesEnabled) { + if (securitySolutionNotesDisabled) { ACTION_BUTTON_COUNT--; } diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx index 8e6b817e275e5..32b0b10d61ffd 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/left/index.tsx @@ -36,8 +36,8 @@ export const LeftPanel: FC> = memo(({ path }) => { const { openLeftPanel } = useExpandableFlyoutApi(); const { eventId, indexName, scopeId, getFieldsData, isPreview } = useDocumentDetailsContext(); const eventKind = getField(getFieldsData('event.kind')); - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const [visualizationInFlyoutEnabled] = useUiSetting$( @@ -49,14 +49,14 @@ export const LeftPanel: FC> = memo(({ path }) => { eventKind === EventKind.signal ? [tabs.insightsTab, tabs.investigationTab, tabs.responseTab] : [tabs.insightsTab]; - if (securitySolutionNotesEnabled && !isPreview) { + if (!securitySolutionNotesDisabled && !isPreview) { tabList.push(tabs.notesTab); } if (visualizationInFlyoutEnabled && !isPreview) { return [tabs.visualizeTab, ...tabList]; } return tabList; - }, [eventKind, isPreview, securitySolutionNotesEnabled, visualizationInFlyoutEnabled]); + }, [eventKind, isPreview, securitySolutionNotesDisabled, visualizationInFlyoutEnabled]); const selectedTabId = useMemo(() => { const defaultTab = tabsDisplayed[0].id; diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.test.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.test.tsx index 6d72ca9e58dfa..8a8293badb6af 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.test.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.test.tsx @@ -78,7 +78,7 @@ describe('', () => { }); it('should render notes section if experimental flag is enabled', () => { - (useIsExperimentalFeatureEnabled as jest.Mock).mockReturnValue(true); + (useIsExperimentalFeatureEnabled as jest.Mock).mockReturnValue(false); const { getByTestId } = renderHeader(mockContextValue); expect(getByTestId(NOTES_TITLE_TEST_ID)).toBeInTheDocument(); diff --git a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.tsx b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.tsx index f128fada5fb29..931da6e8e57c8 100644 --- a/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.tsx +++ b/x-pack/plugins/security_solution/public/flyout/document_details/right/components/alert_header_title.tsx @@ -40,8 +40,8 @@ export const AlertHeaderTitle = memo(() => { refetchFlyoutData, getFieldsData, } = useDocumentDetailsContext(); - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const { isAlert, ruleName, timestamp, ruleId } = useBasicDataFromDetailsData( @@ -98,7 +98,30 @@ export const AlertHeaderTitle = memo(() => { /> )} - {securitySolutionNotesEnabled ? ( + {securitySolutionNotesDisabled ? ( + + + + + + + + + + + + ) : ( { - ) : ( - - - - - - - - - - - )} ); diff --git a/x-pack/plugins/security_solution/public/management/links.ts b/x-pack/plugins/security_solution/public/management/links.ts index d033fdf491ce8..ee9b1005808d1 100644 --- a/x-pack/plugins/security_solution/public/management/links.ts +++ b/x-pack/plugins/security_solution/public/management/links.ts @@ -229,7 +229,7 @@ export const links: LinkItem = { path: NOTES_PATH, skipUrlState: true, hideTimeline: true, - experimentalKey: 'securitySolutionNotesEnabled', + hideWhenExperimentalKey: 'securitySolutionNotesDisabled', }, ], }; diff --git a/x-pack/plugins/security_solution/public/management/pages/index.tsx b/x-pack/plugins/security_solution/public/management/pages/index.tsx index dc8314acc276c..d558b1271dc6b 100644 --- a/x-pack/plugins/security_solution/public/management/pages/index.tsx +++ b/x-pack/plugins/security_solution/public/management/pages/index.tsx @@ -88,8 +88,8 @@ const NotesTelemetry = () => ( ); export const ManagementContainer = memo(() => { - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const { @@ -162,7 +162,7 @@ export const ManagementContainer = memo(() => { hasPrivilege={canReadActionsLogManagement} /> - {securitySolutionNotesEnabled && ( + {!securitySolutionNotesDisabled && ( )} diff --git a/x-pack/plugins/security_solution/public/notes/hooks/use_fetch_notes.test.ts b/x-pack/plugins/security_solution/public/notes/hooks/use_fetch_notes.test.ts index eb5b23641b80c..7498a6f40c6b6 100644 --- a/x-pack/plugins/security_solution/public/notes/hooks/use_fetch_notes.test.ts +++ b/x-pack/plugins/security_solution/public/notes/hooks/use_fetch_notes.test.ts @@ -45,8 +45,8 @@ describe('useFetchNotes', () => { expect(typeof result.current.onLoad).toBe('function'); }); - it('should not dispatch action when securitySolutionNotesEnabled is false', () => { - mockedUseIsExperimentalFeatureEnabled.mockReturnValue(false); + it('should not dispatch action when securitySolutionNotesDisabled is true', () => { + mockedUseIsExperimentalFeatureEnabled.mockReturnValue(true); const { result } = renderHook(() => useFetchNotes()); result.current.onLoad([{ _id: '1' }]); @@ -54,7 +54,7 @@ describe('useFetchNotes', () => { }); it('should not dispatch action when events array is empty', () => { - mockedUseIsExperimentalFeatureEnabled.mockReturnValue(true); + mockedUseIsExperimentalFeatureEnabled.mockReturnValue(false); const { result } = renderHook(() => useFetchNotes()); result.current.onLoad([]); @@ -62,7 +62,7 @@ describe('useFetchNotes', () => { }); it('should dispatch fetchNotesByDocumentIds with correct ids when conditions are met', () => { - mockedUseIsExperimentalFeatureEnabled.mockReturnValue(true); + mockedUseIsExperimentalFeatureEnabled.mockReturnValue(false); const { result } = renderHook(() => useFetchNotes()); const events = [{ _id: '1' }, { _id: '2' }, { _id: '3' }]; @@ -74,7 +74,7 @@ describe('useFetchNotes', () => { }); it('should memoize onLoad function', () => { - mockedUseIsExperimentalFeatureEnabled.mockReturnValue(true); + mockedUseIsExperimentalFeatureEnabled.mockReturnValue(false); const { result, rerender } = renderHook(() => useFetchNotes()); const firstOnLoad = result.current.onLoad; @@ -84,7 +84,7 @@ describe('useFetchNotes', () => { expect(firstOnLoad).toBe(secondOnLoad); }); - it('should update onLoad when securitySolutionNotesEnabled changes', () => { + it('should update onLoad when securitySolutionNotesDisabled changes', () => { mockedUseIsExperimentalFeatureEnabled.mockReturnValue(true); const { result, rerender } = renderHook(() => useFetchNotes()); diff --git a/x-pack/plugins/security_solution/public/notes/hooks/use_fetch_notes.ts b/x-pack/plugins/security_solution/public/notes/hooks/use_fetch_notes.ts index 2cf599e76bcc9..cdfa8b7600dfd 100644 --- a/x-pack/plugins/security_solution/public/notes/hooks/use_fetch_notes.ts +++ b/x-pack/plugins/security_solution/public/notes/hooks/use_fetch_notes.ts @@ -22,19 +22,19 @@ export interface UseFetchNotesResult { */ export const useFetchNotes = (): UseFetchNotesResult => { const dispatch = useDispatch(); - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const onLoad = useCallback( (events: Array>) => { - if (!securitySolutionNotesEnabled || events.length === 0) return; + if (securitySolutionNotesDisabled || events.length === 0) return; const eventIds: string[] = events .map((event) => event._id) .filter((id) => id != null) as string[]; dispatch(fetchNotesByDocumentIds({ documentIds: eventIds })); }, - [dispatch, securitySolutionNotesEnabled] + [dispatch, securitySolutionNotesDisabled] ); return { onLoad }; diff --git a/x-pack/plugins/security_solution/public/notes/links.ts b/x-pack/plugins/security_solution/public/notes/links.ts index ef6c691b6246a..b09877e200fb9 100644 --- a/x-pack/plugins/security_solution/public/notes/links.ts +++ b/x-pack/plugins/security_solution/public/notes/links.ts @@ -21,5 +21,5 @@ export const links: LinkItem = { }), ], links: [], - experimentalKey: 'securitySolutionNotesEnabled', + hideWhenExperimentalKey: 'securitySolutionNotesDisabled', }; diff --git a/x-pack/plugins/security_solution/public/timelines/components/notes/old_notes.tsx b/x-pack/plugins/security_solution/public/timelines/components/notes/old_notes.tsx index 71432267ac0da..09c45d887b373 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/notes/old_notes.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/notes/old_notes.tsx @@ -111,7 +111,7 @@ interface NotesTabContentProps { } /** - * Renders the "old" notes tab content. This should be removed when we remove the securitySolutionNotesEnabled feature flag + * Renders the "old" notes tab content. This should be removed when we remove the securitySolutionNotesDisabled feature flag */ export const OldNotes: React.FC = React.memo(({ timelineId }) => { const dispatch = useDispatch(); diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/eql/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/eql/index.tsx index f83d783667e4b..602d2353f342f 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/eql/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/eql/index.tsx @@ -117,8 +117,8 @@ export const EqlTabContentComponent: React.FC = ({ }); const { openFlyout } = useExpandableFlyoutApi(); - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const { @@ -139,7 +139,7 @@ export const EqlTabContentComponent: React.FC = ({ const onToggleShowNotes = useCallback( (eventId?: string) => { const indexName = selectedPatterns.join(','); - if (eventId && securitySolutionNotesEnabled) { + if (eventId && !securitySolutionNotesDisabled) { openFlyout({ right: { id: DocumentDetailsRightPanelKey, @@ -177,7 +177,7 @@ export const EqlTabContentComponent: React.FC = ({ }, [ openFlyout, - securitySolutionNotesEnabled, + securitySolutionNotesDisabled, selectedPatterns, telemetry, timelineId, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.tsx index 601a31d97fa5c..40d4f939b13fd 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/index.tsx @@ -253,8 +253,8 @@ const TabsContentComponent: React.FC = ({ selectTimelineESQLSavedSearchId(state, timelineId) ); - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const [visualizationInFlyoutEnabled] = useUiSetting$( @@ -320,16 +320,20 @@ const TabsContentComponent: React.FC = ({ } }, [fetchNotes, isTimelineSaved]); - const numberOfNotesNewSystem = useSelector((state: State) => + const notesNewSystem = useSelector((state: State) => selectSortedNotesBySavedObjectId(state, { savedObjectId: timelineSavedObjectId, sort: { field: 'created', direction: 'asc' }, }) ); + const numberOfNotesNewSystem = useMemo( + () => notesNewSystem.length + (isEmpty(timelineDescription) ? 0 : 1), + [notesNewSystem, timelineDescription] + ); const numberOfNotes = useMemo( - () => (securitySolutionNotesEnabled ? numberOfNotesNewSystem.length : numberOfNotesOldSystem), - [numberOfNotesNewSystem, numberOfNotesOldSystem, securitySolutionNotesEnabled] + () => (securitySolutionNotesDisabled ? numberOfNotesOldSystem : numberOfNotesNewSystem), + [numberOfNotesNewSystem, numberOfNotesOldSystem, securitySolutionNotesDisabled] ); const setActiveTab = useCallback( @@ -446,9 +450,7 @@ const TabsContentComponent: React.FC = ({ > {i18n.NOTES_TAB} {showTimeline && numberOfNotes > 0 && timelineType === TimelineTypeEnum.default && ( -
- {numberOfNotes} -
+ {numberOfNotes} )} = ({ {showTimeline && numberOfPinnedEvents > 0 && timelineType === TimelineTypeEnum.default && ( -
- {numberOfPinnedEvents} -
+ {numberOfPinnedEvents} )}
diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.test.tsx index 4de3728e2290f..452dc1620b946 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.test.tsx @@ -70,14 +70,14 @@ const mockGlobalStateWithUnSavedTimeline: State = { describe('NotesTabContentComponent', () => { beforeEach(() => { jest.clearAllMocks(); - (useIsExperimentalFeatureEnabled as jest.Mock).mockReturnValue(true); + (useIsExperimentalFeatureEnabled as jest.Mock).mockReturnValue(false); (useUserPrivileges as jest.Mock).mockReturnValue({ kibanaSecuritySolutionsPrivileges: { crud: true }, }); }); it('should show the old note system', () => { - (useIsExperimentalFeatureEnabled as jest.Mock).mockReturnValue(false); + (useIsExperimentalFeatureEnabled as jest.Mock).mockReturnValue(true); const { getByTestId, queryByTestId } = render( diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.tsx index aad74f15d4f62..58522d32dd55f 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/notes/index.tsx @@ -71,7 +71,7 @@ interface NotesTabContentProps { /** * Renders the notes tab content. - * At this time the component support the old notes system and the new notes system (via the securitySolutionNotesEnabled feature flag). + * At this time the component support the old notes system and the new notes system (via the securitySolutionNotesDisabled feature flag). * The old notes system is deprecated and will be removed in the future. * In both cases, the component fetches the notes for the timeline and renders: * - the timeline description @@ -86,8 +86,8 @@ const NotesTabContentComponent: React.FC = React.memo(({ t const { kibanaSecuritySolutionsPrivileges } = useUserPrivileges(); const canCreateNotes = kibanaSecuritySolutionsPrivileges.crud; - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const getScrollToTop = useMemo(() => getScrollToTopSelector(), []); @@ -180,7 +180,9 @@ const NotesTabContentComponent: React.FC = React.memo(({ t - {securitySolutionNotesEnabled ? ( + {securitySolutionNotesDisabled ? ( + + ) : ( {timelineDescription} @@ -213,8 +215,6 @@ const NotesTabContentComponent: React.FC = React.memo(({ t - ) : ( - )} diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/pinned/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/pinned/index.tsx index fb488d7c6d21b..a12f3bb9fd530 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/pinned/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/pinned/index.tsx @@ -146,8 +146,8 @@ export const PinnedTabContentComponent: React.FC = ({ }); const { openFlyout } = useExpandableFlyoutApi(); - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const { @@ -168,7 +168,7 @@ export const PinnedTabContentComponent: React.FC = ({ const onToggleShowNotes = useCallback( (eventId?: string) => { const indexName = selectedPatterns.join(','); - if (eventId && securitySolutionNotesEnabled) { + if (eventId && !securitySolutionNotesDisabled) { openFlyout({ right: { id: DocumentDetailsRightPanelKey, @@ -206,7 +206,7 @@ export const PinnedTabContentComponent: React.FC = ({ }, [ openFlyout, - securitySolutionNotesEnabled, + securitySolutionNotesDisabled, selectedPatterns, telemetry, timelineId, diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.test.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.test.tsx index 493fdb4bc603e..70afec0d73135 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.test.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.test.tsx @@ -882,12 +882,12 @@ describe('query tab with unified timeline', () => { }); describe('Leading actions - notes', () => { - describe('securitySolutionNotesEnabled = true', () => { + describe('securitySolutionNotesDisabled = false', () => { beforeEach(() => { (useIsExperimentalFeatureEnabled as jest.Mock).mockImplementation( jest.fn((feature: keyof ExperimentalFeatures) => { - if (feature === 'securitySolutionNotesEnabled') { - return true; + if (feature === 'securitySolutionNotesDisabled') { + return false; } return allowedExperimentalValues[feature]; }) @@ -937,12 +937,12 @@ describe('query tab with unified timeline', () => { ); }); - describe('securitySolutionNotesEnabled = false', () => { + describe('securitySolutionNotesDisabled = true', () => { beforeEach(() => { (useIsExperimentalFeatureEnabled as jest.Mock).mockImplementation( jest.fn((feature: keyof ExperimentalFeatures) => { - if (feature === 'securitySolutionNotesEnabled') { - return false; + if (feature === 'securitySolutionNotesDisabled') { + return true; } return allowedExperimentalValues[feature]; }) @@ -1071,12 +1071,12 @@ describe('query tab with unified timeline', () => { }); describe('Leading actions - pin', () => { - describe('securitySolutionNotesEnabled = true', () => { + describe('securitySolutionNotesDisabled = false', () => { beforeEach(() => { (useIsExperimentalFeatureEnabled as jest.Mock).mockImplementation( jest.fn((feature: keyof ExperimentalFeatures) => { - if (feature === 'securitySolutionNotesEnabled') { - return true; + if (feature === 'securitySolutionNotesDisabled') { + return false; } return allowedExperimentalValues[feature]; }) @@ -1155,12 +1155,12 @@ describe('query tab with unified timeline', () => { ); }); - describe('securitySolutionNotesEnabled = false', () => { + describe('securitySolutionNotesDisabled = true', () => { beforeEach(() => { (useIsExperimentalFeatureEnabled as jest.Mock).mockImplementation( jest.fn((feature: keyof ExperimentalFeatures) => { - if (feature === 'securitySolutionNotesEnabled') { - return false; + if (feature === 'securitySolutionNotesDisabled') { + return true; } return allowedExperimentalValues[feature]; }) diff --git a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.tsx b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.tsx index d12c213b7f3e2..8ea1db39a3618 100644 --- a/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.tsx +++ b/x-pack/plugins/security_solution/public/timelines/components/timeline/tabs/query/index.tsx @@ -184,8 +184,8 @@ export const QueryTabContentComponent: React.FC = ({ }); const { openFlyout } = useExpandableFlyoutApi(); - const securitySolutionNotesEnabled = useIsExperimentalFeatureEnabled( - 'securitySolutionNotesEnabled' + const securitySolutionNotesDisabled = useIsExperimentalFeatureEnabled( + 'securitySolutionNotesDisabled' ); const { @@ -206,7 +206,7 @@ export const QueryTabContentComponent: React.FC = ({ const onToggleShowNotes = useCallback( (eventId?: string) => { const indexName = selectedPatterns.join(','); - if (eventId && securitySolutionNotesEnabled) { + if (eventId && !securitySolutionNotesDisabled) { openFlyout({ right: { id: DocumentDetailsRightPanelKey, @@ -244,7 +244,7 @@ export const QueryTabContentComponent: React.FC = ({ }, [ openFlyout, - securitySolutionNotesEnabled, + securitySolutionNotesDisabled, selectedPatterns, telemetry, timelineId, diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/event_rendered_view.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/event_rendered_view.cy.ts index e028b751c0bf5..a62c60572ea10 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/event_rendered_view.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/event_rendered_view.cy.ts @@ -33,7 +33,8 @@ import { XY_CHART, } from '../../../screens/shared'; -describe(`Event Rendered View`, { tags: ['@ess', '@serverless'] }, () => { +// skipping as this test is also failing on main (see https://github.com/elastic/security-team/issues/10874) +describe.skip(`Event Rendered View`, { tags: ['@ess', '@serverless'] }, () => { beforeEach(() => { login(); createRule(getNewRule()); diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/expandable_flyout/alert_details_right_panel.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/expandable_flyout/alert_details_right_panel.cy.ts index ab8f5557a5faf..8eac8a410f600 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/expandable_flyout/alert_details_right_panel.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/alerts/expandable_flyout/alert_details_right_panel.cy.ts @@ -42,6 +42,8 @@ import { DOCUMENT_DETAILS_FLYOUT_TABLE_TAB, DOCUMENT_DETAILS_FLYOUT_FOOTER_ISOLATE_HOST, DOCUMENT_DETAILS_FLYOUT_HEADER_ASSIGNEES_TITLE, + DOCUMENT_DETAILS_FLYOUT_HEADER_NOTES_TITLE, + DOCUMENT_DETAILS_FLYOUT_HEADER_NOTES_VALUE, } from '../../../../screens/expandable_flyout/alert_details_right_panel'; import { closeFlyout, @@ -95,9 +97,8 @@ describe('Alert details expandable flyout right panel', { tags: ['@ess', '@serve cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_ASSIGNEES_TITLE).should('have.text', 'Assignees'); - // TODO uncomment when the securitySolutionNotesEnabled feature flag is removed - // cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_NOTES_TITLE).should('have.text', 'Notes'); - // cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_NOTES_VALUE).should('have.text', '0'); + cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_NOTES_TITLE).should('have.text', 'Notes'); + cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_NOTES_VALUE).should('exist'); cy.get(DOCUMENT_DETAILS_FLYOUT_HEADER_SEVERITY_VALUE) .should('be.visible') diff --git a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/notes_tab.cy.ts b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/notes_tab.cy.ts index 3730e0ec924a5..7bda7c4e4bfc3 100644 --- a/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/notes_tab.cy.ts +++ b/x-pack/test/security_solution_cypress/cypress/e2e/investigations/timelines/notes_tab.cy.ts @@ -90,7 +90,7 @@ describe('Timeline notes tab', { tags: ['@ess', '@serverless'] }, () => { it('should be able to delete a note', () => { const deleteNoteContent = 'delete me'; addNotesToTimeline(deleteNoteContent); - cy.get(DELETE_NOTE).last().click(); + cy.get(DELETE_NOTE(0)).click(); cy.get(MODAL_CONFIRMATION_BTN).click(); cy.get(NOTE_DESCRIPTION).last().should('not.have.text', deleteNoteContent); }); diff --git a/x-pack/test/security_solution_cypress/cypress/screens/expandable_flyout/alert_details_right_panel.ts b/x-pack/test/security_solution_cypress/cypress/screens/expandable_flyout/alert_details_right_panel.ts index e84a70cbea621..b972a5edd21b8 100644 --- a/x-pack/test/security_solution_cypress/cypress/screens/expandable_flyout/alert_details_right_panel.ts +++ b/x-pack/test/security_solution_cypress/cypress/screens/expandable_flyout/alert_details_right_panel.ts @@ -55,10 +55,10 @@ export const DOCUMENT_DETAILS_FLYOUT_HEADER_ASSIGNEES_VALUE = getDataTestSubject 'securitySolutionFlyoutHeaderAssignees' ); export const DOCUMENT_DETAILS_FLYOUT_HEADER_NOTES_TITLE = getDataTestSubjectSelector( - 'securitySolutionFlyoutHeaderAssigneesTitle' + 'securitySolutionFlyoutHeaderNotesTitle' ); export const DOCUMENT_DETAILS_FLYOUT_HEADER_NOTES_VALUE = getDataTestSubjectSelector( - 'securitySolutionFlyoutHeaderAssigneesValue' + 'securitySolutionFlyoutHeaderNotesAddNoteButton' ); /* Footer */ diff --git a/x-pack/test/security_solution_cypress/cypress/screens/timeline.ts b/x-pack/test/security_solution_cypress/cypress/screens/timeline.ts index a4aac97091af2..df81ad54ecd48 100644 --- a/x-pack/test/security_solution_cypress/cypress/screens/timeline.ts +++ b/x-pack/test/security_solution_cypress/cypress/screens/timeline.ts @@ -8,7 +8,7 @@ import type { TimelineFilter } from '../objects/timeline'; import { getDataTestSubjectSelector } from '../helpers/common'; -export const ADD_NOTE_BUTTON = '[data-test-subj="add-note"]'; +export const ADD_NOTE_BUTTON = '[data-test-subj="securitySolutionNotesAddNotesButton"]'; export const ADD_FILTER = '[data-test-subj="timeline-search-or-filter"] [data-test-subj="addFilter"]'; @@ -61,15 +61,13 @@ export const UNLOCKED_ICON = '[data-test-subj="timeline-date-picker-unlock-butto export const ROW_ADD_NOTES_BUTTON = '[data-test-subj="timeline-notes-button-small"]'; -export const ADD_NOTE_CONTAINER = '[data-test-subj="add-note-container"]'; +export const NOTE_CARD_CONTENT = (index: number) => + `[data-test-subj="securitySolutionNotesNotesComment-${index}"]`; -export const RESOLVER_GRAPH_CONTAINER = '[data-test-subj="resolver:graph"]'; +export const NOTE_DESCRIPTION = + '[data-test-subj="securitySolutionNotesTimelineDescriptionComment"]'; -export const NOTE_CARD_CONTENT = '[data-test-subj="notes"]'; - -export const NOTE_DESCRIPTION = '[data-test-subj="note-preview-description"]'; - -export const NOTES_TEXT_AREA = '[data-test-subj="add-a-note"] textarea'; +export const NOTES_TEXT_AREA = '[data-test-subj="euiMarkdownEditorTextArea"]'; export const NOTES_TAB_BUTTON = '[data-test-subj="timelineTabs-notes"]'; @@ -81,7 +79,8 @@ export const NOTES_AUTHOR = '.euiCommentEvent__headerUsername'; export const NOTES_LINK = '[data-test-subj="markdown-link"]'; -export const DELETE_NOTE = '[data-test-subj="delete-note"]'; +export const DELETE_NOTE = (index: number) => + `[data-test-subj="securitySolutionNotesDeleteNotesButton-${index}"]`; export const MARKDOWN_INVESTIGATE_BUTTON = '[data-test-subj="insight-investigate-in-timeline-button"]'; @@ -218,8 +217,6 @@ export const TIMELINE_TITLE = '[data-test-subj="timeline-modal-header-title"]'; export const TIMELINE_TITLE_INPUT = '[data-test-subj="save-timeline-modal-title-input"]'; -export const TIMESTAMP_HEADER_FIELD = '[data-test-subj="header-text-@timestamp"]'; - export const TIMESTAMP_TOGGLE_FIELD = '[data-test-subj="actionItem-security-detailsFlyout-cellActions-toggleColumn"]';