[Security Solution][Expandable flyout] - remove unused code (#201477)

## Summary

Some code was added in [this
PR](https://github.com/elastic/kibana/pull/189633) to allow the
expandable flyout to be used in the OneDiscover context. Later on, [this
PR](https://github.com/elastic/kibana/pull/198294) reverted most of the
changes, but some files remained.

This PR cleans up all the files (that I could find) that are now
unnecessary and unused
This commit is contained in:
Philippe Oberti 2024-11-27 11:59:01 -06:00 committed by GitHub
parent dac87ef6fe
commit 7ebd1506ff
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 0 additions and 112 deletions

View file

@ -7,37 +7,8 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import React from 'react';
import type { IStorage } from '@kbn/kibana-utils-plugin/public';
export const useExpandableFlyoutApi = jest.fn(() => ({
openFlyout: jest.fn(),
closeFlyout: jest.fn(),
openPanels: jest.fn(),
openRightPanel: jest.fn(),
openLeftPanel: jest.fn(),
openPreviewPanel: jest.fn(),
closeRightPanel: jest.fn(),
closeLeftPanel: jest.fn(),
closePreviewPanel: jest.fn(),
closePanels: jest.fn(),
previousPreviewPanel: jest.fn(),
}));
export const useExpandableFlyoutState = jest.fn();
export const ExpandableFlyoutProvider = jest.fn(({ children }: React.PropsWithChildren<{}>) => {
return <>{children}</>;
});
export const withExpandableFlyoutProvider = <T extends object>(
Component: React.ComponentType<T>
) => {
return (props: T) => {
return <Component {...props} />;
};
};
export const ExpandableFlyout = jest.fn();
export const localStorageMock = (): IStorage => {

View file

@ -15,7 +15,6 @@ export { useExpandableFlyoutState } from './src/hooks/use_expandable_flyout_stat
export { type FlyoutPanels as ExpandableFlyoutState } from './src/store/state';
export { ExpandableFlyoutProvider } from './src/provider';
export { withExpandableFlyoutProvider } from './src/with_provider';
export type { ExpandableFlyoutProps } from './src';
export type { FlyoutPanelProps, PanelPath, ExpandableFlyoutApi } from './src/types';

View file

@ -1,30 +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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { render } from '@testing-library/react';
import { useExpandableFlyoutApi } from './hooks/use_expandable_flyout_api';
import React from 'react';
import { withExpandableFlyoutProvider } from './with_provider';
const TestComponent = () => {
useExpandableFlyoutApi();
return <div data-test-subj="test-comp" />;
};
describe('withExpandableFlyoutProvider', () => {
it('should throw when rendered without Expandable Provider', () => {
expect(() => render(<TestComponent />)).toThrow();
});
it('should not throw when rendered with Expandable Provider', () => {
const TestComponentWithProvider = withExpandableFlyoutProvider(TestComponent);
expect(() => render(<TestComponentWithProvider />)).not.toThrow();
});
});

View file

@ -1,26 +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", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import React from 'react';
import { ComponentType } from 'react';
import { ExpandableFlyoutContextProviderProps } from './context';
import { ExpandableFlyoutProvider } from './provider';
export const withExpandableFlyoutProvider = <Props extends {}>(
Component: ComponentType<Props>,
expandableProviderProps?: ExpandableFlyoutContextProviderProps
) => {
return (props: Props) => {
return (
<ExpandableFlyoutProvider {...(expandableProviderProps ?? {})}>
<Component {...props} />
</ExpandableFlyoutProvider>
);
};
};

View file

@ -5,8 +5,6 @@
* 2.0.
*/
import React from 'react';
export const createExpandableFlyoutApiMock = () => ({
closeFlyout: jest.fn(),
closeLeftPanel: jest.fn(),
@ -18,17 +16,3 @@ export const createExpandableFlyoutApiMock = () => ({
openPreviewPanel: jest.fn(),
openRightPanel: jest.fn(),
});
export const createExpandableFlyoutMock = () => {
return {
useExpandableFlyoutApi: jest.fn().mockReturnValue(createExpandableFlyoutApiMock()),
useExpandableFlyoutState: jest.fn(),
ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}</>,
withExpandableFlyoutProvider: <T extends object>(Component: React.ComponentType<T>) => {
return (props: T) => {
return <Component {...props} />;
};
},
ExpandableFlyout: jest.fn(),
};
};

View file

@ -22,11 +22,6 @@ import { createTelemetryServiceMock } from '../../../../common/lib/telemetry/tel
jest.mock('@kbn/expandable-flyout', () => ({
useExpandableFlyoutApi: jest.fn(),
ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}</>,
withExpandableFlyoutProvider: <T extends object>(Component: React.ComponentType<T>) => {
return (props: T) => {
return <Component {...props} />;
};
},
}));
const mockedTelemetry = createTelemetryServiceMock();

View file

@ -34,11 +34,6 @@ jest.mock('../../../common/lib/kibana', () => {
jest.mock('@kbn/expandable-flyout', () => ({
useExpandableFlyoutApi: jest.fn(),
ExpandableFlyoutProvider: ({ children }: React.PropsWithChildren<{}>) => <>{children}</>,
withExpandableFlyoutProvider: <T extends object>(Component: React.ComponentType<T>) => {
return (props: T) => {
return <Component {...props} />;
};
},
}));
const renderPreviewLink = (field: string, value: string, dataTestSuj?: string) =>