From 8581908dd09e54d24484ea48815203cccf2b5791 Mon Sep 17 00:00:00 2001 From: Rodney Norris Date: Wed, 15 Jan 2025 15:15:31 +0000 Subject: [PATCH] search: remove logstream component, no longer used --- .../applications/shared/log_stream/index.ts | 8 -- .../shared/log_stream/log_stream.test.tsx | 89 ------------------- .../shared/log_stream/log_stream.tsx | 38 -------- 3 files changed, 135 deletions(-) delete mode 100644 x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/index.ts delete mode 100644 x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.test.tsx delete mode 100644 x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.tsx diff --git a/x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/index.ts b/x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/index.ts deleted file mode 100644 index fc37e9ae317f4..0000000000000 --- a/x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -export { EntSearchLogStream } from './log_stream'; diff --git a/x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.test.tsx b/x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.test.tsx deleted file mode 100644 index 3d94a6e3b22e2..0000000000000 --- a/x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.test.tsx +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; - -import { shallow } from 'enzyme'; - -import { LogStream } from '@kbn/logs-shared-plugin/public'; - -import { EntSearchLogStream } from '.'; - -const fakeSourceId = 'fake-source-id'; - -describe('EntSearchLogStream', () => { - const mockDateNow = jest.spyOn(global.Date, 'now').mockReturnValue(160000000); - - describe('renders with default props', () => { - const wrapper = shallow( - - ); - - it('renders a LogStream (wrapped in React.Suspense) component', () => { - expect(wrapper.type()).toEqual(LogStream); - }); - - it('renders with the empty sourceId', () => { - expect(wrapper.prop('sourceId')).toBeUndefined(); - }); - - it('renders with a default last-24-hours timestamp if no timestamp is passed', () => { - expect(wrapper.prop('startTimestamp')).toEqual(73600000); - expect(wrapper.prop('endTimestamp')).toEqual(160000000); - }); - }); - - describe('renders custom props', () => { - it('overrides the default props', () => { - const wrapper = shallow( - - ); - - expect(wrapper.prop('logView')).toEqual({ type: 'log-view-reference', logViewId: 'test' }); - expect(wrapper.prop('startTimestamp')).toEqual(1); - expect(wrapper.prop('endTimestamp')).toEqual(2); - }); - - it('allows passing a custom hoursAgo that modifies the default start timestamp', () => { - const wrapper = shallow( - - ); - - expect(wrapper.prop('startTimestamp')).toEqual(156400000); - expect(wrapper.prop('endTimestamp')).toEqual(160000000); - }); - - it('allows passing any prop that the LogStream component takes', () => { - const wrapper = shallow( - - ); - - expect(wrapper.prop('height')).toEqual(500); - expect(wrapper.prop('highlight')).toEqual('some-log-id'); - expect(wrapper.prop('columns')).toBeTruthy(); - expect(wrapper.prop('filters')).toEqual([]); - }); - }); - - afterAll(() => mockDateNow.mockRestore()); -}); diff --git a/x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.tsx b/x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.tsx deleted file mode 100644 index 5748d306b6319..0000000000000 --- a/x-pack/solutions/search/plugins/enterprise_search/public/applications/shared/log_stream/log_stream.tsx +++ /dev/null @@ -1,38 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License - * 2.0; you may not use this file except in compliance with the Elastic License - * 2.0. - */ - -import React from 'react'; - -import { LogStream, LogStreamProps } from '@kbn/logs-shared-plugin/public'; - -/* - * EnterpriseSearchLogStream is a light wrapper on top of logsShared's embeddable LogStream component. - * It prepopulates our log source ID (set in server/plugin.ts) and sets a basic 24-hours-ago - * default for timestamps. All other props get passed as-is to the underlying LogStream. - * - * Documentation links for reference: - * - https://github.com/elastic/kibana/blob/main/x-pack/plugins/observability_solution/logs_shared/public/components/log_stream/log_stream.stories.mdx - * - Run `yarn storybook logsShared` for live docs - */ - -interface Props extends Omit { - startTimestamp?: LogStreamProps['startTimestamp']; - endTimestamp?: LogStreamProps['endTimestamp']; - hoursAgo?: number; -} - -export const EntSearchLogStream: React.FC = ({ - startTimestamp, - endTimestamp, - hoursAgo = 24, - ...props -}) => { - if (!endTimestamp) endTimestamp = Date.now(); - if (!startTimestamp) startTimestamp = endTimestamp - hoursAgo * 60 * 60 * 1000; - - return ; -};